Part I. Highlights of Linear Algebra
Singular Values and Singular Vectors in the SVD
The centre of the book. Every matrix (any shape, any rank) factors into a rotation, a stretch, and another rotation. This is the section to slow down on.
The one idea
Eigenvalues are wonderful and they have a fatal limitation: they only exist for square matrices, and even then a matrix may not have a full set of independent eigenvectors. Data matrices are rectangular. You need something better.
The singular value decomposition works for every matrix:
A = UΣVᵀ
with U and V orthogonal and Σ diagonal with non-negative entries
σ₁ ≥ σ₂ ≥ ⋯ ≥ 0.
Geometrically A does exactly three things, in order: rotate (Vᵀ), stretch
each axis independently (Σ), rotate again (U). That is all any linear map
ever does. A sphere goes to an ellipsoid, always. The singular values are the
lengths of its semi-axes.
In the rank-one form from I.2:
A = σ₁u₁v₁ᵀ + σ₂u₂v₂ᵀ + ⋯ + σᵣuᵣvᵣᵀ
with r = rank(A) terms, ordered from most to least important.
Where the pieces come from
The defining relation is Avᵢ = σᵢuᵢ. The vᵢ are an orthonormal basis of the
input space; A sends each to a scaled member of an orthonormal basis of the
output space. Finding two bases that make A diagonal between them is the
trick that eigenvectors, using one basis for both, cannot always pull off.
Concretely:
Vand theσᵢ²come from the eigenvectors and eigenvalues ofAᵀAUand the sameσᵢ²come fromAAᵀ- both are symmetric positive semidefinite, so by I.7 they have real non-negative eigenvalues and orthonormal eigenvectors, which is exactly why the SVD always exists
That last point is the payoff for Part I’s ordering. I.7 was not a detour; it is what guarantees this section works.
Why it matters later
Almost everything downstream is the SVD wearing a different hat:
- I.9: the top
kterms give the best rank-kapproximation (PCA). - II.2: least squares and the pseudoinverse are the SVD with the zero singular values handled carefully.
- II.3, III.3: how fast
σᵢdecays decides whether a matrix compresses well. Fast decay is why images and covariance matrices are so compressible. - VI, VII: the condition number
σ₁/σᵣgoverns whether optimization on a problem is well-behaved or crawls.
What to actually do
- Take
A = [[3, 0], [4, 5]]. FormAᵀA, find its eigenvalues, take square roots. Those areσ₁, σ₂. Do it by hand once: the arithmetic is small and the process is what you are learning. - In numpy:
U, s, Vt = np.linalg.svd(A). CheckU @ np.diag(s) @ VtreturnsA. ConfirmU.T @ Uis the identity. - Rebuild
Afroms[0] * np.outer(U[:,0], Vt[0,:])alone. Compare to the original. How much of the matrix did one rank-one layer already capture? - Load any grayscale image as a matrix and repeat step 3 with the top 5, 20, and 50 layers. This makes low-rank approximation something you have seen rather than something you have been told.
Check yourself
- Why does every matrix have an SVD when not every matrix has an eigendecomposition?
- What do the singular values of an orthogonal matrix look like, and why?
- How do you read
rank(A)offΣ? - If you multiply
Aby 3, what happens toU,Σ, andVindividually?
Common sticking points
Confusing singular values with eigenvalues. For a symmetric positive
definite matrix they coincide. In general they do not. Singular values are
always real and non-negative, eigenvalues can be negative or complex. σᵢ are
the square roots of the eigenvalues of AᵀA, which is a different matrix from
A.
Sign and ordering ambiguity. You can flip the sign of uᵢ and vᵢ
together and nothing changes. Your answer disagreeing with the textbook’s by a
sign is usually not an error. Equal singular values leave even more freedom.
Treating Σ as square. For an m×n matrix, Σ is m×n with zeros
padding it out. Libraries return the “economy” version by default, which is why
np.linalg.svd gives you a 1-D array of singular values instead of a matrix, so
you have to build Σ yourself, and getting its shape wrong is the most common
reason a reconstruction fails.
There is no free section PDF for I.8, but lecture 6 covers it directly and is one of the clearest hours in the course. Watch it before reading, not after.