MFML Interactive/ Unit 5 · Decompositions & SVD Checks 0/12
Unit 5 · Covers Session 5 · ZC416 MFML · Prof. Saurabh

Matrix Decompositions & SVD

You can't tell much about 12 until you write it as 2×2×32\times2\times3 — then everything about it is obvious. This unit does the same to matrices: take the tangled transformation apart into a few pure moves — rotate, stretch, rotate back. We climb a three-rung ladder: the flawless symmetric case, the general square case, and then the boldest factorization in linear algebra — the SVD, which works on every matrix ever written, and whose truncation is the mathematics inside image compression, recommender systems, and PCA.

≈ 55 min read + play 5 interactive widgets · live image compression 12 inline checks
1

Taking things apart — the oldest trick in mathematics

Imagine this

Someone hands you the number 5040 and asks: is it divisible by 48? Ugly question — until you factor it: 5040=2432575040 = 2^4\cdot3^2\cdot5\cdot7, and 48=24348=2^4\cdot 3. Read the exponents: yes, instantly. You didn't change the number; you revealed what it was made of. Now recall from Unit 1 that a matrix isn't a grid of numbers — it's a verb, a machine that moves space. A raw matrix tangles rotation, stretching, and shearing into one bundle of entries. Matrix decomposition is prime factorization for transformations: rewrite AA as a short sequence of pure moves you can actually picture.

The punchline of the whole unit, up front: almost every matrix you'll meet can be written as rotate → stretch along axes → rotate. The three famous decompositions are not three unrelated tricks — they are one idea applied to progressively harder matrices, each rung dropping one requirement and gaining one power:

