Tutorials › Linear Algebra › Computing Pseudoinverses of Small Matrices

Pseudoinverse and Low-Rank Approximation · Tutorial 808 of 1000

Computing Pseudoinverses of Small Matrices

Use the SVD to compute small pseudoinverses reliably, with careful attention to matrix dimensions, zero singular values, and verification.

Advanced 9 min read

What You'll Learn

  • Identify the dimensions of each factor in a full or compact SVD.
  • Construct the pseudoinverse by transposing the rectangular diagonal factor and reciprocating its positive singular values.
  • Compute pseudoinverses for full-column-rank and full-row-rank matrices.
  • Handle rank deficiency without attempting to divide by zero.
  • Check a computed pseudoinverse by multiplying it with the original matrix in both orders.

From a Supplied SVD to a Pseudoinverse

A singular value decomposition turns a matrix into orthogonal changes of coordinates and a diagonal scaling. The pseudoinverse reverses each scaling that is nonzero and reverses the direction of the map: it sends left singular vectors back toward their corresponding right singular vectors. The computation is compact, but dimensions and zero singular values need careful attention, especially when the matrix is rectangular or rank deficient.

All matrices in this tutorial have real entries. Let \(\mathbf{A}\in\mathbb{R}^{m\times n}\). In a full singular value decomposition, \(\mathbf{A}=\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^{\top}\), where \(\mathbf{U}\in\mathbb{R}^{m\times m}\) and \(\mathbf{V}\in\mathbb{R}^{n\times n}\) are orthogonal, and \(\boldsymbol{\Sigma}\in\mathbb{R}^{m\times n}\) is rectangular diagonal. Its diagonal entries are the singular values, conventionally listed in nonincreasing order. Suppose there are exactly \(r\) positive singular values \(\sigma_1,\dots,\sigma_r\); any remaining diagonal entries are zero.

Definition: Given this SVD, the pseudoinverse \(\mathbf{A}^{+}\in\mathbb{R}^{n\times m}\) is computed as \(\mathbf{A}^{+}=\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top}\). The \(n\times m\) matrix \(\boldsymbol{\Sigma}^{+}\) is rectangular diagonal: its first \(r\) diagonal entries are \(1/\sigma_1,\dots,1/\sigma_r\), and every other entry is zero. Thus, only positive singular values are reciprocated.

For computations, it is often convenient to use the compact SVD, which keeps only the singular-vector columns corresponding to positive singular values. Write \(\mathbf{A}=\mathbf{U}_r\boldsymbol{\Sigma}_r\mathbf{V}_r^{\top}\), where \(\mathbf{U}_r\in\mathbb{R}^{m\times r}\) and \(\mathbf{V}_r\in\mathbb{R}^{n\times r}\) have orthonormal columns, and \(\boldsymbol{\Sigma}_r=\operatorname{diag}(\sigma_1,\dots,\sigma_r)\in\mathbb{R}^{r\times r}\). The same computation becomes \(\mathbf{A}^{+}=\mathbf{V}_r\boldsymbol{\Sigma}_r^{-1}\mathbf{U}_r^{\top}\). If \(r=0\), then \(\mathbf{A}=\mathbf{O}\) and \(\mathbf{A}^{+}=\mathbf{O}\) of size \(n\times m\); there are no positive singular values to reciprocate.

Why the Computation Has These Dimensions

The rectangular diagonal factor changes shape when it is pseudoinverted. If \(\boldsymbol{\Sigma}\) is \(m\times n\), then \(\boldsymbol{\Sigma}^{+}\) is \(n\times m\). Consequently, the product \(\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top}\) has dimensions \((n\times n)(n\times m)(m\times m)=n\times m\), as required for a map that reverses the input and output dimensions of \(\mathbf{A}\).

Theorem (SVD computation rule): Suppose \(\mathbf{A}=\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^{\top}\) is a full SVD of a real \(m\times n\) matrix, and its positive singular values are \(\sigma_1,\dots,\sigma_r\). The SVD construction of the pseudoinverse is \(\mathbf{A}^{+}=\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top}\), where \(\boldsymbol{\Sigma}^{+}\in\mathbb{R}^{n\times m}\) has entries \(1/\sigma_i\) in the corresponding first \(r\) diagonal positions and zero elsewhere. In particular, \(\mathbf{A}^{+}\) is \(n\times m\).

