Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

logm

Matrix logarithm

Syntax

  • L = logm(A)
  • [L,exitflag] = logm(A)
    example

Description

L = logm(A) is the principal matrix logarithm of A, the inverse of expm(A). The output, L, is the unique logarithm for which every eigenvalue has imaginary part lying strictly between –π and π. If A is singular or has any eigenvalues on the negative real axis, then the principal logarithm is undefined. In this case, logm computes a nonprincipal logarithm and returns a warning message.

example

[L,exitflag] = logm(A) returns a scalar exitflag that describes the exit condition of logm:

  • If exitflag = 0, the algorithm was successfully completed.

  • If exitflag = 1, too many matrix square roots had to be computed. However, the computed value of L might still be accurate.

Examples

collapse all

Compare Matrix Logarithms

Calculate the matrix exponential of a matrix, A.

A = [1 1 0; 0 0 2; 0 0 -1];
Y = expm(A)
Y =

    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, A.

P = logm(Y)
P =

    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 =

   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

Input Arguments

collapse all

A — Input matrixsquare matrix

Input matrix, specified as a square matrix.

Data Types: single | double
Complex Number Support: Yes

Limitations

  • For most matrices:

    logm(expm(A)) = A = expm(logm(A))

    These identities can fail for some A. For example, if the computed eigenvalues of A include an exact zero, then logm(A) generates infinity. Or, if the elements of A are too large, expm(A) can overflow.

More About

collapse all

Tips

  • If A is real symmetric or complex Hermitian, then so is logm(A).

  • Some matrices, like A = [0 1; 0 0], do not have any logarithms, real or complex, so logm cannot be expected to produce one.

Algorithms

The algorithm logm uses is described in [1] and [2].

References

[1] 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

[2] 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

See Also

| |

Introduced before R2006a

Was this topic helpful?