MatrixExp
Details and Options
- MatrixExp[m] effectively evaluates the power series for the exponential function, with ordinary powers replaced by matrix powers. »
- MatrixExp works only on square matrices.
- MatrixExp takes the following options:
-
Method Automatic method to use Parameter 1 scalar parameter in exponential - Possible values for the option Method include:
-
Automatic automatic selection "BlockDecomposition" Jordan decomposition with triangular optimization and block preprocessing "Jordan" direct Jordan decomposition "Krylov" Krylov iteration for the exponential applied to a vector "Pade" Padé approximation for inexact input "SpectralBasis" spectral method for exact matrices » "Schur" Schur decomposition - The Krylov method is only applicable to the two-argument form MatrixExp[m,v] with inexact numerical inputs.
- The Padé approximation and Schur methods are only applicable to inexact numerical inputs.
- The default setting of Method->Automatic uses "Pade" for inexact numerical matrices, "Krylov" for inexact numerical matrix—vector pairs and, based on input contents, selects between the "BlockDecomposition" and the "SpectralBasis" for exact and symbolic matrices.
- MatrixExp[m,…,Parametert] effectively computes MatrixExp[m t,…]. »
Examples
open all close allBasic Examples (3)
Exponential of a 3×3 numerical matrix:
m = (| | | |
| ---- | ---- | --- |
| 1.2 | 3.7 | 5.6 |
| 0 | -2.2 | 4 |
| -5.3 | 0 | 1.4 |)MatrixExp[m]//MatrixFormThis is not simply the exponential of each entry in the matrix:
Exp[m]//MatrixFormExponential of a 2×2 symbolic matrix:
MatrixExp[(| | |
| -- | - |
| 0 | 1 |
| -1 | 0 |) t]//MatrixFormExponential applied to a vector:
MatrixExp[{{1.2, 5.6}, {3, 4}}, {1, 2}]Scope (12)
Basic Uses (7)
Exponentiate a machine-precision matrix:
MatrixExp[{{1.2, 2.5, -3.2}, {0.7, -9.4, 5.8}, {-0.2, 0.3, 6.4}}]Exponentiate a complex matrix:
MatrixExp[{{1. + I, 2, 3 - 2 I}, {0, 4 π, 5I}, {E, 0, 6}}]Compute the exponential of an exact matrix:
MatrixExp[{{2, 3, 0}, {4, 9, 0}, {0, 0, 4}}]The exponential of an arbitrary-precision matrix:
MatrixExp[RandomReal[1, {2, 2}, WorkingPrecision -> 20]]Exponential of a symbolic matrix:
MatrixExp[{{a, b}, {0, c}}]Computing the exponential of large machine-precision matrices is efficient:
m = RandomReal[{0, 1}, {800, 800}];MatrixExp[m]; //AbsoluteTimingDirectly applying the exponential to a single vector is even more efficient:
MatrixExp[m, Range[800]]; //AbsoluteTimingThe exponential of a CenteredInterval matrix:
(m = Map[CenteredInterval, RandomReal[{-10, 10}, {3, 3}, WorkingPrecision -> 10], {2}])//MatrixForm(mexp = MatrixExp[m])//MatrixFormFind a random representative mrep of m:
ranrep[e_CenteredInterval] := e["Center"] + RandomInteger[{-1000, 1000}] / 1000 e["Radius"]
(mrep = Map[ranrep, m, {2}])//MatrixFormVerify that mexp contains the exponential of mrep:
MapThread[IntervalMemberQ, {mexp, MatrixExp[mrep]}, 2]//MatrixFormSpecial Matrices (5)
The exponential of an exact sparse matrix is typically returned as a normal matrix:
mat = SparseArray[{{1, 3} -> 1, {2, 2} -> 2, {3, 1} -> 3}, {3, 3}]MatrixExp[mat]%//MatrixFormIf the sparse matrix contains machine-precision elements, the result is typically sparse:
MatrixExp[N[mat]]% == %%Directly apply the matrix exponential of a sparse matrix to a sparse vector:
m = SparseArray[Band[{1, 2}] -> 2, {1000, 1000}]v = SparseArray[{{1} -> 1, {-1} -> -1.5}, {1000}]MatrixExp[m, v]//ShortCompute the exponential of a structured array:
SymmetrizedArray[{{1, 1} -> 3, {2, 2} -> 1, {3, 1} -> -5}, {3, 3}, Symmetric[All]]MatrixExp[%]Exponentiate IdentityMatrix:
MatrixExp[IdentityMatrix[3]]More generally, the exponential of any diagonal matrix is the exponential of its diagonal elements:
MatrixExp[DiagonalMatrix[{a, b, c}]]Exponentiate HilbertMatrix:
MatrixExp[HilbertMatrix[2]]//MatrixFormOptions (3)
Method (2)
When it is applicable, "SpectralBasis" can be orders of magnitude faster than "BlockDecomposition":
mat = {{8, 4, 8, -4, -8, -4}, {2, 6, 14, -4, 2, -8}, {4, 2, 4, -2, -4, -2}, {1, -2, 5, 5, 2, 4}, {1, -2, -5, 1, -3, 3}, {0, 0, 1, -4, 1, -3}};AbsoluteTiming[mexp1 = MatrixExp[mat, Method -> "SpectralBasis"];]AbsoluteTiming[mexp2 = MatrixExp[mat, Method -> "BlockDecomposition"];]It can also produce much simpler results:
AbsoluteTiming[LeafCount[mexp1]]AbsoluteTiming[LeafCount[mexp2]]The two results are equal, however:
AbsoluteTiming[Chop[N[mexp1 - mexp2], 10^-8]]The method is chosen automatically for matrices of exact numbers, where it excels:
MatrixQ[mat, NumberQ] && Precision[mat] == Infinity && mexp1 === MatrixExp[mat]"BlockDecomposition" is generally faster than "Jordan", often much faster as matrix size grows:
mat = RandomInteger[{-8, 8}, {6, 6}];
AbsoluteTiming[mexp1 = MatrixExp[mat, Method -> "BlockDecomposition"];]AbsoluteTiming[mexp2 = MatrixExp[mat, Method -> "Jordan"];]It can also produce much simpler results:
LeafCount /@ {mexp1, mexp2}However, there are exceptions:
mat = {{8, 4, 8, -4, -8, -4}, {2, 6, 14, -4, 2, -8}, {4, 2, 4, -2, -4, -2}, {1, -2, 5, 5, 2, 4}, {1, -2, -5, 1, -3, 3}, {0, 0, 1, -4, 1, -3}};
AbsoluteTiming[mexp1 = MatrixExp[mat, Method -> "BlockDecomposition"];]AbsoluteTiming[mexp2 = MatrixExp[mat, Method -> "Jordan"];]Even though "Jordan" was faster in this case, it did not produce a simpler result:
LeafCount /@ {mexp1, mexp2}For matrices of exact numbers, "SpectralBasis" will produce the simplest result and be of comparable or much greater speed than either Jordan-based method:
AbsoluteTiming[LeafCount[MatrixExp[mat, Method -> "SpectralBasis"]]]Applications (5)
Suppose a particle is moving in a planar force field and its position vector
satisfies
and
, where
and
are as follows. Solve this initial problem for
:
a = (| | |
| -- | -- |
| 4 | -5 |
| -2 | 1 |);Subscript[x, 0] = (| |
| --- |
| 1.9 |
| 3.6 |);The solution to this differential equation is
:
x[t_] = MatrixExp[a t, Subscript[x, 0]]Verify the solution using DSolveValue:
x[t] == DSolveValue[{{u1'[t], u2'[t]} == a.{u1[t], u2[t]}, {u1[0], u2[0]} == Subscript[x, 0]}, {u1[t], u2[t]}, t] //SimplifyA system of first-order linear differential equations:
system = | |
| :------------------ |
| x'[t] == z[t] |
| y'[t] == y[t] - z[t] |
| z'[t] == -x[t] |;Write the system in the form
with
:
a = (| | | |
| :- | :- | :- |
| 0 | 0 | 1 |
| 0 | 1 | -1 |
| -1 | 0 | 0 |);The matrix exponential gives the basis for the general solution:
MatrixExp[a t]//MatrixFormDSolve[system, {x[t], y[t], z[t]}, t]The matrix exponential applied to a vector gives a particular solution:
MatrixExp[a t, {1, 0, 0}]//MatrixForm% == DSolveValue[{system, {x[0], y[0], z[0]} == {1, 0, 0}}, {x[t], y[t], z[t]}, t]//SimplifyIn quantum mechanics, the energy operator is called the Hamiltonian
. Given the Hamiltonian for a spin-1 particle in constant magnetic field in the
direction, find the state at time
of a particle that is initially in the state
representing
:
ℋ = (Subscript[ω, 0]ℏ/Sqrt[2]) (| | | |
| - | -- | -- |
| 0 | -I | 0 |
| I | 0 | -I |
| 0 | I | 0 |);Subscript[ψ, 0] = {1, 0, 0};The system evolves according to the Schrödinger equation
:
MatrixExp[-(I ℋ t/ℏ), Subscript[ψ, 0]]//FullSimplifyCross products with respect to fixed three-dimensional vectors can be represented by matrix multiplication, which is useful in studying rotational motion. Construct the antisymmetric matrix representing the linear operator
, where
is an angular velocity about the
axis:
Overscript[ω, ⇀] = {0, 0, 2};(Subscript[ℒ, L] = Map[Cross[#, Overscript[ω, ⇀]]&, IdentityMatrix[3]])//MatrixFormVerify that the action of
is the same as doing a cross product with
:
Subscript[ℒ, L]. {x, y, z} == Overscript[ω, ⇀]⨯{x, y, z}The rotation matrix at time
is the matrix exponential of
times the previous matrix:
(rot[t_] = MatrixExp[t Subscript[ℒ, L]])//MatrixFormVerify
using RotationMatrix:
rot[t] == RotationMatrix[Norm[Overscript[ω, ⇀]]t, Overscript[ω, ⇀]]The point
at time zero will be
at time
:
Overscript[r, ⇀] = rot[t].{x, y, z}The velocity of
will be given by
:
Overscript[v, ⇀] = Overscript[ω, ⇀]⨯Overscript[r, ⇀]And the vector from the axis of rotation to
is
:
(Overscript[v, ⇀]⨯Overscript[ω, ⇀]/Overscript[ω, ⇀].Overscript[ω, ⇀])//ExpandVisualize this motion and the associated vectors:
With[{w = Overscript[ω, ⇀], x = rot[s].{1, 1, 1}}, Animate[Legended[Graphics3D[{AbsoluteThickness[3], StandardRed, Arrow[{{0, 0, 0}, w}], StandardBlue, Arrow[{{0, 0, 0}, x}], StandardCyan, Arrow[{{0, 0, 1}, x}], StandardPurple, Translate[Arrow[{{0, 0, 0}, w⨯x}], x]}, PlotRange -> {{-3, 3}, {-3, 3}, {0, 2}}], SwatchLegend[{StandardRed, StandardBlue, StandardPurple, StandardCyan}, {ω, r[t], v[t] == ω⨯r[t], Subscript[r, "⟂"] == (v[t]⨯ω/ω.ω)}]], {{s, 0, t}, 0, 2π}]]The matrix s approximates the second derivative periodic on
on the grid x:
L = 10;
n = 500;
x = L * (2N[Range[n]] / n - 1);
s = N[Block[{h = 2. L / n}, (1/h^2)SparseArray[{{i_, i_} -> -2, {i_, j_} /; Abs[i - j] == 1 -> 1, {1, n} -> 1, {n, 1} -> 1}, {n, n}]]]A vector representing a soliton on the grid x:
u = Sech[x + Pi ] Exp[Pi I x];
ListPlot[Transpose[{x, Abs[u]}]]Propagate the solution of
using a splitting
:
Timing[Module[{Δt = 0.05, m},
m = Δt (0. + 1. I) s;
Do[
u = Exp[Δt I u Conjugate[u]] u;
u = MatrixExp[m, u];
u = Exp[Δt I u Conjugate[u]] u,
{1 / Δt}]]]Plot the solution and 10 times the error from the solution of the cubic Schrödinger equation:
ListPlot[{Transpose[{x, Abs[u]}], Transpose[{x, 10Abs[u - Sech[x - Pi]Exp[I(Pi x + (1 - Pi ^ 2))]]}]}, PlotRange -> All]Properties & Relations (10)
MatrixExp effectively uses the power series for Exp, with Power replaced by MatrixPower:
a = {{1, 2}, {2, 1}};
MatrixExp[a] == Sum[ (MatrixPower[a, k]/k!), {k, 0, ∞}]Equivalently, MatrixExp is MatrixFunction applied to Exp:
MatrixExp[a] == MatrixFunction[Exp, a]The matrix exponential of a diagonal matrix is a diagonal matrix with the diagonal entries exponentiated:
d = {1, 2, 3, 4};MatrixExp[DiagonalMatrix[d t]]DiagonalMatrix[Exp[d t]]If m is diagonalizable with
, then
:
m = RandomReal[1, {3, 3}];{d, vt} = Eigensystem[m]v = Transpose[vt];
v.DiagonalMatrix[Exp[d]].Inverse[v] - MatrixExp[m]//ChopMatrixExp[m] is always invertible, and the inverse is given by MatrixExp[-m]:
m = KroneckerProduct[RandomReal[1, 3], RandomReal[1, 3]];{MatrixRank[m], MatrixRank[MatrixExp[m]]}MatrixExp[m].MatrixExp[-m]//ChopMatrixExp of a real, antisymmetric matrix is orthogonal:
a = {{0, 1, 2}, {-1, 0, 3}, {-2, -3, 0}};AntisymmetricMatrixQ[a]OrthogonalMatrixQ[MatrixExp[a]]MatrixExp of an antihermitian matrix is unitary:
a = {{0, 1 + 4I, 2 - 5I}, {-1 + 4I, 0, 3 + 6I}, {-2 - 5I, -3 + 6I, 0}};AntihermitianMatrixQ[a]UnitaryMatrixQ[MatrixExp[a]]MatrixExp of a Hermitian matrix is positive-definite:
h = {{1, 2 + 3I}, {2 - 3I, -4}};HermitianMatrixQ[h]PositiveDefiniteMatrixQ[MatrixExp[h]]MatrixExp satisfies
:
m = {{1, 2}, {3, 4}};D[MatrixExp[m t], t] == m . MatrixExp[m t]//FullSimplifyThe matrix exponential of a nilpotent matrix is a polynomial in the exponentiation parameter:
n = {{0, 2, 3, 4}, {0, 0, 5, 6}, {0, 0, 0, 7}, {0, 0, 0, 0}};MatrixExp[n t]//MatrixFormConfirm that
is nilpotent (
for some
):
MatrixPower[n, 4]
can be computed from the JordanDecomposition as ![]()
m = {{2, 0, 0, 0}, {0, 1, 0, 0}, {1, -1, 1, 0}, {1, -1, 1, 1}};
{s, j} = JordanDecomposition[m];
MatrixExp[m] == s.MatrixExp[j].Inverse[s]Moreover,
is zero except in upper triangular blocks delineated by
s in the superdiagonal:
MatrixForm /@ {j, MatrixExp[j]}Possible Issues (1)
For a large sparse matrix, computing the matrix exponential may take a long time:
Block[{n = 1000},
v = RandomComplex[1 + I, 1000];
s = N[SparseArray[{{i_, i_} -> -2 I, {i_, j_} /; Abs[i - j] == 1 -> I, {1, n} -> I, {n, 1} -> I}, {n, n}, (0. + 0. I)]]]Timing[m = MatrixExp[s];]Computing the application of it to a vector uses less memory and is much faster:
Timing[ev = MatrixExp[s, v];]The results are essentially the same:
Max[Abs[ev - m.v]]History
Introduced in 1991 (2.0) | Updated in 2007 (6.0) ▪ 2014 (10.0) ▪ 2024 (14.0) ▪ 2026 (15.0)
Text
Wolfram Research (1991), MatrixExp, Wolfram Language function, https://reference.wolfram.com/language/ref/MatrixExp.html (updated 2026).
CMS
Wolfram Language. 1991. "MatrixExp." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/MatrixExp.html.
APA
Wolfram Language. (1991). MatrixExp. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MatrixExp.html
BibTeX
@misc{reference.wolfram_2026_matrixexp, author="Wolfram Research", title="{MatrixExp}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/MatrixExp.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_matrixexp, organization={Wolfram Research}, title={MatrixExp}, year={2026}, url={https://reference.wolfram.com/language/ref/MatrixExp.html}, note=[Accessed: 12-June-2026]}