Take the number 12. Write it as 2×2×3, and it suddenly becomes easy to work with. This unit does the same thing to matrices. A matrix mixes turning and stretching into one block of numbers. A decomposition pulls them apart into a few simple moves: turn, resize, turn. We get there in three steps — symmetric matrices (the easy case), square matrices, and then the SVD, which works for every matrix of any shape. The SVD is the engine inside photo compression, recommendations and PCA. By the end you will shrink a real photograph with it, and know exactly why it works.
≈ 70 min read + play10 interactive widgets · 6 in 3D · a real photo17 inline checks🧾 7 rules derived step by step✍ 12 solved practice problems
sphere
drag the space to orbit
1
Taking things apart — the oldest trick in mathematics
Imagine this
Open any photo on your phone and tap Edit. You get two simple tools. Rotate turns the photo. Resize lets you drag the width and the height, each on its own.
That is all. There is no "slant" tool and no "twist" tool. Yet here is a surprising fact: every matrix is just rotate, resize, rotate. Three taps in a photo editor.
Remember from Unit 1: a matrix is a machine that moves space. Its numbers mix the turning and the stretching together, so you cannot see them. Look at [3405]. Does it turn things? By how much? The four numbers do not say.
Numbers have the same problem. Is 5040 divisible by 48? Hard to tell. Now write both in pieces: 5040=24⋅32⋅5⋅7 and 48=24⋅3. Suddenly the answer is an easy yes. The number did not change. We only wrote it in a form that shows what it is made of.
A decomposition does this for a matrix. It is factoring, for matrices. It rewrites a matrix A as a few simple moves, done one after another. Watch it happen to a photo:
The photo editorone matrix = turn · resize · turn — watch it happen to a photo
Try: press ▶ play. Then pick the shear and play again.
drag the picture to orbit
—
The dashed orange outline is where the matrix sends the photo in one go. The three simple moves land on it exactly.
Turn, resize, turn — that is where we are heading. We get there in three steps. Each step asks for less and works for more matrices:
Step 1 · SpectralA = QΛQᵀsymmetric A only — perpendicular axes, free inverse (just the transpose)
↓ now allow axes that lean
Step 2 · EigendecompositionA = PDP⁻¹any square A with enough eigenvectors — leaning axes, real inverse
↓ now allow any shape at all
Step 3 · SVDA = UΣVᵀEVERY matrix, any shape — two perpendicular frames, always works
Why this order? Step 1 is the perfect case: the matrix only resizes, along directions at right angles. Step 2 asks: what if those directions lean? The idea still works, but it costs more. Step 3 asks the big question: what if the matrix is not even square? The SVD answers it with one recipe that works for every matrix.
The realization
A matrix looks like a block of numbers. Underneath, it is a short list of simple moves. Writing A=(turn)(resize)(turn) does not change A at all. It only lets you see what A does.
Pause & predict
Pick the shear. It slides the top of the photo sideways. Yet the three moves are only turns and a resize. What does that tell you?
Pause & predict
When we write 12=2×2×3, the number does not change. What is the same idea for A=UΣV⊤?
In one sentence: a decomposition rewrites a matrix as a few simple moves — turn, resize, turn — without changing what it does.
2
The goal — diagonal matrices are easy
Imagine this
In the photo editor, the resize tool has two handles. One sets the width. The other sets the height. Make the width ×2 and the height ×0.6.
The width handle never touches the height. The height handle never touches the width. Each handle minds its own business.
A matrix that works like the resize tool has numbers only on its diagonal — the line from top-left to bottom-right. Every other entry is zero. We call it a diagonal matrix:
D=[2000.6](width×2,height×0.6)
Diagonal matrices are the easiest matrices there are. Every hard question turns into easy arithmetic, one axis at a time:
The question
In everyday words
For this D
Do it 3 times, D3
Width ×2 three times, height ×0.6 three times.
diag(8,0.216)
Undo it, D−1
Divide by each handle instead.
diag(0.5,1.667)
Area change, detD
Multiply the two handles.
2×0.6=1.2
Solve Dx=b
One division per axis.
x1=b1/2,x2=b2/0.6
In general we write D=diag(d1,…,dn) (read it: "the matrix with d1 to dn down its diagonal, zeros everywhere else"). It is really n separate one-number problems. Nothing mixes with anything.
So here is the plan for the whole unit. Take a messy matrix. Find a new point of view in which it becomes a resize tool. First, play with the two handles:
The resize toola diagonal matrix = one handle per axis · repeat and undo come free
Try: press "set d₂ to 0" and read the undo line. Then try "flip d₁".
—
Each handle owns one axis and cannot touch the other. A handle at 0 flattens its axis, and nothing can undo that.
The realization
A diagonal matrix is a resize tool: one handle per axis. Repeating, undoing and measuring area all work one number at a time: Dk=diag(d1k,…,dnk). The only danger is a handle set to 0 — that axis is flattened for good.
Pause & predict
D=diag(5,−1). What is D3, and how long did it take you?
In one sentence: a diagonal matrix is easy because each axis minds its own business — so this unit is a hunt for the diagonal hiding inside every matrix.
3
Diagonalizable — same machine, better glasses
Imagine this
A carpenter looks at a plank before cutting it. Along the grain, the wood splits cleanly. Across the grain, it fights back. The plank has its own favourite directions.
A good carpenter works along those directions, not along the edges of the table. Matrices are the same.
Take the lecture's matrix A=[1243]. In the usual x–y grid it looks messy: it turns and stretches at once. But it has two favourite directions, where it does nothing but resize:
Along p1=(1,1) it stretches by 5: Ap1=(5,5)=5p1.
Along p2=(−2,1) it just flips: Ap2=(2,−1)=−1⋅p2.
You met these in Unit 4: they are the eigenvectors, and 5 and −1 are the eigenvalues. Now use the two favourite directions as your new axes. In those axes, A is a resize tool: ×5 on one axis, ×(−1) on the other. That is what diagonalizable means. In symbols:
A=PDP−1,P=[11−21],D=[500−1]
Read it right to left, like a sentence. P−1 switches to the new axes. D resizes along them. P switches back. The columns of P are the favourite directions. The diagonal of D says how much each one is stretched.
Why must the columns be eigenvectors? Multiply A=PDP−1 on the right by P to get AP=PD. Read it one column at a time and it says Api=λipi: "A only stretches pi." That is the definition of an eigenvector. So diagonalizing is Unit 4's eigen-hunt, packed into one formula.
A=[1243]: the columns of P are the only directions that A just resizes.
If you want the algebra · why AP = PD forces eigenvectors
Why AP = PD forces eigenvectors — derived
Claim. If AP=PD with P=[p1⋯pn] and D=diag(λ1,…,λn), then Api=λipi for every i.
1
Column i of the left side:
(AP)ei=A(Pei)=ApiMultiplying by ei picks out column i, and matrix products associate — so column i of AP is A applied to column i of P.
2
Column i of the right side:
(PD)ei=P(Dei)=P(λiei)=λiPei=λipiColumn i of a diagonal matrix is λiei — one number, in one slot. Scalars slide through a matrix product.
3
The two sides are the same matrix, so their i-th columns agree:
Api=λipi(i=1,…,n)Every column of P is an eigenvector and its diagonal partner is the eigenvalue. Run the steps backwards and you get the converse: stack any n eigenvectors as columns and AP=PD holds automatically. When those columns are independent, P−1 exists and A=PDP−1. ∎
One catch, straight from Unit 4. You need n independent favourite directions to fill the n columns of P. Otherwise P has no inverse, and the recipe breaks. Some matrices do not have enough — Section 6 shows who.
One more example, a symmetric one: [2.5−1−12.5] stretches (1,−1) by 3.5 and (1,1) by 1.5. This time the two favourite directions are at right angles. That is no accident — it is the next section.
The realization
A=PDP−1 says: in its own favourite directions, A is just a resize tool. The columns of P are those directions (the eigenvectors). The diagonal of D says how much each is stretched (the eigenvalues).
In one sentence:A=PDP−1 just says: put A's eigenvectors in the columns of P and their eigenvalues in D.
4
Step 1 · Spectral — the perfect case, read a new way
Imagine this
Open the equalizer in your music app. It splits the song into bass and treble. You turn the bass up ×3 and leave the treble at ×1. Then the app adds the two parts back together and plays the result.
Split, turn each part up or down, add back. Hold on to that. It is exactly how a symmetric matrix works.
A symmetric matrix equals its own mirror image across the diagonal: A=A⊤ (read it: "A equals A-transpose"). Our running example is A=[2112].
Unit 4's Spectral Theorem promised two things about symmetric matrices. Their favourite directions are at right angles. And their stretch amounts are real numbers. For our A:
q1=21(1,1) is stretched by λ1=3. Call it the "bass" channel.
q2=21(−1,1) is stretched by λ2=1. Call it the "treble" channel.
Now run the equalizer on the input x=(2,0):
Split. The shadow of x on the q1 line is (1,1). Its shadow on the q2 line is (1,−1). Check: (1,1)+(1,−1)=(2,0) ✓.
Turn each part up. Bass ×3 gives (3,3). Treble ×1 stays (1,−1).
Add back.(3,3)+(1,−1)=(4,2). And directly, Ax=(2⋅2+1⋅0,1⋅2+2⋅0)=(4,2) ✓.
In symbols, "the shadow on the line through qi" is the small matrix qiqi⊤. Unit 3 called it a projector. So the whole matrix is a sum of layers, one per channel:
A=λ1q1q1⊤+λ2q2q2⊤+⋯+λnqnqn⊤
Stack the directions as the columns of a matrix Q, and the stretches into a diagonal Λ ("capital lambda"). Then the same sum reads A=QΛQ⊤. This is the spectral decomposition.
Its bonus: the columns of Q are at right angles and have length 1. So undoing Q costs nothing — Q−1 is just Q⊤, the transpose. The biggest λ is the loudest layer. Keep that thought; in Section 10 it becomes photo compression. Now play with the layers:
The equalizerA = 3·q₁q₁ᵀ + 1·q₂q₂ᵀ — two layers fall together into one matrix
Try: press ▶ play. Then press "x on the q₂ line" and pick "λ₁ layer only".
drag the picture to orbit · drag the gold x on the floor
—
Each layer alone squashes the circle flat onto its own line. Added together, they rebuild the full oval — and the matrix.
The realization
A symmetric matrix is an equalizer. It splits the input along directions at right angles, turns each part up by its own λ, and adds them back: A=∑iλiqiqi⊤=QΛQ⊤. Undoing the split is free, because Q−1=Q⊤.
The lecture's 3 × 3 spectral workout — every step
Decompose A=2−10−12−10−12. It is symmetric, so the theorem applies and we know in advance the answer will have perpendicular axes.
Eigenvalues.det(A−λI)=(2−λ)[(2−λ)2−2]=0, so λ1=2+2≈3.414, λ2=2, λ3=2−2≈0.586 — all real, as promised.
Eigenvectors. Solve each (A−λI)v=0 by Unit 1 elimination and normalise: q1=21(1,−2,1), q2=21(1,0,−1), q3=21(1,2,1).
Free sanity check.q1⋅q2=0 and q1⋅q3=41(1−2+1)=0: orthogonality arrived without being asked — the Spectral Theorem at work.
Assemble.A=QΛQ⊤ with Λ=diag(2+2,2,2−2); as layers, A=(2+2)q1q1⊤+2q2q2⊤+(2−2)q3q3⊤.
So what: the first layer does most of the work; the 0.586 layer is a finishing touch. Drop it and you have a rank-2 matrix that is already close to A — Section 10 turns that observation into compression.
If you want the algebra · why QΛQᵀ is a sum of layers
Why QΛQᵀ is a sum of layers — derived
Claim. If Q=[q1⋯qn] and Λ=diag(λ1,…,λn), then QΛQ⊤=∑i=1nλiqiqi⊤.
1
First the inner product QΛ, column by column:
QΛ=[λ1q1λ2q2⋯λnqn]Same fact as in Section 3: multiplying by a diagonal matrix on the right scales each column by its own diagonal entry.
2
Now multiply by Q⊤, whose rows are q1⊤,…,qn⊤. Write the product entry-wise:
(QΛQ⊤)jk=i=1∑n(QΛ)ji(Q⊤)ik=i=1∑nλi(qi)j(qi)kThe definition of a matrix product — entry jk is a sum over the shared index i. Step 1 says (QΛ)ji=λi(qi)j, and (Q⊤)ik=(qi)k.
3
Recognise each summand as an entry of an outer product: (qiqi⊤)jk=(qi)j(qi)k. So
QΛQ⊤=i=1∑nλiqiqi⊤The sum over i of "column i times row i" is the column-times-row way of multiplying — it is always available, and here each term is a rank-1 layer.
4
Why each layer is a projector: for unit qi, (qiqi⊤)x=qi(qi⊤x)=(qi⋅x)qi.
That is the shadow of x on the line through qi (Unit 3). So Ax=∑iλi(qi⋅x)qi: take each shadow, scale it by its eigenvalue, add. Exactly what the widget draws. ∎
Pause & predict
In A=QΛQ⊤, undoing the outer factor costs only a transpose. In A=PDP−1 it costs a real inverse. What gives symmetric matrices this discount?
In one sentence: a symmetric matrix is a set of perpendicular directions, each turned up by its own eigenvalue — nothing more.
5
Step 2 · Eigendecomposition — the matrix's own language
Imagine this
Your grandmother tells a joke in Marathi. Translated word by word into English, it sounds long and confusing. In Marathi it is short and simple.
The joke was never complicated. You were just hearing it in the wrong language. So: translate in, enjoy it there, translate back.
A general square matrix is the same. In the usual x–y grid it looks complicated. In its own language — its favourite directions — it only resizes.
Outside the symmetric world there is one price. The favourite directions lean: they are no longer at right angles. Take A=[1243] again. Its directions are p1=(1,1) (stretch ×5) and p2=(−2,1) (flip, ×−1). Their dot product is 1⋅(−2)+1⋅1=−1, not 0. So they lean.
Because they lean, the free transpose trick is gone. We need a real inverse: P−1=31[1−121]. The formula A=PDP−1 is now a translator in three steps:
P−1 translates x into the matrix's language: "how much of p1, how much of p2?"
D does the simple job there: ×5 and ×(−1).
P translates the answer back to x–y.
Why bother? Because repeating the matrix becomes almost free. Doing A three times is A3. Write each A as a translator, and every P−1P in the middle cancels out:
A3=(PDP−1)(PDP−1)(PDP−1)=PD3P−1
So you only cube two plain numbers: 53=125 and (−1)3=−1. Translate back once, and A3=[41428483]. The same shortcut powers Google's PageRank, population models and Markov chains — anything that repeats one step many times. Watch the translator work:
The translatorA = PDP⁻¹ on leaning axes · then repeat it for free
Try: step through 1 → 4. Then drag the gold x onto the dashed p₂ line and watch step 3.
✋ drag the gold arrowhead to choose x
—
The dashed axes lean, so x splits into a slanted parallelogram, not a rectangle. Slide k: Dk is just (5k,(−1)k).
The realization
A=PDP−1 is a translator: into the matrix's own directions, resize, and back. Its best trick is repetition: Ak=PDkP−1. Powers of a matrix become powers of plain numbers.
If you want the algebra · why Aᵏ = PDᵏP⁻¹
Why Aᵏ = PDᵏP⁻¹ — derived
Claim. If A=PDP−1, then Ak=PDkP−1 for every whole number k≥1.
1
Do k=2 by hand:
A2=(PDP−1)(PDP−1)=PD(P−1P)DP−1=PDIDP−1=PD2P−1Matrix multiplication is associative, so the brackets can be regrouped freely; the only thing that happens is the P−1P in the middle collapsing to I.
2
Suppose it holds for some k. Multiply once more by A:
Ak+1=AkA=(PDkP−1)(PDP−1)=PDk(P−1P)DP−1=PDk+1P−1The same collapse, one more time. Starting from step 1 and repeating step 2 reaches every k — that is induction.
3
And Dk costs nothing: for a diagonal matrix, (Dk)ii=λik and every off-diagonal entry stays 0.
A diagonal times a diagonal multiplies entry by entry (Section 2). For the lecture's D=diag(5,−1): D3=diag(125,−1), then one product PD3P−1 gives [41428483]. Two scalar cubes replaced two matrix multiplications. ∎
Pause & predict
With D=diag(5,−1), what happens to Akx when k is large and even?
Pause & predict
Diagonalize [2013] in your head. What are the eigenvalues, and is this spectral or only eigen?
In one sentence:P−1 translates into the matrix's own language, D does a simple resize there, and P translates back.
6
Where eigendecomposition fails — and the fix
Imagine this
Look at three everyday motions. A ceiling fan spins: every direction on its blades turns, none stays put. A deck of cards pushed sideways: only the direction along the table stays put — one direction, not two.
And a shadow on the wall: your 3-D hand becomes a flat 2-D shape. The input and the output do not even live in the same world.
Eigendecomposition needs enough favourite directions — directions the matrix does not turn. These three kinds of matrix do not have them:
The matrix
Everyday picture
What goes wrong
The shear [1011]
a deck of cards pushed sideways
Only one direction stays unturned. A 2×2 matrix needs two. (Unit 4 called this "defective".)
The rotation [01−10]
a spinning fan
Every direction turns. The eigenvalues are the imaginary ±i, so no real P exists.
A 3×2 data matrix
2-D in, 3-D out
Not square. "Av=λv" makes no sense: input and output live in different spaces.
Three failures, one cause. Eigendecomposition insists on one set of axes for both the input and the output. The SVD drops that demand, and all three failures disappear at once.
See it for yourself first. Sweep a direction around the circle and watch for the moments when Av points the same way as v:
The eigen-huntersweep the dial · an eigenvector is a direction the matrix does not turn
Try: press ▶ auto-sweep on each matrix and count the pauses.
✋ drag the dial — or press play and let it sweep
—
The strip shows how much every direction gets turned. Each place it touches zero is an eigenvector: symmetric 2, leaning 2, shear 1, rotation 0.
The realization
An eigenvector is a direction the matrix does not turn. Eigendecomposition needs n independent ones for an n×n matrix. The shear has one, the rotation has none, and a rectangular matrix cannot even ask the question.
Pause & predict
On the strip, the shear's curve touches zero exactly once (along the x-axis). What does that say, in Unit 4's words?
In one sentence: eigendecomposition fails whenever one set of axes must serve both input and output — the shear, the rotation, and every rectangular matrix.
7
Step 3 · SVD — two frames, every matrix, no exceptions
Imagine this
Draw a circle on a flat sheet of rubber. Now pull, push and twist the sheet any way you like, keeping it flat. The circle always becomes an oval.
And every oval has a longest direction and a shortest direction. Those two are always at right angles. Always.
That one fact is the whole SVD. Eigendecomposition asked: "which directions does the matrix not turn?" Sometimes the answer is "none". The SVD asks a friendlier question that always has an answer: "which directions at right angles land on directions at right angles?"
Feed any matrix the unit circle and you get an oval (an ellipse). Its two axes are at right angles. Now walk backwards: which input directions landed on those axes? They turn out to be at right angles too. So we get two frames — one for the input, one for the output.
For the lecture's A=[3405], the oval's long half-axis is σ1=35≈6.71 and its short half-axis is σ2=5≈2.24. These lengths are the singular values (σ is the Greek letter "sigma").
Here is the theorem. Every matrix A, of any shape m×n, can be written as
A=UΣV⊤
Piece
What it does
Photo editor
V⊤
Turns the input so the special input directions vi sit on the axes.
rotate
Σ
Stretches axis i by σi. The σ's are never negative and are sorted biggest first.
resize
U
Turns the result into place, so the axes land on the output directions ui.
rotate
The vi are called right-singular vectors (the input frame). The ui are left-singular vectors (the output frame). The whole story fits in one line: Avi=σiui — "input direction i lands on output direction i, stretched by σi." Watch it on a lit sphere, including the matrices that eigendecomposition turned away:
The universal machineA = UΣVᵀ acted out — even for the matrices eigendecomposition rejects
Try: pick the rotation and press ▶ play. The resize step does nothing (σ₁ = σ₂ = 1), yet the SVD still exists.
drag the picture to orbit · the matrix acts on the floor plane; the up-axis just rides along
σ₁ = —σ₂ = —σ₁/σ₂ = —
—
Watch the orange input frame ride the pipeline and land exactly on the blue axes σiui. That landing is Avi=σiui, acted out.
The realization
Every matrix is turn · resize · turn: A=UΣV⊤. There are two frames at right angles — V for inputs, U for outputs — and a list of stretches σ1≥σ2≥⋯≥0. No exceptions: not rotations, not shears, not rectangles.
Pause & predict
The rotation [01−10] had no real eigendecomposition. What about its SVD?
Pause & predict
A=[3405] has eigenvalues 3 and 5 (read off the diagonal of a triangular matrix). Are its singular values also 3 and 5?
In one sentence: every matrix is turn · resize · turn — V⊤, then Σ, then U — no exceptions.
8
Building U, Σ, V — the symmetric-matrix bridge
Imagine this
Shout "hello" across a valley. Your voice travels out, hits the far hill, and comes back as an echo. From some spots the echo comes back loud and straight at you. From others it comes back faint.
Listening to the round trip tells you a lot about the valley. We will find the SVD the same way.
We do not attack A head-on. A sends a vector out; its transpose A⊤ brings it back. The round trip is the matrix A⊤A. Whatever shape A has, A⊤A is always square and symmetric — exactly the easy case that Step 1 already solved.
The picture below shows why the round trip works. A sends vi to σiui. Then A⊤ sends that straight back along vi, stretched by σi again. So:
A⊤Avi=σi2vi
Read it aloud: "vi is an eigenvector of A⊤A, and its eigenvalue is σi2." The echo comes back in the same direction, σi2 times as loud.
Why the detour works: A carries vi to σiui, and A⊤ carries σiui straight back to σi2vi. Round trip: A⊤Avi=σi2vi.
So the recipe writes itself:
Take the round trip. Form A⊤A (or AA⊤ — whichever is smaller).
Use Step 1 on it. Find its eigenvalues λi and its perpendicular eigenvectors. The eigenvectors are the input frame vi.
Get the stretches.σi=λi, sorted biggest first. The λi are never negative, so the square root always works.
Get the output frame for free.ui=σi1Avi: push each input direction through A, then shrink it to length 1.
Assemble.A=UΣV⊤. Pad Σ with zeros so it has exactly the shape of A.
If you want the algebra · why AᵀA hands over V and the σ's, and why the uᵢ come out perpendicular
Why AᵀA hands over V and the σ's — derived
Claim. If A=UΣV⊤ with orthonormal U,V, then A⊤A=V(Σ⊤Σ)V⊤; hence each vi is an eigenvector of A⊤A with eigenvalue σi2≥0.
1
Transpose the factorization:
A⊤=(UΣV⊤)⊤=(V⊤)⊤Σ⊤U⊤=VΣ⊤U⊤The transpose of a product is the product of the transposes in reverse order, and (V⊤)⊤=V.
2
Multiply and let the middle collapse:
A⊤A=VΣ⊤=IU⊤UΣV⊤=V(Σ⊤Σ)V⊤U has orthonormal columns, so U⊤U=I — the same free inverse that made Step 1 cheap.
3
Look at the middle factor. Σ is m×n with σi in slot (i,i), so Σ⊤Σ is n×n and
(Σ⊤Σ)jk=i∑ΣijΣik={σj20j=k≤rotherwiseColumn j of Σ has at most one non-zero entry, σj; two different columns never share a row, so their dot product is 0. Result: Σ⊤Σ=diag(σ12,…,σr2,0,…,0).
4
Step 2 now reads A⊤A=VΛV⊤ with Λ diagonal and V orthonormal — a spectral decomposition. By Section 3, column i of V is an eigenvector:
A⊤Avi=σi2viSo λi(A⊤A)=σi2 and σi=λi. Those eigenvalues can never be negative: λi=vi⊤A⊤Avi=∥Avi∥2≥0. Real, non-negative σ's — for every matrix. ∎
Why uᵢ = Avᵢ/σᵢ come out orthonormal — derived
Claim. Let v1,…,vr be orthonormal eigenvectors of A⊤A with eigenvalues σi2>0, and set ui=Avi/σi. Then ui⋅uj=1 if i=j and 0 otherwise.
1
Write the dot product as a matrix product and move A across:
ui⋅uj=σiσj(Avi)⊤(Avj)=σiσjvi⊤(A⊤Avj)(Avi)⊤=vi⊤A⊤, then regroup the brackets — associativity again.
2
Use the eigen-equation A⊤Avj=σj2vj:
ui⋅uj=σiσjσj2(vi⋅vj)=σiσj(vi⋅vj)The scalar σj2 comes out in front, and one σj cancels against the denominator.
3
The v's are orthonormal, so vi⋅vj is 1 when i=j and 0 otherwise:
ui⋅ui=σiσi⋅1=1,ui⋅uj=σiσj⋅0=0(i=j)Unit length and mutually perpendicular — no Gram–Schmidt, no second eigen-problem. The outputs inherit orthogonality from the inputs through A⊤A. (If r<m, complete U with any orthonormal extra columns; they ride on σ = 0.) ∎
Let's run the recipe on the lecture's wide matrix A=[1−20110]. It is 2×3 (2 rows, 3 columns): it eats 3-D vectors and returns 2-D ones. Its rank is 2, so expect two non-zero σ's and one input direction that gets flattened.
Round trip.A⊤A=5−21−210101 — 3×3 and symmetric, as promised.
Eigenvalues.6,1,0. The 0 is expected: a 2×3 matrix squeezes 3-D into 2-D, so one input direction must be flattened.
Stretches.σ1=6,σ2=1. So Σ=[600100] — 2×3 like A, padded with a zero column.
Input frame.v1=301(5,−2,1), v2=51(0,1,2), v3=61(−1,−2,1). The last one goes with σ=0: it is the direction A flattens to zero.
Output frame, free.u1=61Av1=51(1,−2) and u2=Av2=51(2,1). They come out perpendicular without being asked.
Multiply back and A=UΣV⊤ exactly. The whole job cost one 3×3 eigen-problem and two quick products.
The tall twin: the SVD of a 3×2 matrix — featuring an old friend
B is 3×2, so be smart and take the smaller Gram matrix: B⊤B=[2112] — the very matrix this unit keeps meeting. Its spectral data is familiar by now: λ=3,1 on 21(1,1), 21(1,−1). So σ1=3,σ2=1, v1,2 as above, and u1=31Bv1=61(2,1,1), u2=Bv2=21(0,−1,1). A third vector u3=31(1,−1,−1) completes the 3×3 U but rides on σ3=0: Σ=300010 pads with a zero row, because B 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 (flattened inputs). Σ always has A's shape.
Tall: Σ pads with a zero row. Wide: with a zero column. Count the non-zero σ's and you have read off the rank.
The realization
To find the SVD, take the round trip. The eigenvectors of A⊤A are the input frame V, and σi=λi. The output frame comes free: ui=Avi/σi. Σ always has the same shape as A, padded with zeros.
Pause & predict
A data matrix is 500×4 (500 samples, 4 features) with rank 4. What does its Σ look like?
Pause & predict
You need the SVD of a 1000×3 data matrix. Which round-trip matrix do you break down?
Pause & predict
In the wide example, v3=61(−1,−2,1) goes with σ3=0. What is this direction, in Unit 1's words?
In one sentence: to break down A, break down the symmetric round trip A⊤A instead: V and the σ's fall out, and ui=Avi/σi finishes the job.
9
Seeing a rectangular matrix — 2-D in, 3-D out
Imagine this
Hold a sheet of paper in the air and tilt it. The sheet is flat — it is 2-D. But it sits inside your 3-D room.
Anything drawn on the sheet stays on the sheet. And one direction, straight out of the paper, can never be reached by anything drawn on it.
A tall matrix does exactly this. B=101110 takes a flat 2-D vector and returns a point in 3-D. Feed it the whole unit circle. The output is an oval lying on a tilted sheet inside 3-D space.
The SVD names everything you see. The sheet is spanned by u1 and u2. The oval's long half-axis is σ1u1 with σ1=3≈1.73. Its short half-axis is u2, since σ2=1. The third direction u3 points straight out of the sheet. No input ever lands there — it is the zero row of Σ, made visible.
Drag the probe around the input circle and watch its image travel around the oval:
Two spaces, one matrixB is 3×2 · the input circle lives in 2-D, its image lies on a sheet in 3-D
Try: press "look along the sheet". The oval flattens to a thin line, and u₃ stands straight up out of it.
✋ input space ℝ² — drag the probe
output space ℝ³ — drag to orbit
—
Put the probe on v1 and its image lands on σ1u1, length 3. The grey u3 is the direction no input can ever reach.
The realization
A rectangular matrix maps one world into another. A 3×2 matrix can only fill a flat sheet inside 3-D space. The SVD's u1,u2 span that sheet, and u3 is the direction it can never reach.
In one sentence: a rectangular matrix maps one world into another: its image is a flat slice of the bigger world, and u3 is the direction it can never reach.
10
The layer cake — low-rank approximation, live
Imagine this
Watch an artist paint a face. First come a few big, rough shapes: the head, the hair, the dark side. Then the eyes and the nose. The tiny details come last.
Stop after the first few strokes and you can already tell who it is. The big strokes carry most of the picture.
The SVD paints a matrix the same way. Multiply UΣV⊤ out one column at a time, and it becomes a stack of simple layers — just like the equalizer in Section 4, but now for every matrix:
Each layer σiuivi⊤ is one simple pattern: a column times a row (a "rank-1" matrix). The σ's are sorted, so the layers come biggest first. Real-world matrices keep most of their content in the first few layers.
So keep only the top k layers. The result is the rank-k approximation, written A^(k) (read "A-hat of k"). A famous result, the Eckart–Young theorem, says no other rank-k matrix gets closer to A. And the error is exactly the first layer you dropped: ∥A−A^(k)∥2=σk+1.
A tiny example. Keep only the biggest layer of the tall B from Section 9: B^(1)=3⋅61(2,1,1)⊤⋅21(1,1)=10.50.510.50.5. The error is the dropped σ2=1.
Now scale up. A photo is a matrix: every pixel is one number. Below is a real photograph of a NASA astronaut, 36×36 pixels — 1,296 numbers. Watch her face appear, biggest layer first:
The image squeezera picture is a matrix · keep k layers · watch it come back
Try: slide k from 1 to 8. Watch the third panel: each new layer adds one stripe pattern.
drag the relief to orbit
storage —energy —error σ₍k₊₁₎ = —
—
Watch out — the noise lesson
Switch the widget to pure noise and slide k. The picture barely improves. Noise spreads itself evenly over all the layers, so there are no quiet layers to drop for free.
Turn that around and you get a superpower. Real content lives in the big early layers. Noise lives in the faint tail. So cutting the tail removes noise. Structure squeezes well; noise does not.
Pause & predict
You keep k=3 layers of a matrix whose singular values are 9,4,2,0.5,0.1. What is ∥A−A^(3)∥2?
Pause & predict
A 1000×1000 image is stored as 50 layers. Roughly what fraction of the original million numbers is that?
If you want the algebra · why the error is exactly σk+1
Why the truncation error is exactly σk+1 — derived
Claim. With A^(k)=∑i≤kσiuivi⊤, the leftover A−A^(k) has spectral norm σk+1. (That no other rank-k matrix beats this is the Eckart–Young theorem; here we derive the size of the error you actually make.)
1
Subtract the kept layers from the full stack:
A−A^(k)=i=1∑rσiuivi⊤−i=1∑kσiuivi⊤=i=k+1∑rσiuivi⊤The first k terms cancel exactly; what remains is the tail of the layer cake, loudest-dropped layer first.
2
Read the tail as its own SVD. Let Σ′ be Σ with σ1,…,σk replaced by 0. Then
A−A^(k)=UΣ′V⊤Multiply UΣ′V⊤ out column-times-row (Section 4's derivation, same steps): the zeroed slots contribute nothing, and the surviving terms are exactly the tail in step 1. U and V are still orthonormal, so this is a genuine SVD of the leftover, with singular values σk+1≥σk+2≥⋯.
3
Apply the spectral-norm rule (derived in Section 11): a matrix's ∥⋅∥2 is its largest singular value. The largest entry of Σ′ is σk+1, so
∥A−A^(k)∥2=σk+1Check it in the widget: the "error" chip is always the first grey bar. And the direction that suffers most is vk+1: (A−A^(k))vk+1=σk+1uk+1, while every kept direction v1,…,vk is reproduced perfectly. The error is the loudest thing you threw away. ∎
One more disguise, because this is where the SVD earns its keep in machine learning. A matrix does not have to be a picture. A table is a matrix too. Below: six friends, five films, thirty star ratings. It looks like thirty separate opinions. It is not:
The taste machinethirty ratings, only two patterns — how a recommender sees a table
Try: press "hide 5 ratings". Guess them from the two taste patterns, then let the patterns fill them in.
—
Each pattern is a column of person-numbers times a row of film-numbers — one layer, like the photo's. Two layers rebuild all thirty ratings.
The realization
Sort the layers biggest first and keep the top k: A^(k)=∑i≤kσiuivi⊤. No rank-k matrix does better, and the error is σk+1. Each layer costs only m+n+1 numbers — so this is compression, for photos and for tables of ratings alike.
Pause & predict
A streaming app has a million users and 10,000 films — ten billion possible ratings, almost all missing. Why does the layer idea rescue it?
In one sentence: sort the layers biggest first and keep the top few — the best possible summary of any matrix, whether it is a photograph or a table of tastes.
11
The spectral norm — and the family portrait
Imagine this
Speak into a megaphone. Point it straight at the crowd and your voice is at its loudest. Point it a little off, and it gets quieter.
Every megaphone has one direction of biggest boost. Every matrix has one too.
What is the most a matrix can ever stretch a vector? That biggest boost is called the spectral norm, written ∥A∥2. The SVD answers it at once: it is the longest half-axis of the output oval.
∥A∥2=x=0max∥x∥∥Ax∥=σ1
Read it: "try every input direction, measure how much it grows, take the biggest — that is σ1." The winning input is v1.
The lecture's example: A=[1324] has σ1≈5.465 and σ2≈0.366. So its biggest boost is ×5.465, and its smallest is ×0.366. The ratio σ1/σ2≈14.9 is called the condition number. A big condition number means trouble — you will see why in a moment.
Hunt for the loudest direction yourself:
The amplifier dial‖Ax‖ for every input direction · the loudest one is the spectral norm
Try: turn the dial until the verdict says "peak found". Then pick nearly singular and find the quietest direction.
✋ drag the gold x to aim the input · drag empty space to orbit
‖A‖₂ = σ₁ = —σ₂ = —σ₁/σ₂ = —
—
The orange curve shows the boost in every direction at once. Its farthest reach is σ1; its nearest is σ2.
Why a big ratio is trouble. Solving Ax=b means undoing A. Undoing a stretch means dividing by it. Along u2 you divide by the tiny σ2=0.366, so any small error in b grows about 2.7 times. Along u1 you divide by 5.465, so errors shrink. A round blob of noise becomes a long needle:
A=[1324], σ1=5.465,σ2=0.366. Solving divides each output component by its σ, so noise along u2 is amplified by 1/σ2≈2.7 while noise along u1 is damped by 1/σ1≈0.18.
A matrix with a huge σ1/σ2 is called ill-conditioned, and numerical software fears it. The same number decides whether signals in a deep network blow up or fade away — and it gives "spectral normalization" its name.
If you want the algebra · why the biggest boost is exactly σ₁
Why the worst-case stretch is exactly σ₁ — derived
Claim. For every x, ∥Ax∥≤σ1∥x∥, with equality at x=v1. Hence ∥A∥2=σ1.
1
Rename the input in the V frame: y=V⊤x. Its length is unchanged:
∥y∥2=x⊤VV⊤x=x⊤x=∥x∥2V is square with orthonormal columns, so VV⊤=I — a rotation never changes length.
2
Apply A and drop the outer rotation:
∥Ax∥2=∥UΣy∥2=(Σy)⊤U⊤U(Σy)=∥Σy∥2Ax=UΣV⊤x=UΣy, and U⊤U=I removes U. Only the stretch step can change length.
3
A diagonal stretch is easy to bound:
∥Σy∥2=i∑σi2yi2≤σ12i∑yi2=σ12∥y∥2=σ12∥x∥2Each σi≤σ1 because the σ's are sorted, and yi2≥0, so replacing every σi by σ1 can only increase the sum. Step 1 turns ∥y∥ back into ∥x∥.
4
The bound is reached. Take x=v1: then y=V⊤v1=e1 and
∥Av1∥2=σ12⋅12=σ12So the maximum of ∥Ax∥/∥x∥ is at most σ1 (step 3) and at least σ1 (this step): it equals σ1. The same argument with ≥σr gives the quietest response, σr — the valley in the widget. The spectral norm is the top singular value. ∎
And the family portrait — the whole ladder in one table:
Eigen / Spectral
SVD
Formula
A=PDP−1 (or QΛQ⊤)
A=UΣV⊤
Works on
square matrices with enough eigenvectors
every matrix, any shape
Frames
one set of axes, shared by input and output
two: V for input, U for output
At right angles?
P: usually not (Q: yes)
U and V: always
The stretches
eigenvalues — can be negative or imaginary
singular values — always real, ≥0, sorted
The link
V = eigenvectors of A⊤A · U = eigenvectors of AA⊤ · σi=λi(A⊤A)
The realization
σ1 is the biggest boost a matrix can give: ∥A∥2=σ1. The ratio σ1/σ2 says how uneven the boosts are. When it is huge, undoing the matrix blows up tiny errors.
Pause & predict
On nearly singular, the orange curve is long one way and pinched almost to zero the other. What does that mean for solving Ax=b?
Pause & predict
For A=[1324], which number is ∥A∥2?
In one sentence:σ1 is the loudest a matrix can ever be, and σ1/σ2 says how uneven its boosts are.
12
The whole story, in five lines
Imagine this
Back to the photo editor one last time. Rotate, resize, rotate. With just those two tools you can now rebuild any matrix — and you know how to find the three taps.
A matrix moves space. A decomposition rewrites it as simple moves — turn, resize, turn — without changing what it does.
The goal is always a diagonal middle, a resize tool, because it turns every question into arithmetic on separate numbers.
Spectral, A=QΛQ⊤, is for symmetric matrices: perpendicular directions, a free inverse, and the equalizer view A=∑λiqiqi⊤. Eigen, A=PDP−1, keeps the idea on leaning directions and pays with a real inverse — earning Ak=PDkP−1.
The SVD, A=UΣV⊤, works for every matrix. It uses two perpendicular frames, found through the round trip A⊤A, with ui=Avi/σi for free.
Sorted biggest first, the σ's turn any matrix into a stack of layers. Keep the top few for the best compression (Eckart–Young). Read σ1 as the biggest boost (the spectral norm).
The realization
Every matrix is turn · resize · turn. Sort the stretches biggest first and keep the top few, and you have the best short summary a matrix can have. Photo compression, noise removal, PCA and recommenders are all that one move.
In one sentence: find the two frames and the sorted stretches, and any matrix becomes simple enough to read, repeat, undo and compress.
13
Practice arena — the unit's problem set, solved in full
These twelve problems come from the unit's problem set. That set covers this unit and Unit 4, so the pure eigenvalue problems live in Unit 4's arena. Try each one on paper first. Then open the solution — every step is shown.
Problem 1Easy
For each matrix, state the eigenvalue(s), their algebraic multiplicity am and geometric multiplicity gm, and decide whether the matrix is diagonalizable:
A=[3013],B=[3003],C=300130013.
What this tests. Reading off am and gm quickly, and using them to decide diagonalizability.
Show the worked solution — every step
Step 1 · Matrix A. Triangular, so the only eigenvalue is λ=3 with am=2. For the geometric multiplicity, gm=2−rank(A−3I)=2−rank[0010]=2−1=1. Since gm=1<2=am, A is not diagonalizable.
Step 2 · Matrix B.B=3I: eigenvalue λ=3 with am=2, and B−3I=0 has rank 0, so gm=2−0=2. Here gm=am, so B is diagonalizable (it is already diagonal).
Step 3 · Matrix C. Triangular, eigenvalue λ=3 with am=3. Now
C−3I=000100010
has rank 2 (two independent nonzero rows), so gm=3−2=1<3. Not diagonalizable — a single 3×3 Jordan block.
Answer. A: λ=3, am=2, gm=1 — not diagonalizable. B: λ=3, am=gm=2 — diagonalizable. C: λ=3, am=3, gm=1 — not diagonalizable.
Watch out
am counts how often λ is a root of det(A−λI); gm counts independent eigenvectors, and the reliable formula is gm(λ)=n−rank(A−λI). Never assume they match — compute the rank.
Key takeaway
Same eigenvalue, same am — but the number of independent eigenvectors (gm) is what decides diagonalizability: A is diagonalizable ⟺gm(λ)=am(λ) for every eigenvalue.
Wait — really?
A and B have the identical characteristic polynomial (λ−3)2, yet opposite verdicts. The characteristic polynomial alone can never tell you whether a matrix diagonalizes — that information lives in the eigenspaces, not in the spectrum.
Problem 2Medium
Let a,b,c∈R with b=0 and consider the upper-triangular matrix
A=[a0bc].
(a) Find the eigenvalues and an eigenvector for each (in terms of a,b,c). (b) State, with justification, exactly when A is diagonalizable.
What this tests. Running the whole eigen-and-diagonalizability pipeline in symbols, and locating the exact parameter condition where it breaks.
Show the worked solution — every step
Part (a) · Eigenvalues. For a triangular matrix the eigenvalues are the diagonal entries: λ1=a, λ2=c.
Part (a) · Eigenvector for λ1=a.A−aI=[00bc−a].
The equations are by=0 and (c−a)y=0; since b=0 we get y=0 with x free, so v1=(1,0)⊤.
Part (a) · Eigenvector for λ2=c (assume c=a).A−cI=[a−c0b0]
gives (a−c)x+by=0⇒x=−a−cby. Taking y=a−c clears the fraction: v2=(−b,a−c)⊤. (Check: Av2=(−ab+b(a−c),c(a−c))⊤=(−bc,c(a−c))⊤=cv2. ✓)
Part (b) · When is A diagonalizable?Case a=c: two distinct eigenvalues ⇒ two independent eigenvectors ⇒ diagonalizable.
Case a=c: then λ=a has am=2, but A−aI=[00b0] has rank 1 (because b=0), so the eigenspace is only 1-dimensional: gm=1<2⇒ not diagonalizable (defective).
Answer. λ1=a with v1=(1,0)⊤; λ2=c with v2=(−b,a−c)⊤. A is diagonalizable ⟺a=c (when a=c and b=0 it is defective).
Watch out
The hypothesis b=0 is what kills the a=c case — if b=0 the matrix would already be diagonal. And avoid dividing by a−c blindly: scaling the eigenvector by y=a−c sidesteps the fraction and stays valid right up to the boundary.
Key takeaway
Distinct eigenvalues ⇒ diagonalizable, no further checks. A repeated eigenvalue forces you to compute rank(A−λI) before you may conclude anything.
Wait — really?
Diagonalizability here fails only on the razor-thin set a=c: nudge a by any ε=0 and the matrix instantly diagonalizes again. Defective matrices live on a knife-edge — which is exactly why numerical libraries treat "nearly repeated" eigenvalues with such care.
Problem 3Easy
Decide whether
A=200120003
is diagonalizable. Justify using eigenvalues, algebraic and geometric multiplicities.
What this tests. The multiplicity test on a 3×3: spotting a defective eigenvalue hidden in a triangular matrix.
Show the worked solution — every step
Step 1 · Eigenvalues.A is upper-triangular, so the eigenvalues are the diagonal entries: λ=2 (algebraic multiplicity 2) and λ=3 (algebraic multiplicity 1).
Step 2 · Eigenspace of the repeated eigenvalue.A−2I=000100001.
This has rank 2, so its null space has dimension 3−2=1: the equations force y=0 and z=0 with x free, i.e. eigenspace span{(1,0,0)⊤}. Geometric multiplicity 1.
Step 3 · Compare. For λ=2 the geometric multiplicity (1) is less than the algebraic multiplicity (2). Only two independent eigenvectors exist in total — not enough for a basis of R3, so A cannot be diagonalized.
Answer. A is not diagonalizable: for λ=2, geometric multiplicity 1< algebraic multiplicity 2 (only one independent eigenvector, (1,0,0)⊤). The block [2012] is a defective Jordan block.
Watch out
It is not the repeated eigenvalue itself that blocks diagonalization — it is the missing second eigenvector. Compute rank(A−2I); do not guess from the diagonal.
Key takeaway
One defective eigenvalue sinks the whole matrix: if any λ has gm<am, no eigenbasis exists and no invertible P can ever diagonalize A.
Wait — really?
The eigenvalue 3 is perfectly healthy, and A is just one entry away from diagonal — yet the tiny 2×2 shear block [2012] tucked in the corner is enough to make the entire 3×3 matrix undiagonalizable.
Problem 4Medium
Find an eigendecomposition A=PDP−1 of the non-symmetric matrix
A=[52−12],
giving P,D,P−1 explicitly, and verify the factorization.
What this tests. Building P and D for a non-symmetric matrix — where P−1 must be computed, not transposed — and verifying the product.
Show the worked solution — every step
Step 1 · Eigenvalues.det(A−λI)=(5−λ)(2−λ)+2=λ2−7λ+12=(λ−3)(λ−4)=0,
so λ1=3, λ2=4.
Step 2 · Eigenvectors.λ1=3: A−3I=[22−1−1]⇒2x=y, so p1=(1,2)⊤.
λ2=4: A−4I=[12−1−2]⇒x=y, so p2=(1,1)⊤.
Step 3 · Assemble P, D, and invert P.P=[1211],D=[3004],detP=1⋅1−1⋅2=−1,P−1=−11[1−2−11]=[−121−1].
Step 4 · Verify, entry by entry. First PD=[1⋅32⋅31⋅41⋅4]=[3644]. Then
PDP−1=[3644][−121−1]=[3(−1)+4(2)6(−1)+4(2)3(1)+4(−1)6(1)+4(−1)]=[52−12]=A.✓
Answer. A=PDP−1 with P=[1211], D=[3004], P−1=[−121−1].
Watch out
Column order must match: p1 under λ1, p2 under λ2 — swap one and not the other, and the "decomposition" silently produces a different matrix. And since A is not symmetric, P−1=P⊤: the eigenvectors (1,2)⊤,(1,1)⊤ are not orthogonal, so the inverse must be computed the usual way.
Key takeaway
The PDP−1 recipe: eigenvalues → eigenvectors → stack into P, D→ invert P→ multiply back and check. The verification costs two small multiplications and catches nearly every bookkeeping error.
Wait — really?
A non-symmetric matrix can still diagonalize perfectly — but on a slanted basis. A acts as pure stretching (by 3 and by 4) along the directions (1,2) and (1,1), axes that are not perpendicular. Orthogonal eigenvectors are a luxury reserved for symmetric matrices.
Problem 5Medium
Using diagonalization, derive a closed form for An and evaluate A4, where
A=[2−1−12].
What this tests. The workhorse pattern An=PDnP⊤: diagonalize once, then raise only the diagonal.
Show the worked solution — every step
Step 1 · Diagonalize (orthogonally).det(A−λI)=(2−λ)2−1=(λ−1)(λ−3)=0⇒λ1=1,λ2=3. Eigenvectors: for λ=1, Av=(2x−y,−x+2y)⊤=v forces x=y; for λ=3, x=−y. Orthonormal eigenvectors 21(1,1)⊤ and 21(1,−1)⊤ give
P=21[111−1],D=[1003],A=PDP⊤.
Step 2 · Power formula. Since A=PDP⊤ with P orthogonal, An=PDnP⊤, and only the diagonal is raised:
An=21[111−1][1003n][111−1]=21[1+3n1−3n1−3n1+3n].
(Middle step: PDn=21[113n−3n], then multiply by P⊤: the (1,1) entry is 21(1+3n), the (1,2) entry 21(1−3n), and symmetrically below.)
Step 3 · Evaluate n=4.34=81, so
A4=21[1+811−811−811+81]=21[82−80−8082]=[41−40−4041].
Answer. An=21[1+3n1−3n1−3n1+3n], and A4=[41−40−4041].
Watch out
Only D gets raised to the n: P and P⊤ appear once each, at the ends. And 1n stays 1 — a surprisingly common slip is powering only the larger eigenvalue.
Key takeaway
An=PDnP⊤ turns n−1 matrix multiplications into n-th powers of two scalars. Diagonalize once; reuse forever.
Wait — really?
The closed form works for everyn simultaneously — n=0 gives I, n=1 gives A back, and since no eigenvalue is zero, n=−1 even produces A−1. One formula quietly encodes the entire orbit of A.
Problem 6Hard
Find a full singular value decomposition A=UΣV⊤ of
A=110101,
including the third column of U obtained by orthogonal completion.
What this tests. The full SVD pipeline — A⊤A, singular values, ui=σi1Avi — plus completing U to a genuine 3×3 orthogonal matrix.
Show the worked solution — every step
Step 1 · A⊤A, singular values, right singular vectors.A⊤A=[111001]110101=[2112]
(entries: (1,1):12+12+02=2; (1,2):1⋅1+1⋅0+0⋅1=1; (2,2):1+0+1=2). Eigenvalues: det[2−λ112−λ]=(2−λ)2−1=0⇒λ=3,1. Thus σ1=3, σ2=1, with
v1=21(1,1)⊤(λ=3),v2=21(1,−1)⊤(λ=1).
Step 2 · Left singular vectors ui=σi1Avi. Entry by entry, Av1=21(1+1,1+0,0+1)⊤=21(2,1,1)⊤, so
u1=31⋅21211=61211;u2=11⋅211−11−00−1=2101−1.
Step 3 · Orthogonal completion u3. We need a unit vector with u3⊥u1 and u3⊥u2. Writing u3=(p,q,r)⊤: from u2, q−r=0⇒q=r; from u1, 2p+q+r=0⇒2p+2q=0⇒p=−q. Normalising: u3=31(−1,1,1)⊤.
Step 4 · Assemble.U=2/61/61/601/2−1/2−1/31/31/3,Σ=300010,V⊤=21[111−1].Σ has the same 3×2 shape as A; its zero third row is what u3 multiplies.
Σ must have the shape of A (3×2) — forgetting the zero row makes UΣV⊤ undefined. Keep the normalisations straight: u1 picks up 31⋅21=61, not 31.
Key takeaway
Full-SVD recipe: eigen-decompose A⊤A for V and the σi=λi, push through ui=σi1Avi, then complete U to an orthonormal basis of the output space.
Wait — really?
The completed column u3=31(−1,1,1)⊤ satisfies A⊤u3=0: it spans the part of R3 that A's columns can never reach. The "filler" column is actually a precise description of what the matrix cannot do.
Problem 7Hard
Find the SVD of
A=[101101].
(Hint: it is quicker to get U and the singular values from the 2×2 matrix AA⊤, then recover V from vi=σi1A⊤ui; the missing right vector spans ker(A⊤A).)
What this tests. Choosing the smaller Gram matrix (AA⊤ instead of a 3×3A⊤A with a zero eigenvalue), and fetching the last right vector from the null space.
Show the worked solution — every step
Step 1 · AA⊤, singular values, left singular vectors.AA⊤=[101101]110011=[2112]
(entries: row 1 · row 1 =1+1+0=2; row 1 · row 2 =0+1+0=1; row 2 · row 2 =0+1+1=2). Its eigenvalues are λ=3,1, so σ1=3, σ2=1, with
u1=21(1,1)⊤(λ=3),u2=21(1,−1)⊤(λ=1).
Step 2 · Right singular vectors vi=σi1A⊤ui. With A⊤=110011: entry by entry, A⊤u1=21(1,1+1,1)⊤=21(1,2,1)⊤, so
v1=31⋅21121=61121;v2=11⋅2111−1−1=2110−1.
Step 3 · Third right vector from the null space.A is 2×3, so V needs a third column v3 with singular value 0, spanning ker(A) (equivalently kerA⊤A). Solving Av=0: x+y=0 and y+z=0 give y=−x,z=x, so v3=31(1,−1,1)⊤.
Step 4 · Assemble.U=21[111−1],Σ=[300100],V=1/62/61/61/20−1/21/3−1/31/3.
The single zero column of Σ reflects that A has rank 2 but 3 columns.
v3 cannot come from v3=σ31A⊤u3 — that would divide by σ3=0. Vectors paired with zero singular values must be fetched from the null space directly.
Key takeaway
Always eigen-decompose the smaller of A⊤A and AA⊤ — they share their nonzero eigenvalues — then transfer across with σi1Avi or σi1A⊤ui. For a wide matrix, that is AA⊤.
Wait — really?
An entire line of inputs — every multiple of (1,−1,1)⊤ — is crushed to zero: check Av3=(1−1+0,0−1+1)⊤=0. "Rank 2 out of 3 columns" is not an abstraction; it is a concrete direction the matrix simply deletes.
Problem 8Hard
(a) Find the SVD of A=[1−11−1]. (b) Show that A is not diagonalizable, yet its SVD still exists, and explain why.
What this tests. A rank-deficient SVD (zero singular value), and the sharp contrast between diagonalizability and the always-available SVD.
Show the worked solution — every step
Part (a), Step 1 · Singular values.A⊤A=[11−1−1][1−11−1]=[2222]
(entries: (1,1):12+(−1)2=2; (1,2):1⋅1+(−1)(−1)=2; (2,2):1+1=2). Eigenvalues: (2−λ)2−4=0⇒λ=4,0, so σ1=2,σ2=0. The single nonzero singular value shows rankA=1.
Part (a), Step 2 · Right and left vectors. Eigenvectors of A⊤A: v1=21(1,1)⊤ (for 4), v2=21(1,−1)⊤ (for 0). Then
u1=σ11Av1=21⋅21[2−2]=21[1−1],u2⊥u1:u2=21[11].U=21[1−111],Σ=[2000],V=21[111−1].
Part (b) · Not diagonalizable, but the SVD exists. The eigenvalues of A itself satisfy det(A−λI)=(1−λ)(−1−λ)+1=λ2=0, so λ=0 has algebraic multiplicity 2 — while Av=0 has the single solution direction (1,−1)⊤, geometric multiplicity 1. Since 1<2, A has no eigenbasis and is not diagonalizable. Nevertheless the SVD is built from the symmetric matrices A⊤A and AA⊤, which are always orthogonally diagonalizable — this is exactly why an SVD exists for every matrix, diagonalizable or not.
Answer. σ1=2, σ2=0; U=21[1−111], Σ=[2000], V=21[111−1]. A is not diagonalizable (λ=0: algebraic multiplicity 2, geometric multiplicity 1).
Watch out
Do not read rank off the eigenvalues: here both eigenvalues are 0, yet A=0 and rankA=1. It is the count of nonzero singular values that equals the rank — eigenvalues of a non-symmetric matrix can lie about size and rank.
Key takeaway
Diagonalization can fail (defective matrices); the SVD cannot. It inherits its existence from the spectral theorem applied to A⊤A and AA⊤, which are symmetric no matter what A is.
Wait — really?
A matrix with no eigen-decomposition has a perfectly clean SVD. The trick is freedom: diagonalization must use one basis for input and output, while the SVD is allowed two different orthonormal frames (U=V) — and that extra freedom never runs out.
Problem 9Medium
For A=[2−121], find the singular values and the best rank-1 approximation A1=σ1u1v1⊤.
What this tests. Extracting σ1u1v1⊤ from a computed SVD and knowing (Eckart–Young) that it is the closest rank-1 matrix.
Show the worked solution — every step
Step 1 · Singular values and top right vector.A⊤A=[22−11][2−121]=[5335]
(entries: (1,1):4+1=5; (1,2):4−1=3; (2,2):4+1=5). Then det[5−λ335−λ]=(5−λ)2−9=(λ−8)(λ−2)=0, so
σ1=8=22,σ2=2,v1=21(1,1)⊤(for λ=8).
Step 2 · Top left vector.u1=σ11Av1=221⋅21[2+2−1+1]=41[40]=[10].
Step 3 · Rank-1 approximation.A1=σ1u1v1⊤=22[10]⋅21[11]=2[1010]=[2020].
By the Eckart–Young theorem this is the closest rank-1 matrix to A; the discarded part corresponds to the dropped singular value σ2=2, and indeed ∥A−A1∥2=σ2=2.
Answer. σ1=22, σ2=2; A1=σ1u1v1⊤=[2020] with u1=(1,0)⊤, v1=21(1,1)⊤.
Watch out
A1 needs all three ingredients — σ1 out front and unit vectors u1,v1. Forgetting a normalisation rescales the whole approximation and silently breaks Eckart–Young optimality.
Key takeaway
Truncating the SVD after k terms gives the best rank-k approximation, and the error is exactly the first dropped singular value: ∥A−Ak∥2=σk+1.
Wait — really?
The best rank-1 stand-in keeps the top row (2,2)exactly and zeroes the bottom row — the SVD judged the row of size 22 worth keeping and the orthogonal remainder of size 2 expendable. Approximation by importance, not by position.
(a) Reconstruct A=σ1u1v1⊤+σ2u2v2⊤. (b) Write down the best rank-1 approximation and the relative weight it keeps.
What this tests. Reading the SVD as A=∑iσiuivi⊤ — a weighted stack of rank-1 layers — and measuring a truncation's kept energy.
Show the worked solution — every step
Part (a) · Two rank-1 layers.σ1u1v1⊤=3⋅21[11]⋅21[11]=23[1111],σ2u2v2⊤=21[1−1−11].
Adding, entry by entry: (1,1):23+21=2; (1,2):23−21=1; (2,1):1; (2,2):2:
A=21[3333]+21[1−1−11]=[2112].
Part (b) · Best rank-1 approximation and its weight. Keep the largest singular value only:
A1=σ1u1v1⊤=23[1111].
This is the rank-k truncation A^(k)=∑i=1kσiuivi⊤ with k=1. The energy kept is
σ12+σ22σ12=109=90%.
Answer. A=[2112]; best rank-1 approximation A1=23[1111], keeping σ12/(σ12+σ22)=90% of the energy.
Watch out
Energy is measured in σ2, not σ: the weights here are 9:1, not 3:1. Squaring is what makes truncation so effective — and forgetting it understates how much the top layer carries.
Key takeaway
The SVD writes any matrix as a sum of rank-1 layers σiuivi⊤, sorted by importance. Compression = keep the top k layers, drop the rest.
Wait — really?
Half the singular values carry 90% of the energy. This uneven split is the entire business model of image compression and PCA: real-world matrices almost always hide a steep σ-decay, and the squares make it steeper.
Problem 11Medium
Compute the spectral norm ∥A∥2 of
A=[4035],
and state the corresponding right singular vector.
What this tests. The definition ∥A∥2=σmax=λmax(A⊤A) — the largest stretch factor of the matrix.
Show the worked solution — every step
Step 1 · Form A⊤A.A⊤A=[4305][4035]=[16121234]
(entries: (1,1):16+0=16; (1,2):4⋅3+0⋅5=12; (2,2):9+25=34).
Step 2 · Largest eigenvalue of A⊤A. Trace =50 and determinant =16⋅34−122=544−144=400, so det(A⊤A−λI)=λ2−50λ+400=0 and
λ=250±2500−1600=250±30=40or10.
Hence σmax=40=210 and σmin=10.
Step 3 · Right singular vector for σmax.(A⊤A−40I)v=[−241212−6]v=0⇒2x=y,
so v1=51(1,2)⊤, and
∥A∥2=210≈6.32.
(Consistency check: σ1σ2=4010=400=20=∣detA∣. ✓)
Answer. ∥A∥2=σmax=210≈6.32, attained along v1=51(1,2)⊤ (the other singular value is 10).
Watch out
Do not take the largest ∣eigenvalue of A∣ — that would give 5 here, and it is wrong. The spectral norm always comes from A⊤A: ∥A∥2=λmax(A⊤A). Eigenvalues equal singular values only for symmetric matrices (up to sign).
Key takeaway
∥A∥2=σmax is the largest factor by which A can stretch any vector, and the top right singular vector is the direction that achieves it.
Wait — really?
A's eigenvalues are 4 and 5, yet A stretches the direction (1,2)/5 by 210≈6.32 — more than any eigenvalue suggests. Non-symmetric matrices can out-stretch their own spectrum; that hidden extra gain is exactly what the spectral norm measures.
Problem 12Hard
Capstone. For A=[1221]: (a) find its eigendecomposition (note the negative eigenvalue); (b) find its SVD; (c) explain precisely how the two are related.
What this tests. How the eigendecomposition and the SVD of one symmetric matrix line up — and exactly where a negative eigenvalue forces them apart.
Show the worked solution — every step
Part (a) · Eigendecomposition.det(A−λI)=(1−λ)2−4=(λ−3)(λ+1)=0⇒λ1=3,λ2=−1. Orthonormal eigenvectors q1=21(1,1)⊤ (for 3) and q2=21(1,−1)⊤ (for −1). With Q=21[111−1],
A=Q[300−1]Q⊤.
Part (b) · SVD.A⊤A=A2=[5445] has eigenvalues 9 and 1, so σ1=3,σ2=1 — note σi=∣λi∣. The right singular vectors are the same eigenvectors v1=21(1,1)⊤, v2=21(1,−1)⊤, and
u1=31Av1=21[11]=v1,u2=11Av2=21[−11]=−v2.U=21[11−11],Σ=[3001],V=21[111−1].
Part (c) · The relationship. For a symmetric matrix the singular values are the absolute values of the eigenvalues, σi=∣λi∣, and the right singular vectors are the eigenvectors. Where an eigenvalue is positive, ui=vi; where it is negative (here λ2=−1), the minus sign is absorbed into the left vector, ui=−vi. Thus EVD and SVD coincide exactly when every eigenvalue is non-negative (a positive-semidefinite matrix); otherwise they differ only by these sign flips between U and V.
Answer. EVD: A=Qdiag(3,−1)Q⊤ with Q=21[111−1]. SVD: Σ=diag(3,1)=diag(∣λi∣), V=Q, U=21[11−11] (the negative eigenvalue flips the sign of u2 relative to v2).
Watch out
σi=∣λi∣ holds only for symmetric matrices — Problem 11 just showed a triangular matrix where no singular value matches any eigenvalue. And even here, symmetric or not, U=V: the sign bookkeeping is part of the decomposition.
Key takeaway
Symmetric A: singular values =∣eigenvalues∣, V= eigenvectors, and EVD = SVD precisely when A is positive semidefinite. The SVD is the eigendecomposition with all stretches forced non-negative.
Wait — really?
Compare D=diag(3,−1) with Σ=diag(3,1): the SVD refuses negative stretches. It rewrites "stretch by −1" as "stretch by 1, then flip", and hides the flip inside U. Same matrix, same action — two bookkeeping conventions for a reflection.
Part I is complete: you can move, measure, and decompose space. Part II asks how things change. Unit 6 builds the derivative from a shrinking secant up to the Jacobian matrices behind backpropagation — and answers the question every model is really asking: which way is down?