Singular Values & the SVD

Study Sheet

Singular Values & the SVD

Every matrix is rank-one layers, sorted by importance

The Master Decomposition

Tip
Singular values: stretch factors for ANY matrix
Av₁v₂σ₁u₁σ₂u₂
A = [[2, 2], [−1, 1]] turns the unit circle into an ellipse with half-axes σ₁ = 2√2 and σ₂ = √2.

Eigenvalues need square matrices and can be complex. Singular values exist for every matrix and are real and nonnegative: σi=λi(ATA)\sigma_i = \sqrt{\lambda_i(A^{\mathsf T}A)}. This is legal because ATAA^{\mathsf T}A is symmetric with xTATAx=∣Ax∣2≥0\mathbf x^{\mathsf T}A^{\mathsf T}A\mathbf x = |A\mathbf x|^2 \ge 0, so its eigenvalues are real and nonnegative.

Meaning: σ1\sigma_1 is the largest stretch AA applies to any unit vector; the number of nonzero σ\sigma's is the rank; and ∑σi2\sum\sigma_i^2 equals the sum of squares of all entries. The unit circle maps to an ellipse with semi-axes σ1,σ2\sigma_1, \sigma_2 — every matrix, however ugly, is geometrically just rotate–stretch–rotate. Example: A=(22−11)A = \begin{pmatrix}2&2\\-1&1\end{pmatrix} has ATA=(5335)A^{\mathsf T}A = \begin{pmatrix}5&3\\3&5\end{pmatrix} with eigenvalues 88 and 22, so σ1=22\sigma_1 = 2\sqrt2 and σ2=2\sigma_2 = \sqrt2. The unit vector v1=12(1,1)\mathbf v_1 = \tfrac{1}{\sqrt2}(1, 1) goes to (22,0)(2\sqrt2, 0) and v2=12(1,−1)\mathbf v_2 = \tfrac{1}{\sqrt2}(1, -1) goes to (0,−2)(0, -\sqrt2): perpendicular in, perpendicular out, stretched by σ1\sigma_1 and σ2\sigma_2.

Tip
The SVD and best low-rank approximation

The singular value decomposition writes A=∑iσi uiviTA = \sum_i \sigma_i\,\mathbf u_i\mathbf v_i^{\mathsf T}: a sum of rank-one layers, ordered by importance σ1≥σ2≥⋯\sigma_1 \ge \sigma_2 \ge \cdots. The Eckart–Young theorem: keeping just the first kk layers gives the best possible rank-kk approximation, with error exactly σk+1\sigma_{k+1}.

This is data compression as a theorem: an image is a matrix, most of its singular values are tiny, and storing a few layers reproduces it almost perfectly. Principal component analysis is the same truncation applied to centered data — "find the directions that matter, drop the rest."

Side note
Eigen vs. singular: when they agree

For symmetric positive-definite matrices, singular values are the eigenvalues; for the diagonal matrix diag(3,−4)\mathrm{diag}(3, -4) they are the absolute values 3,43, 4 — stretch has no sign. For a genuinely non-symmetric matrix the two sets differ, and the singular values are the honest geometry: a matrix with all eigenvalues zero (nilpotent) can still stretch vectors enormously, and its σ1\sigma_1 says by how much.

Try it
Try it: a rank-one matrix bare-handed

Find the singular values of A=(2412)A = \begin{pmatrix}2&4\\1&2\end{pmatrix} without solving a characteristic equation.

Show the answer

