Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Advanced linear algebra

Matrix Functions: the Matrix Exponential and Square Root

Apply exp, √ or any function to a matrix. The exponential solves every linear ODE, turns rotation rates into rotations, and discretizes dynamics for robots, filters and state-space models. The square root whitens data and samples Gaussians.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

From “how fast it changes” to “where it ends up”

If your savings grow by a fixed percentage, the money follows an exponential curve. Knowing the growth rate tells you the amount at any future time.

Now imagine many things changing together. A spinning satellite’s orientation changes depending on how it’s already turned, and a robot arm’s position and speed affect each other. The matrix exponential does the same job for all of them at once: it turns a table of rates into a map that says where everything will be after time tt.

ẋ = Ax: the matrix exponential moves every point
A =
eigenvalues: -0.30 ± 1.50i → stable: every trajectory decays to 0
e^(tA) = [[-0.401, -0.496], [0.496, -0.401]] · det = 0.4066 = e^(t·tr A) = 0.4066
Grey dots = starting points x₀; orange dots = e^(tA)x₀ at the chosen time; blue = full paths. The real parts of the eigenvalues decide stability; imaginary parts make it spin.
Why engineers care

Every flight computer that predicts where a spacecraft will be a second from now, and every robot that turns a spin rate into a new orientation, is using a matrix exponential, or an approximation of one.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Money doubles every year. After 3 years it has grown by…
  2. 2. Something halves every second. After 2 seconds, what fraction is left?
  3. 3. In the demo, the 'stable spiral' paths…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

The exponential series

For numbers, ex=1+x+x22!+x33!+⋯e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots. Since we can multiply and add matrices, the same recipe works for them:

eA=I+A+A22!+A33!+⋯e^A = I + A + \frac{A^2}{2!} + \frac{A^3}{3!} + \cdots
  • Diagonal matrices are easy: ediag⁡(a,b)=diag⁡(ea,eb)e^{\operatorname{diag}(a,b)} = \operatorname{diag}(e^a, e^b).
  • Why we care: the solution of x˙=ax\dot x = ax is x(t)=eatx0x(t) = e^{at}x_0. The solution of x˙=Ax\dot{\mathbf x} = A\mathbf x is
x(t)=etAx0\mathbf x(t) = e^{tA}\mathbf x_0

The matrix square root

A square root of AA is any BB with B2=AB^2 = A. For a positive semidefinite AA, there’s exactly one PSD root. For a diagonal matrix, take the square root of each entry: diag⁡(9,4)=diag⁡(3,2)\sqrt{\operatorname{diag}(9,4)} = \operatorname{diag}(3,2).

📝 Quick check (Level 1)
0/3 answered
  1. 1. e^(diag(0, ln 2)) has bottom-right entry…
  2. 2. e^O (the zero matrix) = ?
  3. 3. √diag(9, 4) = ?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

Functions of a diagonalizable matrix

If A=VΛV−1A = V\Lambda V^{-1}, then Ak=VΛkV−1A^k = V\Lambda^kV^{-1}. Every power series therefore passes through:

f(A)=V f(Λ) V−1=Vdiag⁡(f(λ1),…,f(λn))V−1f(A) = V\,f(\Lambda)\,V^{-1} = V\operatorname{diag}\big(f(\lambda_1),\dots,f(\lambda_n)\big)V^{-1}

For symmetric A=QΛQ⊤A = Q\Lambda Q^\top, this gives eAe^A, A\sqrt A (when λi≥0\lambda_i\ge0), A−1/2A^{-1/2}, log⁡A\log A and so on. The eigenvalues of f(A)f(A) are f(λi)f(\lambda_i).

Properties of the exponential

Property Why it matters
ddtetA=AetA\frac{d}{dt}e^{tA} = Ae^{tA} solves x˙=Ax\dot{\mathbf x} = A\mathbf x
det⁡eA=etr⁡A\det e^A = e^{\operatorname{tr}A} volume growth rate = trace (divergence)
(eA)−1=e−A(e^A)^{-1} = e^{-A} eAe^A is always invertible
eA+B=eAeBe^{A+B} = e^Ae^B only if AB=BAAB = BA the order of rotations matters
Re⁡λi<0 ∀i  ⟺  etA→0\operatorname{Re}\lambda_i < 0\ \forall i \iff e^{tA}\to0 stability of linear systems and controllers
A⊤=−A  ⟹  eAA^\top = -A\implies e^A orthogonal rotation rates → rotations

Rotation example. For J=(0−110)J = \begin{pmatrix}0&-1\\1&0\end{pmatrix}, J2=−IJ^2 = -I. The series splits into cos and sin: eθJ=(cos⁡θ−sin⁡θsin⁡θcos⁡θ)e^{\theta J} = \begin{pmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{pmatrix}.

🐍 Exercise 1: two ways to compute e^A
Implement e^A via the eigendecomposition and via the Taylor series. Check the rotation example, det e^A = e^(tr A), and (e^A)⁻¹ = e^(−A).

The square root in data science

  • Whitening: z=Σ−1/2(x−μ)\mathbf z = \Sigma^{-1/2}(\mathbf x - \boldsymbol\mu) has identity covariance. Whitening is used in ICA, Mahalanobis distance and preconditioning.
  • Sampling: if z∼N(0,I)\mathbf z\sim\mathcal N(0,I), then Σ1/2z∼N(0,Σ)\Sigma^{1/2}\mathbf z\sim\mathcal N(0,\Sigma). The Cholesky factor (A2.3-4) is another valid “square root” (LL⊤=ΣLL^\top = \Sigma).
  • Optimal transport between Gaussians: the Wasserstein distance and the Fréchet Inception Distance (FID) use (Σ11/2Σ2Σ11/2)1/2(\Sigma_1^{1/2}\Sigma_2\Sigma_1^{1/2})^{1/2}.
📝 Quick check (Level 2)
0/3 answered
  1. 1. det(e^A) when tr A = 2?
  2. 2. ẋ = [[−1, 5], [0, −2]]x is…
  3. 3. e^(A+B) = e^A e^B is guaranteed when…

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Convergence and the derivative

The series always converges: ∥Ak/k!∥≤∥A∥k/k!\lVert A^k/k!\rVert\le\lVert A\rVert^k/k!, so it is dominated by e∥A∥e^{\lVert A\rVert}. Differentiating term by term gives

ddt∑ktkAkk!=∑k≥1tk−1Ak(k−1)!=A etA\frac{d}{dt}\sum_k\frac{t^kA^k}{k!} = \sum_{k\ge1}\frac{t^{k-1}A^k}{(k-1)!} = A\,e^{tA}

Since e0A=Ie^{0A} = I, the function etAx0e^{tA}\mathbf x_0 solves x˙=Ax\dot{\mathbf x} = A\mathbf x with x(0)=x0\mathbf x(0) = \mathbf x_0. By uniqueness of ODE solutions, it is the solution.

Non-diagonalizable matrices

For the Jordan block J=λI+NJ = \lambda I + N with N=(0100)N = \begin{pmatrix}0&1\\0&0\end{pmatrix}, we have N2=0N^2 = 0. Also λI\lambda I and NN commute, so

etJ=eλt(I+tN)=eλt(1t01)e^{tJ} = e^{\lambda t}(I + tN) = e^{\lambda t}\begin{pmatrix}1&t\\0&1\end{pmatrix}

The factor tt creates the transient growth of defective (critically damped) systems. In general, by Cayley–Hamilton every f(A)f(A) equals a polynomial in AA of degree <n< n. That is the basis of Sylvester’s formula and of the Cauchy-integral definition f(A)=12πi∮f(z)(zI−A)−1dzf(A) = \frac1{2\pi i}\oint f(z)(zI - A)^{-1}dz.

The principal square root

Theorem

Every symmetric PSD AA has a unique symmetric PSD square root A1/2=QΛ1/2Q⊤A^{1/2} = Q\Lambda^{1/2}Q^\top.

Proof sketch of uniqueness. If BB is PSD with B2=AB^2 = A, then BB commutes with AA, so it preserves each eigenspace of AA. On the eigenspace for λ\lambda, BB is PSD with B2=λIB^2 = \lambda I, which forces B=λIB = \sqrt\lambda I there. ∎ General matrices may have many square roots, or none at all (NN above has none). For large matrices, use the Newton or Denman–Beavers iteration.

Exercise 3.1: Why is det e^A = e^(tr A)?

The eigenvalues of eAe^A are eλie^{\lambda_i} (this holds for triangularizable, i.e. all, complex matrices). So det⁡eA=∏eλi=e∑λi=etr⁡A\det e^A = \prod e^{\lambda_i} = e^{\sum\lambda_i} = e^{\operatorname{tr}A}.

📝 Quick check (Level 3)
0/3 answered
  1. 1. e^(tN) with N = [[0, 1], [0, 0]] and t = 3 has top-right entry…
  2. 2. For 3×3 A, f(A) equals a polynomial in A of degree at most…
  3. 3. ‖A‖ = 2. A bound on ‖e^A‖?

Level 4: Expert

★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.

Computing the exponential: “nineteen dubious ways”

Moler and Van Loan (1978, revisited 2003) catalogued many methods and showed that most fail somewhere. The naive Taylor series can be ruined by cancellation. The stable 2×2 matrix with eigenvalues −2 and −34 below produces terms near 101510^{15}, which cancel down to an answer of order 1. The standard algorithm (Higham, 2005; used by scipy.linalg.expm and MATLAB) is scaling and squaring with a Padé approximant:

eA=(eA/2s)2se^A = \big(e^{A/2^s}\big)^{2^s}
🐍 Exercise 2 (research): scaling and squaring vs the naive series
On Moler and Van Loan's example, compare the naive Taylor series (150 terms!) with scaling and squaring.

The exponential in robotics, control and ML

  • Lie groups. Rotations form the group SO(3), and rigid motions form SE(3). Their “rates” are skew matrices [ω]×[\boldsymbol\omega]_\times and twists, and exp⁡\exp maps rates to motions. Rodrigues’ formula eθ[k]×=I+sin⁡θ K+(1−cos⁡θ)K2e^{\theta[\mathbf k]_\times} = I + \sin\theta\,K + (1 - \cos\theta)K^2 is the closed form. Robot kinematics in the product-of-exponentials form, T(θ)=e[S1]θ1⋯e[Sn]θnMT(\boldsymbol\theta) = e^{[\mathcal S_1]\theta_1}\cdots e^{[\mathcal S_n]\theta_n}M (Brockett, 1984; Lynch and Park, 2017), is standard in modern robotics. On-manifold IMU preintegration for visual-inertial odometry also relies on these maps (Forster et al., 2017).
  • Exact discretization. Continuous dynamics x˙=Ax+Bu\dot{\mathbf x} = A\mathbf x + B\mathbf u sampled every Δt\Delta t with a zero-order hold become xk+1=eAΔtxk+(∫0ΔteAτdτ)Buk\mathbf x_{k+1} = e^{A\Delta t}\mathbf x_k + \big(\int_0^{\Delta t}e^{A\tau}d\tau\big)B\mathbf u_k. This is how digital controllers and Kalman filters handle physical models.
  • State-space sequence models. S4 and Mamba discretize a continuous linear system with Aˉ=exp⁡(ΔA)\bar A = \exp(\Delta A) (Gu et al., 2022; Gu and Dao, 2023). Neural ODEs integrate learned dynamics (Chen et al., 2018).
  • Quantum and Markov dynamics. e−iHte^{-iHt} evolves quantum states. etQe^{tQ} gives the transition probabilities of continuous-time Markov chains.

References

  1. C. Moler, C. Van Loan (2003). “Nineteen dubious ways to compute the exponential of a matrix, twenty-five years later.” SIAM Review, 45(1).
  2. N. Higham (2005). “The scaling and squaring method for the matrix exponential revisited.” SIAM J. Matrix Anal. Appl., 26(4).
  3. N. Higham (2008). Functions of Matrices: Theory and Computation. SIAM.
  4. R. Brockett (1984). “Robotic manipulators and the product of exponentials formula.” Mathematical Theory of Networks and Systems.
  5. K. Lynch, F. Park (2017). Modern Robotics: Mechanics, Planning, and Control. Cambridge University Press. Chapters 3–4.
  6. C. Forster, L. Carlone, F. Dellaert, D. Scaramuzza (2017). “On-manifold preintegration for real-time visual-inertial odometry.” IEEE Transactions on Robotics, 33(1).
  7. R. T. Q. Chen, Y. Rubanova, J. Bettencourt, D. Duvenaud (2018). “Neural ordinary differential equations.” NeurIPS.
  8. A. Gu, K. Goel, C. Ré (2022). “Efficiently modeling long sequences with structured state spaces.” ICLR.