Tutorials › Linear Algebra › Constructing the Truncated SVD

Pseudoinverse and Low-Rank Approximation · Tutorial 818 of 1000

Constructing the Truncated SVD

Learn to build a truncated SVD and compute exactly how much Frobenius- and operator-norm error remains.

Advanced 9 min read

What You'll Learn

  • Write a rank-k truncated SVD using the k largest singular values and their singular vectors.
  • Identify how to handle k equal to zero, k equal to the rank, and ties among singular values.
  • Prove that the truncation has rank k when k does not exceed the matrix rank.
  • Derive the Frobenius-norm error from the sum of squares of discarded singular values.
  • Derive the operator-norm error from the largest discarded singular value.
  • Check a truncation by reconstructing the original matrix from the retained part and residual.

Keeping the Leading Singular Components

A singular value decomposition expresses a matrix as a sum of simple, structured pieces. The truncated SVD keeps only the pieces corresponding to the largest singular values. This gives a specific rank-limited matrix and a residual whose two common measures of size can be read directly from the discarded singular values. Here the goal is to construct that matrix and calculate its errors; deciding whether another rank-\(k\) matrix could do better is a separate question.

Work over \(\mathbb{R}\). Let \(\mathbf{A}\in\mathbb{R}^{m\times n}\) have rank \(r\). A compact singular value decomposition writes \(\mathbf{A}\) as

$$ \mathbf{A}=\sum_{i=1}^{r}\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}, \qquad \sigma_1\geq\sigma_2\geq\cdots\geq\sigma_r>0. $$

Here \(\mathbf{u}_1,\dots,\mathbf{u}_r\) are orthonormal columns in \(\mathbb{R}^m\), \(\mathbf{v}_1,\dots,\mathbf{v}_r\) are orthonormal columns in \(\mathbb{R}^n\), and \(\sigma_i\) are the positive singular values. Each summand \(\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}\) is one singular component of \(\mathbf{A}\). The integer \(k\) will satisfy \(0\leq k\leq r\).

Definition: The rank-\(k\) truncated SVD of \(\mathbf{A}\) is the matrix \(\mathbf{A}_k=\sum_{i=1}^{k}\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}\), formed by retaining the first \(k\) singular components in an ordering of the singular values from largest to smallest. For \(k=0\), the sum is empty and \(\mathbf{A}_0=\mathbf{O}\).

The residual is the part omitted from the truncation, \(\mathbf{E}_k=\mathbf{A}-\mathbf{A}_k\). For convenience, define \(\sigma_{r+1}=0\). This convention lets formulas for the largest discarded singular value also describe the case \(k=r\), when no positive singular values are discarded.

The Frobenius norm of a matrix \(\mathbf{B}=(b_{ij})\) is \(\|\mathbf{B}\|_F=\left(\sum_{i,j}b_{ij}^2\right)^{1/2}\). Its operator norm is \(\|\mathbf{B}\|_2=\max_{\|\mathbf{x}\|=1}\|\mathbf{B}\mathbf{x}\|\), where \(\|\mathbf{x}\|\) is the Euclidean norm. The Frobenius norm measures the combined size of all entries; the operator norm measures the largest amount by which the matrix stretches a unit vector.

Constructing and Checking a Truncation

A practical construction has three steps: order the singular values, retain the first \(k\) singular components, and subtract the retained matrix from the original to obtain the residual. Keeping whole components matters: the truncation is not made by deleting selected entries of \(\mathbf{A}\).

1
Order the SVD.
Write the positive singular values in nonincreasing order and keep their matching left and right singular vectors paired with them.
2
Retain the first \(k\).
Form \(\mathbf{A}_k=\sum_{i=1}^k\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}\). Do not retain a singular value without its corresponding vectors.
3
Compute the residual.
Use \(\mathbf{E}_k=\mathbf{A}-\mathbf{A}_k=\sum_{i=k+1}^r\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}\), then evaluate the desired norm.

Worked Example: Truncating a Diagonal Matrix

Let \(\mathbf{A}=\begin{bmatrix}5&0&0\\0&3&0\\0&0&1\end{bmatrix}\) and take \(k=1\). Its singular values are \(5,3,1\), with both sets of singular vectors equal to the standard basis vectors. Thus the first component is \(5\mathbf{e}_1\mathbf{e}_1^{\top}\), and

$$ \mathbf{A}_1 =5\begin{bmatrix}1\\0\\0\end{bmatrix} \begin{bmatrix}1&0&0\end{bmatrix} =\begin{bmatrix}5&0&0\\0&0&0\\0&0&0\end{bmatrix}. $$

