Tutorials › Linear Algebra › Rank-Deficient Least-Squares Examples

Pseudoinverse and Low-Rank Approximation · Tutorial 816 of 1000

Rank-Deficient Least-Squares Examples

Use singular-vector coordinates to compute least-squares residuals and the full family of minimizers, including the unique minimum-norm solution.

Advanced 9 min read

What You'll Learn

  • Identify the positive singular values and form the pseudoinverse from an SVD.
  • Compute the residual when the system is inconsistent.
  • Describe every least-squares minimizer as a particular solution plus a null-space vector.
  • Find the minimum-norm minimizer in underdetermined systems.
  • Check computed solutions by multiplying them by the original matrix.

What Rank Deficiency Changes

When a matrix is rank-deficient, some directions in its input space are sent to zero, and some target vectors cannot be reached at all. These two features lead to different questions: an inconsistent system has no exact solution, while an underdetermined system may have multiple exact solutions. Least squares handles the first situation by minimizing the residual; the pseudoinverse selects a particular minimizer, namely the one with smallest norm. In this tutorial, small SVD calculations will make both the residual and the entire family of minimizers explicit.

Work over \(\mathbb{R}\). For \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{b}\in\mathbb{R}^m\), a least-squares minimizer is a vector \(\mathbf{x}\in\mathbb{R}^n\) that minimizes \(\|\mathbf{A}\mathbf{x}-\mathbf{b}\|\) over all \(\mathbf{x}\). The residual at \(\mathbf{x}\) is \(\mathbf{b}-\mathbf{A}\mathbf{x}\). The system is inconsistent if no \(\mathbf{x}\) satisfies \(\mathbf{A}\mathbf{x}=\mathbf{b}\). A matrix is rank-deficient when its rank is less than the smaller of its numbers of rows and columns.

Recall the SVD pseudoinverse formula. Write an SVD as \(\mathbf{A}=\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^{\top}\), where \(\mathbf{U}\) and \(\mathbf{V}\) are orthogonal matrices. If the rank is \(r\), the positive singular values are \(\sigma_1,\dots,\sigma_r\), and the corresponding left and right singular vectors are \(\mathbf{u}_i\) and \(\mathbf{v}_i\). Then

$$ \mathbf{A}^{+}=\sum_{i=1}^{r}\frac{1}{\sigma_i}\mathbf{v}_i\mathbf{u}_i^{\top}. $$

Only positive singular values are inverted. Zero singular values are omitted, rather than divided into. This is essential for rank-deficient matrices. The earlier results on least squares and the pseudoinverse give the candidate minimum-norm minimizer \(\mathbf{A}^{+}\mathbf{b}\); the singular-coordinate argument below explains both why it minimizes the residual and how to find all the other minimizers.

The Full Family of Least-Squares Minimizers

Theorem: Let \(\mathbf{A}\in\mathbb{R}^{m\times n}\) have rank \(r\), and let \(\mathbf{A}=\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^{\top}\) be an SVD. For every \(\mathbf{b}\in\mathbb{R}^m\), the least-squares minimizers are exactly \(\mathbf{x}=\mathbf{A}^{+}\mathbf{b}+\sum_{j=r+1}^{n}c_j\mathbf{v}_j\), where the \(c_j\) are arbitrary real numbers. The unique minimizer with smallest norm is \(\mathbf{A}^{+}\mathbf{b}\), and its residual is \(\sum_{i=r+1}^{m}(\mathbf{u}_i^{\top}\mathbf{b})\mathbf{u}_i\). A sum with no indices is understood to be zero.

Proof. Set \(\mathbf{y}=\mathbf{U}^{\top}\mathbf{b}\) and \(\mathbf{z}=\mathbf{V}^{\top}\mathbf{x}\). Since \(\mathbf{U}\) and \(\mathbf{V}\) are orthogonal, they preserve norms, and \(\mathbf{x}=\mathbf{V}\mathbf{z}\). The first \(r\) diagonal entries of \(\boldsymbol{\Sigma}\) are \(\sigma_1,\dots,\sigma_r>0\); all its other entries are zero. Therefore

