Practice / Linear algebra

Matrix exponentials and linear systems of ODEs

Ten problems on matrix exponentials and linear systems of differential equations: solving x′ = Ax from the eigenvectors and the initial condition, e^(At) = Ve^(Λt)V⁻¹ for a 2×2 matrix, a repeated eigenvalue with one eigenvector and e^(At) = e^(λt)(I + Nt), the rotation e^(Jt) from the series and a decaying spiral, classifying four equilibria from the trace and determinant, a second-order equation rewritten as a first-order system, det e^(At) = e^(t tr A), two matrices with e^(A+B) ≠ e^A e^B, a two-state machine with rate matrix Q and P(t) = e^(Qt), and gradient flow on a quadratic loss compared with gradient descent, with worked solutions and the mistakes of exponentiating entry by entry, splitting e^(A+B) when A and B do not commute, writing V⁻¹e^(Λt)V, treating a defective matrix as diagonalizable and reading stability off the diagonal.

Before you start

A single linear differential equation x′=axx' = ax has the solution x(t)=eatx(0)x(t) = e^{at}x(0). A system of them, x′=Axx' = Ax with a vector xx and a square matrix AA, has exactly the same solution, x(t)=eAtx(0)x(t) = e^{At}x(0), once the exponential of a matrix is defined by the same power series. Computing eAte^{At} is an eigenvalue problem: each eigenvector of AA grows or decays at its own rate eλte^{\lambda t}, complex eigenvalues turn the motion into a rotation, and the signs of the real parts decide whether every solution dies out. The same object turns a rate matrix into the transition probabilities of a continuous-time Markov chain, and it is what gradient descent approximates when the step size is small. These ten problems compute eAte^{At} in each of the cases that come up by hand, and the places where the scalar rules stop working for matrices.

  • The matrix exponential is eM=I+M+12!M2+13!M3+⋯e^{M} = I + M + \tfrac{1}{2!}M^2 + \tfrac{1}{3!}M^3 + \cdots, which converges for every square matrix. It satisfies ddteAt=AeAt\tfrac{d}{dt}e^{At} = Ae^{At} and eA⋅0=Ie^{A\cdot0} = I, so x(t)=eAtx(0)x(t) = e^{At}x(0) solves x′=Axx' = Ax.
  • Diagonalizable case. If Avi=λiviAv_i = \lambda_iv_i and VV has the eigenvectors as columns, then A=VΛV−1A = V\Lambda V^{-1} and eAt=VeΛtV−1e^{At} = Ve^{\Lambda t}V^{-1}, where eΛte^{\Lambda t} is diagonal with entries eλite^{\lambda_it}. Equivalently x(t)=∑icieλitvix(t) = \sum_i c_ie^{\lambda_it}v_i, with the constants c=V−1x(0)c = V^{-1}x(0).
  • Commuting matrices. If AB=BAAB = BA then eA+B=eAeBe^{A + B} = e^Ae^B. In particular e(λI+N)t=eλteNte^{(\lambda I + N)t} = e^{\lambda t}e^{Nt}, and if N2=0N^2 = 0 the series stops: eNt=I+Nte^{Nt} = I + Nt. Without AB=BAAB = BA the product rule fails.
  • Complex eigenvalues α±βi\alpha \pm \beta i of a real matrix give solutions eαte^{\alpha t} times a rotation at angular speed β\beta: a spiral, inward if α<0\alpha < 0.
  • Stability. Every solution tends to 00 exactly when every eigenvalue has negative real part. For a 2×22\times2 matrix with trace τ\tau and determinant Δ\Delta the eigenvalues solve λ2−τλ+Δ=0\lambda^2 - \tau\lambda + \Delta = 0: Δ<0\Delta < 0 is a saddle; with Δ>0\Delta > 0 the origin is stable if τ<0\tau < 0 and unstable if τ>0\tau > 0, a center if τ=0\tau = 0, and a spiral when τ2<4Δ\tau^2 < 4\Delta.
  • det⁡eA=etr⁡A\det e^{A} = e^{\operatorname{tr}A}, so eAe^{A} is never singular, and its inverse is e−Ae^{-A}.

Builds on: Eigenvalues and eigenvectors by hand, Second-order linear differential equations with constant coefficients