Proof. Let \(\mathbf{u}_i\) and \(\mathbf{v}_i\) be the \(i\)th columns of \(\mathbf{U}\) and \(\mathbf{V}\). The SVD writes \(\mathbf{A}=\sum_{i=1}^{r}\sigma_i\mathbf{u}_i\mathbf{v}_i^{\top}\); zero singular values contribute zero terms. Reversing each nonzero rank-one term gives \(\mathbf{A}^{+}=\sum_{i=1}^{r}(1/\sigma_i)\mathbf{v}_i\mathbf{u}_i^{\top}\). In matrix form this is exactly \(\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top}\): the reciprocal \(1/\sigma_i\) occupies the \(i\)th diagonal position, while zero singular values have no term to reverse. Each outer product \(\mathbf{v}_i\mathbf{u}_i^{\top}\) has \(n\) rows and \(m\) columns, so their sum has size \(n\times m\). This also covers \(r=0\), when the sum is empty and equals the zero matrix. \(\square\)

There is a direct multiplication check behind this rule. Orthonormality gives \(\mathbf{u}_i^{\top}\mathbf{u}_j=0\) for \(i\ne j\), \(\mathbf{u}_i^{\top}\mathbf{u}_i=1\), and the corresponding identities for the \(\mathbf{v}_i\). Therefore

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

For example, in the first product, multiplying the sums produces terms \((1/\sigma_i)\sigma_j\mathbf{v}_i(\mathbf{u}_i^{\top}\mathbf{u}_j)\mathbf{v}_j^{\top}\). Every term with \(i\ne j\) is zero; when \(i=j\), the scalar factor is \(1\). The second identity follows by the same multiplication using orthonormality of the \(\mathbf{v}_i\). These identities are useful checks: their sizes are \(n\times n\) and \(m\times m\), respectively.

Full-Column-Rank and Full-Row-Rank Cases

Worked Example: A Full-Column-Rank Matrix

Suppose a \(3\times2\) matrix is supplied in the SVD \(\mathbf{A}=\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^{\top}\), with \(\mathbf{U}=\mathbf{I}_3\), \(\mathbf{V}=\mathbf{I}_2\), and

$$ \boldsymbol{\Sigma} =\begin{bmatrix}3&0\\0&2\\0&0\end{bmatrix}. $$

Both singular values are positive, so the rank is \(2\), equal to the number of columns. The matrix is full column rank. Since the orthogonal factors are identities, \(\mathbf{A}=\boldsymbol{\Sigma}\). Transpose the rectangular diagonal factor and reciprocate its two positive entries:

$$ \boldsymbol{\Sigma}^{+} =\begin{bmatrix}\tfrac13&0&0\\0&\tfrac12&0\end{bmatrix}, \qquad \mathbf{A}^{+} =\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top} =\begin{bmatrix}\tfrac13&0&0\\0&\tfrac12&0\end{bmatrix}. $$

The result is \(2\times3\), the reverse of the \(3\times2\) size of \(\mathbf{A}\). Multiplication checks the scaling and dimensions:

$$ \mathbf{A}^{+}\mathbf{A} =\begin{bmatrix}\tfrac13&0&0\\0&\tfrac12&0\end{bmatrix} \begin{bmatrix}3&0\\0&2\\0&0\end{bmatrix} =\begin{bmatrix}1&0\\0&1\end{bmatrix}, \qquad \mathbf{A}\mathbf{A}^{+} =\begin{bmatrix}3&0\\0&2\\0&0\end{bmatrix} \begin{bmatrix}\tfrac13&0&0\\0&\tfrac12&0\end{bmatrix} =\begin{bmatrix}1&0&0\\0&1&0\\0&0&0\end{bmatrix}. $$

The reciprocal entries cancel the original positive singular values, while the third coordinate contributes a zero row in the second product.

Worked Example: A Full-Row-Rank Matrix

Let \(\mathbf{U}=\mathbf{I}_2\), let \(\mathbf{V}\) have columns \(\mathbf{e}_2,\mathbf{e}_3,\mathbf{e}_1\) in that order, and let

