# logm

## Purpose

Matrix logarithm.

## Synopsis

    Y = logm(X)

## Description

`logm(A)` is the inverse function of `expm(A)` in that for most matrices `A`

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

These identities may 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)` may overflow.

## Examples

Start with the matrix `X` produced by the example in `expm`.

    X =
        2.7183    1.7183    1.0862
             0    1.0000    1.2642
             0         0    0.3679

Then `A = logm(X)` produces the original matrix `A` used in the `expm` example.

    A =
        1.0000    1.0000    0.0000
             0         0    2.0000
             0         0   -1.0000

But `log(X)` involves taking the logarithm of zero, and so produces

    ans =
        1.0000    0.5413    0.0826
          -Inf         0    0.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 can 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

    expm, funm, sqrtm

## References

[1] G. H. Golub and C. F. Van Loan, Matrix Computation, Johns Hopkins University Press, 1983, p. 384.

[2] C. B. Moler and C. F. Van Loan, "Nineteen Dubious Ways to Compute the Exponential of a Matrix," SIAM Review 20, pp. 801-836, 1979.

(c) Copyright 1994 by The MathWorks, Inc.