The rows are proportional (row 1 is twice row 2), so AA has rank 11 and exactly one nonzero singular value: σ2=0\sigma_2 = 0. The sum of the squared singular values is the sum of the squared entries (both equal tr⁡(ATA)\operatorname{tr}(A^{\mathsf T}A)), so σ12=4+16+1+4=25\sigma_1^2 = 4 + 16 + 1 + 4 = 25 and σ1=5\sigma_1 = 5. Structure check: A=(21)(12)A = \begin{pmatrix}2\\1\end{pmatrix}\begin{pmatrix}1&2\end{pmatrix}, and a rank-one matrix abT\mathbf a\mathbf b^{\mathsf T} sends b/∣b∣\mathbf b/|\mathbf b| to a∣b∣\mathbf a|\mathbf b|, a stretch of ∣a∣ ∣b∣=5⋅5=5|\mathbf a|\,|\mathbf b| = \sqrt5\cdot\sqrt5 = 5 ✓.

Computing the SVD

Tip
A = UΣVᵀ, column by column

Every m×nm\times n matrix factors as A=UΣVTA = U\Sigma V^{\mathsf T}:

  • the columns vi\mathbf v_i of VV are orthonormal eigenvectors of ATAA^{\mathsf T}A (the input directions);
  • σi=λi(ATA)\sigma_i = \sqrt{\lambda_i(A^{\mathsf T}A)}, listed in decreasing order down the diagonal of Σ\Sigma;
  • for each σi>0\sigma_i > 0, ui=Avi/σi\mathbf u_i = A\mathbf v_i/\sigma_i (the output directions), completed to an orthonormal basis if needed.

The key fact is that the images AviA\mathbf v_i are automatically perpendicular: (Avi)⋅(Avj)=viT(ATAvj)=λj vi⋅vj(A\mathbf v_i)\cdot(A\mathbf v_j) = \mathbf v_i^{\mathsf T}(A^{\mathsf T}A\mathbf v_j) = \lambda_j\,\mathbf v_i\cdot\mathbf v_j, which is 00 for i≠ji \ne j and λi=σi2\lambda_i = \sigma_i^2 for i=ji = j. So AA takes one perpendicular set of directions to another, stretching by σi\sigma_i; AV=UΣAV = U\Sigma says exactly that, and multiplying by VTV^{\mathsf T} (which is V−1V^{-1}) gives A=UΣVTA = U\Sigma V^{\mathsf T}.

Example
Worked: a complete SVD

Find the SVD of A=(22−11)A = \begin{pmatrix}2&2\\-1&1\end{pmatrix}. ATA=(5335)A^{\mathsf T}A = \begin{pmatrix}5&3\\3&5\end{pmatrix} has eigenvalues 88 and 22, with unit eigenvectors v1=12(1,1)\mathbf v_1 = \tfrac{1}{\sqrt2}(1, 1) and v2=12(1,−1)\mathbf v_2 = \tfrac{1}{\sqrt2}(1, -1). So σ1=22\sigma_1 = 2\sqrt2 and σ2=2\sigma_2 = \sqrt2.

Output directions: Av1=12(4,0)A\mathbf v_1 = \tfrac{1}{\sqrt2}(4, 0), so u1=Av122=(1,0)\mathbf u_1 = \tfrac{A\mathbf v_1}{2\sqrt2} = (1, 0); Av2=12(0,−2)A\mathbf v_2 = \tfrac{1}{\sqrt2}(0, -2), so u2=Av22=(0,−1)\mathbf u_2 = \tfrac{A\mathbf v_2}{\sqrt2} = (0, -1). Assemble:

A=(100−1)(22002)12(111−1).A = \begin{pmatrix}1&0\\0&-1\end{pmatrix}\begin{pmatrix}2\sqrt2&0\\0&\sqrt2\end{pmatrix}\frac{1}{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}.

Check: ΣVT=(221−1)\Sigma V^{\mathsf T} = \begin{pmatrix}2&2\\1&-1\end{pmatrix}, and UU negates the second row, giving (22−11)\begin{pmatrix}2&2\\-1&1\end{pmatrix} ✓. Also σ1σ2=4=∣det⁡A∣\sigma_1\sigma_2 = 4 = |\det A| ✓.

Example
Worked: a rank-one matrix that is not square