Rung 1 · SpectralA = QΛQᵀsymmetric A only — ⊥ axes, clean transpose (Unit 4's crown jewel)
↓ drop the requirement that eigen-axes be perpendicular
Rung 2 · EigendecompositionA = PDP⁻¹any square, diagonalizable A — tilted axes, honest inverse
↓ drop the requirement that A be square at all
Rung 3 · SVDA = UΣVᵀEVERY matrix, any shape, any rank — two ⊥ frames, always exists

Why climb in this order? Because each rung teaches one lesson. Spectral shows the dream scenario: perpendicular axes, real scalings, no distortion. Eigendecomposition asks what if the natural axes lean? — the idea survives, but the tidy transpose becomes a real inverse. And SVD asks the boldest question — what if the matrix isn't even square, so "eigenvector" is meaningless? — and answers it with one elegant move that works for every matrix in existence.

Pause & predict

When we factor 12=2×2×312 = 2\times2\times3, the number doesn't change. What's the analogue for A=UΣVA=U\Sigma V^{\top}?

2

The shape we're chasing — diagonal matrices are trivial

Every decomposition in this unit is a scheme for smuggling a diagonal matrix into the middle of the product. Why the obsession? Because for a diagonal

D=[d1dn]D=\begin{bmatrix}d_1&&\\&\ddots&\\&&d_n\end{bmatrix}

every hard matrix question collapses into arithmetic on nn separate numbers. The determinant is just the product idi\prod_i d_i (Unit 4's volume dial, read off directly). The kk-th power DkD^k is each entry raised to the kk — no matrix multiplication at all. The inverse is each non-zero entry flipped to 1/di1/d_i. Solving Dx=bD\mathbf{x}=\mathbf{b} is nn one-line divisions. A diagonal matrix is nn independent one-dimensional problems wearing a trench coat — nothing interacts, nothing tangles.

So the game is: given a general AA, find a change of viewpoint in which AA becomes diagonal. That's it. That's the unit.

Pause & predict

D=diag(5,1)D=\operatorname{diag}(5,-1). What is D3D^{3}, and how long did it take you?

3

Diagonalizable — same machine, better glasses

Formally: ARn×nA\in\mathbb{R}^{n\times n} is diagonalizable if there is an invertible PP and a diagonal DD with

D=P1APA=PDP1D=P^{-1}AP\qquad\Longleftrightarrow\qquad A=PDP^{-1}

Where do PP and DD come from? Multiply the definition out. AP=PDAP=PD, and because DD is diagonal, the product PDPD just scales each column of PP by its own diagonal entry. Column by column, AP=PDAP=PD says:

Api=λipiA\mathbf{p}_i=\lambda_i\,\mathbf{p}_i

— which you have seen before. The columns of PP must be eigenvectors of AA, and the diagonal of DD must be their eigenvalues. Diagonalization isn't a new technique; it is Unit 4's eigen-hunt, repackaged as a factorization. The lecture's opening example: A=[1423]A=\begin{bmatrix}1&4\\2&3\end{bmatrix} with P=[2111]P=\begin{bmatrix}-2&1\\1&1\end{bmatrix} gives P1AP=[1005]P^{-1}AP=\begin{bmatrix}-1&0\\0&5\end{bmatrix} — and sure enough, the columns (2,1)(-2,1) and (1,1)(1,1) are exactly the eigenvectors of AA for λ=1\lambda=-1 and λ=5\lambda=5 (check: A(21)=(21)=1(21)A\binom{-2}{1}=\binom{2}{-1}=-1\binom{-2}{1} ✓).

One catch, straight from Unit 4's fine print: this needs n independent eigenvectors to fill PP's columns — and PP must be genuinely invertible. Matrices with enough eigenvectors get the luxury; defective ones (the shear!) are turned away at the door. Hold that thought for Section 6.

4

Rung 1 · Spectral — the flawless case, plus a reading you haven't seen

In plain words

The trampoline. Grab a circular trampoline at two perpendicular points and pull: one axis stretches by λ1\lambda_1, the perpendicular one by λ2\lambda_2, and the circle becomes an ellipse whose axes line up exactly with your hands. That is a symmetric matrix: pure stretch along perpendicular directions, no twist. Unit 4's Spectral Theorem is the guarantee: symmetric AA has orthonormal eigenvectors and real eigenvalues, so

A=QΛQA=Q\Lambda Q^{\top},   with Q1=QQ^{-1}=Q^{\top} free of charge.

In the language of this unit: spectral decomposition is diagonalization where PP happens to be orthonormal — the lucky rung where the inverse costs nothing.

Now the new reading, and it's the most important formula of the unit. Multiply QΛQQ\Lambda Q^{\top} out column-against-row instead of the usual row-against-column, and the product unpacks into a sum of rank-1 layers:

A=QΛQ=λ1q1q1+λ2q2q2++λnqnqnA=Q\Lambda Q^{\top}=\lambda_1\,\mathbf{q}_1\mathbf{q}_1^{\top}+\lambda_2\,\mathbf{q}_2\mathbf{q}_2^{\top}+\cdots+\lambda_n\,\mathbf{q}_n\mathbf{q}_n^{\top}

Each block qiqi\mathbf{q}_i\mathbf{q}_i^{\top} is a projector — Unit 3's shadow machine, boxed up as a matrix: it flattens any input onto the line through qi\mathbf{q}_i. So a symmetric matrix literally reads: "project onto axis 1 and amplify by λ1\lambda_1, plus project onto axis 2 and amplify by λ2\lambda_2, …" The eigenvalues become an honest importance ranking of the axes. Toggle the layers yourself:

The layer viewA = 3·q₁q₁ᵀ + 1·q₂q₂ᵀ — watch a matrix assemble from projections

The example is Unit 4's friend A=[2112]A=\begin{bmatrix}2&1\\1&2\end{bmatrix}: λ1=3\lambda_1=3 on q1=12(1,1)\mathbf{q}_1=\tfrac{1}{\sqrt2}(1,1), λ2=1\lambda_2=1 on q2=12(1,1)\mathbf{q}_2=\tfrac{1}{\sqrt2}(-1,1). Each layer alone crushes the circle onto a line (rank 1!). Their weighted sum rebuilds the full ellipse — and the matrix. Hold this picture: in Section 10 it becomes image compression.

The lecture's 3 × 3 spectral workout — every step

Decompose A=[210121012]A=\begin{bmatrix}2&-1&0\\-1&2&-1\\0&-1&2\end{bmatrix} (symmetric, so the theorem applies). Eigenvalues: det(AλI)=(2λ)[(2λ)22]=0\det(A-\lambda I)=(2-\lambda)\big[(2-\lambda)^2-2\big]=0 gives λ1=2+23.414\lambda_1=2+\sqrt2\approx3.414, λ2=2\lambda_2=2, λ3=220.586\lambda_3=2-\sqrt2\approx0.586 — all real, as promised. Eigenvectors: solving each (AλI)v=0(A-\lambda I)\mathbf{v}=\mathbf{0} by Unit 1 elimination: q1=12(1,2,1)\mathbf{q}_1=\tfrac12(1,-\sqrt2,1), q2=12(1,0,1)\mathbf{q}_2=\tfrac{1}{\sqrt2}(1,0,-1), q3=12(1,2,1)\mathbf{q}_3=\tfrac12(1,\sqrt2,1). Sanity check for free: q1q2=0\mathbf{q}_1\cdot\mathbf{q}_2=0, q1q3=14(12+1)=0\mathbf{q}_1\cdot\mathbf{q}_3=\tfrac14(1-2+1)=0 — orthogonality arrived without being asked, the Spectral Theorem working in the wild. Assembled: A=QΛQA=Q\Lambda Q^{\top} with Λ=diag(2+2,2,22)\Lambda=\operatorname{diag}(2+\sqrt2,\,2,\,2-\sqrt2), or as layers: A=(2+2)q1q1+2q2q2+(22)q3q3A=(2{+}\sqrt2)\,\mathbf{q}_1\mathbf{q}_1^{\top}+2\,\mathbf{q}_2\mathbf{q}_2^{\top}+(2{-}\sqrt2)\,\mathbf{q}_3\mathbf{q}_3^{\top} — the first layer does most of the work, the 0.5860.586 layer is a finishing touch.

Pause & predict

In A=QΛQA=Q\Lambda Q^{\top}, undoing the rotation costs a transpose. In A=PDP1A=PDP^{-1}, it costs a genuine matrix inverse. What buys symmetric matrices the discount?

5

Rung 2 · Eigendecomposition — speak the matrix's native language

In plain words

A general square matrix looks chaotic in your standard x,yx,y grid because it rotates and stretches at once. But the matrix has a private coordinate system — its eigenvectors — in which it does nothing but scale numbers. A=PDP1A=PDP^{-1} is a translator: read right-to-left, P1P^{-1} translates your vector into the matrix's native eigen-language, DD does the embarrassingly simple scaling there, and PP translates back to your language. The transformation was never complicated — you were just listening in the wrong language.

The price of leaving the symmetric world: the eigenvectors lean. For the lecture's A=[1423]A=\begin{bmatrix}1&4\\2&3\end{bmatrix}: eigenvalues from λ24λ5=(λ5)(λ+1)=0\lambda^2-4\lambda-5=(\lambda-5)(\lambda+1)=0, so λ1=5, λ2=1\lambda_1=5,\ \lambda_2=-1 (a negative eigenvalue — flip-and-scale — something a positive-definite symmetric matrix never shows). Eigenvectors: p1=(1,1)\mathbf{p}_1=(1,1) and p2=(2,1)\mathbf{p}_2=(-2,1). Check the angle: p1p2=10\mathbf{p}_1\cdot\mathbf{p}_2=-1\neq0not perpendicular. So P=[1211]P=\begin{bmatrix}1&-2\\1&1\end{bmatrix} is invertible but not orthonormal, and the clean transpose is gone: P1=13[1211]P^{-1}=\tfrac13\begin{bmatrix}1&2\\-1&1\end{bmatrix}, computed honestly.

Why bother? The payoff is matrix powers for free. Sandwiched between PP and P1P^{-1}, repeated multiplication telescopes — every interior P1PP^{-1}P collapses to II:

Ak=(PDP1)(PDP1)(PDP1)=PDkP1A^{k}=(PDP^{-1})(PDP^{-1})\cdots(PDP^{-1})=P\,D^{k}\,P^{-1}

Computing A3A^3 by brute force is nine dot products, twice. With the decomposition: cube two numbers (53=1255^3=125, (1)3=1(-1)^3=-1) and translate once — A3=[41844283]A^3=\begin{bmatrix}41&84\\42&83\end{bmatrix}, done. The same telescope drives matrix exponentials, Markov-chain steady states, and the long-run behaviour of recurrent networks. Watch the translator and the telescope run:

The translatorA = PDP⁻¹ on tilted axes · then raise it to a power for free
✋ drag the gold arrowhead to choose x · note the leaning dashed eigen-axes
1

The dashed axes are p1=(1,1)\mathbf{p}_1=(1,1) (λ=5) and p2=(2,1)\mathbf{p}_2=(-2,1) (λ=−1) — visibly not perpendicular. Slide kk: the chips compute Ak=PDkP1A^k=PD^kP^{-1} live; DkD^k is just (5k,(1)k)(5^k,(-1)^k). At k=3 you get the lecture's [41844283]\begin{bmatrix}41&84\\42&83\end{bmatrix}.

Pause & predict

Using Ak=PDkP1A^k=PD^kP^{-1} with D=diag(5,1)D=\operatorname{diag}(5,-1): what happens to AkxA^{k}\mathbf{x} for large even kk?

Pause & predict

Diagonalize the triangular [2103]\begin{bmatrix}2&1\\0&3\end{bmatrix} in your head: eigenvalues, and is this spectral or merely eigen?

6

Where the ladder breaks — and why we need one more rung

Eigendecomposition is powerful, but it has a door policy, and Unit 4 already showed you both bouncers. Defective matrices: the shear [1101]\begin{bmatrix}1&1\\0&1\end{bmatrix} owns a single eigen-direction — algebraic multiplicity 2, geometric multiplicity 1 — so there aren't enough independent columns to build an invertible PP. No decomposition. Rotations: [0110]\begin{bmatrix}0&-1\\1&0\end{bmatrix} turns every real direction, its eigenvalues fled to ±i\pm i — no real PP exists at all. And beyond both: a 3×23\times2 data matrix isn't even square, so Av=λvA\mathbf{v}=\lambda\mathbf{v} is meaningless — the input is 2-D, the output 3-D; they can't be parallel because they don't live in the same space.

Three failures, one root cause: eigendecomposition insists on using a single set of axes for both input and output. The fix — dropping that insistence — is the SVD, and it repairs all three failures at once.

7

Rung 3 · SVD — two frames, every matrix, no exceptions

The idea, in one question

Eigendecomposition asked: "which directions does the matrix not rotate?" — too demanding; rotations and rectangles refuse. SVD asks the question that always has an answer: "which perpendicular frame of input directions lands on a perpendicular frame of output directions?" Feed any matrix the unit circle (or sphere) and the output is always a perfect ellipse (or ellipsoid). SVD names the perpendicular input directions vi\mathbf{v}_i that map onto the ellipse's perpendicular axes σiui\sigma_i\mathbf{u}_i. Two frames instead of one — that single generosity makes it universal.

The theorem, in full dress. Every ARm×nA\in\mathbb{R}^{m\times n} of rank rr factors as

A=UΣVA=U\,\Sigma\,V^{\top}

where VRn×nV\in\mathbb{R}^{n\times n} is orthonormal (the right-singular vectors — input axes), URm×mU\in\mathbb{R}^{m\times m} is orthonormal (the left-singular vectors — output axes), and ΣRm×n\Sigma\in\mathbb{R}^{m\times n} is "diagonal" with the singular values σ1σ2σr>0\sigma_1\ge\sigma_2\ge\cdots\ge\sigma_r>0 on its diagonal, sorted loudest-first by convention, padded with zeros to match AA's shape. Read right-to-left, it is the unit's mantra in its final form: VV^{\top} rotates the input so the special directions sit on the axes, Σ\Sigma stretches each axis by σi\sigma_i, UU rotates into the final pose. Rotate · stretch · rotate — now for any matrix, including the ones eigendecomposition rejected:

The universal machineA = UΣVᵀ acted out — including the matrices eigen turned away
σ₁ = σ₂ = σ₁/σ₂ =

Both frames stay perpendicular at every stage — the input frame v1,v2\mathbf{v}_1,\mathbf{v}_2 (orange) and the output frame u1,u2\mathbf{u}_1,\mathbf{u}_2 (blue). The σ chips are the ellipse's semi-axes; their ratio is the condition number — how much more the matrix amplifies its favourite direction than its least favourite.

Pause & predict

The rotation [0110]\begin{bmatrix}0&-1\\1&0\end{bmatrix} had no real eigendecomposition. Its SVD?

Pause & predict

A=[3045]A=\begin{bmatrix}3&0\\4&5\end{bmatrix} has eigenvalues 33 and 55 (triangular shortcut). Are its singular values also 3 and 5?

8

Building U, Σ, V — the symmetric-matrix bridge

Where do the three factors come from? From the rung we already own. AA may be rectangular, but AAA^{\top}A (size n×nn\times n) and AAAA^{\top} (size m×mm\times m) are both square, symmetric — Unit 4's Gram matrices — so Rung 1 applies to them. Substitute the SVD and watch the structure fall out:

AA=(UΣV)(UΣV)=VΣΣVA^{\top}A=(U\Sigma V^{\top})^{\top}(U\Sigma V^{\top})=V\,\Sigma^{\top}\Sigma\,V^{\top}

That is a spectral decomposition of AAA^{\top}A — so VV is its eigenvector matrix, and the eigenvalues sitting in ΣΣ\Sigma^{\top}\Sigma are σi2\sigma_i^2: the singular values are the square roots of AAA^{\top}A's eigenvalues (which the spectral theorem guarantees are real and 0\ge0 — this is why σ's never go negative or complex). Symmetrically, AA=UΣΣUAA^{\top}=U\Sigma\Sigma^{\top}U^{\top} hands UU to us as the eigenvectors of AAAA^{\top}. And in practice you never even compute the second one: post-multiplying A=UΣVA=U\Sigma V^{\top} by VV gives AV=UΣAV=U\Sigma, i.e. column by column

ui=1σiAvi(i=1,,r)\mathbf{u}_i=\frac{1}{\sigma_i}A\mathbf{v}_i\qquad(i=1,\dots,r)

— each output axis is just the normalized image of its input axis. One eigendecomposition plus rr matrix–vector products and you own the whole factorization.

The recipe card

① Form the smaller of AAA^{\top}A or AAAA^{\top}. ② Spectrally decompose it (Rung 1 / Unit 4 machinery). ③ σi=λi\sigma_i=\sqrt{\lambda_i}, sorted descending, zeros dropped. ④ Its eigenvectors are VV (or UU); the other family comes free via ui=Avi/σi\mathbf{u}_i=A\mathbf{v}_i/\sigma_i. ⑤ Assemble A=UΣVA=U\Sigma V^{\top}, padding Σ\Sigma with zero rows/columns to match AA's shape.

The lecture's wide example, walked through. A=[101210]A=\begin{bmatrix}1&0&1\\-2&1&0\end{bmatrix} (2×3, rank 2). Step 1: AA=[521210101]A^{\top}A=\begin{bmatrix}5&-2&1\\-2&1&0\\1&0&1\end{bmatrix}, symmetric as promised. Step 2: its eigenvalues are 6, 1, 06,\ 1,\ 0 — the zero is no accident: a 2×3 matrix has rank at most 2, so one input direction must be crushed. Step 3: σ1=6, σ2=1\sigma_1=\sqrt6,\ \sigma_2=1, so Σ=[600010]\Sigma=\begin{bmatrix}\sqrt6&0&0\\0&1&0\end{bmatrix} — 2×3 like AA, with a zero column of padding. Step 4: eigenvectors v1=130(5,2,1)\mathbf{v}_1=\tfrac{1}{\sqrt{30}}(5,-2,1), v2=15(0,1,2)\mathbf{v}_2=\tfrac{1}{\sqrt5}(0,1,2), v3=16(1,2,1)\mathbf{v}_3=\tfrac{1}{\sqrt6}(-1,-2,1) — and v3\mathbf{v}_3, riding the zero eigenvalue, is exactly the nullspace direction AA annihilates. Step 5: u1=1σ1Av1=15(1,2)\mathbf{u}_1=\tfrac{1}{\sigma_1}A\mathbf{v}_1=\tfrac{1}{\sqrt5}(1,-2), u2=1σ2Av2=15(2,1)\mathbf{u}_2=\tfrac{1}{\sigma_2}A\mathbf{v}_2=\tfrac{1}{\sqrt5}(2,1) — automatically orthonormal. Assembled, A=UΣVA=U\Sigma V^{\top} exactly.

The tall twin: SVD of B = [[1,1],[0,1],[1,0]] — featuring an old friend

BB is 3×2, so be smart and take the smaller Gram matrix: BB=[2112]B^{\top}B=\begin{bmatrix}2&1\\1&2\end{bmatrix}the very matrix this unit keeps meeting. Its spectral data is memorized by now: λ=3,1\lambda=3,1 on 12(1,1)\tfrac{1}{\sqrt2}(1,1), 12(1,1)\tfrac{1}{\sqrt2}(1,-1). So σ1=3, σ2=1\sigma_1=\sqrt3,\ \sigma_2=1, v1,2\mathbf{v}_{1,2} as above, and u1=13Bv1=16(2,1,1)\mathbf{u}_1=\tfrac{1}{\sqrt3}B\mathbf{v}_1=\tfrac{1}{\sqrt6}(2,1,1), u2=Bv2=12(0,1,1)\mathbf{u}_2=B\mathbf{v}_2=\tfrac{1}{\sqrt2}(0,-1,1). A third vector u3=13(1,1,1)\mathbf{u}_3=\tfrac{1}{\sqrt3}(1,-1,-1) completes the 3×3 UU but rides on σ3=0\sigma_3=0: Σ=[300100]\Sigma=\begin{bmatrix}\sqrt3&0\\0&1\\0&0\end{bmatrix} pads with a zero row, because BB sends 2-D into 3-D and the third output dimension receives nothing. Tall matrices pad with zero rows (unreachable outputs); wide ones with zero columns (annihilated inputs). Σ\Sigma always wears AA's shape.

Pause & predict

You need the SVD of a 1000×3 dataset matrix. Which Gram matrix do you eigendecompose?

Pause & predict

In the wide example, v3=16(1,2,1)\mathbf{v}_3=\tfrac{1}{\sqrt6}(-1,-2,1) carries σ3=0\sigma_3=0. What is this direction, in Unit 1's vocabulary?

9

Seeing a rectangular matrix — 2-D in, 3-D out

This is the picture eigendecomposition could never draw: a matrix whose input and output live in different spaces. B=[110110]B=\begin{bmatrix}1&1\\0&1\\1&0\end{bmatrix} eats a flat 2-D vector and produces a point in 3-D. Feed it the whole unit circle and the output is an ellipse — but an ellipse floating on a tilted plane inside 3-D space, the plane spanned by u1\mathbf{u}_1 and u2\mathbf{u}_2. The third output direction u3\mathbf{u}_3 sticks out of that plane and receives exactly nothing — it is the zero row of Σ\Sigma made visible. Drag the probe around the input circle and watch its image travel the ellipse:

Two spaces, one matrixB is 3×2 · the input circle lives in 2-D, its image lives on a plane in 3-D
✋ input space ℝ² — drag the probe
✋ output space ℝ³ — drag to orbit

When the probe sits on v1\mathbf{v}_1 (orange), its image lands on σ1u1\sigma_1\mathbf{u}_1 — the ellipse's long axis, length 3\sqrt3. On v2\mathbf{v}_2, it lands on u2\mathbf{u}_2, length 1. The grey arrow u3\mathbf{u}_3 is the direction no input can ever reach: Σ\Sigma's zero row, standing upright out of the image plane.

10

The layer cake — low-rank approximation, live

Now collect the unit's two best ideas and let them collide. Section 4 read a symmetric matrix as a sum of importance-ranked projection layers. The SVD does the same for every matrix: multiply UΣVU\Sigma V^{\top} out column-against-row and Σ\Sigma's diagonal pairs each ui\mathbf{u}_i with its vi\mathbf{v}_i:

A=i=1rσiuivi=σ1u1v1loudest+σ2u2v2quieter++σrurvrfaintestA=\sum_{i=1}^{r}\sigma_i\,\mathbf{u}_i\mathbf{v}_i^{\top}=\underbrace{\sigma_1\mathbf{u}_1\mathbf{v}_1^{\top}}_{\text{loudest}}+\underbrace{\sigma_2\mathbf{u}_2\mathbf{v}_2^{\top}}_{\text{quieter}}+\cdots+\underbrace{\sigma_r\mathbf{u}_r\mathbf{v}_r^{\top}}_{\text{faintest}}

— a stack of rank-1 layers, sorted loudest-first because the σ's are sorted. Since real-world matrices concentrate their energy in the first few singular values, truncating the sum at kk terms gives the rank-kk approximation A^(k)=i=1kσiuivi\hat A(k)=\sum_{i=1}^{k}\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}, and the Eckart–Young theorem says this is not merely a compression — it is provably the best possible rank-kk approximation of AA, with error exactly the loudest singular value you discarded: AA^(k)2=σk+1\|A-\hat A(k)\|_2=\sigma_{k+1}.

The companion's tiny example, by hand: keep only the loudest layer of the tall BB. B^(1)=σ1u1v1=316(2,1,1)12(1,1)=[110.50.50.50.5]\hat B(1)=\sigma_1\mathbf{u}_1\mathbf{v}_1^{\top}=\sqrt3\cdot\tfrac{1}{\sqrt6}(2,1,1)^{\top}\cdot\tfrac{1}{\sqrt2}(1,1)=\begin{bmatrix}1&1\\0.5&0.5\\0.5&0.5\end{bmatrix}, and the error is the dropped σ2=1\sigma_2=1. Six numbers describing a matrix of six — no saving yet at this toy size. But scale it up: an image is a matrix, and now the layer cake becomes a compressor. Try it:

The image squeezera picture is a matrix · keep k layers · watch it reassemble
3
storage error σ₍k₊₁₎ =
Watch out — the noise lesson

Switch the widget to pure noise and drag kk: the reconstruction barely improves, because noise spreads its energy evenly across all singular values — there are no quiet layers to discard for free. Structure compresses; noise doesn't. Flip that insight around and you get denoising: real signal hides in the loud early layers, noise in the faint tail, so truncating the SVD removes noise. One theorem, two superpowers.

Pause & predict

You keep k=3k=3 layers of a matrix whose singular values are 9,4,2,0.5,0.19,\,4,\,2,\,0.5,\,0.1. What is AA^(3)2\|A-\hat A(3)\|_2?

Pause & predict

A 1000×10001000\times1000 image, stored as rank-50 layers: roughly what fraction of the original million numbers?

11

The spectral norm — and the family portrait

One last gift from the SVD. Ask: what is the most a matrix can ever amplify a vector? That worst-case stretch is the spectral norm,

A2=maxx0Ax2x2=σ1\|A\|_2=\max_{\mathbf{x}\neq\mathbf{0}}\frac{\|A\mathbf{x}\|_2}{\|\mathbf{x}\|_2}=\sigma_1

— simply the longest semi-axis of the output ellipsoid, achieved by feeding in v1\mathbf{v}_1 (the output points along u1\mathbf{u}_1). The lecture's example: A=[1234]A=\begin{bmatrix}1&2\\3&4\end{bmatrix} has Σ=diag(5.465,0.366)\Sigma=\operatorname{diag}(5.465,\,0.366), so A2=5.465\|A\|_2=5.465 — and the ratio σ1/σ215\sigma_1/\sigma_2\approx15 says this matrix amplifies its favourite direction fifteen times more than its least favourite: fairly ill-conditioned, the kind of matrix that makes numerical software sweat. Spectral norms bound errors, govern the stability of deep networks (exploding/vanishing signals track products of σ's), and put the "spectral" in spectral normalization for GANs.

