Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Decompositions

The Singular Value Decomposition (SVD)

Every matrix, of any shape, is a rotation, then a stretch, then another rotation. The SVD reveals rank, size and the most important directions of any data or map. It's the Swiss-army knife of applied linear algebra.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Every machine is turn, stretch, turn

Draw a circle on a rubber sheet and apply any linear machine. The circle always becomes an ellipse (or, if the machine squashes, a flat line). Here’s the amazing part: every linear machine can be done in three simple steps:

  1. Turn the sheet;
  2. Stretch it along the two straight axes, by different amounts;
  3. Turn it again.

This recipe is the Singular Value Decomposition. The stretch amounts are the singular values: the long and short radii of the ellipse.

The SVD picture: circle in, ellipse out
v₁v₂σ₁u₁σ₂u₂
A = [[3.0, 0.0], [4.0, 5.0]] · σ₁ = 6.708, σ₂ = 2.236 · σ₁σ₂ = 15.000 = |det A| · rank 2
The dashed arrows v₁, v₂ are perpendicular on the circle; A sends them to the ellipse's perpendicular axes, of lengths σ₁ and σ₂.
Why AI cares

A photo is a big table of numbers. The SVD finds the few “main patterns” that make up most of the picture. Keep only those and you have a compressed photo that still looks almost the same (A2.3-6).

📝 Quick check (Level 0)
0/3 answered
  1. 1. A linear machine turns a circle into…
  2. 2. How many steps does the SVD recipe have?
  3. 3. A circle of radius 1 stretched 3× sideways and 2× upward. Longest radius?

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

The formula

A=UΣV⊤A = U\Sigma V^\top
  • V⊤V^\top: rotate (an orthogonal matrix).
  • Σ\Sigma: stretch along the axes by σ1≥σ2≥⋯≥0\sigma_1\ge\sigma_2\ge\dots\ge0.
  • UU: rotate again (orthogonal).

It works for any matrix, even rectangular or singular ones. Eigen-decompositions can’t do that.

Simple examples

  • diag⁡(3,−2)\operatorname{diag}(3,-2): the singular values are 33 and 22. Singular values are always ≥0\ge 0. The minus sign is absorbed into UU or VV.
  • A rotation: both singular values are 1. It turns but doesn’t stretch.
  • (0200)\begin{pmatrix}0&2\\0&0\end{pmatrix}: singular values 2 and 0. A zero means a squashed direction.

Rank from singular values

The rank equals the number of non-zero singular values. diag⁡(5,0,1)\operatorname{diag}(5,0,1) has rank 2.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Largest singular value of diag(3, −2)?
  2. 2. Singular values of any rotation?
  3. 3. A matrix has singular values 7, 2, 0, 0. Its rank?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Shapes and pieces

For A∈Rm×nA\in\mathbb{R}^{m\times n} with rank rr:

A=UΣV⊤=∑i=1rσi uivi⊤A = U\Sigma V^\top = \sum_{i=1}^r\sigma_i\,\mathbf u_i\mathbf v_i^\top
Piece Meaning
vi\mathbf v_i (right singular vectors) orthonormal input directions
ui\mathbf u_i (left singular vectors) orthonormal output directions, with Avi=σiuiA\mathbf v_i = \sigma_i\mathbf u_i
σi\sigma_i how much direction ii is stretched

The “thin” SVD keeps only rr (or min⁡(m,n)\min(m,n)) columns. For a 5×35\times3 matrix, UU is 5×35\times3.

Connection to eigenvalues

A⊤A=VΣ2V⊤,AA⊤=UΣ2U⊤A^\top A = V\Sigma^2V^\top, \qquad AA^\top = U\Sigma^2U^\top

So the σi2\sigma_i^2 are the eigenvalues of A⊤AA^\top A. For example, A=(3045)A = \begin{pmatrix}3&0\\4&5\end{pmatrix} gives A⊤A=(25202025)A^\top A = \begin{pmatrix}25&20\\20&25\end{pmatrix}, with eigenvalues 45 and 5, so σ=45≈6.708\sigma = \sqrt{45}\approx6.708 and 5≈2.236\sqrt5\approx2.236. Check: σ1σ2=15=∣det⁡A∣\sigma_1\sigma_2 = 15 = \lvert\det A\rvert and σ12+σ22=50=∥A∥F2\sigma_1^2 + \sigma_2^2 = 50 = \lVert A\rVert_F^2.