The residual and its two errors are

$$ \mathbf{E}_1=\mathbf{A}-\mathbf{A}_1 =\begin{bmatrix}0&0&0\\0&3&0\\0&0&1\end{bmatrix}, \qquad \|\mathbf{E}_1\|_F=\sqrt{3^2+1^2}=\sqrt{10}, \qquad \|\mathbf{E}_1\|_2=3. $$

Check: adding the truncation and residual gives \(\mathbf{A}_1+\mathbf{E}_1=\begin{bmatrix}5&0&0\\0&3&0\\0&0&1\end{bmatrix}=\mathbf{A}\). The retained matrix is the product of its stated singular component, and the largest discarded singular value is \(3\), matching the operator-norm error.

Worked Example: A Rectangular Matrix

Consider the orthonormal columns \(\mathbf{u}_1=(1,0,0)^{\top}\), \(\mathbf{u}_2=(0,\tfrac35,\tfrac45)^{\top}\), and let \(\mathbf{v}_1=(1,0)^{\top}\), \(\mathbf{v}_2=(0,1)^{\top}\). With singular values \(4\) and \(2\), the SVD gives

$$ \mathbf{A}=4\mathbf{u}_1\mathbf{v}_1^{\top} +2\mathbf{u}_2\mathbf{v}_2^{\top} =\begin{bmatrix}4&0\\0&6/5\\0&8/5\end{bmatrix}. $$

For \(k=1\), retain the first outer product and leave the second out:

$$ \mathbf{A}_1=\begin{bmatrix}4&0\\0&0\\0&0\end{bmatrix}, \qquad \mathbf{E}_1=\begin{bmatrix}0&0\\0&6/5\\0&8/5\end{bmatrix}. $$

The errors are \(\|\mathbf{E}_1\|_F=\sqrt{(6/5)^2+(8/5)^2}=\sqrt{100/25}=2\), and \(\|\mathbf{E}_1\|_2=2\). For the latter, the residual maps \((x_1,x_2)^{\top}\) to \(x_2(0,\tfrac65,\tfrac85)^{\top}\), whose norm is \(2|x_2|\); the maximum over unit vectors is \(2\).

Check: \(\mathbf{A}_1+\mathbf{E}_1=\begin{bmatrix}4&0\\0&6/5\\0&8/5\end{bmatrix}=\mathbf{A}\), and the second column of \(\mathbf{A}\) is \(2\mathbf{u}_2\), as required by the SVD. The sole discarded singular value is \(2\), agreeing with both calculated errors.

Rank and Error Formulas

Theorem: Let \(\mathbf{A}\in\mathbb{R}^{m\times n}\) have compact SVD \(\mathbf{A}=\sum_{i=1}^r\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}\), with \(\sigma_1\geq\cdots\geq\sigma_r>0\), and let \(0\leq k\leq r\). Then \(\operatorname{rank}\mathbf{A}_k=k\), and \(\|\mathbf{A}-\mathbf{A}_k\|_F=\left(\sum_{i=k+1}^r\sigma_i^2\right)^{1/2}\) and \(\|\mathbf{A}-\mathbf{A}_k\|_2=\sigma_{k+1}\), using \(\sigma_{r+1}=0\).

Proof. The columns of \(\mathbf{A}_k\) lie in \(\operatorname{span}\{\mathbf{u}_1,\dots,\mathbf{u}_k\}\), because each summand has its columns proportional to one of those vectors. For \(1\leq j\leq k\), orthonormality of the \(\mathbf{v}_i\) gives \(\mathbf{A}_k\mathbf{v}_j=\sigma_j\mathbf{u}_j\). Since \(\sigma_j>0\) and the \(\mathbf{u}_j\) are orthonormal, these \(k\) images are linearly independent. Therefore the column space has dimension \(k\), so \(\operatorname{rank}\mathbf{A}_k=k\). If \(k=0\), \(\mathbf{A}_0=\mathbf{O}\) has rank \(0\), giving the same conclusion.

Write the residual as \(\mathbf{E}_k=\sum_{i=k+1}^r\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}\). In the Frobenius inner product, the inner product of two matrices \(\mathbf{B},\mathbf{C}\) of the same size is the sum of the products of corresponding entries. Direct expansion gives \(\langle\mathbf{u}_i\mathbf{v}_i^{\top},\mathbf{u}_j\mathbf{v}_j^{\top}\rangle_F=(\mathbf{u}_i^{\top}\mathbf{u}_j)(\mathbf{v}_i^{\top}\mathbf{v}_j)\). For \(i\ne j\), this is zero; for \(i=j\), it is \(1\). Consequently, the squared Frobenius norm of the residual is the sum of the squares of its coefficients, \(\|\mathbf{E}_k\|_F^2=\sum_{i=k+1}^r\sigma_i^2\), proving the stated formula, including the empty sum when \(k=r\).

