Unit 7 of 8 · about 6 hours · derive, implement

SVD, pseudoinverse and low-rank approximation

SVD describes every real linear map, including rectangular and rank-deficient ones. It unifies lost directions, minimum-norm solutions and the best low-rank representation.

You'll be able to

  • Construct an SVD from the symmetric eigendecomposition of , including its zero-singular-value case.
  • Derive the pseudoinverse as the minimum-norm least-squares solution map.
  • Prove the spectral-norm Eckart-Young bound and derive PCA as maximum projected variance.
  • Implement truncated-SVD reconstruction and check its error against the singular-value tail.

Covers

Singular-value decomposition and the pseudoinversePCA, low-rank approximation and reconstruction error
1

Read

In this order, only the parts listed

0 of 4 done

  1. SVD and the pseudoinverseMIT 18.06 - Linear Algebra

    Video Lecture 29, Singular value decomposition; Lecture 33, Left and right inverses; pseudoinverse

  2. Constructing and truncating the SVDMathematics for Machine Learning

    Chapter 4, section 4.5 (pp. 119 to 129), especially construction equations (4.71) to (4.79) on pp. 123 to 124; section 4.6, Theorems 4.24 and 4.25 and the proof on pp. 131 to 132

    Follow the construction, not the movie-rating example. Normalize only when ; complete the left basis orthonormally for the remaining directions.

  3. Best rank-k approximationMIT 18.065 - Applied matrix bridge

    Lecture 7, Eckart-Young: The Closest Rank k Matrix to A

    Focus on the rank constraint and the norm in the optimality claim. Leave large-data applications.

  4. PCA as a variance maximization problemMathematics for Machine Learning

    Chapter 10, section 10.2 (pp. 320 to 325), equations (10.9) to (10.25)

    Use the spectral decomposition to bound the Rayleigh quotient; no optimization algorithm is needed. The book stores samples as columns. Transpose its convention for the row-sample NumPy check.

2

Focus on

  • For each positive eigenvalue of set , . Prove . Zero eigenvalues mean , not a vector to normalize.
  • For , . The row-space solution is orthogonal to all null-space additions, hence has minimum Euclidean norm.
  • For rank at most , Eckart-Young gives minimum spectral error . The truncated SVD also has squared Frobenius error . State which norm you measure.
  • For centered row-sample with , sample covariance is . A unit direction's variance is its Rayleigh quotient; right singular vectors maximize it, and retained variance is sum of retained .
Common mistakes · 3
  • Deriving existence from does not recommend forming it to compute an SVD. Its conditioning cost is proved in the next unit.
  • Repeated singular values allow rotations within a singular subspace, not just sign flips. Compare reconstructed matrices or subspace projectors.
  • A numerical pseudoinverse must declare its singular-value cutoff. Inverting tiny retained values amplifies noise; never divide by zero and then mask the result.
3

Try it yourself

Closed-book, before checking anything

Construct the SVD and pseudoinverse by hand for MML Exercise 4.8's . Singular values are 5 and 3; its rank-1 truncation is , and . Give the spectral-norm Eckart-Young proof from self-test. As one NumPy check, use float64 A, no random draws, and U,s,Vt=np.linalg.svd(A,full_matrices=False). Implement A1=(U[:,:1]*s[:1])@Vt[:1] and Ap=(Vt.T/s)@U.T. The reconstruction Frobenius norm is 1.2e-15; spectral and Frobenius truncation errors are approximately 3; norm(A@Ap@A-A,'fro') is 2.9e-15. Require identity residuals below 1e-12 and scalar errors within 1e-12 of 3. In the same check use centered float64 X=[[3,0],[-3,0],[0,1],[0,-1]], take its first right singular vector v, and reconstruct (X@v[:,None])@v[None,:]. Verify sample variances (6,2/3) and squared Frobenius reconstruction error 2 within 1e-12. Explain both results from the spectrum, rather than treating this as a fitted ML evaluation.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Why does the SVD construction cover rectangular and rank-deficient matrices?Answer

    is real symmetric PSD, so the spectral theorem gives an orthonormal domain basis with nonnegative eigenvalues. For positive values, . For zero values, . Complete the output vectors to an orthonormal basis of ; permits this. The identities on every domain basis vector then give .

  2. 2.What proves the spectral-norm Eckart-Young lower bound?Answer

    For , any of rank at most has a kernel of dimension at least . Its intersection with is nontrivial since the dimension sum exceeds . Choose a unit there: and , so . Orthogonality in the SVD makes the truncated tail attain this bound. For , choosing gives zero error.

  3. 3.Why does select the minimum-norm least-squares solution?Answer

    In orthonormal output coordinates, minimize each reachable component by setting for positive . Unreachable output components remain in the residual. The null-space coordinates do not affect the residual, but add their squared norm to . Setting them to zero uniquely minimizes the norm.

  4. 4.Why must the unit-length constraint and centering appear in the PCA derivation?Answer

    Centering makes the sample covariance rather than an uncentered second moment. For unit , since . Equality is attained in a leading eigendirection. Without the length constraint, scaling a nonzero-variance direction makes the objective unbounded.

