Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Decompositions

Diagonalization and the Spectral Theorem

Change to the eigenvector basis and a matrix becomes a list of independent stretches. Powers, exponentials and long-run behaviour become easy, and symmetric matrices always allow it, with perpendicular axes.

Level 0: Foundation

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

Use the special directions as your rulers

In A2.3-1 you found the special directions a matrix only stretches. Now here’s the trick: use those directions as your measuring rulers. In those rulers, the complicated machine is just “stretch this way by 3, stretch that way by 1”. Nothing gets mixed up any more. Rewriting a matrix like this is called diagonalization.

Why it’s handy: applying the machine 10 times is now easy. Just stretch by 3103^{10} one way and 1101^{10} the other way.

Mirror-shaped tables are extra friendly

For a symmetric matrix (one that matches its own mirror image, A2.2-3), the special directions always exist, are always real, and always meet at right angles. Pick the “Symmetric” preset in the demo and look at the two green bands. Then try the “Non-symmetric” one: its bands aren’t perpendicular.

Eigenvector hunt: find directions that Ax doesn't turn
xAx
A = [[2, 1], [1, 2]] · Ax points in a different direction: keep turning x.
Eigenvalues: λ₁ = 3.000, λ₂ = 1.000 (green bands = eigen-directions).
📝 Quick check (Level 0)
0/3 answered
  1. 1. A machine stretches one direction by 2 and another by 3. Applied twice, the first direction is stretched by…
  2. 2. For a symmetric matrix, the special directions meet at…
  3. 3. In 2D, how many independent stretches describe a diagonalizable machine?

Level 1: Beginner

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

The factorization

If AA has nn independent eigenvectors, put them in the columns of PP and the eigenvalues on the diagonal of DD:

A=PDP−1,D=diag⁡(λ1,…,λn)A = PDP^{-1}, \qquad D = \operatorname{diag}(\lambda_1,\dots,\lambda_n)

Read it right to left: change into eigen-coordinates (P−1P^{-1}), stretch each coordinate (DD), and change back (PP).

Powers become easy

Ak=PDkP−1,Dk=diag⁡(λ1k,…,λnk)A^k = PD^kP^{-1}, \qquad D^k = \operatorname{diag}(\lambda_1^k,\dots,\lambda_n^k)

Example. A=(2112)A = \begin{pmatrix}2&1\\1&2\end{pmatrix} has eigenvalues 3 and 1, with eigenvectors (1,1)(1,1) and (1,−1)(1,-1). So A5A^5 stretches (1,1)(1,1) by 35=2433^5 = 243 and leaves (1,−1)(1,-1) alone. That gives A5=(122121121122)A^5 = \begin{pmatrix}122&121\\121&122\end{pmatrix}.

📝 Quick check (Level 1)
0/3 answered
  1. 1. diag(2, 3)¹⁰ has (1,1) entry…
  2. 2. In A = PDP⁻¹, the columns of P are…
  3. 3. The eigenvectors (1,1) and (1,−1) of [[2,1],[1,2]] have dot product…

Level 2: Intermediate

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

When can you diagonalize?

AA is diagonalizable iff it has nn linearly independent eigenvectors. Sufficient conditions:

  • nn distinct eigenvalues (A2.3-1);
  • AA is symmetric (the spectral theorem, below).

Counter-example: the shear (1101)\begin{pmatrix}1&1\\0&1\end{pmatrix} has only one eigen-direction, so it can’t be diagonalized. (Defective matrices need the Jordan form, a topic for advanced texts.)

The spectral theorem

Spectral theorem (real symmetric matrices)

If S=S⊤S = S^\top, then all eigenvalues are real, and there is an orthonormal basis of eigenvectors:

S=QΛQ⊤=∑i=1nλi qiqi⊤,Q⊤Q=I.S = Q\Lambda Q^\top = \sum_{i=1}^n\lambda_i\,\mathbf q_i\mathbf q_i^\top, \qquad Q^\top Q = I.

There’s no inverse to compute, because Q−1=Q⊤Q^{-1} = Q^\top. Each term λiqiqi⊤\lambda_i\mathbf q_i\mathbf q_i^\top is a stretched projection onto one axis. Symmetric matrices are everywhere: covariance matrices, Hessians, graph Laplacians, kernel matrices, and inertia tensors.