Find the SVD of A=(112222)A = \begin{pmatrix}1&1\\2&2\\2&2\end{pmatrix}. Every column is a multiple of (1,2,2)(1, 2, 2), so A=(122)(11)A = \begin{pmatrix}1\\2\\2\end{pmatrix}\begin{pmatrix}1&1\end{pmatrix} has rank 11.

A rank-one product abT\mathbf a\mathbf b^{\mathsf T} has the single singular value ∣a∣ ∣b∣|\mathbf a|\,|\mathbf b|, here 3⋅2=323\cdot\sqrt2 = 3\sqrt2, with u1=a/∣a∣=13(1,2,2)\mathbf u_1 = \mathbf a/|\mathbf a| = \tfrac13(1, 2, 2) and v1=b/∣b∣=12(1,1)\mathbf v_1 = \mathbf b/|\mathbf b| = \tfrac{1}{\sqrt2}(1, 1):

A=32 u1v1T.A = 3\sqrt2\,\mathbf u_1\mathbf v_1^{\mathsf T}.

Check against ATA=(9999)A^{\mathsf T}A = \begin{pmatrix}9&9\\9&9\end{pmatrix}, whose eigenvalues are 1818 and 00: σ1=18=32\sigma_1 = \sqrt{18} = 3\sqrt2 ✓ and σ2=0\sigma_2 = 0. The sum of squared entries is 1+1+4+4+4+4=18=σ121 + 1 + 4 + 4 + 4 + 4 = 18 = \sigma_1^2 ✓.

Example
Worked: a shear stretches more than its eigenvalues say
Av₁v₂σ₁ = √2 + 1σ₂
The shear [[1, 2], [0, 1]] maps the unit circle to an ellipse with half-axes √2 + 1 and √2 − 1.

Find the singular values of the shear A=(1201)A = \begin{pmatrix}1&2\\0&1\end{pmatrix}, whose eigenvalues are 1,11, 1. ATA=(1225)A^{\mathsf T}A = \begin{pmatrix}1&2\\2&5\end{pmatrix} has trace 66 and determinant 11, so λ2−6λ+1=0\lambda^2 - 6\lambda + 1 = 0 and λ=3±22\lambda = 3 \pm 2\sqrt2.

Notice 3±22=(2±1)23 \pm 2\sqrt2 = (\sqrt2 \pm 1)^2, so σ1=2+1≈2.41\sigma_1 = \sqrt2 + 1 \approx 2.41 and σ2=2−1≈0.41\sigma_2 = \sqrt2 - 1 \approx 0.41. Their product is (2)2−1=1=∣det⁡A∣(\sqrt2)^2 - 1 = 1 = |\det A| ✓: the shear preserves area but squeezes the unit circle into a long thin ellipse. The eigenvalues 1,11, 1 only report that no direction is stretched without also being turned; the singular values report how much stretching actually happens.

Side note
Where it goes wrong: using the eigenvalues of A

Singular values are not the absolute values of the eigenvalues unless AA is symmetric. The shear above has eigenvalues 1,11, 1 but σ1=2+1\sigma_1 = \sqrt2 + 1: the unit vector v1\mathbf v_1 is stretched to length 2.412.41, which no eigenvalue predicts. Taking square roots of the eigenvalues of AA itself is also wrong — the square roots belong to the eigenvalues of ATAA^{\mathsf T}A.

Try it
Try it: circle to circle

Find the singular values of A=(1−221)A = \begin{pmatrix}1&-2\\2&1\end{pmatrix}, and describe what AA does to the unit circle.

Show the answer

