← mapVector Spaces

The Spectral Theorem

⚗ Dr. Möbius, from the lab

This. Is. The. Summit. Sixty-eight nodes ago you didn't know what a fucking number was — and now you are going to prove that every real symmetric matrix is, in its heart, a clean stretch along a set of perpendicular axes. No rotation, no shear, no lies, no bullshit. The spectral theorem is the most beautiful sentence in linear algebra, and you — you absolute disaster of a human being — have personally built every single word of it from scratch. Let's finish this.

THE BIG IDEA

Every real symmetric matrix has an orthonormal basis of eigenvectors, so it factors as A = QDQᵀ with Q orthogonal and D diagonal — a pure stretch along perpendicular axes.

The statement that earns every word

Here it is. The whole course points at this.

The Spectral Theorem (real symmetric case). Let AA be a real n×nn\times n matrix with AT=AA^T = A (symmetric). Then:

  1. all eigenvalues of AA are real;
  2. eigenvectors for distinct eigenvalues are orthogonal;
  3. AA has an orthonormal basis of eigenvectors, so

A=QDQT,A = Q D Q^T,

with QQ orthogonal (QTQ=IQ^T Q = I, columns the orthonormal eigenvectors) and DD diagonal (the eigenvalues).

Read every hypothesis as a debt paid. Symmetric — you needed the transpose from the matrices stratum. Eigenvectors — last three lessons. Orthonormal, orthogonal QQ — last lesson's Gram–Schmidt and QTQ=IQ^TQ=I. Diagonal DD — the diagonalization you just learned to crave. Real eigenvalues — they exist because R\mathbb{R} exists, which you forged back in the bedrock. Nothing here is borrowed; you minted every goddamn bit of it.

Compare to ordinary diagonalization, A=PDP1A = PDP^{-1}. There PP could be any invertible matrix — a skewed, distorting change of basis. The spectral theorem upgrades PP to an orthogonal QQ: the change of basis is a rotation/reflection, distortion-free, and Q1=QTQ^{-1} = Q^T comes free. That's the difference between "diagonalizable" and "diagonalizable beautifully." It's the difference between a decent lab and my lab.

Proving the accessible parts

Two of the three claims are within reach, and the proofs are gorgeous. (Claim 1, real eigenvalues, needs complex conjugates to do cleanly, so we state it — it's true, and it's what guarantees there's anything real to find.)

Eigenvectors for distinct eigenvalues are orthogonal — the two-line transpose dance. This proof is so short and so ruthless it should be illegal. Suppose AT=AA^T = A, with Av=λvAv = \lambda v and Aw=μwAw = \mu w, where λμ\lambda \ne \mu. Watch the dot product vw=vTwv \cdot w = v^T w get squeezed from both sides:

λ(vw)=(λv)Tw=(Av)Tw=vTATw=vTAw=vT(μw)=μ(vw).\lambda (v \cdot w) = (\lambda v)^T w = (A v)^T w = v^T A^T w = v^T A w = v^T(\mu w) = \mu (v \cdot w).

The pivot move is AT=AA^T = A in the middle — symmetry lets the matrix slide across the dot product from vv's side to ww's side untouched. So λ(vw)=μ(vw)\lambda(v\cdot w) = \mu(v\cdot w), i.e.

(λμ)(vw)=0.(\lambda - \mu)(v \cdot w) = 0.

Since λμ\lambda \ne \mu, the first factor is nonzero, forcing vw=0v \cdot w = 0. Orthogonal. \blacksquare That's it — two lines, and the whole damn thing falls out. It only worked because the matrix was symmetric. For a non-symmetric matrix the eigenvectors have no reason to be perpendicular; symmetry is exactly the property that snaps them to right angles. I find this proof almost offensively elegant.

From there to A=QDQTA = QDQ^T. If AA has nn distinct eigenvalues, the eigenvectors are automatically orthogonal by the dance; normalize each (divide by its length) and you have an orthonormal basis of eigenvectors. Stack them as the columns of QQ. Then QQ is orthogonal, and the diagonalization A=QDQ1A = QDQ^{-1} becomes A=QDQTA = QDQ^T because Q1=QTQ^{-1} = Q^T. (When eigenvalues repeat, the full theorem still holds — Gram–Schmidt orthonormalizes within each eigenspace — but the clean engine is the dance above.)

End to end on a 2×2

Let's run the whole machine on A=(2112)A = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}. Symmetric — check the transpose, it's its own.

Eigenvalues. trace=4\operatorname{trace} = 4, det=3\det = 3, so λ24λ+3=(λ1)(λ3)=0\lambda^2 - 4\lambda + 3 = (\lambda - 1)(\lambda - 3) = 0: λ=3\lambda = 3 and λ=1\lambda = 1. Both real, as promised.

Eigenvectors. λ=3\lambda = 3: A3I=(1111)A - 3I = \begin{pmatrix} -1 & 1 \\ 1 & -1 \end{pmatrix} gives y=xy = x, so v1=(11)v_1 = \begin{pmatrix} 1 \\ 1 \end{pmatrix}. λ=1\lambda = 1: AI=(1111)A - I = \begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix} gives y=xy = -x, so v2=(11)v_2 = \begin{pmatrix} 1 \\ -1 \end{pmatrix}.

