Determinants, Eigenvalues & the Spectral Theorem
Every matrix is a motion — it stretches, squashes, turns. This unit finds what the motion cannot change: one number that says how much space is scaled (the determinant), and the special directions the matrix can only stretch, never turn (the eigenvectors). Find those, and the messiest matrix falls apart into turn · stretch · turn back — the fact that quietly runs PCA, SVD, and half of machine learning.
What survives the machine?
Your dataset has a thousand columns. Somewhere inside it, a handful of directions carry almost all the signal — customer taste, disease risk, market mood — and the rest is noise. PCA finds those directions by asking a strange-sounding question about a matrix: which directions does it refuse to turn, and how hard does it stretch along each one? By the end of this unit, that question — and its answer, — will feel inevitable.
Units 1–3 gave us the machinery: matrices as machines that move space (Unit 1), the spaces they act on (Unit 2), and rulers to measure with (Unit 3). Now we interrogate the machine itself. If a matrix is a motion, what are its invariants — its fingerprints? We'll find exactly two kinds: numbers that summarize the whole motion (determinant, trace) and directions that pass through it unturned (eigenvectors, each wearing its own scale factor ).
The route: ① the determinant — a volume dial with an alarm bell at zero; ② how to actually compute it (minors, cofactors, and the lazy-row trick); ③ the trace, an absurdly easy number with a hidden double life; ④ eigenvectors — hunting the directions a matrix cannot bend, first by dragging, then by algebra (the characteristic equation); ⑤ the Spectral Theorem — for symmetric matrices the fingerprints organize into a perfect perpendicular grain, ; ⑥ two encores that ML uses daily: complex eigenvalues (rotations) and the Cholesky square root of a covariance matrix.
The determinant — a volume dial with an alarm bell
Before hunting special directions, we need one number for what a matrix does to space as a whole. Take the unit square, feed its corners through , and watch it land as a parallelogram — remember from Unit 1 that the columns of are exactly where the basis arrows go. The determinant is the signed area of that parallelogram:
Compute one to see how cheap it is: the widget's opening matrix has — this machine doubles every area it touches. Now the three readings of the number. Magnitude: is the scaling factor for area (volume in 3D) — doubles every area, halves it. Sign: negative means the motion flips space over, like a mirror — orientation reverses. Zero: the alarm bell. The parallelogram has collapsed to a line segment: the columns are linearly dependent, space has been squashed flat, information is destroyed, and no inverse can ever rebuild it. singular — Unit 1's "machine that squashes" now has a one-number detector.
Think of rolling out pizza dough. Press it so it covers twice the area — that "×2" is the determinant. Flatten it into a paper-thin crease and its area hits zero — and no amount of un-pressing recovers the original ball. That irreversible flattening is . The determinant is the oomph of a matrix, with its sign remembering whether you flipped the dough over.
A transformation has . What does it do to a shape of area 5?
In the widget, the ones preset sets both columns to . What is , and what does that mean?
Computing it — minors, cofactors, and the lazy row
Geometry says what the determinant means; the cofactor expansion is how we compute it. The idea is recursive: an determinant is a weighted sum of determinants. Delete row and column and the small determinant that remains is the minor ; dress it with a checkerboard sign and it becomes the cofactor . Then, expanding along any row — or any column — gives the same number:
That "any row, any column, same answer" is not obvious — it is a small miracle you can test below on the lecture's example. And it hands you a strategy for free: expand along the line with the most zeros, because every zero entry deletes an entire cofactor's worth of work.
Two behaviours make determinants elimination-friendly, and the lecture proves both by induction: swapping two rows multiplies by (one more mirror), and adding a multiple of one row to another changes nothing. So you can run Unit 1's Gaussian elimination, reduce to a triangle , and read the answer off the diagonal — because for triangular matrices the determinant is just the product of the diagonal entries:
Why does adding a row to another leave det unchanged? (the two-line induction)
Expand the altered determinant: each term splits into the original plus times a determinant whose rows and are identical. Swap those equal rows: the determinant must flip sign, yet it is unchanged — so it equals its own negative, which forces it to be . The extra piece vanishes, and survives elimination untouched. The same equal-rows trick powers half the determinant identities you'll ever meet.
The bridge theorem: full rank ⟺ det ≠ 0 (this is where eigenvalues will come from)
Eliminate down to . Full rank means every column has a pivot, so every diagonal entry is non-zero, so . Conversely, forces every : all pivots present, columns independent, only solves . Hold this thought: in Section 6 an eigenvalue will be born at exactly the values where the shifted matrix loses full rank — and is the tripwire that detects it.
(scaling factors of chained machines multiply) · (transposing preserves volume) · (the undo machine un-scales) · triangular (the shortcut elimination cashes in).
For the widget's matrix — with its single zero at — which expansions cost the least hand-work?
The trace — a pulse reading
The determinant's understated sibling costs almost nothing: the trace is the sum of the diagonal,
and it behaves beautifully: , , , and — the workhorse — the cyclic property , which holds even when , even when the two products have different sizes. Countless ML derivations (gradients of , for one) lean on that single identity.
Why should a doctor's quick pulse-check deserve a section? Because of a secret we'll prove in Section 6: the trace is the sum of the eigenvalues, and the determinant is their product. Two numbers you can read straight off the matrix silently summarize the spectrum you haven't computed yet.
is and is . is but is — they aren't even the same size. What about their traces?
Eigenvectors — the directions a matrix cannot turn
Now the star of the unit. A matrix moves every vector — but a few special vectors it can only stretch or flip along their own line, never knock off it. Those unbendable directions are the eigenvectors, and each one carries a personal stretch factor, its eigenvalue:
Positive stretches () or squeezes () along the direction; negative flips it end-over-end and then scales. The zero vector is banned from the club — holds for every , so it points at nothing. But if qualifies, so does every non-zero multiple : eigenvectors are really eigen-directions, whole lines the matrix owns.
A spinning globe: every city moves, but the axis through the poles stays put — an eigenvector with . Stretching dough: pull it one way, it thins the other — the pull direction has , the thinning direction . A sheared deck of cards: push the top sideways and every card slides horizontally — horizontal vectors keep their direction () while every other vector tilts. The "grain" of a transformation, made visible.
You can verify a claimed eigenvector with one multiplication. The lecture's example: for and ,
— so is an eigenvector with : flips it and stretches it by 4, but the line through is untouched. Try instead: , which is on nobody's line through — not an eigenvector. Below, hunt eigen-directions by hand: drag the probe around the circle and feel for the angles where snaps into alignment.
Switch the widget to the symmetric matrix and find both eigen-directions. They're perpendicular — and they sit exactly on the axes of the image ellipse. Now recall Unit 3's geometry lens, where an SPD matrix bent the unit circle into an ellipse: you were staring at eigenvectors all along. The axes of any symmetric matrix's ellipse are its eigen-directions — a coincidence that Section 7 upgrades into a theorem. Then switch to rotation and feel the opposite: nothing ever aligns. A merry-go-round has no direction it leaves alone — hold that mystery for Section 9.
For , one multiplication gives . What did we just learn?
In the widget, the shear resonates along exactly one line — the x-axis. How many independent eigen-directions does it have?
Hunting eigenvalues — the characteristic equation
An eigenvalue is like the one musical note that makes a wine glass ring. Sweep a dial through every frequency: mostly the glass sits inert — then at one special pitch it resonates. Our dial is , and "resonance" means the shifted matrix suddenly goes limp and collapses space. Section 3 built the exact tripwire for that collapse: the determinant hitting zero.
The algebra takes three lines. Rearrange the eigen-equation:
A non-zero vector mapped to zero means is singular — full rank lost — and by the bridge theorem that happens precisely when
This is the characteristic equation. Its left side is a degree- polynomial in — the characteristic polynomial — and its roots are the complete list of eigenvalues. For each root, the eigenvectors are the non-zero solutions of : Unit 1's elimination, pointed at the nullspace of the collapsed matrix. That nullspace is the eigenspace , and the set of all eigenvalues is the matrix's spectrum.
For matrices the polynomial wears its meaning openly:
— trace and determinant are literally its coefficients. (In general : the top coefficients can only come from the diagonal product , and setting gives the constant term .)
Run the lecture's example by hand once — it's the template for every eigen-computation you'll ever do. For :
Roots: . Then two small eliminations find the directions. For : forces , so . For : gives , so — exactly the we verified in Section 5. Notice both collapsed matrices visibly lost rank: their rows became parallel. That's no accident — it's the definition of being at an eigenvalue.
① Write (subtract down the diagonal, touch nothing else). ② Set and solve — the roots are all the eigenvalues. ③ For each root , run Unit 1's elimination on and describe the nullspace — that's the eigenspace . ④ Free audit: the roots must sum to and multiply to . Four steps, no exceptions — exam questions, PCA libraries, and Google's PageRank all walk this exact staircase.
Triangular matrices hand you their eigenvalues for free. If is triangular, so is , and a triangle's determinant is its diagonal product: . The eigenvalues are the diagonal entries, no computation at all. Two more freebies in the same spirit: and share a spectrum (because makes their characteristic polynomials identical), and the eigenvalues of are all 1 with eigenspace the whole of .
Factor the polynomial through its roots, , expand, and compare coefficients with the direct expansion. Two identities fall out:
Every time you compute eigenvalues, spend five seconds checking both. For the example: ✓ and ✓. This pair catches arithmetic slips instantly — and it explains the determinant's alarm bell one level deeper: if and only if some eigenvalue is zero, i.e. some direction gets crushed to nothing.
Without touching a pencil: the eigenvalues of ?
A classmate computes the eigenvalues of our (tr = 3, det = −28) and reports . Ten-second verdict?
The Spectral Theorem — symmetric matrices come apart cleanly
Nearly every matrix machine learning builds from data is symmetric: covariance matrices, Gram matrices , kernel matrices, graph Laplacians. A theorem about symmetric matrices is not a special case — it's a theorem about the matrices you'll actually meet.
Think of wood grain. A plank splits cleanly along its grain and resists across it: a hidden set of perpendicular directions built into the material. The Spectral Theorem says every symmetric matrix () has exactly that structure:
① every eigenvalue is real; ② eigenvectors of distinct eigenvalues are orthogonal; ③ there are enough of them to form an orthonormal basis of — so is always diagonalisable, and by an orthonormal matrix at that:
, = eigenvectors as columns (, Unit 3's honest motions), .
Read right-to-left and a "complicated" matrix becomes three innocent moves: turn into the eigenbasis ( — a pure rotation, lengths untouched), stretch along the now-straight axes ( — just numbers on a diagonal), turn back (). Like straightening a crooked picture frame before enlarging it, then hanging it back at its angle. Every symmetric matrix is a rotation away from being diagonal.
The worked example, start to finish: has , so . Eigenvectors and — orthogonal, as promised — normalise to
and multiplying back: ✓. Watch the three moves happen to a vector you control:
Proof that symmetric ⇒ real eigenvalues (four lines, one clever conjugate)
Allow and to be complex for a moment and let . Hit both sides with the conjugate-transpose (Section 9 explains this operator): . The left side is a matrix equal to its own conjugate-transpose — since is real symmetric — so it is a real number. And is real too. A real number divided by a positive real number: is real. ∎
Proof that distinct eigenvalues ⇒ perpendicular eigenvectors
Let and with . Then — the middle step is symmetry, . So , and since , : perpendicular. With repeated eigenvalues the eigenspace has extra dimensions, and Gram–Schmidt (Unit 3!) manufactures an orthonormal basis inside it — that's how the full orthonormal set gets assembled. The one genuinely hard fact, which we take on faith, is that the dimensions always add up to : geometric multiplicity equals algebraic multiplicity for symmetric matrices, so no direction goes missing.
PCA: the principal components are the eigenvectors of the (symmetric) covariance matrix; each eigenvalue is the variance captured along its component. Keep the top few and you've compressed the data with least loss — Units 12–13 build this in full. SVD: apply the spectral theorem to and and you get the singular value decomposition of any matrix — Unit 5's headline. Quadratic forms: draws an ellipsoid whose axes are the eigenvectors with semi-axes — the geometry behind confidence regions and Unit 3's unit balls. Dynamics: solutions of are mixtures of — the signs of eigenvalues decide decay, oscillation, or blow-up.
In , we wrote where diagonalisation in general demands . What makes legitimate here?
The theorem in 3D — a sphere becomes an ellipsoid
Everything scales up. A symmetric matrix has three real eigenvalues on three mutually perpendicular eigen-directions; feed it the unit sphere and out comes an ellipsoid whose axes lie exactly along that grain, stretched by . And the fingerprints multiply: the ellipsoid's volume is times the sphere's — Section 2's volume dial, now factored into per-direction stretches. Drag a to zero and watch dimension die: the ellipsoid pancakes flat, , the matrix goes singular in front of you.
When nothing aligns — rotations and complex eigenvalues
Section 5 left a mystery: the rotation matrix resonated nowhere. Picture a merry-go-round — as it spins, not a single horse keeps pointing the same way. No real direction survives, so there is no real eigenvector to find. Does the theory just fail?
It doesn't — it expands. Run the machinery honestly for :
The roots exist — they've just stepped off the real line into the complex plane, landing on the unit circle as a conjugate pair. And they're not nonsense: is precisely the complex number that means "turn by ". A complex eigenvalue from any real matrix always arrives with its conjugate twin and encodes rotation-by--while-scaling-by- inside some invariant plane. The eigenvalues didn't fail to describe the motion — they described it perfectly, in a language built for turning.
Complex vectors force one honest repair. The old squared length breaks: for it gives — a "length" that isn't even real. The fix is to conjugate one side: define (the conjugate-transpose, or Hermitian transpose), and then
behaves like a length again. With replacing , the whole symmetric story generalises: a matrix is Hermitian if — e.g. — and Hermitian matrices have real eigenvalues and orthogonal eigenvectors, by the very proofs in Section 7 (which, you may notice, were written with all along). This is why quantum mechanics writes every observable — energy, momentum, spin — as a Hermitian operator: measured values must come out real, and Hermitian spectra are the mathematical guarantee that they do.
Set the widget to θ = 90° — the quarter-turn . Its eigenvalues?
Cholesky — the square root of a matrix
One more factorisation, for the friendliest matrices of all: symmetric and positive-definite (all eigenvalues — Unit 3's engine-room matrices, wearing this unit's vocabulary). Just as gives the number 9 a square root, an SPD matrix has a tidy "square root" of its own:
with lower-triangular and positive on its diagonal. And like ordinary square roots, it only works for "positive" inputs. The entries of fall out one at a time, top-left to bottom-right — for :
The lecture's example: gives , , , and indeed ✓. Notice every diagonal step takes a real square root — if the matrix isn't positive-definite, some radicand goes negative and the algorithm halts. Cholesky doubles as the cheapest positive-definiteness test in practice: don't check eigenvalues, just try to factor.
A multivariate Gaussian is governed by a covariance matrix — symmetric positive-definite, as data-built matrices are. To sample from that distribution: factor , draw an easy uncorrelated standard-normal vector (each coordinate independently), and output . The covariance of is — exactly right. is the lens that bends a featureless round cloud into the tilted ellipse your data actually lives on. Every simulation library you'll ever call does precisely this.
Factor in your head: , , and ?
The fine print — defective matrices and the ML bridge
Diagonalisability. The general recipe needs independent eigenvectors to fill 's columns. When do you get them? Always, if the eigenvalues are distinct — eigenvectors of different eigenvalues are automatically independent (a chain of them collapsing would force two 's to coincide). Always, if is symmetric — that's the spectral theorem, with the bonus . But with repeated eigenvalues and no symmetry, it can fail: the shear has counted twice by the polynomial (algebraic multiplicity 2) yet only the single eigen-line (geometric multiplicity 1). One direction short of a basis: the shear is defective, and no change of basis will ever make it diagonal. You met this in the widget — the missing second resonance was this fact, felt through your fingertips.
The bridge into the next units. Take any data matrix with independent columns (rank ) and form the Gram matrix . It is symmetric — — and positive-definite: for , because full column rank means . So everything in this unit applies to it: real positive eigenvalues, orthonormal eigenbasis, Cholesky factor. That one observation is the engine of least squares (Unit 9's normal equations solve ), of SVD (Unit 5 strings together the eigen-structure of and ), and of PCA (Units 12–13 eigendecompose the covariance matrix, which is a scaled Gram matrix of centred data). The chapter you just finished is the load-bearing wall.
Your data matrix (100 rows of examples, 8 columns of features, all columns independent). Which toolbox applies to ?
The whole story, in five lines
① The determinant is the volume dial — scales area/volume, the sign records a mirror flip, and is the alarm bell of collapse: singular, rank-deficient, irreversible. Compute it by cofactors along the laziest line, or by elimination to a triangle. ② The trace adds the diagonal in a heartbeat and moonlights as the sum of the eigenvalues, while the determinant is their product — the free pair of sanity checks. ③ Eigenvectors are the directions a matrix cannot turn, ; the characteristic equation hunts every , and elimination on the collapsed matrix recovers each eigenspace. ④ For symmetric matrices the fingerprints organise perfectly: real eigenvalues on perpendicular directions, — every symmetric matrix is just turn, stretch, turn back. Rotations opt out into the complex plane (), where Hermitian matrices carry the theorem onward. ⑤ Cholesky is the SPD square root — the working end of covariance matrices, Gaussian sampling, and the fastest positive-definiteness test there is.
A matrix is its spectrum, wearing a coordinate system. Find the directions it cannot turn and the numbers it stretches them by, and you have seen through the array of entries to the skeleton underneath — which is exactly what PCA, SVD, spectral clustering, and stability analysis do for a living.