# jax.scipy.linalg.expm¶

jax.scipy.linalg.expm(A, *, upper_triangular=False, max_squarings=16)[source]

Compute the matrix exponential using Pade approximation.

LAX-backend implementation of expm().

In addition to the original NumPy argument(s) listed below, also supports the optional boolean argument upper_triangular to specify whether the A matrix is upper triangular, and the optional argument max_squarings to specify the max number of squarings allowed in the scaling-and-squaring approximation method. Return nan if the actual number of squarings required is more than max_squarings.

The number of required squarings = max(0, ceil(log2(norm(A)) - c) where norm() denotes the L1 norm, and

c=2.42 for float64 or complex128, c=1.97 for float32 or complex64

Original docstring below.

Parameters

A ((N, N) array_like or sparse matrix) – Matrix to be exponentiated.

Returns

expm – Matrix exponential of A.

Return type

(N, N) ndarray

References

1

Awad H. Al-Mohy and Nicholas J. Higham (2009) “A New Scaling and Squaring Algorithm for the Matrix Exponential.” SIAM Journal on Matrix Analysis and Applications. 31 (3). pp. 970-989. ISSN 1095-7162

Examples

>>> from scipy.linalg import expm, sinm, cosm


Matrix version of the formula exp(0) = 1:

>>> expm(np.zeros((2,2)))
array([[ 1.,  0.],
[ 0.,  1.]])


Euler’s identity (exp(i*theta) = cos(theta) + i*sin(theta)) applied to a matrix:

>>> a = np.array([[1.0, 2.0], [-1.0, 3.0]])
>>> expm(1j*a)
array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
[ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])
>>> cosm(a) + 1j*sinm(a)
array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j],
[ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])