expm

Matrix exponential.

Category: Mathematics > Linear Algebra

Syntax

E = expm(A)

Returns the matrix exponential exp(A) of the square matrix A.

Description

The matrix exponential solves linear systems of differential equations: the solution of x' = A*x with x(0) = x0 is x(t) = expm(t*A)*x0. It is computed with scaling and squaring and a Pade approximant, not entry by entry.

Do not confuse it with exp(A), which exponentiates each element separately. The two agree only for diagonal matrices.

Input arguments

A
Square matrix.

Output arguments

E
Matrix of the same size defined by the power series I + A + A^2/2! + ....

Example

Nilpotent matrix and a rotation

expm(zeros(2))
expm([0 1; 0 0])
expm([0 pi; -pi 0])
Output
ans = 2×2

     1     0
     0     1
ans = 2×2

     1     1
     0     1
ans = 2×2

   -1.0000    0.0000
   -0.0000   -1.0000

See also

logm sqrtm funm expmv exp