MATLAB Function Reference    
funm

Evaluate general matrix function

Syntax

Description

F = funm(A,fun) for a square matrix argument A, evaluates the matrix version of the function fun. For matrix exponentials, logarithms and square roots, use expm(A), logm(A) and sqrtm(A) instead.

[F,esterr] = funm(A,fun) does not print any message, but returns a very rough estimate of the relative error in the computed result.

If A is symmetric or Hermitian, then its Schur form is diagonal and funm is able to produce an accurate result.

L = logm(A) uses funm to do its computations, but it can get more reliable error estimates by comparing expm(L) with A. S = sqrtm(A) and E = expm(A) use completely different algorithms.

Examples

Example 1. fun can be specified using @:

is the matrix sine of the 3-by-3 magic matrix.

Example 2. The statements

produce the same results to within roundoff error as

In either case, the results satisfy S*S+C*C = I, where I = eye(size(X)).

Algorithm

funm uses a potentially unstable algorithm. If A is close to a matrix with multiple eigenvalues and poorly conditioned eigenvectors, funm may produce inaccurate results. An attempt is made to detect this situation and print a warning message. The error detector is sometimes too sensitive and a message is printed even though the the computed result is accurate.

The matrix functions are evaluated using Parlett's algorithm, which is described in [1].

See Also

expm, logm, sqrtm, function_handle (@)

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.


  functions fwrite