TExcelTAD
Home › Linear Algebra & Matrix Theory › Application: Systems of Linear Differential Equations

Application: Systems of Linear Differential Equations

When several quantities change at rates that depend linearly on each other, such as temperatures in neighbouring rooms or masses joined by springs, you get a system x′=Ax\mathbf{x}' = A\mathbf{x}. In the eigenvector basis the system falls apart into separate one-variable equations, each solved by an exponential. This is how engineers find a structure's vibration modes and how a physics engine can understand what its springs will do.

One equation, then many

The scalar equation x′=λxx' = \lambda x has the solution x(t)=eλt⋅x(0)x(t) = e^{\lambda t} \cdot x(0) (see Differential Equations). Now let x(t)\mathbf{x}(t) be a vector and AA a constant n×nn \times n matrix:

x′(t)=Ax(t),x(0)=x0\mathbf{x}'(t) = A\mathbf{x}(t), \qquad \mathbf{x}(0) = \mathbf{x}_0

If v\mathbf{v} is an eigenvector, Av=λvA\mathbf{v} = \lambda\mathbf{v}, then x(t)=eλt⋅v\mathbf{x}(t) = e^{\lambda t} \cdot \mathbf{v} is a solution: its derivative is λeλtv=eλtAv=Ax(t)\lambda e^{\lambda t}\mathbf{v} = e^{\lambda t}A\mathbf{v} = A\mathbf{x}(t). If AA is diagonalizable with eigenpairs (λi,vi)(\lambda_i, \mathbf{v}_i), every solution is a combination of these:

x(t)=c1eλ1tv1+c2eλ2tv2+⋯+cneλntvn,with x0=c1v1+⋯+cnvn\mathbf{x}(t) = c_1e^{\lambda_1t}\mathbf{v}_1 + c_2e^{\lambda_2t}\mathbf{v}_2 + \cdots + c_ne^{\lambda_nt}\mathbf{v}_n, \qquad \text{with } \mathbf{x}_0 = c_1\mathbf{v}_1 + \cdots + c_n\mathbf{v}_n

The cic_i are the coordinates of x0\mathbf{x}_0 in the eigenvector basis, found by solving Pc=x0P\mathbf{c} = \mathbf{x}_0. Equivalently: substitute x=Py\mathbf{x} = P\mathbf{y}, and the system becomes y′=Dy\mathbf{y}' = D\mathbf{y}, nn decoupled equations yi′=λiyiy_i' = \lambda_iy_i.

Example: heat flowing between two rooms

Two rooms share a wall, and each also loses heat to the outside. Let x1,x2x_1, x_2 be their temperatures above the outdoor temperature. Each room cools at rate 2 and gains heat from the other at rate 1:

x1′=−2x1+x2A=[−211−2]x2′=x1−2x2eigenvalues −1 with (1,1), −3 with (1,−1)\begin{aligned} x_1' &= -2x_1 + x_2 && A = \begin{bmatrix} -2 & 1 \\ 1 & -2 \end{bmatrix} \\ x_2' &= x_1 - 2x_2 && \text{eigenvalues } -1 \text{ with } (1, 1), \ -3 \text{ with } (1, -1) \end{aligned}

Start with room 1 at 10 degrees above outside and room 2 at 0: x0=(10,0)=5⋅(1,1)+5⋅(1,−1)\mathbf{x}_0 = (10, 0) = 5 \cdot (1, 1) + 5 \cdot (1, -1). So

x(t)=5e−t⋅(1,1)+5e−3t⋅(1,−1)x1(t)=5e−t+5e−3t,x2(t)=5e−t−5e−3t\begin{aligned} \mathbf{x}(t) &= 5e^{-t} \cdot (1, 1) + 5e^{-3t} \cdot (1, -1) \\ x_1(t) &= 5e^{-t} + 5e^{-3t}, \qquad x_2(t) = 5e^{-t} - 5e^{-3t} \end{aligned}

The (1,−1)(1, -1) mode, the difference between the rooms, dies three times faster than the (1,1)(1, 1) mode, the shared average. After a short while both rooms have about the same temperature and cool together like e−te^{-t}. Let's check the formula against SciPy's numerical solver:

python · try it yourself
import numpy as np
from scipy.integrate import solve_ivp

A = np.array([[-2.0, 1.0], [1.0, -2.0]])
sol = solve_ivp(lambda t, x: A @ x, (0, 3), [10.0, 0.0], t_eval=[0.5, 1, 2, 3],
                rtol=1e-10, atol=1e-12)
for t, x1, x2 in zip(sol.t, *sol.y):
    f1 = 5 * np.exp(-t) + 5 * np.exp(-3 * t)
    f2 = 5 * np.exp(-t) - 5 * np.exp(-3 * t)
    print(f"t={t:3.1f}  solver ({x1:.5f}, {x2:.5f})  formula ({f1:.5f}, {f2:.5f})")
