| MATLAB Function Reference | Search  Help Desk |
| funm | Examples See Also |
Evaluate functions of a matrix
Syntax
Y = funm(X,'function') [Y,esterr] = funm(X,'function')
Description
Y = funm(X,'function')
evaluates function using Parlett's method [1]. X must be a square matrix, and function any element-wise function.
The commands funm(X,'sqrt') and funm(X,'log') are equivalent to the commands sqrtm(X) and logm(X). The commands funm(X,'exp') and expm(X) compute the same function, but by different algorithms. expm(X) is preferred.
[Y,esterr] = funm(X,'function')
does not print any message, but returns a very rough estimate of the relative error in the computer result. If X is symmetric or Hermitian, then its Schur form is diagonal, and funm is able to produce an accurate result.
Examples
The statementsS = funm(Xproduce the same results to within roundoff error as,'sin'); C = funm(X,'cos');
E = expm(i*X); C = real(E); S = imag(E);In either case, the results satisfy
S*S+C*C = I, where I = eye(size(X)).
Algorithm
The matrix functions are evaluated using Parlett's algorithm, which is described in [1]. The algorithm uses the Schur factorization of the matrix and may give poor results or break down completely when the matrix has repeated eigenvalues. A warning message is printed when the results may be inaccurate.See Also
expm, logm, sqrtm
References
[1] Golub, G. H. and C. F. Van Loan, Matrix Computation, Johns Hopkins University Press, 1983, p. 384. [2] Moler, C. B. and C. F. Van Loan, "Nineteen Dubious Ways to Compute the Exponential of a Matrix," SIAM Review 20, 1979, pp. 801-836.