$$ \|\mathbf{A}\mathbf{x}-\mathbf{b}\|^2 =\|\boldsymbol{\Sigma}\mathbf{z}-\mathbf{y}\|^2 =\sum_{i=1}^{r}(\sigma_i z_i-y_i)^2 +\sum_{i=r+1}^{m}y_i^2. $$

The second sum does not depend on \(\mathbf{x}\). Each term in the first sum is nonnegative and can be made zero by setting \(z_i=y_i/\sigma_i\). Since each \(\sigma_i\) is positive, this is the unique minimizing choice for each \(i\le r\). No term in the objective depends on \(z_{r+1},\dots,z_n\), so those coordinates are arbitrary. The SVD formula for \(\mathbf{A}^{+}\) gives \(\mathbf{A}^{+}\mathbf{b}=\mathbf{V}\mathbf{z}_0\), where \((\mathbf{z}_0)_i=y_i/\sigma_i\) for \(i\le r\) and \((\mathbf{z}_0)_j=0\) for \(j>r\). Thus all the minimizers have the stated form.

For any such minimizer, orthogonality of the columns of \(\mathbf{V}\) gives \(\|\mathbf{x}\|^2=\sum_{i=1}^{r}(y_i/\sigma_i)^2+\sum_{j=r+1}^{n}c_j^2\). This is smallest exactly when every \(c_j=0\), and that choice is unique. Finally, the residual in \(\mathbf{U}\)-coordinates has entries \(0\) for \(i\le r\) and \(y_i\) for \(i>r\). Multiplying back by \(\mathbf{U}\) gives the residual formula in the theorem. These calculations also cover \(r=0\): the first sum is empty, all input coordinates are free, and the smallest-norm choice is \(\mathbf{0}\). \(\square\)

The vectors \(\mathbf{v}_{r+1},\dots,\mathbf{v}_n\) describe the directions that do not change \(\mathbf{A}\mathbf{x}\). Indeed, for \(j>r\), the corresponding singular value is zero, so \(\mathbf{A}\mathbf{v}_j=\mathbf{0}\). The theorem therefore separates two tasks: the positive singular directions determine the best fit, while the zero singular directions account for every other minimizer.

An Inconsistent System with a Nonzero Residual

Worked Example: A Diagonal Rank-Deficient Matrix

Find the least-squares minimizers for \(\mathbf{A}=\begin{bmatrix}2&0\\0&0\end{bmatrix}\) and \(\mathbf{b}=\begin{bmatrix}1\\3\end{bmatrix}\). Give the residual and the minimum-norm minimizer.

An SVD is \(\mathbf{A}=\mathbf{I}_2\boldsymbol{\Sigma}\mathbf{I}_2^{\top}\), with \(\boldsymbol{\Sigma}=\begin{bmatrix}2&0\\0&0\end{bmatrix}\). There is one positive singular value, \(2\), and its left and right singular vectors are both \(\mathbf{e}_1\). Hence

$$ \mathbf{A}^{+} =\frac{1}{2}\mathbf{e}_1\mathbf{e}_1^{\top} =\begin{bmatrix}\tfrac12&0\\0&0\end{bmatrix}, \qquad \mathbf{A}^{+}\mathbf{b} =\begin{bmatrix}\tfrac12\\0\end{bmatrix}. $$

The theorem says that every minimizer is \(\mathbf{x}=\begin{bmatrix}\tfrac12\\0\end{bmatrix}+t\mathbf{e}_2 =\begin{bmatrix}\tfrac12\\t\end{bmatrix}\), with \(t\in\mathbb{R}\). Multiplication gives the same fitted vector for every \(t\):

$$ \mathbf{A}\mathbf{x} =\begin{bmatrix}2&0\\0&0\end{bmatrix} \begin{bmatrix}\tfrac12\\t\end{bmatrix} =\begin{bmatrix}1\\0\end{bmatrix}, \qquad \mathbf{b}-\mathbf{A}\mathbf{x} =\begin{bmatrix}0\\3\end{bmatrix}. $$

The residual is nonzero, so the system is inconsistent. Its norm is \(3\), independent of \(t\). Also, \(\|\mathbf{x}\|^2=\tfrac14+t^2\), which is minimized uniquely at \(t=0\). Thus \(\mathbf{A}^{+}\mathbf{b}=\begin{bmatrix}\tfrac12\\0\end{bmatrix}\) is the minimum-norm minimizer, as claimed.