🐍 Exercise 1: compute and check an SVD
Compute the thin SVD, reconstruct A, check the orthonormal factors, and check that σ² are the eigenvalues of AᵀA.

What the SVD tells you

Question Answer from the SVD
Rank? the number of σi>0\sigma_i > 0 (above a tolerance, in practice)
Largest stretch, ∥A∥2\lVert A\rVert_2? σ1\sigma_1
How close to singular? σmin⁡\sigma_{\min}, and the condition number σ1/σmin⁡\sigma_1/\sigma_{\min}
Column and row spaces? the first rr columns of UU and of VV
Null space? the remaining columns of VV (A2.1-6)
Best rank-kk approximation? keep the top kk terms (A2.3-6)
PCA = SVD of centred data

For a centred data matrix XcX_c, the right singular vectors are the principal components, and σi2/(n−1)\sigma_i^2/(n-1) are the variances. Working on XcX_c directly avoids forming the covariance matrix, which squares the condition number, so libraries like scikit-learn compute PCA by SVD (D9).

📝 Quick check (Level 2)
0/3 answered
  1. 1. The σᵢ² are the eigenvalues of…
  2. 2. For a square A, the product of its singular values equals…
  3. 3. Shape of U in the thin SVD of a 5 × 3 matrix?

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Existence for every matrix

Theorem (SVD)

Every real m×nm\times n matrix has a factorization A=UΣV⊤A = U\Sigma V^\top with orthogonal U∈Rm×mU\in\mathbb{R}^{m\times m}, orthogonal V∈Rn×nV\in\mathbb{R}^{n\times n}, and Σ\Sigma diagonal with non-negative entries in decreasing order. The singular values are unique.

Proof. A⊤AA^\top A is symmetric PSD, so the spectral theorem (A2.3-2) gives orthonormal eigenvectors vi\mathbf v_i with eigenvalues λi≥0\lambda_i\ge0. Set σi=λi\sigma_i = \sqrt{\lambda_i}, and for σi>0\sigma_i > 0 let ui=Avi/σi\mathbf u_i = A\mathbf v_i/\sigma_i. These are orthonormal: ui⊤uj=vi⊤A⊤Avj/(σiσj)=λjδij/(σiσj)=δij\mathbf u_i^\top\mathbf u_j = \mathbf v_i^\top A^\top A\mathbf v_j/(\sigma_i\sigma_j) = \lambda_j\delta_{ij}/(\sigma_i\sigma_j) = \delta_{ij}. Extend the ui\mathbf u_i to an orthonormal basis of Rm\mathbb{R}^m. Then Avi=σiuiA\mathbf v_i = \sigma_i\mathbf u_i for every ii, which in matrix form is AV=UΣAV = U\Sigma. ∎

Extremal characterization

σ1=max⁡∥x∥=1∥Ax∥=∥A∥2,σmin⁡=min⁡∥x∥=1∥Ax∥ (square A)\sigma_1 = \max_{\lVert\mathbf x\rVert = 1}\lVert A\mathbf x\rVert = \lVert A\rVert_2, \qquad \sigma_{\min} = \min_{\lVert\mathbf x\rVert=1}\lVert A\mathbf x\rVert \ (\text{square } A)

So ∥Av∥≤σ1∥v∥\lVert A\mathbf v\rVert\le\sigma_1\lVert\mathbf v\rVert for every v\mathbf v. It follows from writing v\mathbf v in the VV basis: ∥Av∥2=∑σi2ci2≤σ12∑ci2\lVert A\mathbf v\rVert^2 = \sum\sigma_i^2c_i^2 \le \sigma_1^2\sum c_i^2.

SVD vs eigen-decomposition

