Singular Value Decomposition (SVD)

The one-line intuition

Eigendecomposition rotates, stretches, and rotates back (A=QΛQ1 — same basis both sides).
SVD rotates from one basis, stretches, and rotates into a possibly different basis (A=UΣV). That freedom to use two different bases is exactly what lets SVD handle rectangular matrices.

Understanding Singular Value Decomposition (SVD)

SVD is a powerful matrix decomposition technique that decomposes a matrix A into three components to extract its fundamental structure and insights. For a given matrix X (of size m×n):
ML_AI/images/svd-1.png500

Each of these components has a specific role in describing the structure and action of the matrix.

1. Left Singular Vectors (U from AAT)

Mathematical Insight:

Role:

Properties:

2. Right Singular Vectors (V from AA)

Mathematical Insight:

Role

Properties:

3. Singular Values (Σ)

Mathematical Insight:

σ1σ20

Role:

Properties:

4. Mutual Properties of SVD (Orthonormal Bases & Vector Spaces)

Geometric Interpretation of SVD

SVD explains Ax (applying matrix A to vector x) as three sequential transformations:

Ax=U3. rotateΣ2. stretchV1. rotatex

ML_AI/images/svd-2.png500

Physical Steps, Right-to-Left:

  1. V — Rotate the Input:
    Align the incoming vector (x) with the "natural input axes" (vi, the right singular vectors).

  2. Σ — Stretch:
    Scale each of the input axes by the singular values (σi). This step changes the lengths of vectors, i.e., the magnitude of stretching or shrinking.

  3. U — Rotate the Output:
    Reorient the stretched input vector (Σx), turning it into the "natural output axes" (ui, the left singular vectors).

Derivation: Where U, Σ, and V Come From

The Trick — Turn a Rectangular Matrix Into a Symmetric One

The problem with a general m×n matrix A is that it is not square, so it has no eigenvectors of its own. The insight behind SVD is simple: multiply A by its own transpose to manufacture a symmetric, square matrix that does have well-behaved eigenvectors.

There are two ways to do this, and each hands us one half of the decomposition:

AA(size n×n)AA(size m×m)

Both are symmetric ((AA)=AA) and positive semi-definite, so by the spectral theorem each has real, non-negative eigenvalues and a full set of orthogonal eigenvectors.

Assembling the Three Factors

Start from the claim A=UΣV and see what AA becomes. Because UU=I (the columns of U are orthonormal):

AA=(UΣV)(UΣV)=VΣUUΣV=V(ΣΣ)diagonalV

Compare this with the eigendecomposition AA=QΛQ1 (and note Q1=Q since Q is orthogonal). Term by term:

SVD factor Comes from Meaning
V (right singular vectors) eigenvectors of AA natural axes of the input space
ΣΣ=Λ eigenvalues of AA, so σi=λi how much each axis stretches
U (left singular vectors) eigenvectors of AA (equivalently ui=1σiAvi) natural axes of the output space

That is the whole derivation. SVD is just two coupled eigendecompositions — one for the input space (AA) and one for the output space (AA) — stitched together by the singular values.

This is the eigenvector → SVD bridge

The right singular vectors are literally the eigenvectors of AA. So if you already understand eigendecomposition, you already understand SVD — you are just eigendecomposing AA and taking square roots of the eigenvalues.

Worked Example — SVD, Step by Step

Let us decompose:

A=[3045]

Step 1 — Form AA

AA=[3405][3045]=[25202025]

Step 2 — Eigenvalues of AA (→ singular values)

Solve det(AAλI)=0:

(25λ)2202=0(25λ)2=40025λ=±20λ1=45,λ2=5

The singular values are the square roots:

σ1=45=356.708,σ2=52.236

Sanity check: the product of singular values equals |detA|. Here σ1σ2=455=225=15, and |detA|=|3504|=15

Step 3 — Right singular vectors V (eigenvectors of AA)

For λ1=45: solve (AA45I)v=0:

[20202020]v=0x=yv1=12[11]

For λ2=5: solve (AA5I)v=0:

[20202020]v=0x=yv2=12[11]V=12[1111]

Step 4 — Left singular vectors U (via ui=1σiAvi)

u1=1σ1Av1=135[3045]12[11]=1310[39]=110[13]u2=1σ2Av2=15[3045]12[11]=110[31]U=110[1331]

Step 5 — Assemble and verify A=UΣV

A=110[1331]U[35005]Σ12[1111]V

Multiplying UΣ first, then V, reproduces [3045]=A ✓. The matrix A takes the unit circle and stretches it into an ellipse with semi-axes 6.708 and 2.236.