t=0.5  solver (4.14830, 1.91700)  formula (4.14830, 1.91700)
t=1.0  solver (2.08833, 1.59046)  formula (2.08833, 1.59046)
t=2.0  solver (0.68907, 0.66428)  formula (0.68907, 0.66428)
t=3.0  solver (0.24955, 0.24832)  formula (0.24955, 0.24832)

Stability can be read off the eigenvalues: if every eigenvalue has negative real part, every solution decays to 0. One eigenvalue with positive real part is enough for most solutions to blow up.

Coupled springs and normal modes

Two equal masses (m=1m = 1) sit between two walls, joined wall–spring–mass–spring–mass–spring–wall, every spring with stiffness k=1k = 1. Newton's law gives a second-order system:

x1′′=−x1+(x2−x1)=−2x1+x2x2′′=−(x2−x1)−x2=x1−2x2x′′=Ax,A=[−211−2]\begin{aligned} x_1'' &= -x_1 + (x_2 - x_1) = -2x_1 + x_2 \\ x_2'' &= -(x_2 - x_1) - x_2 = x_1 - 2x_2 && \mathbf{x}'' = A\mathbf{x}, \quad A = \begin{bmatrix} -2 & 1 \\ 1 & -2 \end{bmatrix} \end{aligned}

It is the same matrix. Along an eigenvector v\mathbf{v} with eigenvalue −ω2-\omega^2, the equation becomes y′′=−ω2yy'' = -\omega^2y, a simple harmonic oscillator with angular frequency ω\omega (Second-Order Linear Equations):

Mode Eigenvalue Eigenvector Frequency Motion
1 −1 (1,1)(1, 1) ω=1\omega = 1 both masses swing together
2 −3 (1,−1)(1, -1) ω=3≈1.732\omega = \sqrt{3} \approx 1.732 masses swing against each other

These are the normal modes. Every motion is a mix of them. Pulling mass 1 out to x1=1x_1 = 1 and letting go from rest gives x(t)=12cos⁡(t)⋅(1,1)+12cos⁡(3t)⋅(1,−1)\mathbf{x}(t) = \frac{1}{2}\cos(t) \cdot (1, 1) + \frac{1}{2}\cos(\sqrt{3}t) \cdot (1, -1). The two frequencies are not in a rational ratio, so the motion never exactly repeats, and energy sloshes back and forth between the masses:

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

A = np.array([[-2.0, 1.0], [1.0, -2.0]])
values, P = np.linalg.eigh(A)              # eigenvalues sorted: -3, -1
omegas = np.sqrt(-values)
c = np.linalg.solve(P, [1.0, 0.0])         # modal coordinates of x(0)
t = np.linspace(0, 30, 1500)
x = P @ (c[:, None] * np.cos(np.outer(omegas, t)))   # sum of c_i cos(w_i t) v_i

plt.figure(figsize=(7, 3.5))
plt.plot(t, x[0], label="mass 1"); plt.plot(t, x[1], label="mass 2")
plt.xlabel("t"); plt.legend(); plt.title("Two coupled springs")
print("mode frequencies:", [round(float(w), 4) for w in omegas])
print("x(5) =", [round(float(v), 4) for v in P @ (c * np.cos(omegas * 5))])
mode frequencies: [1.7321, 1.0]
x(5) = [-0.219, 0.5027]

In software

  • Game physics: cloth, soft bodies and ropes are big spring networks. The stiffest mode (largest ω\omega) limits the time step an explicit integrator can take, which is why engines use implicit or position-based solvers (Springs, Integrators).
  • Engineering and audio: finite-element packages compute the lowest normal modes of bridges and buildings; physical-modelling synthesizers sum modes to make bells and drums sound real.
  • Control and robotics: a controller is designed so that all eigenvalues of the closed-loop matrix have negative real parts.
  • Graph diffusion: heat spreading on a network is x′=−Lx\mathbf{x}' = -L\mathbf{x} with the graph Laplacian LL; its eigenvectors are the basis of spectral clustering and graph neural networks.

For the solver side see ODEs in SciPy. A closed form for any AA, including non-diagonalizable ones, is the matrix exponential.

Exercises

Exercise 1: Solve a 2×22 \times 2 system

Solve x′=[1221]x\mathbf{x}' = \begin{bmatrix} 1 & 2 \\ 2 & 1 \end{bmatrix}\mathbf{x} with x(0)=(3,1)\mathbf{x}(0) = (3, 1).

Answer

x(t)=2e3t⋅(1,1)+e−t⋅(1,−1)\mathbf{x}(t) = 2e^{3t} \cdot (1, 1) + e^{-t} \cdot (1, -1), i.e. x1=2e3t+e−tx_1 = 2e^{3t} + e^{-t}, x2=2e3t−e−tx_2 = 2e^{3t} - e^{-t}.

