MATLAB Function Reference | Search  Help Desk |
logm | Examples See Also |
Y=
logm(X) [Y,esterr] = logm(X)
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)
.
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.
For most matrices:
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.
Suppose A
is the 3-by-3 matrix
1 1 0 0 0 2 0 0 -1and
X
=
expm(A)
is
XThen=
2.7183
1.7183
1.0862
0
1.0000
1.2642
0
0
0.3679
A = logm(X)
produces the original matrix A
.
ABut=
1.0000
1.0000
0.0000
0
0
2.0000
0
0
-1.0000
log(X)
involves taking the logarithm of zero, and so produces
ans =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.1.0000
0.5413
0.0826
-Inf
0
0.2345
-Inf
-Inf
-1.0000
expm
Matrix exponential
funm
Evaluate functions of a matrix
sqrtm
Matrix square root