Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Low-Rank Approximation with SVD

Introduction

In our last lesson, we developed a complete algebraic algorithm for computing the Singular Value Decomposition (SVD), , by leveraging the eigendecomposition of the symmetric matrix . We now understand not only the geometric meaning of SVD as a sequence of rotation-scaling-rotation but also the precise method for finding the matrices , , and .

Today, we delve into one of the most consequential applications of SVD: low-rank approximation. The central idea is to find a "simpler" matrix of a lower rank that is as close as possible to our original matrix. This technique is the mathematical engine behind a vast array of methods, from data compression and dimensionality reduction to optimizing performance-critical operations in computer graphics. For you, this concept forms the bridge between classical linear algebra and the modern idea of learning compressed or "latent" representations in neural networks like autoencoders.

SVD as a Sum of Rank-One Matrices

To understand how SVD enables approximation, we first need to look at its structure from a different perspective. Instead of viewing as a product of three matrices, we can expand it into a sum.

Let's write out the matrices: has columns , has columns (so has rows ), and has diagonal entries . The product can be expressed as:

where is the rank of matrix . Each term in this sum, , is an outer product of two vectors. An column vector multiplied by a row vector results in an matrix.

Question: What is the rank of a matrix formed by the outer product of two non-zero vectors, like ? Why?

Answer The rank is exactly **one**. Every column of the resulting matrix is just the vector $\vec{u}_i$ scaled by a different element of $\vec{v}_i^T$. Therefore, all columns are linearly dependent on a single vector, $\vec{u}_i$, meaning the column space has a dimension of one.

This means the SVD elegantly decomposes any matrix into a weighted sum of rank-one matrices. The singular values , which are sorted in descending order (), act as the weights. This tells us that the first term, , is the most significant rank-one component of the matrix. The second term is the next most significant, and so on.

Let's watch a clear explanation of this expansion.

Singular Value Decomposition (SVD): Matrix Approximation

Professor Steve Brunton provides an excellent visual and algebraic breakdown of this concept in his lecture on SVD.

Watch the segment from this expansion. Focus on how the matrix multiplication U\Sigma V^T naturally unfolds into the sum of outer products. He also provides a great intuition for why an outer product results in a rank-one matrix.

Truncated SVD and the "Best" Approximation

Now that we see as a sum of weighted components, the idea of approximation becomes natural. If the singular values drop off in magnitude quickly, perhaps we can get a very good approximation of by keeping only the first few, most significant terms and discarding the rest.

This is the core idea of low-rank approximation. We can create an approximation of , let's call it , by truncating the sum after terms, where :

This is equivalent to forming the matrix product using only the first singular values and their corresponding singular vectors:

where contains the first columns of , is the top-left block of , and contains the first columns of . Since is a sum of rank-one matrices, its rank is at most .

This diagram shows the full SVD, M = UΣV*. You can imagine the low-rank approximation as taking only the components associated with the largest singular value, σ₁, and ignoring the components associated with σ₂.

This is an approximation, but is it a good one? In fact, it is the best possible approximation of rank . This remarkable result is formalized by the Eckart-Young-Mirsky Theorem.

The theorem addresses the following optimization problem: find the matrix of rank that is "closest" to . We measure "closeness" using the Frobenius norm, which is the matrix equivalent of the Euclidean vector norm:

The theorem states that the rank- matrix that minimizes this error is precisely the truncated SVD, .

To formalize this, let's turn to a set of lecture notes that states the theorem and provides the proof from first principles.

Lecture 19: Low Rank Approximation and the Singular ...

These notes from a Princeton course on Advanced Algorithm Design provide a rigorous treatment of low-rank approximation.

First, read the introduction and the section on low-rank approximation on pages 1-2. This will formally define the problem and the Frobenius norm. Next, read Section 3, The Singular Value Decomposition, and the statement of Claim 2 on page 5. This is the formal statement of the Eckart-Young Theorem. For a deeper, first-principles understanding, I encourage you to read the full proof of Claim 2 on pages 6-7. It builds from the rank-1 case and uses the Pythagorean theorem for matrices to extend to the general rank-k case. It's a beautiful piece of linear algebra.

The Eckart-Young theorem is profound. It guarantees that we don't need to search through the infinite space of all possible rank- matrices. The optimal solution is handed to us directly by the SVD.