Solution
tr⁡=2, det⁡=−3 → λ2−2λ−3=(λ−3)(λ+1)λ=3:(1,1);λ=−1:(1,−1)(3,1)=c1(1,1)+c2(1,−1) → c1+c2=3, c1−c2=1 → c1=2, c2=1\begin{aligned} &\operatorname{tr} = 2,\ \det = -3 \ \to\ \lambda^2 - 2\lambda - 3 = (\lambda - 3)(\lambda + 1) \\ &\lambda = 3: (1, 1); \quad \lambda = -1: (1, -1) \\ &(3, 1) = c_1(1, 1) + c_2(1, -1) \ \to\ c_1 + c_2 = 3,\ c_1 - c_2 = 1 \ \to\ c_1 = 2,\ c_2 = 1 \end{aligned}

The eigenvalue 3>03 > 0 makes this system unstable: the (1,1)(1, 1) part grows without bound.

Exercise 2: Stable or not?

For which of these is every solution of x′=Ax\mathbf{x}' = A\mathbf{x} decaying to 0? (a) [−150−2]\begin{bmatrix} -1 & 5 \\ 0 & -2 \end{bmatrix}, (b) [01−10]\begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}, (c) [−1000.5]\begin{bmatrix} -1 & 0 \\ 0 & 0.5 \end{bmatrix}.

Answer

Only (a).

Solution

(a) is triangular with eigenvalues −1, −2: both negative, so everything decays. (b) has λ2+1=0\lambda^2 + 1 = 0, λ=±i\lambda = \pm i: real part 0, the solutions rotate forever without decaying. (c) has eigenvalue 0.5>00.5 > 0, so the second coordinate grows like e0.5te^{0.5t}.

Exercise 3: Stiffer springs

Masses joined to the walls by springs of stiffness 2 and to each other by a spring of stiffness 1 give x′′=[−311−3]x\mathbf{x}'' = \begin{bmatrix} -3 & 1 \\ 1 & -3 \end{bmatrix}\mathbf{x}. Find the normal modes and their frequencies.

Answer

In-phase mode (1,1)(1, 1) with ω=2≈1.414\omega = \sqrt{2} \approx 1.414; out-of-phase mode (1,−1)(1, -1) with ω=2\omega = 2.

Solution
[−311−3](1,1)=(−2,−2) → eigenvalue −2 → ω=2[−311−3](1,−1)=(−4,4) → eigenvalue −4 → ω=2\begin{aligned} \begin{bmatrix} -3 & 1 \\ 1 & -3 \end{bmatrix}(1, 1) &= (-2, -2) \ \to\ \text{eigenvalue } -2 \ \to\ \omega = \sqrt{2} \\ \begin{bmatrix} -3 & 1 \\ 1 & -3 \end{bmatrix}(1, -1) &= (-4, 4) \ \to\ \text{eigenvalue } -4 \ \to\ \omega = 2 \end{aligned}

The middle spring is only stretched in the out-of-phase mode, which is why that mode is faster.

Exercise 4: Check with a solver

Integrate the system of Exercise 1 numerically up to t=1t = 1 and compare with the closed form.

Answer

Both give x(1)≈(40.5390,39.8032)\mathbf{x}(1) \approx (40.5390, 39.8032).

Solution
python · try it yourself
import numpy as np
from scipy.integrate import solve_ivp

A = np.array([[1.0, 2.0], [2.0, 1.0]])
sol = solve_ivp(lambda t, x: A @ x, (0, 1), [3.0, 1.0], rtol=1e-11, atol=1e-12)
x1, x2 = sol.y[:, -1]
e3, em = np.exp(3.0), np.exp(-1.0)
print(f"solver:  ({x1:.4f}, {x2:.4f})")
print(f"formula: ({2 * e3 + em:.4f}, {2 * e3 - em:.4f})")
solver:  (40.5390, 39.8032)
formula: (40.5390, 39.8032)

Test yourself

If Av=λvA\mathbf{v} = \lambda\mathbf{v}, which function solves x′=Ax\mathbf{x}' = A\mathbf{x}?

  1. x(t)=λt⋅v\mathbf{x}(t) = \lambda t \cdot \mathbf{v}
  2. x(t)=eλt⋅v\mathbf{x}(t) = e^{\lambda t} \cdot \mathbf{v}
  3. x(t)=tλ⋅v\mathbf{x}(t) = t^\lambda \cdot \mathbf{v}
  4. x(t)=cos⁡(λt)⋅v\mathbf{x}(t) = \cos(\lambda t) \cdot \mathbf{v}

A system x′=Ax\mathbf{x}' = A\mathbf{x} has eigenvalues −4 and −0.5. Which mode dominates for large tt?

  1. The −4 mode
  2. The −0.5 mode
  3. Both equally
  4. Neither: the solution grows

For x′′=Ax\mathbf{x}'' = A\mathbf{x}, an eigenvalue −9 of AA corresponds to an oscillation with angular frequency…

  1. 9
  2. −9
  3. 3
  4. 81