What diagonalization buys you

Task In eigen-coordinates
Powers AkA^k PDkP−1PD^kP^{-1}
Long-run behaviour of xk+1=Axk\mathbf x_{k+1} = A\mathbf x_k dominated by the largest ∣λ∣\lvert\lambda\rvert
Differential equations x˙=Ax\dot{\mathbf x} = A\mathbf x x(t)=PeDtP−1x0\mathbf x(t) = Pe^{Dt}P^{-1}\mathbf x_0: each mode decays or grows like eλite^{\lambda_it}
Fibonacci, recurrences closed forms such as Fn=(φn−ψn)/5F_n = (\varphi^n - \psi^n)/\sqrt5
Quadratic forms x⊤Sx\mathbf x^\top S\mathbf x ∑λiyi2\sum\lambda_iy_i^2: a bowl, a saddle or a dome (A2.3-3)
🐍 Exercise 1: diagonalize, take powers, get Fibonacci
Diagonalize with np.linalg.eig, compute Aᵏ = P Dᵏ P⁻¹, and use it on [[1,1],[1,0]] to get Fibonacci numbers.
PCA in one sentence

The covariance matrix Σ\Sigma of a dataset is symmetric, so Σ=QΛQ⊤\Sigma = Q\Lambda Q^\top. The columns of QQ are the principal directions, and the eigenvalues are the variances along them. Keeping the top few is PCA (D9).

📝 Quick check (Level 2)
0/3 answered
  1. 1. Which matrix is guaranteed diagonalizable with orthogonal eigenvectors?
  2. 2. For symmetric S = QΛQᵀ, S⁻¹ = ?
  3. 3. Is the shear [[1, 1], [0, 1]] diagonalizable?

Level 3: Advanced

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

Proof that symmetric eigenvalues are real

Theorem

A real symmetric matrix has only real eigenvalues, and eigenvectors for different eigenvalues are orthogonal.

Proof. Let Sv=λvS\mathbf v = \lambda\mathbf v, with v\mathbf v possibly complex. Then vˉ⊤Sv=λ vˉ⊤v\bar{\mathbf v}^\top S\mathbf v = \lambda\,\bar{\mathbf v}^\top\mathbf v. Taking the conjugate transpose of the left side and using S=S⊤S = S^\top real gives the same number with λˉ\bar\lambda. Since vˉ⊤v=∥v∥2>0\bar{\mathbf v}^\top\mathbf v = \lVert\mathbf v\rVert^2 > 0, we get λ=λˉ\lambda = \bar\lambda.

For orthogonality: if Su=λuS\mathbf u = \lambda\mathbf u and Sw=μwS\mathbf w = \mu\mathbf w, then λ u⊤w=(Su)⊤w=u⊤Sw=μ u⊤w\lambda\,\mathbf u^\top\mathbf w = (S\mathbf u)^\top\mathbf w = \mathbf u^\top S\mathbf w = \mu\,\mathbf u^\top\mathbf w. So (λ−μ)u⊤w=0(\lambda - \mu)\mathbf u^\top\mathbf w = 0, and since λ≠μ\lambda \ne \mu, u⊤w=0\mathbf u^\top\mathbf w = 0. ∎

The full theorem, which says an orthonormal eigenbasis exists even with repeated eigenvalues, follows by induction. Take one eigenvector q1\mathbf q_1. Then SS maps the orthogonal complement q1⊥\mathbf q_1^\perp into itself, so repeat inside that smaller space.

The Rayleigh quotient and extreme eigenvalues

Theorem (Rayleigh–Ritz)

For symmetric SS, λmin⁡≤x⊤Sxx⊤x≤λmax⁡\lambda_{\min}\le\dfrac{\mathbf x^\top S\mathbf x}{\mathbf x^\top\mathbf x}\le\lambda_{\max}, with equality at the corresponding eigenvectors.

Proof. In eigen-coordinates y=Q⊤x\mathbf y = Q^\top\mathbf x, the quotient is ∑λiyi2/∑yi2\sum\lambda_iy_i^2/\sum y_i^2, a weighted average of the eigenvalues. ∎ So “maximize the variance in a direction” (PCA) and “find the top eigenvector” are the same problem. The min–max version (the Courant–Fischer theorem) characterizes every eigenvalue this way.