This diagram shows the concept of approximating a matrix M as the product of two 'thin' matrices, Lₖ and Rₖᵀ. This is exactly what truncated SVD gives us, where Lₖ = UₖΣₖ and Rₖᵀ = Vₖᵀ, resulting in a compressed representation.

Application 1: Image Compression

A classic and highly intuitive application of low-rank approximation is image compression. A grayscale image can be represented as a matrix where each entry is a pixel's intensity. A color image can be three such matrices (for Red, Green, and Blue channels).

By taking the SVD of an image matrix and keeping only the top singular components, we can reconstruct an approximation of the image. The compression comes from the storage requirements. To store the full image, we need numbers. To store the rank- approximation, we need to store (), ( values), and (), for a total of values. If is small, this is a substantial saving.

Let's see this in action.

SVD: Image Compression [Python]

Returning to Steve Brunton's channel, this video provides a Python demonstration of image compression with SVD.

First, watch the introduction from 01:10 to 02:34 to see how the low-rank approximation concept is applied to an image. Next, see the results from 04:15 to 07:34. Observe the quality of the reconstructed image using approximations of rank 5, 20, and 100. Notice how quickly the main features of the image emerge. Finally, examine the plot of singular values from 07:41 to 09:35. The rapid decay of singular values is key. It indicates that most of the image's "energy" or information is captured by the first few modes, making it highly compressible.

Application 2: Approximating Filters in Computer Graphics

This application connects directly to your interests in graphics and high-performance systems. In image processing, we often apply 2D filters (kernels) to an image to achieve effects like blurring, sharpening, or edge detection. This is done via a 2D convolution.

A filter is called separable if it can be written as the outer product of two 1D vectors (a column and a row). Applying a separable filter is much faster than a non-separable one. Instead of operations per pixel, we can perform two passes with operations each, reducing the complexity from to .

This is a linear algebra problem in disguise: a filter matrix is separable if and only if it has a rank of one.

What can we do for non-separable filters, like a circular or hexagonal kernel used for simulating camera bokeh? We can use SVD to find the best rank-1 approximation, which gives us the closest possible separable filter.

If the rank-1 approximation isn't good enough, we can use a rank- approximation. This corresponds to summing independent separable filters. This is still vastly more efficient than a full 2D convolution if is small.

The following blog post from a graphics engineer provides an excellent, practical overview.

Separate your filters! Separability, SVD and low-rank approximation ...

This post by Bartosz Wronski, a professional graphics programmer, explores using SVD to approximate image filters.

Start by reading the introduction to understand the performance benefits of separable filters. Then, read from Linear algebra to the rescue to see how the problem is framed in terms of SVD and rank. Skim the simple examples and jump to the section on Non-separable filters. Now, read the core section on higher-rank approximations. Pay close attention to the plot of cumulative singular values—it tells you how much "energy" is captured by a rank-k approximation. Finally, look at the visual results to see how these approximations perform on a real image, simulating bokeh. This highlights the trade-off between performance (rank) and quality.

Conclusion

In this lesson, we have unlocked a truly powerful application of the SVD. By re-interpreting the decomposition as a weighted sum of rank-one matrices, we developed the idea of low-rank approximation by truncating this sum.

Key Takeaways:

  • SVD as a Sum: Any matrix can be decomposed into , a sum of rank-one matrices weighted by their singular values.
  • Optimal Approximation: The Eckart-Young-Mirsky theorem guarantees that the best rank- approximation of a matrix (in the Frobenius norm sense) is given by the truncated SVD, .
  • Concentration of Energy: The rapid decay of singular values for many real-world matrices (like images) means that a low-rank approximation can capture most of the original information with significantly less data.
  • Practical Applications: This principle is the foundation for data compression (images, signals) and performance optimization in domains like computer graphics (filter approximation).

We are now nearing the end of our foundational module on linear algebra. In the next lesson, we will cover our final topic in this area: orthogonal projection. This concept is not only geometrically elegant but also provides the direct solution to the fundamental problem of Ordinary Least Squares, which will be our entry point into the world of optimization. Following that, we will briefly touch on Principal Component Analysis (PCA) as a self-study topic, as it is a direct application of the eigendecomposition and low-rank approximation concepts we've mastered.

Can't find a good explanation? Sign up and we'll make it for you

Sign up