Lecture 3 — Singular Value Decomposition (SVD)

Lecture 3 — Singular Value Decomposition (SVD)

Theory • 2×2 worked example • ML applications • Interactive calculator

1. What is SVD?

Singular Value Decomposition (SVD) factorizes any real m×n matrix A into three matrices:

A = U Σ VT

Intuitively, SVD expresses A as a composition of: rotate (VT), scale (Σ), rotate (U). It works for any rectangular matrix and is numerically stable — unlike EVD which requires square matrices.

2. Why SVD matters in ML

3. How to compute (idea)

Compute eigen-decomposition of ATA (which is symmetric & positive semidefinite). Its eigenvalues λᵢ ≥ 0. Then singular values σᵢ = sqrt(λᵢ). The columns of V are the eigenvectors of ATA. Finally, U = A V Σ-1 (for non-zero σᵢ).

4. Worked 2×2 example (step-by-step)

Take A = [[3, 1],[1, 3]]. We'll compute SVD.

  1. Compute ATA = [[10,6],[6,10]].
  2. Find eigenvalues of ATA: solve λ² - 20λ + 64 = 0 → λ₁ = 16, λ₂ = 4.
  3. Singular values: σ₁ = 4, σ₂ = 2.
  4. Compute normalized eigenvectors of ATA → columns of V: v₁ = [1/√2, 1/√2], v₂ = [1/√2, -1/√2].
  5. Compute U = A V Σ-1 → U columns are u₁ = (A v₁)/σ₁, u₂ = (A v₂)/σ₂.
  6. Check: A = U Σ VT.
A = [[3,1],[1,3]]
A^T A = [[10,6],[6,10]]
Eigenvalues: 16, 4 → singular values 4, 2
V = [[1/√2, 1/√2],[1/√2, -1/√2]]
Σ = [[4,0],[0,2]]
U = A V Σ^{-1}  (compute column-wise)
          

This yields the SVD where the first singular vector captures the direction [1,1] (largest variance) and the second captures [1,-1].

5. Interactive SVD Calculator (2×2)

Enter numbers for a 2×2 matrix A. Calculator computes AᵀA, eigenvalues, singular values, V, U and Σ (rounded).



Reminders

• ATA is symmetric → eigenvalues are real ≥ 0.
• Singular values are square roots of eigenvalues of ATA.
• If A is m×n and rank r, there are r positive singular values.