Eigen A=PDP−1A = PDP^{-1} SVD A=UΣV⊤A = U\Sigma V^\top
Exists for some square matrices every matrix
Bases one (input = output), maybe not orthogonal two orthonormal ones
Diagonal can be negative or complex always real, ≥0\ge0
Same when AA is symmetric PSD

Polar decomposition

A=(UV⊤)(VΣV⊤)A = (UV^\top)(V\Sigma V^\top) is an orthogonal matrix times a PSD stretch. UV⊤UV^\top is the closest orthogonal matrix to AA. Robotics uses this to re-orthogonalize a rotation matrix that has drifted through integration errors (Practice Code 4).

Exercise 3.1: Show that the singular values of an orthogonal Q are all 1

Q⊤Q=IQ^\top Q = I, whose eigenvalues are all 1, so every σi=1=1\sigma_i = \sqrt1 = 1.

📝 Quick check (Level 3)
0/3 answered
  1. 1. A singular value of 4 corresponds to which eigenvalue of AᵀA?
  2. 2. σ = (10, 0.1). Condition number?
  3. 3. The closest orthogonal matrix to A = UΣVᵀ is…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Aligning point clouds: the Kabsch / Procrustes problem

Given matched 3-D points pi\mathbf p_i and qi\mathbf q_i (for example, two LiDAR scans), find the rotation RR and translation t\mathbf t minimizing ∑∥Rpi+t−qi∥2\sum\lVert R\mathbf p_i + \mathbf t - \mathbf q_i\rVert^2. The answer comes from one SVD of the cross-covariance H=∑(pi−pˉ)(qi−qˉ)⊤=UΣV⊤H = \sum(\mathbf p_i - \bar{\mathbf p})(\mathbf q_i - \bar{\mathbf q})^\top = U\Sigma V^\top: R=Vdiag⁡(1,1,det⁡(VU⊤))U⊤R = V\operatorname{diag}(1,1,\det(VU^\top))U^\top. The determinant term prevents a reflection. This closed form (Kabsch, 1976; Arun, Huang and Blostein, 1987) is the inner step of ICP scan matching, used by every LiDAR-based robot and autonomous car (T4).

🐍 Exercise 2 (research): rigid alignment with the SVD (Kabsch)
Recover the rotation and translation between two noisy copies of a point cloud. Check that the rotation error is small and det R = +1.

SVD across research

  • Computer vision. The essential matrix in two-view geometry is estimated and decomposed by SVD (the 8-point algorithm, Hartley, 1997), giving camera rotation and translation (T4).
  • Deep learning analysis. The singular-value spectra of weight matrices reveal training quality: heavy-tailed spectra correlate with generalization (Martin and Mahoney, 2021). Spectral normalization divides by σ1\sigma_1 to stabilize GAN training (Miyato et al., 2018).
  • Recommender systems. Netflix-prize-era models were low-rank matrix factorizations, close relatives of the SVD (D13).
  • Model compression. Low-rank SVD of trained weight matrices compresses networks. LoRA’s adapters are low-rank by design (F6).

References

  1. E. Beltrami (1873) and C. Jordan (1874). (Independent discoveries of the SVD.)
  2. C. Eckart and G. Young (1936). “The approximation of one matrix by another of lower rank.” Psychometrika, 1.
  3. G. Golub and W. Kahan (1965). “Calculating the singular values and pseudo-inverse of a matrix.” SIAM Journal on Numerical Analysis, 2(2).
  4. W. Kabsch (1976). “A solution for the best rotation to relate two sets of vectors.” Acta Crystallographica A, 32.
  5. K. S. Arun, T. Huang, S. Blostein (1987). “Least-squares fitting of two 3-D point sets.” IEEE TPAMI, 9(5).
  6. T. Miyato, T. Kataoka, M. Koyama, Y. Yoshida (2018). “Spectral normalization for generative adversarial networks.” ICLR.
  7. C. Martin and M. Mahoney (2021). “Implicit self-regularization in deep neural networks.” JMLR, 22(165).
  8. G. Strang (2016). Introduction to Linear Algebra, 5th ed. Chapter 7.