L = logm( is the
principal matrix logarithm of
A, the inverse of
L, is the unique logarithm for which
every eigenvalue has imaginary part lying strictly between –π and π.
A is singular or has any eigenvalues on the
negative real axis, then the principal logarithm is undefined. In
logm computes a nonprincipal logarithm
and returns a warning message.
[L,exitflag] = logm(A) returns a scalar
describes the exit condition of
exitflag = 0, the algorithm
was successfully completed.
exitflag = 1, too many matrix
square roots had to be computed. However, the computed value of
still be accurate.
Calculate the matrix exponential of a matrix,
A = [1 1 0; 0 0 2; 0 0 -1]; Y = expm(A)
Y = 3×3 2.7183 1.7183 1.0862 0 1.0000 1.2642 0 0 0.3679
Calculate the matrix logarithm of
Y to reproduce the original matrix,
P = logm(Y)
P = 3×3 1.0000 1.0000 0.0000 0 0 2.0000 0 0 -1.0000
log(A) involves taking the logarithm of zero, so it produces inferior results.
Q = log(A)
Q = 3×3 complex 0.0000 + 0.0000i 0.0000 + 0.0000i -Inf + 0.0000i -Inf + 0.0000i -Inf + 0.0000i 0.6931 + 0.0000i -Inf + 0.0000i -Inf + 0.0000i 0.0000 + 3.1416i
A— Input matrix
Input matrix, specified as a square matrix.
Complex Number Support: Yes
A is real symmetric or complex
Hermitian, then so is
Some matrices, like
A = [0 1; 0 0],
do not have any logarithms, real or complex, so
be expected to produce one.
 Al-Mohy, A. H. and Nicholas J. Higham, “Improved inverse scaling and squaring algorithms for the matrix logarithm,” SIAM J. Sci. Comput., 34(4), pp. C153–C169, 2012
 Al-Mohy, A. H., Higham, Nicholas J. and Samuel D. Relton, “Computing the Frechet derivative of the matrix logarithm and estimating the condition number,” SIAM J. Sci. Comput.,, 35(4), pp. C394–C410, 2013
Usage notes and limitations:
L is complex.