Check orthogonality (the theorem promised it): v1v2=11=0v_1 \cdot v_2 = 1 - 1 = 0. \checkmark Perpendicular, exactly as the dance guarantees for a symmetric matrix.

Normalize. v1=v2=2\|v_1\| = \|v_2\| = \sqrt2, so

q1=12(11),q2=12(11),Q=12(1111),D=(3001).q_1 = \tfrac{1}{\sqrt2}\begin{pmatrix} 1 \\ 1 \end{pmatrix}, \quad q_2 = \tfrac{1}{\sqrt2}\begin{pmatrix} 1 \\ -1 \end{pmatrix}, \quad Q = \tfrac{1}{\sqrt2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}, \quad D = \begin{pmatrix} 3 & 0 \\ 0 & 1 \end{pmatrix}.

Verify A=QDQTA = QDQ^T. Here QT=QQ^T = Q. First QD=12(3131)QD = \tfrac{1}{\sqrt2}\begin{pmatrix} 3 & 1 \\ 3 & -1 \end{pmatrix}, then

QDQT=12(3131)12(1111)=12(4224)=(2112)=A.QDQ^T = \tfrac{1}{\sqrt2}\begin{pmatrix} 3 & 1 \\ 3 & -1 \end{pmatrix}\cdot\tfrac{1}{\sqrt2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} = \tfrac12\begin{pmatrix} 4 & 2 \\ 2 & 4 \end{pmatrix} = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix} = A. \checkmark

The matrix, fully decoded: rotate into the 4545^\circ axes, stretch one axis by 33 and the other by 11, rotate back.

What it means: circles into ellipses

Geometrically, the spectral theorem says a symmetric matrix is a pure stretch along perpendicular axes — nothing else. Feed it the unit circle and it hands back an ellipse whose axes point along the eigenvectors, with semi-axis lengths equal to the eigenvalues. No twist, no skew; the eigenvectors are the principal axes and the eigenvalues are how hard each gets pulled. Drag a direction and watch a symmetric map stretch space along its perpendicular eigen-axes:

eigen lab — hunt the special directions
vAv
A = [2 1 | 1 2]λ = 3, 1

And here's the same map's grid morphing — the symmetric matrix as a clean, twist-free deformation:

matrix transform — drag the columns
A·e₁=(2,1)A·e₂=(1,2)
A = [2 1 | 1 2]det A = 3

Where this powers the world — the graduation speech

This isn't a theorem that stays in the lab — it escaped the lab and took over the world. Every major quantitative discipline runs on this thing.

  • PCA (principal component analysis): the workhorse of data science finds the directions of maximum variance in data by spectrally decomposing a symmetric covariance matrix. The eigenvectors are the "principal components"; the eigenvalues are how much each explains. Every dimensionality-reduction pipeline you'll ever meet is this theorem wearing a lab coat.
  • Quadratic forms: classifying conics and surfaces (ax2+bxy+cy2ax^2 + bxy + cy^2) is diagonalizing a symmetric matrix — the eigenvalues' signs tell you ellipse vs. hyperbola.
  • Vibrations: the natural frequencies of a bridge, a molecule, a guitar string are eigenvalues of a symmetric stiffness matrix. Engineers spectrally decompose to find the modes that shake.
  • Quantum mechanics: observables are symmetric (Hermitian) operators; the spectral theorem is why measured quantities are real numbers and why states decompose into eigenstates. The theorem you just proved is a load-bearing wall of physical reality.

Roll credits

Look back down the mountain. Every node lit up to put you here. I'm going to describe it, and I want you to actually feel the weight of it.