Problems

  1. ·

    Solve x′=Axx' = Ax with A=(4123)A = \begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix} and x(0)=(2,−1)x(0) = (2, -1), using the eigenvalues and eigenvectors of AA.

  2. ··

    For the matrix AA of Problem 1, compute eAt=VeΛtV−1e^{At} = Ve^{\Lambda t}V^{-1}, and check that it reproduces the solution of Problem 1.

  3. ··

    Show that A=(31−11)A = \begin{pmatrix} 3 & 1 \\ -1 & 1 \end{pmatrix} has a repeated eigenvalue with only one independent eigenvector. Compute eAte^{At} by writing A=2I+NA = 2I + N, and solve x′=Axx' = Ax with x(0)=(1,0)x(0) = (1, 0).

  4. ··

    Let J=(0−110)J = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}. Compute eJte^{Jt} from the power series. Then solve x′=Bxx' = Bx for B=(−1−22−1)B = \begin{pmatrix} -1 & -2 \\ 2 & -1 \end{pmatrix} with x(0)=(1,0)x(0) = (1, 0), and find x(π/2)x(\pi/2) and ∣x(t)∣|x(t)|.

  5. ·

    Classify the equilibrium at the origin of x′=Axx' = Ax from the trace and determinant, and confirm with the eigenvalues, for

    A1=(−311−3),A2=(1−51−1),A_1 = \begin{pmatrix} -3 & 1 \\ 1 & -3 \end{pmatrix},\quad A_2 = \begin{pmatrix} 1 & -5 \\ 1 & -1 \end{pmatrix},
    A3=(1230),A4=(2−332).A_3 = \begin{pmatrix} 1 & 2 \\ 3 & 0 \end{pmatrix},\quad A_4 = \begin{pmatrix} 2 & -3 \\ 3 & 2 \end{pmatrix}.
  6. ··

    Rewrite y′′+3y′+2y=0y'' + 3y' + 2y = 0 with y(0)=1y(0) = 1, y′(0)=0y'(0) = 0 as a first-order system x′=Axx' = Ax for x=(y,y′)x = (y, y'), and solve it with eigenvectors.

  7. ·

    Check that det⁡eAt=ettr⁡A\det e^{At} = e^{t\operatorname{tr}A} for the matrices of Problems 2 and 3, and explain why eAte^{At} is always invertible.

  8. ···

    Let A=(0100)A = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} and B=(0010)B = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}. Compute eAe^A, eBe^B, eAeBe^Ae^B, eBeAe^Be^A and eA+Be^{A + B}, and explain the difference.

  9. ··

    A machine is up (U) or down (D). It fails at rate 11 per day and is repaired at rate 33 per day, so its rate matrix is Q=(−113−3)Q = \begin{pmatrix} -1 & 1 \\ 3 & -3 \end{pmatrix} and its transition matrix is P(t)=eQtP(t) = e^{Qt}. Find P(t)P(t), the probability that a machine up now is down 1212 hours from now, and the long-run fraction of time it is up.

  10. ···

    Gradient flow on the loss L(w)=12w⊤HwL(w) = \tfrac12w^\top Hw with H=(3113)H = \begin{pmatrix} 3 & 1 \\ 1 & 3 \end{pmatrix} is w′=−Hww' = -Hw. Starting from w(0)=(2,0)w(0) = (2, 0), find w(t)w(t), L(w(t))L(w(t)) and when LL first drops below 0.010.01. Then compare gradient descent wk+1=(I−ηH)wkw_{k+1} = (I - \eta H)w_k with η=0.1\eta = 0.1 for 1010 steps against the flow at t=1t = 1, and find the step sizes for which gradient descent converges.

Worked solutions

Problem 1