For a unit vector \(\mathbf{x}\in\mathbb{R}^n\), \(\mathbf{E}_k\mathbf{x}=\sum_{i=k+1}^r\sigma_i(\mathbf{v}_i^{\top}\mathbf{x})\mathbf{u}_i\). Orthonormality of the \(\mathbf{u}_i\) gives \(\|\mathbf{E}_k\mathbf{x}\|^2=\sum_{i=k+1}^r\sigma_i^2(\mathbf{v}_i^{\top}\mathbf{x})^2\). Since \(\sigma_i\leq\sigma_{k+1}\), this is at most \(\sigma_{k+1}^2\sum_{i=k+1}^r(\mathbf{v}_i^{\top}\mathbf{x})^2\leq\sigma_{k+1}^2\), where the last inequality follows because the \(\mathbf{v}_i\) are orthonormal and \(\|\mathbf{x}\|=1\). If \(k<r\), taking \(\mathbf{x}=\mathbf{v}_{k+1}\) gives \(\|\mathbf{E}_k\mathbf{x}\|=\sigma_{k+1}\), so the upper bound is attained. If \(k=r\), the residual is zero and \(\sigma_{r+1}=0\). This proves the operator-norm formula in every case. \(\square\)

Ties and the Choice of Singular Vectors

If several singular values are equal, there may be more than one valid choice of singular vectors within the corresponding singular subspace. At a tie where the cutoff falls, different choices of \(k\) vectors can therefore produce different matrices \(\mathbf{A}_k\). The error formulas do not change: the discarded values, counted with multiplicity, still determine the two errors.

Worked Example: A Tie at the Cutoff

Let \(\mathbf{A}=\begin{bmatrix}3&0&0\\0&2&0\\0&0&2\end{bmatrix}\) and \(k=2\). One valid choice retains the first two standard-coordinate components:

$$ \mathbf{A}_2=\begin{bmatrix}3&0&0\\0&2&0\\0&0&0\end{bmatrix}, \qquad \mathbf{E}_2=\begin{bmatrix}0&0&0\\0&0&0\\0&0&2\end{bmatrix}. $$

Thus \(\|\mathbf{E}_2\|_F=2\) and \(\|\mathbf{E}_2\|_2=2\). Alternatively, retain the first and third coordinate components. Then \(\mathbf{A}_2=\begin{bmatrix}3&0&0\\0&0&0\\0&0&2\end{bmatrix}\), while the residual is \(\begin{bmatrix}0&0&0\\0&2&0\\0&0&0\end{bmatrix}\). The resulting matrix differs, but each error remains \(2\).

Check: in the first choice, adding the displayed \(\mathbf{A}_2\) and \(\mathbf{E}_2\) returns \(\mathbf{A}\); in the alternative choice, their sum is also \(\mathbf{A}\). Each truncation retains the singular values \(3\) and \(2\), and discards one \(2\), so the stated errors agree with the formulas.

Common Pitfall: Adding Discarded Values

A common mistake is to add the discarded singular values and call that the Frobenius error. For the first example, this would give \(3+1=4\), but the Frobenius norm squares the entries before adding, so the correct result is \(\sqrt{3^2+1^2}=\sqrt{10}\). A related distinction is that the operator-norm error is not this square root; it is the largest discarded singular value, \(3\) in that example.

These formulas describe the error of the particular truncation built from the leading singular components. They do not, by themselves, compare it with every other matrix of rank at most \(k\). That optimality question requires a separate argument. For constructing and checking the truncated SVD, keep the two calculations distinct: combine discarded squares for the Frobenius norm, and select the largest discarded singular value for the operator norm.

Check Your Understanding

Use the SVD and the definitions of the two norms to justify each answer.

  1. If the singular values are \(7,4,1\) and \(k=1\), what are the Frobenius- and operator-norm errors?
  2. For a matrix of rank \(r\), what is \(\mathbf{A}_r\), and what are both residual norms?
  3. Explain why the rank of \(\mathbf{A}_k\) is \(k\) when \(0\leq k\leq r\).
  4. A singular value is tied at the truncation cutoff. Can the resulting truncated matrix depend on the choice of singular vectors? Do the two error values depend on that choice?
  5. For singular values \(5,3,3,1\) and \(k=2\), calculate both errors, counting multiplicities correctly.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon