Singular Value Decomposition (SVD)

Subtopic: Decompositions
Topic: Linear algebra

The Ultimate Factorization

The Singular Value Decomposition (SVD) factors ANY matrix — not just square, not just invertible — into three special matrices:

A=U⁢Σ⁢VT A equals U Sigma V to the T power

  • U is m×m orthogonal (columns are left singular vectors)

  • Σ is m×n diagonal (singular values σ₁ ≥ σ₂ ≥ ... ≥ 0 on diagonal)

  • V is n×n orthogonal (columns are right singular vectors)

Geometric Interpretation

The SVD reveals the geometry of any linear transformation. Every matrix A does three things:

  1. Vᵀ rotates/reflects the input space to align with special directions

  2. Σ stretches/compresses along coordinate axes (by singular values)

  3. U rotates/reflects to the final output orientation

The unit sphere maps to an ellipsoid. Singular values are the semi-axis lengths of this ellipsoid.

Finding the SVD

The singular values are the square roots of eigenvalues of AᵀA (or AAᵀ):

The columns of V are eigenvectors of AᵀA. The columns of U are eigenvectors of AAᵀ.

Alternatively: Av_i = σ_i u_i connects the singular vectors.

Example

A=[300200] A equals the 3 by 2 matrix Row 1: 3 0 Row 2: 0 2 Row 3: 0 0

This is already diagonal! The SVD is immediate:

A=[100010001]⁢[300200]⁢[1001] A equals the 3 by 3 matrix Row 1: 1 0 0 Row 2: 0 1 0 Row 3: 0 0 1 times the 3 by 2 matrix Row 1: 3 0 Row 2: 0 2 Row 3: 0 0 times the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1

Singular values: σ₁ = 3, σ₂ = 2. U and V are identity matrices (columns are standard basis).

The Four Fundamental Subspaces

The SVD reveals all four fundamental subspaces of A:

  • Column space: first r columns of U (where r = rank)

  • Row space: first r columns of V

  • Null space: last n-r columns of V

  • Left null space: last m-r columns of U

Low-Rank Approximation

Truncate the SVD by keeping only the largest k singular values:

Ak=∑i=1k(σi)⁢ui⁢viT A sub k equals the sum from i equals 1 to k of open paren sigma sub i close paren u sub i v sub i to the T power

The Eckart-Young theorem: A_k is THE best rank-k approximation to A (minimizes ||A - A_k|| in both Frobenius and spectral norms).

This is the mathematical foundation of data compression, dimensionality reduction, and noise removal.

The Pseudoinverse

The Moore-Penrose pseudoinverse A⁺ is defined via SVD:

A+=V⁢Σ+⁢UT A raised to the plus power equals V Sigma raised to the plus power U to the T power

where Σ⁺ inverts the nonzero singular values. This generalizes matrix inverse to non-square and singular matrices.

Applications

  • Principal Component Analysis (PCA): SVD of centered data gives principal components

  • Image compression: Keep top singular values, discard the rest

  • Recommender systems: Matrix factorization for collaborative filtering

  • Natural language processing: Latent semantic analysis uses truncated SVD

  • Numerical stability: Computing rank, solving least squares, determining matrix condition

  • Signal processing: Separating signal from noise

Mathematical Foundation

Theorem (Singular Value Decomposition): Every m×n matrix A can be factored as A = UΣVᵀ where:

• U is an m×m orthogonal matrix (UᵀU = UUᵀ = I)

• Σ is an m×n diagonal matrix with non-negative entries σ₁ ≥ σ₂ ≥ ... ≥ σᵣ > 0 = σᵣ₊₁ = ... where r = rank(A)

• V is an n×n orthogonal matrix (VᵀV = VVᵀ = I)

A=U⁢Σ⁢VT=[||u1⋯um||]⁢[σ10⋱0σr0]⁢[−v1T−⋮−vnT−] A equals U Sigma V to the T power equals the 3 by 3 matrix Row 1: Column 1, vertical bar Column 2, blank Column 3, vertical bar Row 2: Column 1, u sub 1 Column 2, dot dot dot Column 3, u sub m Row 3: Column 1, vertical bar Column 2, blank Column 3, vertical bar times the 4 by 3 matrix Row 1: Column 1, sigma sub 1 Column 2, blank Column 3, 0 Row 2: Column 1, blank Column 2, down right diagonal ellipsis Column 3, blank Row 3: Column 1, 0 Column 2, blank Column 3, sigma sub r Row 4: Column 1, blank Column 2, 0 Column 3, blank times the 3 by 3 matrix Row 1: Column 1, minus Column 2, v sub 1 to the T power Column 3, minus Row 2: Column 1, blank Column 2, vertical ellipsis Column 3, blank Row 3: Column 1, minus Column 2, v sub n to the T power Column 3, minus