Solve x′=Axx' = Ax with A=(4123)A = \begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix} and x(0)=(2,−1)x(0) = (2, -1), using the eigenvalues and eigenvectors of AA.

  1. λ2−7λ+10=0\lambda^2 - 7\lambda + 10 = 0, so λ1=5\lambda_1 = 5, λ2=2\lambda_2 = 2The trace is 77 and the determinant 12−2=1012 - 2 = 10.
  2. v1=(1,1)v_1 = (1, 1), v2=(1,−2)v_2 = (1, -2)(A−5I)v=0(A - 5I)v = 0 reads −x+y=0-x + y = 0; (A−2I)v=0(A - 2I)v = 0 reads 2x+y=02x + y = 0.
  3. c1(1,1)+c2(1,−2)=(2,−1)c_1(1, 1) + c_2(1, -2) = (2, -1) gives c1=1c_1 = 1, c2=1c_2 = 1Subtracting the second equation from the first: 3c2=33c_2 = 3.
  4. x(t)=e5t(1,1)+e2t(1,−2)x(t) = e^{5t}(1, 1) + e^{2t}(1, -2)Each eigenvector component grows at its own rate eλte^{\lambda t}.
  5. x(t)=(e5t+e2t, e5t−2e2t)x(t) = \big(e^{5t} + e^{2t},\ e^{5t} - 2e^{2t}\big)Check: x(0)=(2,−1)x(0) = (2, -1) and x′(0)=(5+2,5−4)=(7,1)=A (2,−1)x'(0) = (5 + 2, 5 - 4) = (7, 1) = A\,(2, -1). For large tt the e5te^{5t} term dominates and xx points along (1,1)(1, 1).

Problem 2

For the matrix AA of Problem 1, compute eAt=VeΛtV−1e^{At} = Ve^{\Lambda t}V^{-1}, and check that it reproduces the solution of Problem 1.

  1. V=(111−2)V = \begin{pmatrix} 1 & 1 \\ 1 & -2 \end{pmatrix}, V−1=13(211−1)V^{-1} = \tfrac13\begin{pmatrix} 2 & 1 \\ 1 & -1 \end{pmatrix}The eigenvectors of Problem 1 as columns; det⁡V=−3\det V = -3.
  2. eΛtV−1=13(2e5te5te2t−e2t)e^{\Lambda t}V^{-1} = \tfrac13\begin{pmatrix} 2e^{5t} & e^{5t} \\ e^{2t} & -e^{2t} \end{pmatrix}A diagonal matrix on the left scales the rows.
  3. eAt=13(2e5t+e2te5t−e2t2e5t−2e2te5t+2e2t)e^{At} = \tfrac13\begin{pmatrix} 2e^{5t} + e^{2t} & e^{5t} - e^{2t} \\ 2e^{5t} - 2e^{2t} & e^{5t} + 2e^{2t} \end{pmatrix}Multiply by VV on the left.
  4. At t=0t = 0 it is II, and its derivative there is 13(12369)=A\tfrac13\begin{pmatrix} 12 & 3 \\ 6 & 9 \end{pmatrix} = AThe two properties that define eAte^{At}.
  5. eAte^{At} as in step 3; eAt(2,−1)=(e5t+e2t, e5t−2e2t)e^{At}(2, -1) = (e^{5t} + e^{2t},\ e^{5t} - 2e^{2t})The first entry is 13(4e5t+2e2t−e5t+e2t)\tfrac13(4e^{5t} + 2e^{2t} - e^{5t} + e^{2t}), matching Problem 1. Writing V−1eΛtVV^{-1}e^{\Lambda t}V instead gives the transpose of this matrix (Mistake 3).

Problem 3

Show that A=(31−11)A = \begin{pmatrix} 3 & 1 \\ -1 & 1 \end{pmatrix} has a repeated eigenvalue with only one independent eigenvector. Compute eAte^{At} by writing A=2I+NA = 2I + N, and solve x′=Axx' = Ax with x(0)=(1,0)x(0) = (1, 0).

  1. λ2−4λ+4=(λ−2)2\lambda^2 - 4\lambda + 4 = (\lambda - 2)^2Trace 44, determinant 3+1=43 + 1 = 4.
  2. N=A−2I=(11−1−1)N = A - 2I = \begin{pmatrix} 1 & 1 \\ -1 & -1 \end{pmatrix}, and Nv=0Nv = 0 only for multiples of (1,−1)(1, -1)NN has rank 11, so there is one eigenvector and VV cannot be built.
  3. N2=0N^2 = 0, so eNt=I+Nte^{Nt} = I + NtThe series stops after the linear term.
  4. eAt=e2t(I+Nt)=e2t(1+tt−t1−t)e^{At} = e^{2t}(I + Nt) = e^{2t}\begin{pmatrix} 1 + t & t \\ -t & 1 - t \end{pmatrix}2I2I commutes with every matrix, so e(2I+N)t=e2teNte^{(2I + N)t} = e^{2t}e^{Nt}.
  5. x(t)=e2t(1+t, −t)x(t) = e^{2t}(1 + t,\ -t)The first column of eAte^{At}. Check: x′(0)=(2+1,−1)=(3,−1)=A (1,0)x'(0) = (2 + 1, -1) = (3, -1) = A\,(1, 0). The factor tt next to e2te^{2t} is what a repeated eigenvalue adds, as tertte^{rt} does for a repeated characteristic root (Mistake 4).