Underdetermined Systems: Exact Fits and Many Solutions

An underdetermined system has more unknowns than equations. It can have infinitely many exact solutions when the target is reachable. If the matrix is also rank-deficient, some input directions may remain free even after imposing the exact-fit condition. The next two examples use the same matrix with different right-hand sides: one is reachable, and one is not.

Worked Example: An Underdetermined Consistent System

For \(\mathbf{A}=\begin{bmatrix}1&1&0\\2&2&0\end{bmatrix}\) and \(\mathbf{b}=\begin{bmatrix}3\\6\end{bmatrix}\), find every least-squares minimizer and identify the minimum-norm one.

The matrix has rank \(1\). Its nonzero singular value and corresponding unit singular vectors are \(\sigma_1=\sqrt{10}\), \(\mathbf{u}_1=\begin{bmatrix}1\\2\end{bmatrix}/\sqrt{5}\), and \(\mathbf{v}_1=\begin{bmatrix}1\\1\\0\end{bmatrix}/\sqrt{2}\). In fact, \(\mathbf{A}=\sqrt{10}\,\mathbf{u}_1\mathbf{v}_1^{\top}\), as multiplying the right-hand side gives the displayed matrix. Therefore

$$ \mathbf{A}^{+} =\frac{1}{\sqrt{10}}\mathbf{v}_1\mathbf{u}_1^{\top} =\frac{1}{10} \begin{bmatrix}1&2\\1&2\\0&0\end{bmatrix}, \qquad \mathbf{A}^{+}\mathbf{b} =\begin{bmatrix}\tfrac32\\\tfrac32\\0\end{bmatrix}. $$

Direct multiplication checks the fit: \(\mathbf{A}\begin{bmatrix}\tfrac32\\\tfrac32\\0\end{bmatrix} =\begin{bmatrix}3\\6\end{bmatrix}=\mathbf{b}\), so the residual is \(\mathbf{0}\). To find every exact solution, write \(\mathbf{x}=\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}\). The equations are \(x_1+x_2=3\) and \(2x_1+2x_2=6\), with the second equation twice the first. Thus the full family is

$$ \mathbf{x} =\begin{bmatrix}\tfrac32+s\\\tfrac32-s\\t\end{bmatrix}, \qquad s,t\in\mathbb{R}. $$

Its squared norm is \((\tfrac32+s)^2+(\tfrac32-s)^2+t^2=\tfrac92+2s^2+t^2\), which is minimized uniquely when \(s=t=0\). The resulting vector is \(\mathbf{A}^{+}\mathbf{b}\). Substituting it into the original matrix gives \(\begin{bmatrix}3\\6\end{bmatrix}\), confirming the minimum-norm exact solution.

Worked Example: An Underdetermined Inconsistent System

Keep the same matrix \(\mathbf{A}\), but take \(\mathbf{b}=\begin{bmatrix}3\\0\end{bmatrix}\). Find the residual, all least-squares minimizers, and the minimum-norm minimizer.

The pseudoinverse is unchanged, so

$$ \mathbf{A}^{+}\mathbf{b} =\frac{1}{10} \begin{bmatrix}1&2\\1&2\\0&0\end{bmatrix} \begin{bmatrix}3\\0\end{bmatrix} =\begin{bmatrix}\tfrac{3}{10}\\\tfrac{3}{10}\\0\end{bmatrix}. $$

Multiplying back gives \(\mathbf{A}\mathbf{A}^{+}\mathbf{b} =\begin{bmatrix}\tfrac35\\\tfrac65\end{bmatrix}\). The residual is therefore \(\mathbf{b}-\mathbf{A}\mathbf{A}^{+}\mathbf{b} =\begin{bmatrix}\tfrac{12}{5}\\-\tfrac65\end{bmatrix}\), with squared norm \(\tfrac{144}{25}+\tfrac{36}{25}=\tfrac{36}{5}\), hence norm \(\tfrac{6}{\sqrt{5}}\). The target cannot be an exact fit: every vector in the column space of \(\mathbf{A}\) has second entry twice its first, but \(\begin{bmatrix}3\\0\end{bmatrix}\) does not.

