1.1.15Linear Algebra Essentials

Singular Value Decomposition (SVD) intuition and computation

1,784 words8 min readdifficulty · medium

WHAT is SVD?

WHY does this always exist (unlike eigendecomposition, which needs a square, diagonalizable matrix)? Because we build it from AAA^\top A and AAAA^\top, which are always symmetric and positive semidefinite, so they always have a full set of orthonormal eigenvectors with non-negative eigenvalues.


HOW to derive it from scratch

We want orthonormal directions that AA maps to orthogonal directions.

Step 1 — Look at AAA^\top A. It is symmetric ((AA)=AA (A^\top A)^\top = A^\top A) and PSD (xAAx=Ax20x^\top A^\top A x = \|Ax\|^2 \ge 0). By the spectral theorem it has orthonormal eigenvectors v1,,vnv_1,\dots,v_n with eigenvalues λi0\lambda_i \ge 0: AAvi=λivi.A^\top A\, v_i = \lambda_i v_i.

Why this step? Symmetric PSD ⇒ guaranteed orthonormal eigenbasis and non-negative eigenvalues — exactly the raw materials we need.

Step 2 — Define singular values. σi=λi 0.\sigma_i = \sqrt{\lambda_i}\ \ge 0.

Why? λi=Avi2\lambda_i = \|Av_i\|^2 (see below), so σi=Avi\sigma_i = \|Av_i\| — a length, hence non-negative. This is where the "stretch factor" lives.

Check: Avi2=(Avi)(Avi)=viAAvi=viλivi=λi.\|Av_i\|^2 = (Av_i)^\top(Av_i) = v_i^\top A^\top A v_i = v_i^\top \lambda_i v_i = \lambda_i.

Step 3 — Define left singular vectors. For σi>0\sigma_i > 0 set ui=1σiAvi.u_i = \frac{1}{\sigma_i} A v_i.

Why? This normalizes AviAv_i to unit length. And they come out orthonormal: uiuj=1σiσjviAAvj=λjσiσjvivj=δij.u_i^\top u_j = \frac{1}{\sigma_i\sigma_j} v_i^\top A^\top A v_j = \frac{\lambda_j}{\sigma_i\sigma_j} v_i^\top v_j = \delta_{ij}.

Step 4 — Reassemble. Avi=σiuiAv_i = \sigma_i u_i for every ii means, stacking columns, AV=UΣA=UΣVA V = U\Sigma \quad\Rightarrow\quad A = U\Sigma V^\top (using V1=VV^{-1}=V^\top since VV is orthogonal). ∎


Figure — Singular Value Decomposition (SVD) intuition and computation

Dual coding: the unit circle (right singular vectors viv_i) → mapped by AA → an ellipse whose axes are σiui\sigma_i u_i.


Geometric reading (the picture)

A=UΣVA = U\Sigma V^\top acts on a vector xx right-to-left:

  1. VV^\top rotates xx to align with the singular directions.
  2. Σ\Sigma stretches axis ii by factor σi\sigma_i (turns the sphere into an ellipsoid).
  3. UU rotates the result into the output space.

Worked example 1 — a 2×22\times 2 matrix

Let A=(3002)A=\begin{pmatrix}3 & 0\\ 0 & -2\end{pmatrix}.

Step 1: AA=(9004)A^\top A = \begin{pmatrix}9&0\\0&4\end{pmatrix}. Why? We always start from AAA^\top A. Step 2: eigenvalues 9,49,4σ1=3, σ2=2\sigma_1=3,\ \sigma_2=2, with v1=e1,v2=e2v_1=e_1, v_2=e_2. Step 3: u1=13Av1=(1,0)u_1=\frac1{3}Av_1=(1,0), u2=12Av2=(0,1)u_2=\frac1{2}Av_2=(0,-1). Why the sign? Av2=(0,2)Av_2=(0,-2), so normalizing flips it — SVD absorbs the sign into UU, keeping σ>0\sigma>0. Result: U=(1001), Σ=(3002), V=IU=\begin{pmatrix}1&0\\0&-1\end{pmatrix},\ \Sigma=\begin{pmatrix}3&0\\0&2\end{pmatrix},\ V=I.


Worked example 2 — a non-square, rank-1 matrix

Let A=(111111)A=\begin{pmatrix}1&1\\1&1\\1&1\end{pmatrix} (3×23\times 2).

Step 1: AA=(3333)A^\top A=\begin{pmatrix}3&3\\3&3\end{pmatrix}. Why? Column-column dot products. Step 2: eigenvalues of (3333)\begin{pmatrix}3&3\\3&3\end{pmatrix} are 66 and 00σ1=6, σ2=0\sigma_1=\sqrt6,\ \sigma_2=0. Rank 1! Eigenvector for 66: v1=12(1,1)v_1=\frac1{\sqrt2}(1,1). Step 3: u1=16Av1=1612(2,2,2)=13(1,1,1)u_1=\frac1{\sqrt6}Av_1=\frac1{\sqrt6}\cdot\frac1{\sqrt2}(2,2,2)=\frac1{\sqrt3}(1,1,1). Why? Av1=12(2,2,2)Av_1=\frac1{\sqrt2}(2,2,2); dividing by σ1=6\sigma_1=\sqrt6 gives a unit vector. Result: A=6u1v1A=\sqrt6\,u_1 v_1^\top — a single rank-1 term, as expected.


The 80/20: what SVD is FOR


Common mistakes (steel-manned)


Active recall

Recall Feynman: explain it to a 12-year-old

Imagine a stamp that squishes a round blob of dough into an oval pancake. SVD says the stamp does three tidy things in a row: spin the blob, stretch it more one way than another, then spin it again. The stretch amounts (how long the oval's arms are) are the singular values. If one stretch is tiny, you can pretend it's zero and still have almost the same pancake — that's how computers shrink photos.


Flashcards

What are the three geometric actions in A=UΣVA=U\Sigma V^\top?
Rotate (VV^\top), stretch along axes (Σ\Sigma), rotate again (UU).
How do you compute the singular values of AA?
Take the square roots of the eigenvalues of AAA^\top A (equivalently AAAA^\top).
Why are singular values always non-negative?
They equal Avi=λi(AA)\|Av_i\|=\sqrt{\lambda_i(A^\top A)}, a length, so 0\ge 0; signs are absorbed into U,VU,V.
Where do the right singular vectors viv_i come from?
Orthonormal eigenvectors of AAA^\top A.
Given viv_i and σi>0\sigma_i>0, how do you get uiu_i?
ui=1σiAviu_i=\tfrac{1}{\sigma_i}Av_i.
Why does SVD exist for every matrix but eigendecomposition doesn't?
AAA^\top A is always symmetric PSD, so the spectral theorem always applies.
State the best rank-kk approximation of AA.
Ak=i=1kσiuiviA_k=\sum_{i=1}^k \sigma_i u_i v_i^\top (Eckart–Young); error =σk+1=\sigma_{k+1}.
How is SVD related to PCA?
For centered X=UΣVX=U\Sigma V^\top, columns of VV are principal directions and σi2/(m1)\sigma_i^2/(m-1) are the variances.
What is σ1\sigma_1 geometrically?
The longest semi-axis of the image ellipsoid = maxx=1Ax\max_{\|x\|=1}\|Ax\| = operator (spectral) norm.
When does SVD coincide with eigendecomposition?
When AA is symmetric positive semidefinite.

Connections

  • Eigenvalues and Eigenvectors — SVD is built from eigenpairs of AAA^\top A.
  • Spectral Theorem — guarantees the orthonormal eigenbasis SVD relies on.
  • Principal Component Analysis (PCA) — direct application of VV and σi2\sigma_i^2.
  • Orthogonal Matrices — why U,VU,V preserve length (pure rotations/reflections).
  • Matrix NormsA2=σ1\|A\|_2=\sigma_1, AF=σi2\|A\|_F=\sqrt{\sum\sigma_i^2}.
  • Pseudoinverse (Moore–Penrose)A+=VΣ+UA^+ = V\Sigma^+U^\top.
  • Rank of a Matrix — rank = number of nonzero singular values.

Concept Map

factored as

contains

contains

contains

spectral theorem gives

eigenvalues lambda

sigma = sqrt lambda

u = Av over sigma

geometric reading

rank r truncation

ordered by

always PSD ensures

Matrix A

A = U Sigma V-transpose

U orthogonal - left singular vectors

Sigma - singular values

V orthogonal - right singular vectors

A-transpose A symmetric PSD

Stretch factors

Rotate then stretch then rotate

Sum of rank-1 pieces

SVD always exists

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, SVD ka core idea bahut simple hai: koi bhi matrix AA — chahe square ho ya rectangle, invertible ho ya na ho — hamesha teen chhote steps mein toota ja sakta hai: pehle ek rotation (VV^\top), phir har axis ke along ek stretch (Σ\Sigma), aur phir ek aur rotation (UU). Bas yehi hai A=UΣVA = U\Sigma V^\top. Agar aap ek gol circle ko is matrix se transform karo, toh woh ek ellipse ban jaata hai, aur us ellipse ki arms ki lengths hi hamare singular values σi\sigma_i hain. Sabse badi arm σ1\sigma_1 batati hai ki matrix kitna zyada se zyada stretch kar sakta hai.

Compute kaise karein? Simple recipe: AAA^\top A banao (yeh hamesha symmetric aur positive semidefinite hota hai, isliye iske orthonormal eigenvectors hamesha milte hain). Uske eigenvalues ka square root le lo — woh σi\sigma_i ban gaye. Eigenvectors viv_i ban gaye (right singular vectors). Phir ui=1σiAviu_i = \frac{1}{\sigma_i} A v_i se left singular vectors nikal lo. Bas SVD ready. Yaad rakho — singular values kabhi negative nahi hote, kyunki woh ek length hai; koi bhi minus sign UU ya VV ke andar chhup jaata hai.

Yeh matter kyun karta hai? Kyunki SVD ke top kk terms lene se aapko matrix ka best rank-kk approximation milta hai (Eckart–Young theorem). Yani agar σ\sigma chhote hain toh unhe throw kar do — data ka bahut kam loss hoga. Yehi PCA ka dil hai, image compression, noise removal, aur recommender systems sab isi par chalte hain. ML mein jab bhi "dimensionality reduction" ya "low-rank" suno, samajh lo SVD peeche kaam kar raha hai.

Ek chhota sa warning: SVD ko eigendecomposition ke saath confuse mat karna. Eigendecomposition square aur diagonalizable matrix maangta hai, aur eigenvalues negative bhi ho sakte hain. SVD har matrix pe kaam karta hai, hamesha orthogonal U,VU,V deta hai, aur σ0\sigma \ge 0. Dono sirf tab same hote hain jab AA symmetric PSD ho.

Test yourself — Linear Algebra Essentials

Connections