Eigen-things, SVD and low rank
The directions a matrix keeps, and the few that matter
Eigenvectors are the directions a transformation only stretches, and singular values are the stretch factors of any matrix at all. They explain why gradients vanish or explode through deep networks (6.4 Recurrent neural networks and BPTT), why gradient descent zigzags in narrow valleys (1.10 Optimization: from gradient descent to Adam), what PCA computes (3.12 Dimensionality reduction: PCA, t-SNE and UMAP), why a Gaussian's covariance is an ellipse (1.7 Probability II: Bayes, independence, MLE and MAP), and why LoRA can fine-tune a billion-parameter model by learning a rank-8 update (8.2 Fine-tuning and PEFT). Low rank is the single most reused idea in modern ML engineering.
You'll be able to
- Compute eigenvalues and eigenvectors of a 2×2 matrix by hand and interpret them geometrically
- Use diagonalization to reason about repeated multiplication, power iteration and vanishing/exploding gradients
- State the spectral theorem for symmetric matrices and connect PSD matrices to quadratic forms, covariances and Hessians
- Explain the SVD as rotate–stretch–rotate, compute it for a small matrix, and use Eckart–Young to justify low-rank approximation
Key ideas
- Av = λv: eigenvectors are directions that are only scaled; find λ from det(A − λI) = 0, then solve (A − λI)v = 0.
- Diagonalization A = VΛV⁻¹ turns powers into Aᵏ = VΛᵏV⁻¹; the largest |λ| dominates repeated multiplication — the root of vanishing/exploding gradients.
- Checks: Σλᵢ = trace A and Πλᵢ = det A.
Show 4 more key ideas
- Symmetric matrices have real eigenvalues and orthonormal eigenvectors (A = QΛQᵀ); PSD ⇔ all λ ≥ 0 ⇔ xᵀAx ≥ 0; covariances and Hessians at minima are PSD.
- SVD A = UΣVᵀ works for any matrix: rotate, stretch by σᵢ, rotate; σᵢ² are the eigenvalues of AᵀA; rank = number of nonzero σᵢ.
- Eckart–Young: the top-k SVD terms give the best rank-k approximation with error √(Σᵢ>ₖ σᵢ²); storage falls from mn to k(m+n).
- Condition number κ = σmax/σmin measures uneven stretching and error amplification; normal equations square it.
Suggested path through this lesson
Directions a matrix does not rotate
Most vectors change direction under . An eigenvector does not: , it is only scaled by the eigenvalue . Rearranging, has a nonzero solution only if squashes space, that is, — the characteristic equation. For
For , gives ; for , . Along the diagonal the matrix stretches by 3, along the anti-diagonal it leaves lengths alone, and every other vector is a mixture of the two behaviors. Set these numbers in the demo and watch the eigenvector arrows stay on their lines while the grid shears around them.
Intuition. Eigenvectors are the axes along which a transformation is "just scaling". Describe the matrix in that coordinate system and it becomes diagonal — the simplest kind of matrix.
Diagonalization and repeated application
If an matrix has independent eigenvectors, stack them as columns of and put the eigenvalues on the diagonal of ; then , so
Read it as: change to the eigenbasis, scale axis by , change back. Powers of a matrix are therefore governed by the largest : components along that eigenvector grow like and dominate everything else — the idea behind power iteration, Google's original PageRank and the long-run behavior of Markov chains — while components with die out geometrically. This is the mathematical heart of vanishing and exploding gradients: backpropagation through steps of a recurrent network multiplies nearly identical Jacobians, and the result is either (explodes) or (vanishes) (6.4 Recurrent neural networks and BPTT, 4.6 Initialization and normalization). Two free checks on any eigen-computation: and . Above: ✓ and ✓.
Symmetric matrices and the spectral theorem
When , everything is nicer. The spectral theorem says all eigenvalues are real and the eigenvectors can be chosen orthonormal, so
The quadratic form is a weighted sum of squared coordinates in the eigenbasis, so is positive semidefinite exactly when every and positive definite when all are . Covariance matrices — for centered data — are symmetric PSD, and their eigenvectors are the principal axes of the data cloud with eigenvalues equal to the variances along them (3.12 Dimensionality reduction: PCA, t-SNE and UMAP, 1.7 Probability II: Bayes, independence, MLE and MAP). Hessians are symmetric, and their eigenvalues are the curvatures along the eigen-directions: all positive at a minimum, all negative at a maximum, mixed at a saddle (1.5 Multivariable and matrix calculus, 1.10 Optimization: from gradient descent to Adam). Kernel matrices in SVMs are PSD by construction (3.10 Support vector machines and kernels).
The SVD: every matrix is rotate, stretch, rotate
Eigen-decomposition needs a square (and diagonalizable) matrix. The singular value decomposition works for any :
with () and () orthogonal and diagonal holding the singular values . Geometrically: rotate by , stretch axis by , rotate by — so the unit sphere always maps to an ellipsoid whose semi-axes are the . The number of nonzero singular values is the rank , and the sum form shows as a sum of rank-one matrices. The SVD is tied to eigen-decomposition through
so the right singular vectors are the eigenvectors of and are its eigenvalues; for a symmetric PSD matrix the singular values are the eigenvalues. The ratio is the condition number: how unevenly the matrix stretches, and how much a linear solve can amplify rounding error. Forming squares the condition number, which is why least-squares solvers use QR or the SVD rather than the normal equations (3.2 Linear regression).
Low rank: Eckart–Young and why compression works
Keep only the largest terms: . The Eckart–Young theorem says is the best rank- approximation of in both the Frobenius and the spectral norm, with error
Storage drops from numbers to : a image kept at rank 50 needs 100,000 numbers instead of a million, and if the singular values decay quickly you barely see the difference. The same theorem explains PCA (project onto the top singular directions of centered data, 3.12 Dimensionality reduction: PCA, t-SNE and UMAP), why embedding tables and weight matrices are compressible, and why LoRA can adapt a huge model by learning only a rank- update with parameters instead of (8.2 Fine-tuning and PEFT).
Worked example: the SVD of a shear
Let . Then with characteristic equation , so
the golden ratio and its reciprocal. Checks: ✓ and (the sum of squared entries) ✓. The condition number is : a shear that looks mild still stretches one direction 2.6 times more than another. The best rank-one approximation has relative error .
Math check. The right singular vector for solves , giving ; then . Unit-normalize both and you have the first term of the SVD.
import numpy as np
A = np.array([[1., 1.], [0., 1.]])
U, s, Vt = np.linalg.svd(A)
print(s) # [1.618 0.618]
A1 = s[0] * np.outer(U[:, 0], Vt[0]) # best rank-1 approximation
print(np.linalg.norm(A - A1) / np.linalg.norm(A)) # 0.357
Where this shows up later
- PCA is the SVD of centered data — 3.12 Dimensionality reduction: PCA, t-SNE and UMAP; spectral ideas in clustering — 3.11 Clustering: k-means, GMMs/EM, DBSCAN and hierarchical.
- Conditioning governs gradient descent's speed — 1.10 Optimization: from gradient descent to Adam; Hessian eigenvalues are curvatures — 1.5 Multivariable and matrix calculus; repeated Jacobians vanish or explode — 6.4 Recurrent neural networks and BPTT, 4.6 Initialization and normalization.
- Low-rank adapters — 8.2 Fine-tuning and PEFT; attention score matrices have rank at most — 7.2 Scaled dot-product and multi-head attention, fully derived; covariance ellipses of the Gaussian — 1.7 Probability II: Bayes, independence, MLE and MAP.
Common pitfalls (4)
- Assuming every matrix has an eigen-decomposition; non-square and some square matrices do not — use the SVD, which always exists.
- Reading an eigenvector's scale as meaningful; only its direction matters (any multiple is also an eigenvector).
- Confusing singular values with eigenvalues for non-symmetric matrices; they coincide only for symmetric PSD matrices.
- Computing PCA by forming the covariance explicitly and calling eig on it in float32 — numerically worse than an SVD of the centered data.
Recap: all 7 key points
- Av = λv: eigenvectors are directions that are only scaled; find λ from det(A − λI) = 0, then solve (A − λI)v = 0.
- Diagonalization A = VΛV⁻¹ turns powers into Aᵏ = VΛᵏV⁻¹; the largest |λ| dominates repeated multiplication — the root of vanishing/exploding gradients.
- Checks: Σλᵢ = trace A and Πλᵢ = det A.
- Symmetric matrices have real eigenvalues and orthonormal eigenvectors (A = QΛQᵀ); PSD ⇔ all λ ≥ 0 ⇔ xᵀAx ≥ 0; covariances and Hessians at minima are PSD.
- SVD A = UΣVᵀ works for any matrix: rotate, stretch by σᵢ, rotate; σᵢ² are the eigenvalues of AᵀA; rank = number of nonzero σᵢ.
- Eckart–Young: the top-k SVD terms give the best rank-k approximation with error √(Σᵢ>ₖ σᵢ²); storage falls from mn to k(m+n).
- Condition number κ = σmax/σmin measures uneven stretching and error amplification; normal equations square it.
Watch
The geometric meaning of eigenvectors and why the characteristic equation involves a determinant.
Read
Try it live
Interactive demo
runs in your browserExercises
- By hand: eigen-decomposition and checks
Find the eigenvalues and eigenvectors of and of the rotation . Verify trace and determinant checks. Expected: the first has with eigenvectors and ; the rotation has no real eigenvectors (its eigenvalues are ) — a rotation keeps no direction.
- NumPy: image compression with the SVD
Load a grayscale image (any 512×512 photo, or
scipy.datasets.face(gray=True)), compute its SVD, and reconstruct it from the top components. Plot the images and the relative Frobenius error against , and compare with the Eckart–Young formula. Expected: the error curve matches exactly, and already looks close to the original. - Experiment: power iteration and exploding products
Implement power iteration () for a random symmetric 5×5 matrix and compare with
np.linalg.eigh. Then multiply a random vector by a fixed random 50×50 matrix 100 times, tracking the norm, for matrices scaled so that is 0.9, 1.0 and 1.1. Expected: the norm shrinks to zero, stays bounded, or explodes — the three regimes of recurrent-network gradients.
Quiz
Flashcards
These cards are now in your spaced-repetition queue. Review all due cards →