You started not knowing what a number was (what-is-a-number), then forged arithmetic, zero, negatives, fractions, and the reals (arithmetic-laws → irrationals-and-reals) — that's why DD can hold real eigenvalues. You learned to reason: propositions, implication, quantifiers, and the proof techniques (direct-proof, contrapositive, contradiction, induction) that powered every "\blacksquare" in this lesson, including the transpose dance. You built sets, relations, and functions (sets-and-membership → functions-as-mappings → injective-surjective-bijective) — the language of "map," "kernel," "image." Through algebra and functions you met linearity and slope (linear-equations, lines-and-slope, systems-of-equations); through geometry, the dot product and angle (vectors, dot-product) that defines orthogonality.

Then the matrices stratum: arithmetic, multiplication, transformations, determinants (the squash-detector that births the characteristic polynomial), inverses, and elimination (matrices-arithmetic → gaussian-elimination). And finally spaces: you abstracted to vector spaces, subspaces, span, independence, basis and dimension, linear maps (vector-spaces → linear-maps), then conservation (rank-nullity), coordinates (change-of-basis), the directions a map only stretches (eigenvalues-eigenvectors), the favorite-basis factorization (diagonalization), and perpendicular bases (orthogonality-gram-schmidt) — the two direct parents of this very theorem.

Sixty-nine nodes. One creature, upgraded sixty-eight goddamn times. You can now look at A=QDQTA = QDQ^T and read it like a sentence in your mother tongue: here is a transformation; here are the perpendicular directions it lives along; here is how hard it pulls each one. Most people who use this theorem never understood it. They cargo-cult the formula. They push the symbols around and collect the answer without knowing what the hell they're touching.

You built the whole tree. Every root, every branch, every leaf is something you assembled with your own hands in this lab. The tree is lit up behind you.

I built this reactor to teach one thing: that mathematics isn't a list of rules handed down from on high — it's a structure you can see, built on nothing but logic and the willingness to ask why. You've seen it. You're one of the people who actually know.

Now go do the last gauntlet of the course. Then get out of my lab. Go bend the world. I'm proud of you, you magnificent bastard. — Möbius

🔬 SPECIMENS (worked examples)

Worked example 1 — the full spectral decomposition

Orthogonally diagonalize A=(5225)A = \begin{pmatrix} 5 & 2 \\ 2 & 5 \end{pmatrix}: find QQ and DD with A=QDQTA = QDQ^T, and verify.

AT=AA^T = A, so the spectral theorem applies.

Eigenvalues. trace=10\operatorname{trace} = 10, det=254=21\det = 25 - 4 = 21, so λ210λ+21=(λ3)(λ7)=0\lambda^2 - 10\lambda + 21 = (\lambda - 3)(\lambda - 7) = 0: λ=7\lambda = 7 and λ=3\lambda = 3 (both real \checkmark).

Eigenvectors. λ=7\lambda = 7: A7I=(2222)A - 7I = \begin{pmatrix} -2 & 2 \\ 2 & -2 \end{pmatrix}, so y=xy = x, v1=(11)v_1 = \begin{pmatrix} 1 \\ 1 \end{pmatrix}. λ=3\lambda = 3: A3I=(2222)A - 3I = \begin{pmatrix} 2 & 2 \\ 2 & 2 \end{pmatrix}, so y=xy = -x, v2=(11)v_2 = \begin{pmatrix} 1 \\ -1 \end{pmatrix}.

Orthogonality check: v1v2=11=0v_1 \cdot v_2 = 1 - 1 = 0. \checkmark (Symmetry delivered.)

Normalize: v1=v2=2\|v_1\| = \|v_2\| = \sqrt2, so Q=12(1111)Q = \tfrac{1}{\sqrt2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}, D=(7003)D = \begin{pmatrix} 7 & 0 \\ 0 & 3 \end{pmatrix}.

Verify A=QDQTA = QDQ^T (here QT=QQ^T = Q): QD=12(7373)QD = \tfrac{1}{\sqrt2}\begin{pmatrix} 7 & 3 \\ 7 & -3 \end{pmatrix}, then

QDQT=12(7373)12(1111)=12(104410)=(5225)=A.QDQ^T = \tfrac{1}{\sqrt2}\begin{pmatrix} 7 & 3 \\ 7 & -3 \end{pmatrix}\tfrac{1}{\sqrt2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} = \tfrac12\begin{pmatrix} 10 & 4 \\ 4 & 10 \end{pmatrix} = \begin{pmatrix} 5 & 2 \\ 2 & 5 \end{pmatrix} = A. \checkmark

Worked example 2 — the transpose dance, applied

