Skip to main content
`Ctrl`+`K`
scipy.linalg.

# logm

scipy.linalg.logm(A, disp=<object object>)

  Compute matrix logarithm.

  The matrix logarithm is the inverse of expm: expm(logm(A)) == A

  The documentation is written assuming array arguments are of specified “core” shapes. However, array argument(s) of this function may have additional “batch” dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see Batched Linear Operations for details.

  Parameters:
    A(N, N) array_like

      Matrix whose logarithm to evaluate

    disp bool, optional

      Emit warning if error in the result is estimated large instead of returning estimated error. (Default: True)

      Deprecated since version 1.16.0: The disp argument is deprecated and will be removed in SciPy 1.18.0. The previously returned error estimate can be computed as `norm(expm(logm(A)) - A, 1) / norm(A, 1)`.

  Returns:
    logm(N, N) ndarray

      Matrix logarithm of A

    errest float

      (if disp == False)

      1-norm of the estimated error, ||err||_1 / ||A||_1

  References

  [1]

  Awad H. Al-Mohy and Nicholas J. Higham (2012) “Improved Inverse Scaling and Squaring Algorithms for the Matrix Logarithm.” SIAM Journal on Scientific Computing, 34 (4). C152-C169. ISSN 1095-7197

  [2]

  Nicholas J. Higham (2008) “Functions of Matrices: Theory and Computation” ISBN 978-0-898716-46-7

  [3]

  Nicholas J. Higham and Lijing lin (2011) “A Schur-Pade Algorithm for Fractional Powers of a Matrix.” SIAM Journal on Matrix Analysis and Applications, 32 (3). pp. 1056-1078. ISSN 0895-4798

  Examples

      >>> import numpy as np
      >>> from scipy.linalg import logm, expm
      >>> a = np.array([[1.0, 3.0], [1.0, 4.0]])
      >>> b = logm(a)
      >>> b
      array([[-1.02571087,  2.05142174],
             [ 0.68380725,  1.02571087]])
      >>> expm(b)         # Verify expm(logm(a)) returns a
      array([[ 1.,  3.],
             [ 1.,  4.]])