For any input \(\mathbf{x}\), the product is \(\mathbf{A}\mathbf{x}=\begin{bmatrix}x_1+x_2\\2x_1+2x_2\end{bmatrix}\). Its value matches the best-fit vector \(\begin{bmatrix}\tfrac35\\\tfrac65\end{bmatrix}\) exactly when \(x_1+x_2=\tfrac35\); \(x_3\) is unrestricted. Consequently all the minimizers are

$$ \mathbf{x} =\begin{bmatrix}\tfrac{3}{10}+s\\\tfrac{3}{10}-s\\t\end{bmatrix}, \qquad s,t\in\mathbb{R}. $$

For each member of the family, multiplication gives \(\mathbf{A}\mathbf{x}=\begin{bmatrix}\tfrac35\\\tfrac65\end{bmatrix}\), so the residual remains \(\begin{bmatrix}\tfrac{12}{5}\\-\tfrac65\end{bmatrix}\). The squared norm of \(\mathbf{x}\) is \(\tfrac{9}{50}+2s^2+t^2\), minimized uniquely at \(s=t=0\). Thus \(\begin{bmatrix}\tfrac{3}{10}\\\tfrac{3}{10}\\0\end{bmatrix}\) is the minimum-norm minimizer, and its product with \(\mathbf{A}\) verifies the stated best fit.

A Common Mistake: Treating the Pseudoinverse Output as an Exact Solution

For the last example, a tempting but incorrect calculation is to claim that \(\mathbf{A}^{+}\mathbf{b}\) solves \(\mathbf{A}\mathbf{x}=\mathbf{b}\). Substitution shows otherwise:

$$ \mathbf{A}\mathbf{A}^{+}\mathbf{b} =\begin{bmatrix}\tfrac35\\\tfrac65\end{bmatrix} \ne \begin{bmatrix}3\\0\end{bmatrix} =\mathbf{b}. $$

The correction is to distinguish an exact solution from a least-squares minimizer. Here the pseudoinverse output minimizes the residual, but it cannot make that residual zero. A second mistake is to report only this one vector when asked for all minimizers. Adding \(\begin{bmatrix}s\\-s\\t\end{bmatrix}\) changes neither the fitted vector nor the residual. It increases the norm unless \(s=t=0\), which is why the pseudoinverse output is the minimum-norm choice rather than the only minimizer.

How to Read a Rank-Deficient Example

A reliable calculation can be organized around three questions. First, what does the SVD say about the reachable part of the target? Only the left singular-vector directions with positive singular values can be fitted. Second, which input directions are invisible to the matrix? They are the right singular-vector directions associated with zero singular values. Third, what does the requested output require: just the residual, one minimizer, the full family, or the minimum-norm member? Keeping these questions separate prevents a correct pseudoinverse calculation from being mistaken for a complete description.

The distinction matters in applications where different coefficient vectors may produce the same prediction. The residual measures the mismatch between the target and the best reachable fit. The null-space terms describe changes to the coefficients that leave that fit unchanged. Choosing the minimum-norm member gives a well-defined representative without claiming that the other minimizers do not exist.

Check Your Understanding

Use the SVD-coordinate result to answer each question. When a matrix and vector are given, verify the proposed fit by multiplication.

  1. For \(\mathbf{A}=\begin{bmatrix}1&0\\0&0\end{bmatrix}\) and \(\mathbf{b}=\begin{bmatrix}2\\4\end{bmatrix}\), find the residual and the full family of minimizers.
  2. For the \(2\times3\) matrix in the worked examples and \(\mathbf{b}=\begin{bmatrix}1\\2\end{bmatrix}\), find the minimum-norm exact solution and describe every exact solution.
  3. Explain why adding a multiple of \(\mathbf{v}_j\) for a zero singular value does not change the fitted vector.
  4. In an SVD with rank \(r\), which coordinates of \(\mathbf{V}^{\top}\mathbf{x}\) are fixed at a least-squares minimum, and which are free?
  5. For the inconsistent underdetermined example, check directly that its residual is orthogonal to the column \(\begin{bmatrix}1\\2\end{bmatrix}\) of \(\mathbf{A}\).

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