ATA=(1+4−2+2−2+24+1)=(5005)=5IA^{\mathsf T}A = \begin{pmatrix}1 + 4&-2 + 2\\-2 + 2&4 + 1\end{pmatrix} = \begin{pmatrix}5&0\\0&5\end{pmatrix} = 5I. Both eigenvalues are 55, so σ1=σ2=5\sigma_1 = \sigma_2 = \sqrt5. Every unit vector is stretched by exactly 5\sqrt5: the unit circle goes to the circle of radius 5\sqrt5. In fact A=5 RA = \sqrt5\,R with R=15(1−221)R = \tfrac{1}{\sqrt5}\begin{pmatrix}1&-2\\2&1\end{pmatrix} a rotation by arctan⁡2≈63.4∘\arctan2 \approx 63.4^\circ. Consistency: σ1σ2=5=det⁡A\sigma_1\sigma_2 = 5 = \det A ✓. (Its eigenvalues are 1±2i1 \pm 2i, of modulus 5\sqrt5 — here, unusually, the two notions agree in size.)

Low-Rank Approximation in Practice

Tip
Keep the big layers, drop the small ones

Write A=σ1u1v1T+σ2u2v2T+⋯A = \sigma_1\mathbf u_1\mathbf v_1^{\mathsf T} + \sigma_2\mathbf u_2\mathbf v_2^{\mathsf T} + \cdots. The truncation AkA_k (first kk layers) is the best rank-kk approximation, with

∥A−Ak∥2=σk+1,∥Ak∥F2∥A∥F2=σ12+⋯+σk2σ12+σ22+⋯\|A - A_k\|_2 = \sigma_{k+1}, \qquad \frac{\|A_k\|_F^2}{\|A\|_F^2} = \frac{\sigma_1^2 + \cdots + \sigma_k^2}{\sigma_1^2 + \sigma_2^2 + \cdots}

the share of the total "energy" (sum of squared entries) that AkA_k keeps. Storing AkA_k for an m×nm\times n matrix takes k(m+n+1)k(m + n + 1) numbers instead of mnmn.

The layers are orthogonal to each other (their u\mathbf u's and v\mathbf v's are), so squared sizes add like Pythagoras: the squared entries of AA total ∑σi2\sum\sigma_i^2, and each discarded layer removes exactly its σi2\sigma_i^2. The largest stretch of A−AkA - A_k is the largest remaining singular value, σk+1\sigma_{k+1}. Each layer is one column ui\mathbf u_i (mm numbers), one row vi\mathbf v_i (nn numbers) and one weight — hence the storage count.

Example
Worked: the best rank-one approximation, written out

For A=(3045)A = \begin{pmatrix}3&0\\4&5\end{pmatrix}, ATA=(25202025)A^{\mathsf T}A = \begin{pmatrix}25&20\\20&25\end{pmatrix} has eigenvalues 4545 and 55 (worked in full at the end of the chapter), so σ1=35\sigma_1 = 3\sqrt5, σ2=5\sigma_2 = \sqrt5, and v1=12(1,1)\mathbf v_1 = \tfrac{1}{\sqrt2}(1, 1). The matching output direction is u1=Av1σ1=135⋅12(3,9)=110(1,3)\mathbf u_1 = \tfrac{A\mathbf v_1}{\sigma_1} = \tfrac{1}{3\sqrt5}\cdot\tfrac{1}{\sqrt2}(3, 9) = \tfrac{1}{\sqrt{10}}(1, 3).

So A1=σ1u1v1T=35⋅110⋅12(13)(11)=32(1133)A_1 = \sigma_1\mathbf u_1\mathbf v_1^{\mathsf T} = 3\sqrt5\cdot\tfrac{1}{\sqrt{10}}\cdot\tfrac{1}{\sqrt2}\begin{pmatrix}1\\3\end{pmatrix}\begin{pmatrix}1&1\end{pmatrix} = \tfrac32\begin{pmatrix}1&1\\3&3\end{pmatrix}. The error is A−A1=(32−32−1212)=(32−12)(1−1)A - A_1 = \begin{pmatrix}\tfrac32&-\tfrac32\\-\tfrac12&\tfrac12\end{pmatrix} = \begin{pmatrix}\tfrac32\\-\tfrac12\end{pmatrix}\begin{pmatrix}1&-1\end{pmatrix}, itself rank one, with singular value 94+14⋅2=5=σ2\sqrt{\tfrac94 + \tfrac14}\cdot\sqrt2 = \sqrt5 = \sigma_2 ✓ — Eckart–Young, visible in the numbers. The energies: A1A_1 has squared entries 94(1+1+9+9)=45\tfrac94(1 + 1 + 9 + 9) = 45 out of AA's 9+16+25=509 + 16 + 25 = 50.