Problem 4

Let J=(0−110)J = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}. Compute eJte^{Jt} from the power series. Then solve x′=Bxx' = Bx for B=(−1−22−1)B = \begin{pmatrix} -1 & -2 \\ 2 & -1 \end{pmatrix} with x(0)=(1,0)x(0) = (1, 0), and find x(π/2)x(\pi/2) and ∣x(t)∣|x(t)|.

  1. J2=−IJ^2 = -I, so J3=−JJ^3 = -J and J4=IJ^4 = IThe powers cycle with period 44, like the powers of ii.
  2. eJt=(1−t22!+⋯)I+(t−t33!+⋯)Je^{Jt} = \big(1 - \tfrac{t^2}{2!} + \cdots\big)I + \big(t - \tfrac{t^3}{3!} + \cdots\big)JGroup the even and the odd powers.
  3. eJt=(cos⁡t−sin⁡tsin⁡tcos⁡t)e^{Jt} = \begin{pmatrix} \cos t & -\sin t \\ \sin t & \cos t \end{pmatrix}The two series are cos⁡t\cos t and sin⁡t\sin t: rotation by the angle tt.
  4. B=−I+2JB = -I + 2J, so eBt=e−te2Jte^{Bt} = e^{-t}e^{2Jt}−I-I commutes with JJ. The eigenvalues of BB are −1±2i-1 \pm 2i.
  5. x(t)=e−t(cos⁡2t, sin⁡2t)x(t) = e^{-t}(\cos 2t,\ \sin 2t)The first column of e−te^{-t} times the rotation by 2t2t.
  6. x(π/2)=(−e−π/2,0)≈(−0.208,0)x(\pi/2) = (-e^{-\pi/2}, 0) \approx (-0.208, 0) and ∣x(t)∣=e−t|x(t)| = e^{-t}A spiral that turns at angular speed 22, the imaginary part of the eigenvalues, and shrinks at rate 11, the negative of the real part. By t=π2t = \tfrac\pi2 it has turned through the angle π\pi, halfway around.

Problem 5

Classify the equilibrium at the origin of x′=Axx' = Ax from the trace and determinant, and confirm with the eigenvalues, for

A1=(−311−3),A2=(1−51−1),A_1 = \begin{pmatrix} -3 & 1 \\ 1 & -3 \end{pmatrix},\quad A_2 = \begin{pmatrix} 1 & -5 \\ 1 & -1 \end{pmatrix},
A3=(1230),A4=(2−332).A_3 = \begin{pmatrix} 1 & 2 \\ 3 & 0 \end{pmatrix},\quad A_4 = \begin{pmatrix} 2 & -3 \\ 3 & 2 \end{pmatrix}.
  1. A1A_1: τ=−6\tau = -6, Δ=8\Delta = 8, τ2−4Δ=4>0\tau^2 - 4\Delta = 4 > 0Real eigenvalues −6±22=−2,−4\tfrac{-6 \pm 2}{2} = -2, -4: a stable node.
  2. A2A_2: τ=0\tau = 0, Δ=−1+5=4\Delta = -1 + 5 = 4Eigenvalues ±2i\pm 2i: a center. Orbits are closed curves that neither shrink nor grow.
  3. A3A_3: Δ=−6<0\Delta = -6 < 0Eigenvalues 33 and −2-2, of opposite signs: a saddle, unstable.
  4. A4A_4: τ=4\tau = 4, Δ=13\Delta = 13, τ2−4Δ=−36<0\tau^2 - 4\Delta = -36 < 0Eigenvalues 2±3i2 \pm 3i: an unstable spiral.
  5. A1A_1 stable node, A2A_2 center, A3A_3 saddle, A4A_4 unstable spiralOnly A1A_1 sends every solution to 00. A4A_4 has Δ>0\Delta > 0 like A1A_1, so the determinant alone cannot decide stability; and a matrix with a negative diagonal can still be a saddle (Mistake 5).

Problem 6