5

Practice

  • MML Exercises 4.9, 4.11 and 4.12: a square SVD and two spectral proofs

    Chapter 4, Exercises 4.9, 4.11 and 4.12, printed p. 138

    Derive both singular-vector families of the 2 by 2 matrix by hand and keep when fixing signs. Prove 4.11 from the SVD construction in this unit and 4.12 from the spectral decomposition of ; the Eckart-Young proof uses 4.12. The section mini-project should implement a cutoff-aware pseudoinverse and sign-invariant PCA reconstruction on a new matrix, including a zero singular value.

  • 18.06 Problem set 10: the Fibonacci matrix SVD

    Problem set 10, Strang 4th ed., section 6.7, Problem 4

    Attempt before the official solutions. Keep when matching signs; symmetry does not imply when an eigenvalue is negative. Skip the neighbouring section 6.7 Problem 11 solution: it incorrectly sets for orthogonal columns. The normalized columns belong in , with before any reordering.

You're done when

You construct the wide SVD, derive its pseudoinverse and optimal rank-1 error, give the dimension-intersection proof, and explain the PCA variance and reconstruction checks from the singular spectrum.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 5 more in the section
  • MIT 18.06 - Linear AlgebraMIT OpenCourseWare · primary

    Follow lectures 1-10, 14-17, 21-22, 25, 27, 29-31 and 33 with matching problems. This is the ordered first pass.

  • MIT 18.065 - Applied matrix bridgeMIT OpenCourseWare · required

    Use lectures 3-10 after 18.06 for SVD, PCA, low-rank approximation, matrix norms and solver difficulty.

  • Mathematics for Machine LearningDeisenroth, Faisal & Ong · reference

    Use Chapters 2-4 and §10.2 to check notation or re-derive a result. Do not treat it as a second course.

Also in this section

  • MIT 6.042J - Proof strandMIT OpenCourseWare · required

    Study textbook Chapters 1 and 3, §§4.1-4.4 and §§5.1-5.4 with matching Unit 1 problems. Leave the rest of the course.

  • Introduction to Applied Linear AlgebraBoyd & Vandenberghe · support

    Sample Chapters 1-13 and the extra exercises for computational practice in fitting, least squares and pseudoinverses.

  • Essence of Linear Algebra3Blue1Brown · optional

    Open only when a geometric picture is missing; it does not replace derivation or problem solving.

  • NumPy broadcasting and matmul shape rulesNumPy Developers · reference

    Read General broadcasting rules and Broadcastable arrays, then matmul Notes for stacked matrices and one-dimensional promotion. These close the pool's array-semantics gap.

  • Fundamentals of Numerical Computation: conditioning and operation countsDriscoll & Braun · reference

    Python edition, section 2.8 through Residual and backward error for the fixed-matrix perturbation bound; section 2.5.3 for triangular-solve and LU flop counts. Use Exercise 2.8.7 for a condition-number proof, not the unseeded Hilbert experiment.