fn
matrix_exp
→Tensormatrix_exp(A: Tensor)Matrix exponential .
Returns the matrix exponential
which solves the matrix ODE with initial condition . Computed by the scaling-and-squaring algorithm of Higham (2005) with a Padé [6/6] rational approximant:
- Scale so that .
- Approximate via Padé [6/6] using the even/odd polynomial splitting .
- Square a total of times to recover .
Parameters
ATensorSquare matrix of shape
(*, n, n).Returns
Tensor, shape (*, n, n).
Notes
Computational cost is where the scaling parameter . The Frobenius norm is used here as a (conservative) proxy for the 1-norm — this may add one extra squaring step but keeps the result correct.
Differentiable: built entirely on matmul and inv,
so autograd flows naturally. Batched inputs (ndim > 2) are
handled element-wise.
Examples
>>> import lucid
>>> from lucid.linalg import matrix_exp
>>> A = lucid.tensor([[0.0, 1.0], [-1.0, 0.0]]) # 90-deg rotation generator
>>> matrix_exp(A)
Tensor([[ 0.5403, 0.8415],
[-0.8415, 0.5403]])