Rewrite y′′+3y′+2y=0y'' + 3y' + 2y = 0 with y(0)=1y(0) = 1, y′(0)=0y'(0) = 0 as a first-order system x′=Axx' = Ax for x=(y,y′)x = (y, y'), and solve it with eigenvectors.

  1. A=(01−2−3)A = \begin{pmatrix} 0 & 1 \\ -2 & -3 \end{pmatrix}, x(0)=(1,0)x(0) = (1, 0)The first row says y′=y′y' = y'; the second is the equation solved for y′′y''.
  2. det⁡(A−λI)=λ2+3λ+2\det(A - \lambda I) = \lambda^2 + 3\lambda + 2, so λ=−1,−2\lambda = -1, -2The characteristic polynomial of AA is the characteristic equation of the ODE.
  3. v1=(1,−1)v_1 = (1, -1), v2=(1,−2)v_2 = (1, -2)For this companion matrix the eigenvector for λ\lambda is (1,λ)(1, \lambda): y=eλty = e^{\lambda t} has y′=λeλty' = \lambda e^{\lambda t}.
  4. c1+c2=1c_1 + c_2 = 1, −c1−2c2=0-c_1 - 2c_2 = 0, so c1=2c_1 = 2, c2=−1c_2 = -1Match x(0)=(1,0)x(0) = (1, 0).
  5. y(t)=2e−t−e−2ty(t) = 2e^{-t} - e^{-2t}The first entry of 2e−t(1,−1)−e−2t(1,−2)2e^{-t}(1, -1) - e^{-2t}(1, -2). Check: y(0)=1y(0) = 1 and y′(0)=−2+2=0y'(0) = -2 + 2 = 0. Both eigenvalues are negative and real, so yy decays without oscillating: the system is overdamped.

Problem 7

Check that det⁡eAt=ettr⁡A\det e^{At} = e^{t\operatorname{tr}A} for the matrices of Problems 2 and 3, and explain why eAte^{At} is always invertible.

  1. Problem 2: 9det⁡eAt=(2e5t+e2t)(e5t+2e2t)−2(e5t−e2t)29\det e^{At} = (2e^{5t} + e^{2t})(e^{5t} + 2e^{2t}) - 2(e^{5t} - e^{2t})^2The factor 13\tfrac13 squared comes out as 19\tfrac19.
  2. =(2e10t+5e7t+2e4t)−(2e10t−4e7t+2e4t)=9e7t= (2e^{10t} + 5e^{7t} + 2e^{4t}) - (2e^{10t} - 4e^{7t} + 2e^{4t}) = 9e^{7t}So det⁡eAt=e7t\det e^{At} = e^{7t}, and tr⁡A=7\operatorname{tr}A = 7.
  3. Problem 3: det⁡eAt=e4t((1+t)(1−t)+t2)=e4t\det e^{At} = e^{4t}\big((1 + t)(1 - t) + t^2\big) = e^{4t}Pulling e2te^{2t} out of both rows gives e4te^{4t}; the bracket is 11. tr⁡A=4\operatorname{tr}A = 4.
  4. In general det⁡eAt=∏ieλit=et∑iλi\det e^{At} = \prod_i e^{\lambda_it} = e^{t\sum_i\lambda_i}The eigenvalues of eAte^{At} are eλite^{\lambda_it}, and the determinant is their product.
  5. det⁡eAt=e7t\det e^{At} = e^{7t} and e4te^{4t}, never 00; the inverse is e−Ate^{-At}AtAt and −At-At commute, so eAte−At=e0=Ie^{At}e^{-At} = e^{0} = I. Running the system backward in time undoes it.

Problem 8

Let A=(0100)A = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} and B=(0010)B = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}. Compute eAe^A, eBe^B, eAeBe^Ae^B, eBeAe^Be^A and eA+Be^{A + B}, and explain the difference.

  1. eA=I+A=(1101)e^A = I + A = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}, eB=I+B=(1011)e^B = I + B = \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix}A2=B2=0A^2 = B^2 = 0, so each series stops.
  2. eAeB=(2111)e^Ae^B = \begin{pmatrix} 2 & 1 \\ 1 & 1 \end{pmatrix}, eBeA=(1112)e^Be^A = \begin{pmatrix} 1 & 1 \\ 1 & 2 \end{pmatrix}Already the two orders disagree.
  3. (A+B)2=I(A + B)^2 = I, so eA+B=(cosh⁡1)I+(sinh⁡1)(A+B)e^{A + B} = (\cosh 1)I + (\sinh 1)(A + B)Even powers are II and odd powers are A+BA + B, like eJe^{J} in Problem 4 without the signs.
  4. eA+B=(cosh⁡1sinh⁡1sinh⁡1cosh⁡1)≈(1.5431.1751.1751.543)e^{A + B} = \begin{pmatrix} \cosh 1 & \sinh 1 \\ \sinh 1 & \cosh 1 \end{pmatrix} \approx \begin{pmatrix} 1.543 & 1.175 \\ 1.175 & 1.543 \end{pmatrix}Symmetric, unlike either product.
  5. eA+Be^{A + B} equals neither eAeBe^Ae^B nor eBeAe^Be^A, because AB=(1000)≠(0001)=BAAB = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} \ne \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} = BAThe step eaeb=ea+be^{a}e^{b} = e^{a + b} rearranges aas past bbs, which matrices allow only when they commute. All three matrices have determinant 1=etr⁡(A+B)1 = e^{\operatorname{tr}(A + B)}, so the determinant cannot catch the error (Mistake 2).

Problem 9

A machine is up (U) or down (D). It fails at rate 11 per day and is repaired at rate 33 per day, so its rate matrix is Q=(−113−3)Q = \begin{pmatrix} -1 & 1 \\ 3 & -3 \end{pmatrix} and its transition matrix is P(t)=eQtP(t) = e^{Qt}. Find P(t)P(t), the probability that a machine up now is down 1212 hours from now, and the long-run fraction of time it is up.

  1. The eigenvalues of QQ are 00 and −4-4Each row of QQ sums to 00, so Q1=0Q\mathbf 1 = 0; the trace gives the other, −4-4.
  2. P(t)=14(3+e−4t1−e−4t3−3e−4t1+3e−4t)P(t) = \tfrac14\begin{pmatrix} 3 + e^{-4t} & 1 - e^{-4t} \\ 3 - 3e^{-4t} & 1 + 3e^{-4t} \end{pmatrix}The two-state formula of the Markov chains set with λ2n\lambda_2^n replaced by e−4te^{-4t}; at t=0t = 0 it is II, and its derivative there is QQ.
  3. Pr⁡(D at t=12∣U)=14(1−e−2)≈0.216\Pr(D \text{ at } t = \tfrac12 \mid U) = \tfrac14(1 - e^{-2}) \approx 0.216Twelve hours is t=12t = \tfrac12 day, so e−4t=e−2≈0.135e^{-4t} = e^{-2} \approx 0.135.
  4. As t→∞t \to \infty, both rows tend to (34,14)(\tfrac34, \tfrac14)The stationary distribution solves πQ=0\pi Q = 0: −πU+3πD=0-\pi_U + 3\pi_D = 0.
  5. P(t)P(t) as in step 2; down at 1212 hours with probability ≈0.216\approx 0.216; up 34\tfrac34 of the timeThe mean up time is 11 day and the mean repair 13\tfrac13 day, and 1/(1+13)=341/(1 + \tfrac13) = \tfrac34. The other entry of the top row at t=12t = \tfrac12 is ≈0.784\approx 0.784, and each row sums to 11, which an entrywise exponential does not (Mistake 1).

Problem 10

