| MATLAB Function Reference | ![]() |
Syntax
Y=logm(X) [Y,esterr] = logm(X)
Description
Y = logm(X)
returns the matrix logarithm: the inverse function of expm(X). Complex results are produced if X has negative eigenvalues. A warning message is printed if the computed expm(Y) is not close to X.
[Y,esterr] = logm(X)
does not print any warning message, but returns an estimate of the relative residual, norm(expm(Y)-X)/norm(X).
Remarks
If X is real symmetric or complex Hermitian, then so is logm(X).
Some matrices, like X = [0 1; 0 0], do not have any logarithms, real or complex, and logm cannot be expected to produce one.
Limitations
logm(expm(X)) = X = expm(logm(X))
These identities may fail for some X. For example, if the computed eigenvalues of X include an exact zero, then logm(X) generates infinity. Or, if the elements of X are too large, expm(X) may overflow.
Examples
Suppose A is the 3-by-3 matrix
1 1 0
0 0 2
0 0 -1
X=2.71831.71831.086201.00001.2642000.3679
Then A = logm(X) produces the original matrix A.
A=1.00001.00000.0000002.000000-1.0000
But log(X) involves taking the logarithm of zero, and so produces
ans =1.00000.54130.0826-Inf00.2345-Inf-Inf-1.0000
Algorithm
The matrix functions are evaluated using an algorithm due to Parlett, 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
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.
| loglog | logspace | ![]() |