Functions of a matrix

For diagonalizable A=PDP−1A = PDP^{-1}, any function defined on the eigenvalues extends to the matrix: f(A)=Pf(D)P−1f(A) = Pf(D)P^{-1}. Examples are eAte^{At} (dynamics), A1/2A^{1/2} (the square root of a covariance, used to sample Gaussians), and log⁡A\log A.

Exercise 3.1: Compute e^A for A = diag(0, ln 2)

eA=diag⁡(e0,eln⁡2)=diag⁡(1,2)e^A = \operatorname{diag}(e^0, e^{\ln2}) = \operatorname{diag}(1, 2), with trace 3. Note that det⁡eA=etr⁡A=eln⁡2=2\det e^A = e^{\operatorname{tr}A} = e^{\ln 2} = 2. ✓

📝 Quick check (Level 3)
0/3 answered
  1. 1. Max of xᵀSx/xᵀx for S = [[2,1],[1,2]]?
  2. 2. How many mutually orthogonal eigenvectors can a symmetric 4 × 4 matrix have?
  3. 3. det(e^A) equals…

Level 4: Expert

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

Modes of dynamical systems

For linear dynamics x˙=Ax\dot{\mathbf x} = A\mathbf x, diagonalizing splits the motion into independent modes: x(t)=∑icieλitvi\mathbf x(t) = \sum_ic_ie^{\lambda_it}\mathbf v_i. A damped spring with λ=−0.25±1.98i\lambda = -0.25\pm1.98i oscillates at about 1.98 rad/s while decaying like e−0.25te^{-0.25t}. In robotics and aerospace this is modal analysis: the vibration modes of a flexible arm, a solar panel or a launch vehicle are the eigenvectors of the structure’s mass and stiffness matrices. Controllers are designed so they don’t excite the dangerous ones.

🐍 Exercise 2 (research): solve ẋ = Ax through its eigen-decomposition
Compute e^(At) = P e^(Dt) P⁻¹ for a damped spring, and check it against an independent RK4 simulation.

Spectral methods in ML research

  • Graph signal processing and spectral GNNs. Diagonalizing a graph Laplacian, L=UΛU⊤L = U\Lambda U^\top, gives a “Fourier transform” on graphs (U⊤xU^\top\mathbf x). Spectral graph convolutions (Bruna et al., 2014; Defferrard et al., 2016) filter signals by reweighting eigenvalues, the ancestor of GCNs (E14).
  • Neural tangent kernel. In the infinite-width limit, training follows f˙=−Θ(f−y)\dot{\mathbf f} = -\Theta(\mathbf f - \mathbf y). Along each eigenvector of the NTK Θ\Theta, the error decays like e−λite^{-\lambda_it}, so directions with large eigenvalues are learned first. This “spectral bias” explains why networks fit smooth functions before high-frequency detail (B4, J2).
  • Diagonal state-space models. Modern sequence models such as S4D and Mamba parameterize their recurrence hk+1=Ahk+Bxk\mathbf h_{k+1} = A\mathbf h_k + B\mathbf x_k with a diagonal AA. They work in an eigenbasis from the start, so long sequences can be processed fast (E17).

References

  1. A.-L. Cauchy (1829). (Reality of eigenvalues of symmetric matrices.)
  2. R. Courant and D. Hilbert (1924). Methoden der mathematischen Physik. (Min–max principle.)
  3. J. Bruna, W. Zaremba, A. Szlam, Y. LeCun (2014). “Spectral networks and locally connected networks on graphs.” ICLR.
  4. M. Defferrard, X. Bresson, P. Vandergheynst (2016). “Convolutional neural networks on graphs with fast localized spectral filtering.” NeurIPS.
  5. A. Jacot, F. Gabriel, C. Hongler (2018). “Neural tangent kernel: Convergence and generalization in neural networks.” NeurIPS.
  6. A. Gu, K. Goel, A. Gupta, C. Ré (2022). “On the parameterization and initialization of diagonal state space models.” NeurIPS.
  7. G. Strang (2016). Introduction to Linear Algebra, 5th ed. Chapter 6.