Gradient flow on the loss L(w)=12w⊤HwL(w) = \tfrac12w^\top Hw with H=(3113)H = \begin{pmatrix} 3 & 1 \\ 1 & 3 \end{pmatrix} is w′=−Hww' = -Hw. Starting from w(0)=(2,0)w(0) = (2, 0), find w(t)w(t), L(w(t))L(w(t)) and when LL first drops below 0.010.01. Then compare gradient descent wk+1=(I−ηH)wkw_{k+1} = (I - \eta H)w_k with η=0.1\eta = 0.1 for 1010 steps against the flow at t=1t = 1, and find the step sizes for which gradient descent converges.

  1. HH has eigenvalues 44 and 22 with eigenvectors (1,1)(1, 1) and (1,−1)(1, -1), and w(0)=(1,1)+(1,−1)w(0) = (1, 1) + (1, -1)HH is symmetric, so its eigenvectors are orthogonal.
  2. w(t)=e−4t(1,1)+e−2t(1,−1)w(t) = e^{-4t}(1, 1) + e^{-2t}(1, -1)e−Hte^{-Ht} multiplies each eigenvector component by e−λte^{-\lambda t}.
  3. L(w(t))=12(4⋅2e−8t+2⋅2e−4t)=4e−8t+2e−4tL(w(t)) = \tfrac12\big(4\cdot2e^{-8t} + 2\cdot2e^{-4t}\big) = 4e^{-8t} + 2e^{-4t}Orthogonal components add in w⊤Hww^\top Hw; each (1,±1)(1, \pm1) has squared length 22. At t=0t = 0, L=6L = 6.
  4. With u=e−4tu = e^{-4t}: 4u2+2u=0.014u^2 + 2u = 0.01 gives u≈0.00495u \approx 0.00495 and t=−14ln⁡u≈1.33t = -\tfrac14\ln u \approx 1.33The positive root of the quadratic. The slow direction, eigenvalue 22, sets the time.
  5. Gradient descent multiplies the components by 1−0.1⋅4=0.61 - 0.1\cdot4 = 0.6 and 1−0.1⋅2=0.81 - 0.1\cdot2 = 0.8 per step(I−ηH)(I - \eta H) has the same eigenvectors as HH.
  6. After 1010 steps: 0.610≈0.006050.6^{10} \approx 0.00605 and 0.810≈0.1070.8^{10} \approx 0.107, against e−4≈0.0183e^{-4} \approx 0.0183 and e−2≈0.135e^{-2} \approx 0.135Each step is the first two terms of e−ηHe^{-\eta H}; with η=0.1\eta = 0.1 that is close for the slow direction and rough for the fast one.
  7. w(t)=e−4t(1,1)+e−2t(1,−1)w(t) = e^{-4t}(1, 1) + e^{-2t}(1, -1), L=4e−8t+2e−4tL = 4e^{-8t} + 2e^{-4t}, below 0.010.01 from t≈1.33t \approx 1.33; gradient descent converges exactly for 0<η<120 < \eta < \tfrac12Convergence needs ∣1−ηλ∣<1|1 - \eta\lambda| < 1 for both eigenvalues, so η<2/λmax⁡=12\eta < 2/\lambda_{\max} = \tfrac12. The flow converges for every tt; only the discrete steps can overshoot.

Where this goes wrong

1. Exponentiating entry by entry

The scalar exponential is applied to each entry, as np.exp does to an array.

  1. Q=(−113−3)Q = \begin{pmatrix} -1 & 1 \\ 3 & -3 \end{pmatrix}, t=12t = \tfrac12Right so far: Problem 9.
  2. “P(12)=eQtP(\tfrac12) = e^{Qt}, so exponentiate each entry of 12Q\tfrac12Q.”eMe^{M} is the power series in the matrix MM; its entries mix all the entries of MM. In Python it is scipy.linalg.expm, not numpy's np.exp.
  3. P(12)=(e−0.5e0.5e1.5e−1.5)P(\tfrac12) = \begin{pmatrix} e^{-0.5} & e^{0.5} \\ e^{1.5} & e^{-1.5} \end{pmatrix}Its first row is (0.607,1.649)(0.607, 1.649), which sums to 2.2552.255, and at t=0t = 0 the same rule gives a matrix of ones instead of II. The correct first row is (0.784,0.216)(0.784, 0.216).

2. Splitting e^(A+B) when A and B do not commute

The scalar rule ea+b=eaebe^{a + b} = e^ae^b is used to split a matrix into easy pieces.

  1. A=(1102)=D+NA = \begin{pmatrix} 1 & 1 \\ 0 & 2 \end{pmatrix} = D + N with D=(1002)D = \begin{pmatrix} 1 & 0 \\ 0 & 2 \end{pmatrix}, N=(0100)N = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix}Right so far: a diagonal part and a part with N2=0N^2 = 0.
  2. “eAt=eDteNt=eDt(I+Nt)e^{At} = e^{Dt}e^{Nt} = e^{Dt}(I + Nt).”DN=(0100)DN = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} but ND=(0200)ND = \begin{pmatrix} 0 & 2 \\ 0 & 0 \end{pmatrix}, so the split is not allowed. It worked in Problems 3 and 4 because the diagonal part there was a multiple of II.
  3. eA=(ee0e2)e^{A} = \begin{pmatrix} e & e \\ 0 & e^2 \end{pmatrix}The eigenvectors (1,0)(1, 0) and (1,1)(1, 1) give eAt=(ete2t−et0e2t)e^{At} = \begin{pmatrix} e^t & e^{2t} - e^t \\ 0 & e^{2t} \end{pmatrix}, so the corner of eAe^A is e2−e≈4.671e^2 - e \approx 4.671, not e≈2.718e \approx 2.718.

3. V⁻¹ e^(Λt) V instead of V e^(Λt) V⁻¹

The two outer factors are written in the wrong order.

  1. V=(111−2)V = \begin{pmatrix} 1 & 1 \\ 1 & -2 \end{pmatrix}, V−1=13(211−1)V^{-1} = \tfrac13\begin{pmatrix} 2 & 1 \\ 1 & -1 \end{pmatrix} for A=(4123)A = \begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix}Right so far: Problem 2.
  2. “eAt=V−1eΛtVe^{At} = V^{-1}e^{\Lambda t}V.”A=VΛV−1A = V\Lambda V^{-1}: V−1V^{-1} converts xx into eigenvector coordinates, eΛte^{\Lambda t} scales them, and VV converts back, so V−1V^{-1} acts first and sits on the right.
  3. eAt=13(2e5t+e2t2e5t−2e2te5t−e2te5t+2e2t)e^{At} = \tfrac13\begin{pmatrix} 2e^{5t} + e^{2t} & 2e^{5t} - 2e^{2t} \\ e^{5t} - e^{2t} & e^{5t} + 2e^{2t} \end{pmatrix}Its derivative at t=0t = 0 is (4213)=A⊤\begin{pmatrix} 4 & 2 \\ 1 & 3 \end{pmatrix} = A^\top, not AA: here it is the transpose of the right answer, because this VV happens to be symmetric. In general V−1eΛtVV^{-1}e^{\Lambda t}V is the exponential of V−1ΛVV^{-1}\Lambda V, a different matrix with the same eigenvalues, so a check of the trace or the determinant cannot catch the slip.

4. A repeated eigenvalue treated as two eigenvectors

The eigenvalue 22 is listed twice and VV is assumed to exist.

  1. A=(31−11)A = \begin{pmatrix} 3 & 1 \\ -1 & 1 \end{pmatrix} has the double eigenvalue 22Right so far: Problem 3.
  2. “So Λ=2I\Lambda = 2I and eAt=Ve2tIV−1=e2tIe^{At} = Ve^{2tI}V^{-1} = e^{2t}I.”That would make A=V(2I)V−1=2IA = V(2I)V^{-1} = 2I. A matrix that is not already 2I2I has only one eigenvector here, and VV is singular.
  3. x(t)=e2t(1,0)x(t) = e^{2t}(1, 0) for x(0)=(1,0)x(0) = (1, 0)Its derivative at 00 is (2,0)(2, 0), but A (1,0)=(3,−1)A\,(1, 0) = (3, -1). The correct solution is e2t(1+t,−t)e^{2t}(1 + t, -t), with the extra tt from eNt=I+Nte^{Nt} = I + Nt.

5. Stability read off the diagonal

Each entry on the diagonal is treated as a decay rate, as if the coordinates were separate equations.

  1. x′=Axx' = Ax with A=(−133−1)A = \begin{pmatrix} -1 & 3 \\ 3 & -1 \end{pmatrix}Right so far.
  2. “x1′=−x1+…x_1' = -x_1 + \dots and x2′=−x2+…x_2' = -x_2 + \dots: both coordinates decay.”The off-diagonal terms couple the coordinates, and stability is set by the eigenvalues. Here Δ=1−9=−8<0\Delta = 1 - 9 = -8 < 0.
  3. Every solution tends to 00The eigenvalues are 22 and −4-4: a saddle. From x(0)=(1,1)x(0) = (1, 1), an eigenvector for 22, the solution is e2t(1,1)e^{2t}(1, 1), already e2≈7.39e^2 \approx 7.39 times as large at t=1t = 1.

Print this set: matrix-exponentials-and-linear-systems-of-odes.pdf (problems, answers, and worked solutions on separate pages).

Read the guide: Matrix exponentials and linear systems of ODEs: x(t) = eAtx(0), diagonalize as VeΛtV⁻¹, and read stability off the eigenvalues