A symmetric matrix AA has eigenvalue 44 with eigenvector v=(21)v = \begin{pmatrix} 2 \\ 1 \end{pmatrix} and a different eigenvalue μ4\mu \ne 4 with eigenvector w=(a2)w = \begin{pmatrix} a \\ -2 \end{pmatrix}. Use the spectral theorem to find aa.

The spectral theorem (the transpose dance) guarantees that eigenvectors of a symmetric matrix for distinct eigenvalues are orthogonal. So vwv \perp w:

vw=(2)(a)+(1)(2)=2a2=0    a=1.v \cdot w = (2)(a) + (1)(-2) = 2a - 2 = 0 \;\Rightarrow\; a = 1.

So w=(12)w = \begin{pmatrix} 1 \\ -2 \end{pmatrix}, and indeed vw=22=0v \cdot w = 2 - 2 = 0. \checkmark Notice we never needed the matrix AA itself — symmetry plus distinct eigenvalues forced the eigenvectors perpendicular, and that single fact pinned down aa. That's the dance doing real work.

Worked example 3 — the trap: not every matrix gets into the club

Can the spectral theorem be applied to A=(1401)A = \begin{pmatrix} 1 & 4 \\ 0 & 1 \end{pmatrix}? If not, what goes wrong?

Check the hypothesis first. AT=(1041)AA^T = \begin{pmatrix} 1 & 0 \\ 4 & 1 \end{pmatrix} \ne A. The matrix is not symmetric, so the spectral theorem simply does not apply — full stop.

And the consequences are visible. AA is the shear from the diagonalization lesson: its only eigenvalue is 11 (repeated), with a single eigendirection (10)\begin{pmatrix} 1 \\ 0 \end{pmatrix}. It has no second eigenvector, let alone an orthogonal pair, so there's no orthonormal eigenbasis and no A=QDQTA = QDQ^T. It isn't even diagonalizable.

The trap is reaching for QDQTQDQ^T on autopilot. The theorem is a gift with a key, and the key is AT=AA^T = A. No symmetry, no entry. Symmetric matrices are special precisely because they're the ones whose eigenvectors snap to perpendicular — and a shear is the standing counterexample to forgetting that.

☠ KNOWN HAZARDS

  • Applying it to non-symmetric matrices. This is the most common abuse of the theorem and it makes me furious. The orthogonal-eigenvector guarantee requires AT=AA^T = A. A general matrix can fail to have real eigenvalues (a rotation) or fail to be diagonalizable at all (the shear). Check symmetry first — it's the hypothesis that buys everything.

  • Forgetting to normalize before building QQ. Orthogonal eigenvectors give QQ with perpendicular columns, but QTQ=IQ^TQ = I needs them unit length too. Divide each eigenvector by its norm or QQ won't be orthogonal and A=QDQTA = QDQ^T breaks.

  • Writing A=QDQ1A = QDQ^{-1} and stopping. True, but the whole point is Q1=QTQ^{-1} = Q^T — so write A=QDQTA = QDQ^T. If you compute Q1Q^{-1} by hand instead of just transposing, you've thrown away the gift the theorem handed you. That's like being given a free car and walking home.

  • Assuming the eigenvalues are positive. Symmetric guarantees real eigenvalues, not positive ones. A symmetric matrix can have negative eigenvalues (the stretch becomes a flip-and-stretch); positivity is a separate condition (positive-definiteness).

TL;DR

  • Spectral Theorem: every real symmetric matrix (AT=AA^T = A) has real eigenvalues, orthogonal eigenspaces, and an orthonormal eigenbasis, so A=QDQTA = QDQ^T with QQ orthogonal and DD diagonal.

  • It upgrades A=PDP1A = PDP^{-1} (any invertible PP) to A=QDQTA = QDQ^T (orthogonal QQ, with Q1=QTQ^{-1} = Q^T): a distortion-free change of basis.

  • The transpose dance: for symmetric AA, λ(vw)=(Av)Tw=vTATw=vTAw=μ(vw)\lambda(v\cdot w) = (Av)^Tw = v^TA^Tw = v^TAw = \mu(v\cdot w), so (λμ)(vw)=0(\lambda-\mu)(v\cdot w) = 0 forces vwv \perp w when λμ\lambda \ne \mu.

  • Geometrically: a symmetric matrix is a pure stretch along perpendicular axes (eigenvectors), turning the unit circle into an ellipse with semi-axes equal to the eigenvalues.

  • It runs the world: PCA, quadratic forms, vibration modes, and quantum observables are all the spectral theorem in disguise.