$$ \mathbf{V}=\begin{bmatrix}0&0&1\\1&0&0\\0&1&0\end{bmatrix}, \qquad \boldsymbol{\Sigma}=\begin{bmatrix}4&0&0\\0&2&0\end{bmatrix}. $$

The columns of \(\mathbf{V}\) are orthonormal, and the two positive singular values show that this \(2\times3\) matrix has rank \(2\), equal to its number of rows. First form \(\mathbf{A}=\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^{\top}\). Since \(\mathbf{V}^{\top}=\begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix}\),

$$ \mathbf{A} =\begin{bmatrix}4&0&0\\0&2&0\end{bmatrix} \begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix} =\begin{bmatrix}0&4&0\\0&0&2\end{bmatrix}. $$

Now transpose \(\boldsymbol{\Sigma}\), place the reciprocals \(1/4\) and \(1/2\) in its first two diagonal positions, and multiply by \(\mathbf{V}\):

$$ \boldsymbol{\Sigma}^{+} =\begin{bmatrix}\tfrac14&0\\0&\tfrac12\\0&0\end{bmatrix}, \qquad \mathbf{A}^{+} =\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top} =\begin{bmatrix}0&0\\\tfrac14&0\\0&\tfrac12\end{bmatrix}. $$

Here \(\mathbf{A}^{+}\) is \(3\times2\). Multiplying in both orders gives

$$ \mathbf{A}^{+}\mathbf{A} =\begin{bmatrix}0&0\\\tfrac14&0\\0&\tfrac12\end{bmatrix} \begin{bmatrix}0&4&0\\0&0&2\end{bmatrix} =\begin{bmatrix}0&0&0\\0&1&0\\0&0&1\end{bmatrix}, \qquad \mathbf{A}\mathbf{A}^{+} =\begin{bmatrix}0&4&0\\0&0&2\end{bmatrix} \begin{bmatrix}0&0\\\tfrac14&0\\0&\tfrac12\end{bmatrix} =\begin{bmatrix}1&0\\0&1\end{bmatrix}. $$

The products have the expected sizes, \(3\times3\) and \(2\times2\). The permutation in \(\mathbf{V}\) explains why the reciprocal entries appear in rows two and three of \(\mathbf{A}^{+}\), rather than rows one and two.

Rank Deficiency: Leave Zero Singular Values at Zero

Worked Example: A Rank-One Matrix With Two Zero Singular Values

Consider the SVD factors

$$ \mathbf{U}=\begin{bmatrix}0&1\\1&0\end{bmatrix}, \qquad \mathbf{V}=\begin{bmatrix} \tfrac{1}{\sqrt{2}}&\tfrac{1}{\sqrt{2}}&0\\ \tfrac{1}{\sqrt{2}}&-\tfrac{1}{\sqrt{2}}&0\\ 0&0&1 \end{bmatrix}, \qquad \boldsymbol{\Sigma}=\begin{bmatrix}6&0&0\\0&0&0\end{bmatrix}. $$

The columns of each orthogonal factor are orthonormal. There is one positive singular value, so the rank is \(1\). The matrix itself is obtained by first calculating \(\boldsymbol{\Sigma}\mathbf{V}^{\top}\), then multiplying by \(\mathbf{U}\):

$$ \boldsymbol{\Sigma}\mathbf{V}^{\top} =\begin{bmatrix}3\sqrt{2}&3\sqrt{2}&0\\0&0&0\end{bmatrix}, \qquad \mathbf{A} =\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^{\top} =\begin{bmatrix}0&0&0\\3\sqrt{2}&3\sqrt{2}&0\end{bmatrix}. $$

Only the singular value \(6\) is reciprocated. Thus

$$ \boldsymbol{\Sigma}^{+} =\begin{bmatrix}\tfrac16&0\\0&0\\0&0\end{bmatrix}, \qquad \mathbf{A}^{+} =\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top} =\begin{bmatrix} 0&\tfrac{\sqrt{2}}{12}\\ 0&\tfrac{\sqrt{2}}{12}\\ 0&0 \end{bmatrix}. $$