Applications & Practical Use

Low-Rank Approximation — The Superpower

Because the singular values are sorted σ1σ2, the first few terms of the SVD carry most of the "energy" of the matrix. We can throw away the rest and keep an excellent approximation. Writing SVD as a sum of rank-1 pieces:

A=i=1rσiuivii=1kσiuivi(kr)

Keeping only the top k terms gives the best possible rank-k approximation of A (the Eckart–Young theorem). This single idea powers most SVD applications:

Application How SVD is used
Dimensionality reduction / PCA Keep the top-k right singular vectors as the new feature axes
Image compression Store only the top-k singular values/vectors instead of every pixel
Recommender systems Factor the sparse user–item matrix; latent factors = singular vectors
Latent Semantic Analysis (NLP) SVD of a term–document matrix reveals hidden topics
Noise reduction / denoising Small singular values usually correspond to noise — drop them
Solving least-squares / pseudo-inverse The Moore–Penrose pseudo-inverse is built directly from the SVD
Quick intuition — image compression

A grayscale image is just a matrix of pixel intensities. Its SVD often has a handful of large singular values and a long tail of tiny ones. Reconstructing with only the top ~50 singular values (out of, say, 1000) can look nearly identical to the eye while storing a fraction of the numbers — that is lossy compression, powered entirely by dropping small σi.

When to Reach for SVD?

Common Questions & Answers

Q1. How PCA and SVD Differ

They compute the same directions, but they are not interchangeable in practice. The differences matter.

Aspect PCA SVD
What it operates on The covariance matrix C=1n1XX The data matrix X directly
Requires centering? Yes — data must be mean-centered (and usually standardized) No — works on any matrix; centering is optional and only needed to make it equal PCA
Matrix shape Needs a square, symmetric covariance matrix Works on any m×n matrix
Numerical stability Forming XX squares the condition number → precision loss Operates on Xfar more stable and accurate
Output Eigenvectors (PCs) + eigenvalues (variance) U, Σ, V — richer: gives both row-space and column-space axes
Scope A specific application (variance-maximizing projection) A general matrix factorization — PCA is one of its many uses
The punchline

PCA is SVD in disguise. The principal components (W) are exactly the right singular vectors (V), and the PCA eigenvalues are the singular values squared (scaled by n1). Running SVD on centered data gives you PCA — without ever building the covariance matrix.

Practical takeaway

Real libraries (scikit-learn's PCA, NumPy, etc.) implement PCA using SVD under the hood, precisely because forming the covariance matrix throws away numerical precision. So even when you call PCA, SVD is usually doing the work.

One more distinction: eigenvalues vs. singular values

This is worth repeating because it trips people up. Eigenvalues can be negative or complex (they describe how a square matrix scales a direction, sign included). Singular values are always 0 (they are lengths of ellipse axes). See the "Common Pitfall" callout above.

Q2. How SVD Orders Importance?

In Singular Value Decomposition (A=UΣVT), the "importance" of each singular vector is directly dictated by its corresponding singular value (σi).

By mathematical convention, the singular values in the diagonal matrix Σ are always sorted in descending order:

σ1σ2σ3σr>0

Because the matrices U (left singular vectors) and V (right singular vectors) are ordered to match the columns and rows of Σ, they automatically inherit this exact same hierarchy:

Q3. Why Are Singular Values (σ) Never Negative?

There are two primary ways to understand why σ0: geometrically (as a physical length) and algebraically (through the eigenvalues of a symmetric matrix).

1. Geometrically: Scaling Factors Cannot Be Negative

Singular values represent the lengths of the principal semi-axes of the hyper-ellipsoid mapped by the matrix.

2. Algebraically: They Are Square Roots of Positive Eigenvalues

The right singular vectors vi are the eigenvectors of the matrix ATA. Let's look at the eigenvalue equation for ATA:

(ATA)vi=λivi

Because ATA is a symmetric, positive semi-definite matrix, its eigenvalues λi are mathematically guaranteed to be non-negative (λi0).

The singular values σi are defined as the square roots of these eigenvalues:

σi=λi

Since we always take the principal (positive) square root of a non-negative number λi, σi is strictly non-negative (σi0).

Q4. What is "Thin" or "Truncated" or "Reduced" SVD?

In practical computer science and data science applications (like PCA or image compression), we often use a variation called Thin SVD (or Reduced SVD).

If A is a tall matrix (m>n), we don't actually need all m left singular vectors because many of them will just multiply by zeros in Σ. In Thin SVD: