Numerical Algorithms

, Volume 34, Issue 1, pp 13–26

Computing the Matrix Cosine

  • Nicholas J. Higham
  • Matthew I. Smith


An algorithm is developed for computing the matrix cosine, building on a proposal of Serbin and Blalock. The algorithm scales the matrix by a power of 2 to make the ∞-norm less than or equal to 1, evaluates a Padé approximant, and then uses the double angle formula cos (2A)=2cos (A)2I to recover the cosine of the original matrix. In addition, argument reduction and balancing is used initially to decrease the norm. We give truncation and rounding error analyses to show that an [8,8] Padé approximant produces the cosine of the scaled matrix correct to machine accuracy in IEEE double precision arithmetic, and we show that this Padé approximant can be more efficiently evaluated than a corresponding Taylor series approximation. We also provide error analysis to bound the propagation of errors in the double angle recurrence. Numerical experiments show that our algorithm is competitive in accuracy with the Schur–Parlett method of Davies and Higham, which is designed for general matrix functions, and it is substantially less expensive than that method for matrices of ∞-norm of order 1. The dominant computational kernels in the algorithm are matrix multiplication and solution of a linear system with multiple right-hand sides, so the algorithm is well suited to modern computer architectures.

matrix function matrix cosine matrix exponential Taylor series Padé approximation double angle formula rounding error analysis Schur–Parlett method MATLAB 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    E. Anderson, Z. Bai, C.H. Bischof, S. Blackford, J.W. Demmel, J.J. Dongarra, J.J. Du Croz, A. Greenbaum, S.J. Hammarling, A. McKenney and D.C. Sorensen, LAPACK Users' Guide, 3rd ed. (SIAM, Philadelphia, PA, 1999).Google Scholar
  2. [2]
    G.A. Baker, Jr., Essentials of Padé Approximants (Academic Press, New York, 1975).Google Scholar
  3. [3]
    G.A. Baker, Jr. and P. Graves-Morris, Padé Approximants, Encyclopedia of Mathematics and Its Applications, 2nd ed. (Cambridge Univ. Press, Cambridge, 1996).Google Scholar
  4. [4]
    S.H. Cheng, N.J. Higham, C.S. Kenney and A.J. Laub, Approximating the logarithm of a matrix to specified accuracy, SIAM J. Matrix Anal. Appl. 22(4) (2001) 1112–1125.Google Scholar
  5. [5]
    P.I. Davies and N.J. Higham, A Schur-Parlett algorithm for computing matrix functions, Numerical Analysis Report No. 404, Manchester Centre for Computational Mathematics, Manchester, England (July 2002), revised March 2003, to appear in SIAM J. Matrix Anal. Appl.Google Scholar
  6. [6]
    G.H. Golub and C.F. Van Loan, Matrix Computations, 3rd ed. (Johns Hopkins Univ. Press, Baltimore, MD, 1996).Google Scholar
  7. [7]
    N.J. Higham, Evaluating Padé approximants of the matrix logarithm, SIAM J. Matrix Anal. Appl. 22(4) (2001) 1126–1135.Google Scholar
  8. [8]
    N.J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM, Philadelphia, PA, 2002).Google Scholar
  9. [9]
    C. Kenney and A.J. Laub, Condition estimates for matrix functions, SIAM J.Matrix Anal. Appl. 10(2) (1989) 191–209.Google Scholar
  10. [10]
    A. Magnus and J. Wynn, On the Padé table of cos z, Proc. Amer. Math. Soc. 47(2) (1975) 361–367.Google Scholar
  11. [11]
    Maple, Waterloo Maple Inc., Waterloo, ON, Canada; Scholar
  12. [12]
    Mathematica, Wolfram Research, Inc., Champaign, IL, USA; Scholar
  13. [13]
    MATLAB, The MathWorks, Inc., Natick, MA, USA; Scholar
  14. [14]
    Symbolic Math Toolbox Version 2: User's Guide (TheMathWorks, Natick, MA, USA) Online version.Google Scholar
  15. [15]
    C.B. Moler and C.F. Van Loan, Nineteen dubious ways to compute the exponential of a matrix, SIAM Rev. 20(4) (1978) 801–836.Google Scholar
  16. [16]
    J.-M. Muller, Elementary Functions: Algorithms and Implementation (Birkhäuser, Boston, MA, 1997).Google Scholar
  17. [17]
    K.C. Ng, Contributions to the computation of the matrix exponential, Ph.D. thesis, Technical Report PAM-212, Center for Pure and Applied Mathematics, University of California, Berkeley (1984).Google Scholar
  18. [18]
    M.S. Paterson and L.J. Stockmeyer, On the number of nonscalar multiplications necessary to evaluate polynomials, SIAM J. Comput. 2(1) (1973) 60–66.Google Scholar
  19. [19]
    S.M. Serbin and S.A. Blalock, An algorithm for computing the matrix cosine, SIAM J. Sci. Statist. Comput. 1(2) (1980) 198–204.Google Scholar
  20. [20]
    R.C. Ward, Numerical computation of the matrix exponential with accuracy estimate, SIAMJ. Numer. Anal. 14(4) (1977) 600–610.Google Scholar

Copyright information

© Kluwer Academic Publishers 2003

Authors and Affiliations

  • Nicholas J. Higham
    • 1
  • Matthew I. Smith
    • 1
  1. 1.Department of MathematicsUniversity of ManchesterManchester

Personalised recommendations