The pseudoinverse is \(3\times2\). To check it, multiply explicitly:

$$ \mathbf{A}^{+}\mathbf{A} =\begin{bmatrix} 0&\tfrac{\sqrt{2}}{12}\\ 0&\tfrac{\sqrt{2}}{12}\\ 0&0 \end{bmatrix} \begin{bmatrix}0&0&0\\3\sqrt{2}&3\sqrt{2}&0\end{bmatrix} =\begin{bmatrix}\tfrac12&\tfrac12&0\\\tfrac12&\tfrac12&0\\0&0&0\end{bmatrix}, $$ $$ \mathbf{A}\mathbf{A}^{+} =\begin{bmatrix}0&0&0\\3\sqrt{2}&3\sqrt{2}&0\end{bmatrix} \begin{bmatrix} 0&\tfrac{\sqrt{2}}{12}\\ 0&\tfrac{\sqrt{2}}{12}\\ 0&0 \end{bmatrix} =\begin{bmatrix}0&0\\0&1\end{bmatrix}. $$

For instance, the lower-right entry in the second product is \(3\sqrt{2}(\sqrt{2}/12)+3\sqrt{2}(\sqrt{2}/12)=6/12+6/12=1\). The zero singular values contribute no reciprocal terms and no extra rank-one terms.

Common Mistakes and a Reliable Checklist

Mistake: reciprocating every diagonal entry. In the rank-one example, a tempting but invalid step is to write \(1/0\) for the second singular value. Division by zero is undefined. The correct factor is \(\boldsymbol{\Sigma}^{+}=\begin{bmatrix}\tfrac16&0\\0&0\\0&0\end{bmatrix}\): transpose the rectangular shape, reciprocate the positive value \(6\), and leave the zero positions zero.

Mistake: keeping the original matrix dimensions. If \(\mathbf{A}\) is \(m\times n\), then \(\mathbf{A}^{+}\) is \(n\times m\), not \(m\times n\) unless \(m=n\). In the full-row-rank example, \(\mathbf{A}\) is \(2\times3\), but its pseudoinverse is \(3\times2\). The factor order \(\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top}\) makes the dimension reversal explicit.

For a supplied SVD, a dependable computation follows these checks:

  • Record \(m\), \(n\), and the dimensions of \(\mathbf{U}\), \(\boldsymbol{\Sigma}\), and \(\mathbf{V}\).
  • Count the positive singular values; do not infer full rank merely from the matrix being rectangular.
  • Transpose the rectangular diagonal factor and replace each positive \(\sigma_i\) by \(1/\sigma_i\).
  • Keep zero entries zero, then multiply in the order \(\mathbf{V}\boldsymbol{\Sigma}^{+}\mathbf{U}^{\top}\).
  • Check that the result is \(n\times m\) and, when useful, verify both products using the supplied singular vectors.

This procedure applies whether the matrix has full column rank, full row rank, or rank smaller than both dimensions. In every case, the singular vectors identify the directions to pair, the reciprocal singular values undo the nonzero scalings, and the zero singular values remain excluded from the computation.

Check Your Understanding

For each question, keep track of factor dimensions and state which singular values are reciprocated.

  1. A \(4\times2\) matrix has singular values \(5\) and \(1\). What are the dimensions of its pseudoinverse, and what are the positive diagonal entries of \(\boldsymbol{\Sigma}^{+}\)?
  2. A \(2\times3\) matrix has singular values \(7\) and \(0\). What is its rank, and what is the shape of \(\boldsymbol{\Sigma}^{+}\)?
  3. For a compact SVD \(\mathbf{A}=\mathbf{U}_r\boldsymbol{\Sigma}_r\mathbf{V}_r^{\top}\), write the dimensions of all four factors in the formula for \(\mathbf{A}^{+}\).
  4. Explain why a zero singular value contributes no term to \(\mathbf{A}^{+}=\sum_{i=1}^{r}(1/\sigma_i)\mathbf{v}_i\mathbf{u}_i^{\top}\).
  5. For the full-row-rank worked example, multiply \(\mathbf{A}^{+}\mathbf{A}\) and \(\mathbf{A}\mathbf{A}^{+}\), and confirm their sizes.

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