9.88 min read
Computing SVD via Gram Matrix
Alternatively: (1) form ; (2) eigendecompose ; (3) set ; (4) compute for nonzero ; (5) extend for zero .
This path is preferred when (the Gram is smaller). Both paths give the same SVD. MATLAB: [U, S, V] = svd(A) chooses the optimal algorithm internally.
Formal View
Example 9.2 — SVD via Gram — Algorithm
Given (), compute SVD via :
1. Form ().
2. Eigendecompose: , sort descending.
3. ; form .
4. for .
5. Verify: .
Interactive Visualization
Matrix Product — Column Perspective
Why This Matters
Choose Gram vs covariance path based on which gives the smaller matrix to decompose.
- Wide data matrices (many features, few samples): Gram path is small.
- Tall data matrices (many samples, few features): covariance path is small.
- Square matrices: both paths equally sized; use bidiagonalization instead.
Quiz
Question 1
Given from the spectral decomposition of , we compute .
Question 2
For a matrix, which path is more efficient?
Common Mistakes
- Computing without dividing by — the result is not a unit vector.
- Using the Gram path when the covariance path gives a much smaller matrix.