Example
Worked: what compression saves

A grayscale image is a 100×100100\times100 matrix. Its singular values fall off quickly, and the first 1010 layers carry 99%99\% of the energy. How many numbers does the rank-1010 approximation need? Each layer stores ui\mathbf u_i (100100 numbers), vi\mathbf v_i (100100 numbers) and σi\sigma_i (11 number).

That is 10(100+100+1)=201010(100 + 100 + 1) = 2010 numbers instead of 100⋅100=10,000100\cdot100 = 10{,}000 — about 20%20\% of the storage, for an image that keeps 99%99\% of its energy (the relative Frobenius error is 0.01=10%\sqrt{0.01} = 10\%). The saving grows with size: for a 1000×10001000\times1000 image at rank 5050 the count is 50⋅2001=100,05050\cdot2001 = 100{,}050 numbers, about 10%10\% of a million.

Side note
Where it goes wrong: measuring energy with σ instead of σ²

For A=(3045)A = \begin{pmatrix}3&0\\4&5\end{pmatrix}, the rank-one layer's share is σ12σ12+σ22=4550=90%\tfrac{\sigma_1^2}{\sigma_1^2 + \sigma_2^2} = \tfrac{45}{50} = 90\%. Using the singular values themselves gives 3535+5=34=75%\tfrac{3\sqrt5}{3\sqrt5 + \sqrt5} = \tfrac34 = 75\%, which measures nothing: the squared entries of a matrix add up as ∑σi2\sum\sigma_i^2, not ∑σi\sum\sigma_i. And the spectral-norm error of AkA_k is σk+1\sigma_{k+1}, the first singular value dropped, not σk\sigma_k, the last one kept.

Try it
Try it: truncate to rank one

For A=(44−33)A = \begin{pmatrix}4&4\\-3&3\end{pmatrix}, find σ1\sigma_1, σ2\sigma_2, the best rank-one approximation A1A_1, and the fraction of energy it keeps.

Show the answer

ATA=(16+916−916−916+9)=(257725)A^{\mathsf T}A = \begin{pmatrix}16 + 9&16 - 9\\16 - 9&16 + 9\end{pmatrix} = \begin{pmatrix}25&7\\7&25\end{pmatrix}, with eigenvalues 3232 (along (1,1)(1, 1)) and 1818 (along (1,−1)(1, -1)). So σ1=32=42\sigma_1 = \sqrt{32} = 4\sqrt2 and σ2=18=32\sigma_2 = \sqrt{18} = 3\sqrt2. With v1=12(1,1)\mathbf v_1 = \tfrac{1}{\sqrt2}(1, 1): Av1=12(8,0)A\mathbf v_1 = \tfrac{1}{\sqrt2}(8, 0), so u1=(1,0)\mathbf u_1 = (1, 0). Then A1=42(10)12(11)=(4400)A_1 = 4\sqrt2\begin{pmatrix}1\\0\end{pmatrix}\tfrac{1}{\sqrt2}\begin{pmatrix}1&1\end{pmatrix} = \begin{pmatrix}4&4\\0&0\end{pmatrix} — the first row kept, the second dropped. The error (00−33)\begin{pmatrix}0&0\\-3&3\end{pmatrix} has singular value 32=σ23\sqrt2 = \sigma_2 ✓. Energy kept: 3232+18=3250=64%\tfrac{32}{32 + 18} = \tfrac{32}{50} = 64\%.

