We derive an algorithm for computing the wave-kernel functions $\cos h{\sqrt {A}}$ and $\sin h{\sqrt {A}}$ for an arbitrary square matrix $A$, where $\sin hcz=\sin h{\frac {(z)}{z}}$. The algorithm is based on Padé approximation and the use of double angle formulas. We show that the backward error of any approximation to $\cos h{\sqrt {A}}$ can be explicitly expressed in terms of a hypergeometric function. To bound the backward error we derive and exploit a new bound for $\|A^{k}\|^{1/k}$ that is sharper than one previously obtained by Al-Mohy and Higham [SIAM J. Matrix Anal. Appl., 31 (2009), pp. 970--989]. The amount of scaling and the degree of the Padé approximant are chosen to minimize the computational cost subject to achieving backward stability for $\cosh {\sqrt {A}}$ in exact arithmetic. Numerical experiments show that the algorithm behaves in a forward stable manner in floating-point arithmetic and is superior in this respect to the general purpose Schur--Parlett algorithm applied to these functions.