And the family portrait, one table to close the ladder:

Eigen / SpectralSVD
FormA=PDP1A=PDP^{-1} (or QΛQQ\Lambda Q^{\top})A=UΣVA=U\Sigma V^{\top}
Works onsquare, with enough eigenvectorsevery matrix, any shape, always
Framesone set of axes (input = output)two sets: input VV, output UU
OrthogonalityPP generally not orthogonalU,VU,V always orthonormal
Diagonal entrieseigenvalues — can be negative or complexsingular values — always real, 0\ge0, sorted
Outer factorsP, P1P,\ P^{-1} are inversesU, VU,\ V generally unrelated
The linkVV = eigenvectors of AAA^{\top}A · UU = eigenvectors of AAAA^{\top} · σi=λi(AA)\sigma_i=\sqrt{\lambda_i(A^{\top}A)}
Pause & predict

For A=[1234]A=\begin{bmatrix}1&2\\3&4\end{bmatrix}, which number is A2\|A\|_2?

12

The whole story, in five lines

① A matrix is a transformation, and decomposition is prime factorization for transformations: rewrite AA as rotate → stretch → rotate, without changing what it does. ② The chase is always for a diagonal middle — because diagonal matrices reduce every question to arithmetic on nn separate numbers. ③ Spectral (A=QΛQA=Q\Lambda Q^{\top}, symmetric only) is the flawless rung: perpendicular axes, free transpose, and the layer reading A=λiqiqiA=\sum\lambda_i\mathbf{q}_i\mathbf{q}_i^{\top}. Eigen (A=PDP1A=PDP^{-1}, square + enough eigenvectors) keeps the idea on tilted axes and pays with an inverse — earning Ak=PDkP1A^k=PD^kP^{-1}. ④ SVD (A=UΣVA=U\Sigma V^{\top}) drops every remaining requirement by using two orthonormal frames bridged by non-negative stretches — built from the spectral decomposition of AAA^{\top}A, with ui=Avi/σi\mathbf{u}_i=A\mathbf{v}_i/\sigma_i for free. ⑤ Sorting the σ's turns every matrix into a loudest-first layer cake: truncate for the provably-best low-rank approximation (Eckart–Young), read σ1\sigma_1 as the worst-case amplification (spectral norm), and you hold the mathematics of compression, denoising, PCA, and recommenders in one formula.

The one thing to remember

Every matrix is rotate · stretch · rotate. The only questions are whether the two rotations are the same (symmetric), whether they're transposes or inverses (spectral vs eigen), and how fast the stretches fade (that's compressibility). Once you sort the stretches loudest-first, keeping the top few is the best summary a matrix can have — and half of applied ML is exactly that act.

Next up

Unit 6 · Differentiation

Linear algebra's board is complete. Now the pieces start to move: calculus enters, and with it the single most important question in machine learning — if I nudge the input, how does the output change? (Being built next.)