Existence Proof

The matrix AᵀA is n×n, symmetric, and positive semi-definite. Therefore it has n non-negative eigenvalues λ₁ ≥ λ₂ ≥ ... ≥ λₙ ≥ 0 with orthonormal eigenvectors v₁, v₂, ..., vₙ.

Define the singular values as σᵢ = √λᵢ. For each σᵢ > 0, define:

ui=1σi⁢A⁢vi u sub i equals the fraction with numerator 1 and denominator sigma sub i A v sub i

These uᵢ are orthonormal. To see this, compute:

uiT⁢uj=1σi⁢σj⁢viT⁢AT⁢A⁢vj=λjσi⁢σj⁢viT⁢vj={1i=j0i≠j u sub i to the T power u sub j equals 1 over sigma sub i sigma sub j v sub i to the T power A to the T power A v sub j equals the fraction with numerator lamda sub j and denominator sigma sub i sigma sub j v sub i to the T power v sub j equals 2 cases Case 1: 1 i equals j Case 2: 0 i is not equal to j

Extend {u₁, ..., uᵣ} to an orthonormal basis {u₁, ..., uₘ} of ℝᵐ. Now verify Avᵢ = σᵢuᵢ for i ≤ r and Avᵢ = 0 for i > r, which confirms A = UΣVᵀ.

Geometric Intuition: What SVD Reveals

The SVD decomposes any linear transformation into three simple steps:

  1. Vᵀ rotates the input space to align with the "principal axes" of the transformation

  2. Σ stretches along each axis by the corresponding singular value

  3. U rotates the stretched result to the final output orientation

The image of the unit sphere under A is an ellipsoid. The singular values are the lengths of the semi-axes, and the left/right singular vectors give the orientations.

{x:||x||=1}→{A⁢x:||x||=1}=ellipsoid with semi-axes ⁢σ1,σ2,… the set of all x such that the absolute value of times x times the absolute value of equals 1 right arrow the set of all A x such that the absolute value of times x times the absolute value of equals 1 equals ellipsoid with semi minus axes sigma sub 1 comma sigma sub 2 comma dot dot dot

The largest singular value σ₁ equals ||A||₂ = max{||Ax|| : ||x|| = 1} — the maximum "stretching factor" of A.

The Eckart-Young Theorem

Theorem: The best rank-k approximation to A (in both Frobenius and spectral norms) is obtained by keeping only the top k singular values:

Ak=∑i=1k(σi)⁢ui⁢viT A sub k equals the sum from i equals 1 to k of open paren sigma sub i close paren u sub i v sub i to the T power

The approximation error is:

||A−Ak||=σk+12+σk+22+⋯+σr2,||A−Ak||=σk+1 the absolute value of times A minus A sub k times the absolute value of equals the square root of sigma sub k plus 1 squared plus sigma sub k plus 2 squared plus dot dot dot plus sigma sub r squared comma the absolute value of times A minus A sub k times the absolute value of equals sigma sub k plus 1

This is remarkable: among ALL rank-k matrices, Aₖ is the closest to A. No other factorization or approximation can do better.

Proof idea: Any rank-k matrix has at most k nonzero singular values. The error ||A - B||₂ ≥ σₖ₊₁(A) for any rank-k matrix B.

Computing the SVD

Method 1 (Eigenvalue approach): Compute the eigendecomposition of AᵀA = VΛVᵀ. Then σᵢ = √λᵢ and uᵢ = Avᵢ/σᵢ. This works but squaring the matrix doubles the condition number.

Method 2 (Golub-Kahan): First bidiagonalize A = UBVᵀ using Householder reflections from both sides. Then apply QR iterations to the bidiagonal matrix B. This is the standard algorithm.

Method 3 (Divide and conquer): Recursively split the bidiagonal matrix. Fastest for large matrices with many singular values. Used in LAPACK.

Complete Worked Example

Find the SVD of:

A=[32232−2] A equals the 3 by 2 matrix Row 1: 3 2 Row 2: 2 3 Row 3: 2 negative 2

Step 1: Compute AᵀA:

AT⁢A=[32223−2]⁢[32232−2]=[178817] A to the T power A equals the 2 by 3 matrix Row 1: 3 2 2 Row 2: 2 3 negative 2 times the 3 by 2 matrix Row 1: 3 2 Row 2: 2 3 Row 3: 2 negative 2 equals the 2 by 2 matrix Row 1: 17 8 Row 2: 8 17

Step 2: Find eigenvalues of AᵀA. det(AᵀA - λI) = (17-λ)² - 64 = 0, so λ = 25 or λ = 9.

σ1=25=5,σ2=9=3 sigma sub 1 equals the square root of 25 equals 5 comma sigma sub 2 equals the square root of 9 equals 3

Step 3: Find eigenvectors of AᵀA. For λ = 25: v₁ = (1, 1)ᵀ/√2. For λ = 9: v₂ = (1, -1)ᵀ/√2.

Step 4: Compute left singular vectors uᵢ = Avᵢ/σᵢ:

u1=15⁢A⁢[1/21/2]=15⁢2⁢[550]=[1/21/20] u sub 1 equals one fifth A times the 2 by 1 column matrix Row 1: 1 divided by the square root of 2 Row 2: 1 divided by the square root of 2 equals 1 over 5 the square root of 2 times the 3 by 1 column matrix 5 5 0 equals the 3 by 1 column matrix Row 1: 1 divided by the square root of 2 Row 2: 1 divided by the square root of 2 Row 3: 0

u2=13⁢A⁢[1/2−1/2]=13⁢2⁢[1−14]=[1/18−1/184/18] u sub 2 equals one third A times the 2 by 1 column matrix Row 1: 1 divided by the square root of 2 Row 2: negative 1 divided by the square root of 2 equals 1 over 3 the square root of 2 times the 3 by 1 column matrix 1 negative 1 4 equals the 3 by 1 column matrix Row 1: 1 divided by the square root of 18 Row 2: negative 1 divided by the square root of 18 Row 3: 4 divided by the square root of 18

Step 5: Extend to orthonormal basis. Find u₃ perpendicular to u₁ and u₂: u₃ = (0, 0, 1)ᵀ (after verification).

Actually, u₃ must satisfy u₃ᵀu₁ = 0 and u₃ᵀu₂ = 0. We get u₃ = (1, -1, 0)ᵀ/√2 (in the null space of Aᵀ).

The complete SVD:

U=[1/21/181/21/2−1/18−1/204/180],Σ=[500300],V=[1/21/21/2−1/2] U equals the 3 by 3 matrix Row 1: Column 1, 1 divided by the square root of 2 Column 2, 1 divided by the square root of 18 Column 3, 1 divided by the square root of 2 Row 2: Column 1, 1 divided by the square root of 2 Column 2, negative 1 divided by the square root of 18 Column 3, negative 1 divided by the square root of 2 Row 3: Column 1, 0 Column 2, 4 divided by the square root of 18 Column 3, 0 comma Sigma equals the 3 by 2 matrix Row 1: 5 0 Row 2: 0 3 Row 3: 0 0 comma V equals the 2 by 2 matrix Row 1: Column 1, 1 divided by the square root of 2 Column 2, 1 divided by the square root of 2 Row 2: Column 1, 1 divided by the square root of 2 Column 2, negative 1 divided by the square root of 2

Connection to Eigendecomposition

For a symmetric matrix A = Aᵀ, the SVD and eigendecomposition are closely related:

A=Q⁢Λ⁢QT=U⁢Σ⁢VT A equals Q Lamda Q to the T power equals U Sigma V to the T power

If all eigenvalues are non-negative, then U = V = Q and Σ = Λ.

If some eigenvalues are negative, their singular values are |λᵢ|, and the corresponding columns of U differ from those of Q by a sign flip.

Key differences:

• Eigendecomposition: Only for square matrices, may not exist (defective matrices)

• SVD: Exists for ALL matrices (any size), always has real non-negative singular values

• For symmetric positive definite matrices: σᵢ = λᵢ

• For general matrices: σᵢ² = eigenvalues of AᵀA (or AAᵀ)

SVD Intuition: Three Perspectives

Perspective 1: The Outer Product Sum. Every matrix is a weighted sum of rank-1 matrices:

A=σ1⁢u1⁢v1T+σ2⁢u2⁢v2T+⋯+σr⁢ur⁢vrT A equals sigma sub 1 u sub 1 v sub 1 to the T power plus sigma sub 2 u sub 2 v sub 2 to the T power plus dot dot dot plus sigma sub r u sub r v sub r to the T power

Each term σᵢuᵢvᵢᵀ is a rank-1 "layer." The first layer captures the most important pattern (largest σ), subsequent layers add refinements. Image compression keeps only the first few layers.

Perspective 2: Orthonormal Bases. The SVD provides optimal orthonormal bases for both the domain and codomain:

• V columns: orthonormal basis for the row space + null space of A

• U columns: orthonormal basis for the column space + left null space of A

The matrix A maps vᵢ → σᵢuᵢ for i ≤ r and vᵢ → 0 for i > r.

Perspective 3: Maximum Stretching. σ₁ is the maximum factor by which A stretches any unit vector:

σ1=max⁡(|)|A⁢x||=||A|| sigma sub 1 equals max of open paren vertical bar close paren times the absolute value of A x times the absolute value of equals times the absolute value of A vertical bar

The maximizer is v₁, and Av₁ = σ₁u₁ points in the most-stretched direction.

Similarly, σ₂ is the maximum stretching perpendicular to v₁, achieved at v₂. Each singular value is the maximum stretch in the subspace orthogonal to all previous vᵢ.

Visualizing the SVD

For a 2×2 matrix, visualize how A transforms the unit circle:

  1. The unit circle in the domain is aligned with v₁, v₂

  2. A stretches by σ₁ along v₁ and σ₂ along v₂

  3. The result is an ellipse with semi-axes σ₁ and σ₂ aligned with u₁, u₂

If σ₂ = 0, the ellipse collapses to a line segment — the matrix is rank 1 and maps the entire plane to a line.

The ratio σ₁/σₙ is the condition number, measuring how elongated the ellipse is. A large condition number means the matrix nearly collapses some directions — it is ill-conditioned.

Practice Problems

Problem 1: Find the SVD of A = [[2, 0], [0, 3]]. What are the singular values? What are the left and right singular vectors?

Solution: This is already diagonal! σ₁ = 3, σ₂ = 2 (in decreasing order). U = V = I (identity) but we must reorder: U = [[0,1],[1,0]], Σ = [[3,0],[0,2]], V = [[0,1],[1,0]]. Or keep the natural order with σ₁ = 2, σ₂ = 3.

Problem 2: Compute the SVD of A = [[1, 1], [1, 1]]. What is the rank? Find the best rank-1 approximation.

Solution: AᵀA = [[2,2],[2,2]] with eigenvalues λ₁ = 4, λ₂ = 0. So σ₁ = 2, σ₂ = 0. Rank = 1. Eigenvector for λ₁ = 4: v₁ = (1,1)ᵀ/√2. Then u₁ = Av₁/2 = (1,1)ᵀ/√2. The SVD: A = 2·(1,1)ᵀ(1,1)/2 = [[1,1],[1,1]]. Since rank = 1, A is already its own best rank-1 approximation.

Problem 3: If A has singular values σ₁ = 5, σ₂ = 3, σ₃ = 1, what is ||A||₂? What is ||A||_F? What is the best rank-2 approximation error in Frobenius norm?

Solution: ||A||₂ = σ₁ = 5 (spectral norm = largest singular value). ||A||_F = √(25+9+1) = √35 ≈ 5.92. Best rank-2 error: ||A - A₂||_F = σ₃ = 1.

Problem 4: Prove that for any matrix A, the nonzero singular values of A and Aᵀ are identical.

Solution: The singular values of A are √(eigenvalues of AᵀA). The singular values of Aᵀ are √(eigenvalues of AAᵀ). But AᵀA and AAᵀ have the same nonzero eigenvalues (proof: if AᵀAv = λv with λ ≠ 0, then AAᵀ(Av) = A(AᵀAv) = λ(Av), so λ is also an eigenvalue of AAᵀ).

Problem 5: A 100×50 matrix has rank 10. How many nonzero singular values does it have? What are the dimensions of U, Σ, V in the full SVD? In the reduced SVD?

Solution: Exactly 10 nonzero singular values. Full SVD: U is 100×100, Σ is 100×50, V is 50×50. Reduced SVD: U is 100×10, Σ is 10×10, V is 50×10 (or Vᵀ is 10×50).

Proof of the Eckart-Young Theorem

Theorem: Among all rank-k matrices, Aₖ = Σᵢ₌₁ᵏ σᵢuᵢvᵢᵀ minimizes ||A - B||₂ and ||A - B||_F.

Proof (spectral norm): Let B be any rank-k matrix. We show ||A - B||₂ ≥ σₖ₊₁.

The null space of B has dimension at least n - k (by rank-nullity). The span of {v₁, v₂, ..., vₖ₊₁} has dimension k + 1.

Since (n - k) + (k + 1) = n + 1 > n, these subspaces must intersect non-trivially. Let w ≠ 0 be in both, with ||w|| = 1.

Since w ∈ Null(B), we have Bw = 0, so (A - B)w = Aw.

Since w ∈ span{v₁,...,vₖ₊₁}, write w = Σᵢ₌₁ᵏ⁺¹ cᵢvᵢ where Σcᵢ² = 1.

||A⁢w||2=||∑i=1k+1(ci)⁢σi⁢ui||2=∑i=1k+1(ci2)⁢σi2≥σk+12⁢∑i=1k+1ci2=σk+12 the absolute value of times A w the absolute value of squared equals the absolute value of times the sum from i equals 1 to k plus 1 of open paren c sub i close paren sigma sub i u sub i the absolute value of squared equals the sum from i equals 1 to k plus 1 of open paren c sub i squared close paren sigma sub i squared is greater than or equal to sigma sub k plus 1 squared the sum from i equals 1 to k plus 1 of c sub i squared equals sigma sub k plus 1 squared

Thus ||A - B||₂ ≥ ||(A - B)w|| = ||Aw|| ≥ σₖ₊₁. Equality holds for B = Aₖ since (A - Aₖ)vₖ₊₁ = σₖ₊₁uₖ₊₁. ∎

Proof (Frobenius norm): For any matrix M, ||M||²_F = Σσᵢ(M)². The singular values of A - B can be bounded using Weyl inequalities, giving ||A - B||²_F ≥ Σᵢ₌ₖ₊₁ʳ σᵢ². Equality holds for B = Aₖ since A - Aₖ = Σᵢ₌ₖ₊₁ʳ σᵢuᵢvᵢᵀ has exactly those singular values. ∎

Practice Problems

Problem 1: Find the SVD of A = [[3, 0], [0, 2]]. What are σ₁, σ₂?

Solution: Already diagonal! σ₁ = 3, σ₂ = 2. U = V = I (identity).

Problem 2: Find SVD of [[1, 1], [1, 1]]. What is the rank?

Solution: AᵀA = [[2,2],[2,2]], eigenvalues 4, 0. σ₁ = 2, σ₂ = 0. Rank = 1. v₁ = u₁ = (1,1)ᵀ/√2.

Problem 3: If σ₁ = 5, σ₂ = 3, σ₃ = 1, what is ||A||₂? ||A||_F? Best rank-2 error?

Solution: ||A||₂ = 5. ||A||_F = √35. ||A - A₂||_F = 1.

Problem 4: Prove A and Aᵀ have the same nonzero singular values.

Solution: σ(A) = √λ(AᵀA), σ(Aᵀ) = √λ(AAᵀ). AᵀA and AAᵀ have the same nonzero eigenvalues.

Problem 5: 100×50 matrix, rank 10. Dimensions of U, Σ, V in full vs reduced SVD?

Solution: Full: U 100×100, Σ 100×50, V 50×50. Reduced: U 100×10, Σ 10×10, V 50×10.


Practice Problems

Test your understanding of SVD with these exercises.

Problem 1

Find the singular values of A = [[3, 0], [0, 2]]

Problem 2

For A = [[1, 1], [0, 0]], find the full SVD decomposition.

Problem 3

If A has singular values σ₁ = 5, σ₂ = 3, σ₃ = 0, what is rank(A)?

Problem 4

Find the best rank-1 approximation of A = [[3, 0], [0, 2]] using SVD.

Problem 5

Compute AᵀA for A = [[1, 2], [3, 4]] and find its eigenvalues.

Problem 6

Explain why singular values are always non-negative.


Answers

  1. σ₁ = 3, σ₂ = 2. For diagonal matrices, singular values are absolute values of diagonal entries.

  2. U = [[1, 0], [0, 1]], Σ = [[√2, 0], [0, 0]], Vᵀ = [[1/√2, 1/√2], [1/√2, -1/√2]]. AᵀA = [[1, 1], [1, 1]] has eigenvalues 2 and 0, so σ₁ = √2.

  3. rank(A) = 2. Rank equals the number of non-zero singular values.

  4. A₁ = [[3, 0], [0, 0]]. Keep only σ₁ = 3 with its u₁ and v₁. The result captures the largest singular value direction.

  5. AᵀA = [[10, 14], [14, 20]], eigenvalues ≈ 29.87 and 0.13. Singular values of A are √29.87 ≈ 5.47 and √0.13 ≈ 0.36.

  6. Singular values are square roots of eigenvalues of AᵀA. Since AᵀA is positive semi-definite, its eigenvalues are ≥ 0, so their square roots are real and non-negative.