Proofs & Why It Matters

Tip
Proof: σ₁ is the maximum stretch

Maximize ∣Ax∣2=xT(ATA)x|A\mathbf x|^2 = \mathbf x^{\mathsf T}(A^{\mathsf T}A)\mathbf x over unit vectors x\mathbf x. That is a quadratic form in the symmetric matrix ATAA^{\mathsf T}A, and the previous topic proved its maximum on the unit sphere is the largest eigenvalue λ1(ATA)\lambda_1(A^{\mathsf T}A).

Take square roots: max⁡∣Ax∣=λ1=σ1\max|A\mathbf x| = \sqrt{\lambda_1} = \sigma_1. ■\blacksquare Significance: σ1\sigma_1 is the operator norm — it bounds how much a matrix can amplify errors, which is why σ1/σn\sigma_1/\sigma_n (the condition number) decides whether a linear system is numerically trustworthy. Every numerical analyst's first question about a matrix is about its singular values.

Side note
Where you have already met the SVD

Recommendation engines factor the user-movie ratings matrix into a few rank-one "taste" layers; latent semantic analysis does it to word-document counts; noise reduction truncates small singular values because noise spreads evenly across all of them while signal concentrates in the top few. The SVD is the closest thing linear algebra has to a universal tool.

Going Deeper: Worked Problems

Example
Worked: singular values of a non-square matrix

Find the singular values of A=(100111)A = \begin{pmatrix}1&0\\0&1\\1&1\end{pmatrix} (3×23\times2).

Step 1 — ATA=(2112)A^{\mathsf T}A = \begin{pmatrix}2&1\\1&2\end{pmatrix} (a 2×22\times2, so exactly two singular values).

Step 2 — its eigenvalues: trace 44, det 33: λ=3,1\lambda = 3, 1.

Step 3 — singular values σ1=3\sigma_1 = \sqrt3, σ2=1\sigma_2 = 1.

Step 4 — interpret: AA maps the plane into 3-space, stretching by 3\sqrt3 along (1,1)/2(1,1)/\sqrt2 and by 11 along (1,−1)/2(1,-1)/\sqrt2; the check σ12+σ22=4=\sigma_1^2 + \sigma_2^2 = 4 = sum of squared entries (1+0+0+1+1+11+0+0+1+1+1) ✓ confirms the arithmetic.

Example
Worked: how much a rank-one approximation loses
A√45√5
The unit circle and its image under [[3, 0], [4, 5]]: half-axes √45 ≈ 6.71 and √5 ≈ 2.24.

For A=(3045)A = \begin{pmatrix}3&0\\4&5\end{pmatrix}, find σ1,σ2\sigma_1, \sigma_2 and the error of the best rank-one approximation.

Step 1 — ATA=(25202025)A^{\mathsf T}A = \begin{pmatrix}25&20\\20&25\end{pmatrix}.

Step 2 — eigenvalues: trace 5050, det 225225: λ2−50λ+225=(λ−45)(λ−5)\lambda^2 - 50\lambda + 225 = (\lambda-45)(\lambda-5).

Step 3 — σ1=45=35≈6.71\sigma_1 = \sqrt{45} = 3\sqrt5 \approx 6.71, σ2=5≈2.24\sigma_2 = \sqrt5 \approx 2.24.

Step 4 — by Eckart–Young the best rank-one approximation errs by exactly σ2=5\sigma_2 = \sqrt5 in the spectral norm; the fraction of "energy" captured is σ12σ12+σ22=4550=90%\dfrac{\sigma_1^2}{\sigma_1^2 + \sigma_2^2} = \dfrac{45}{50} = 90\%. Sanity: σ1σ2=15=∣det⁡A∣\sigma_1\sigma_2 = 15 = |\det A| ✓ — the product of singular values is always the absolute determinant.