skip to content

How does the Moore-Penrose pseudoinverse solve a rank-deficient least-squares problem?

level: seniorimportance: should knowfreq 40%

answer

  1. invert only the nonzero part
  2. many minimizers, so a rule is needed
  3. the shortest one wins
  4. no component in the null space
  5. V, then S-plus, then U-transpose

basics

~20 s

Build A^+ = V S^+ U^T from the SVD by inverting each nonzero singular value and leaving zeros as zeros. Then x = A^+ b minimizes ||Ax - b|| and, among the infinitely many minimizers, is the one with smallest norm.

solid answer

~50 s

When A is rank deficient the least-squares problem has infinitely many minimizers, differing by any vector in the null space of A, so a rule is needed to pick one. The pseudoinverse supplies it: from `A = U S V^T`, form `S^+` by transposing S and replacing each nonzero `sigma_i` with `1 / sigma_i` while leaving every zero at zero, then set `A^+ = V S^+ U^T`. The vector `x = A^+ b` minimizes `||A x - b||_2`, and it is the unique minimizer of smallest Euclidean norm, because it carries no null-space component. In floating point you also treat singular values below a tolerance as exactly zero rather than inverting them, since `1 / sigma` explodes for tiny sigma and would amplify noise in b into the solution. When A has full column rank there is only one minimizer and the minimum-norm clause is vacuous.

go deeper

for a junior

Know the pseudoinverse as the generalization of the matrix inverse to rectangular or singular matrices, and that it is assembled directly from the SVD factors.

for a middle

Explain how S^+ is built, reciprocals of the nonzero singular values with zeros left alone, and why A^+ b is a least-squares rather than an exact solution.

for a senior

Demonstrate operating judgment: spot when rank deficiency makes the solution non-unique, set a sensible cutoff for small singular values, and say what the minimum-norm choice actually buys.

for a principal

Own the framing that minimum norm is one regularization choice among several, and be able to argue when an explicit penalty or a domain constraint serves the problem better than the default.

## The problem Least squares asks for x minimizing `||A x - b||_2`. When the columns of A are linearly independent there is exactly one minimizer. When A is **rank deficient**, meaning its rank r is smaller than its number of columns n, the minimizer is not unique: if x is a minimizer and z satisfies `A z = 0`, then `A(x + z) = A x`, so `x + z` gives the identical residual. The whole set of minimizers is a shifted copy of the null space of A, which has dimension n - r. Rank deficiency does not make least squares unsolvable; it makes it under-determined, and you must state which of the infinitely many answers you want. ## Building the pseudoinverse Take `A = U S V^T`. Define `S^+` as the n-by-m matrix obtained by transposing the shape of S and replacing each nonzero singular value `sigma_i` with its reciprocal `1 / sigma_i`, while every zero entry stays zero. Then `A^+ = V S^+ U^T` The key detail is that zeros are **not** inverted. There is no reciprocal of zero, and refusing to invent one is precisely what lets the construction work for singular and rectangular matrices. This matrix is the unique one satisfying the four **Moore-Penrose conditions**: `A A^+ A = A`, `A^+ A A^+ = A^+`, and both `A A^+` and `A^+ A` symmetric. When A is square and invertible, `A^+ = A^{-1}`, so it genuinely generalizes the inverse. ## What x = A^+ b gives you Two properties together: 1. **It is a least-squares solution.** `A A^+` is the orthogonal projector onto the column space of A, so `A x = A A^+ b` is the projection of b onto the reachable set, the closest point to b that A can produce. The residual `b - A A^+ b` is orthogonal to every column of A, which is the geometric form of the normal equations. 2. **It is the minimum-norm one.** `A^+ b` lies entirely in the row space of A, the orthogonal complement of the null space, so it has zero null-space component. Any other minimizer is `A^+ b + z` for some nonzero z in the null space, and because the two parts are orthogonal, `||A^+ b + z||^2 = ||A^+ b||^2 + ||z||^2 > ||A^+ b||^2`. So the pseudoinverse answer is strictly the shortest. Choosing the shortest solution is a **decision**, not a mathematical necessity. It is a defensible default: it refuses to put weight on directions the data cannot resolve. ## The numerical part In practice no computed singular value is exactly zero; a truly rank-deficient matrix produces values around the rounding-error level instead. Because A^+ scales the component of b along `u_i` by `1 / sigma_i`, a singular value near the noise floor is amplified enormously and the resulting x is dominated by whatever noise is in b along that direction. The standard remedy is a **tolerance**: treat any `sigma_i` below, say, `max(m, n) * eps * sigma_1` as zero and drop that direction entirely. This is a truncated pseudoinverse. It introduces a small bias in exchange for a large reduction in variance, and it is what makes the pseudoinverse usable on near-rank-deficient data where singular values are small but not zero. Setting the cutoff is a judgment call. Too tight and you keep noise-dominated directions; too loose and you discard real signal. Looking at the actual gap in the spectrum, if there is one, is more informative than any default. ## Relation to full-rank least squares When A has full column rank, every singular value is positive, the null space is trivial, and the minimizer is unique; `A^+ b` returns exactly the ordinary least-squares answer, and the minimum-norm property says nothing extra. Everything distinctive about the pseudoinverse shows up only when rank is deficient or nearly so. ## Common mistakes Saying A^+ equals A inverse for any square matrix (false as soon as A is singular); inverting the zero entries of S; claiming the least-squares solution is always unique; and inverting a tiny singular value without noticing that it multiplies the noise in b by an enormous factor.

  • Why zero out tiny singular values instead of inverting them?
    The pseudoinverse scales the component of b along u_i by 1 / sigma_i, so a singular value near the noise floor is amplified enormously and the solution becomes dominated by measurement noise rather than signal. Treating any sigma below a tolerance as exactly zero drops that direction, trading a small bias for a large reduction in variance and yielding a usable answer.
  • What are the four Moore-Penrose conditions?
    A A^+ A = A, A^+ A A^+ = A^+, and both A A^+ and A^+ A are symmetric. Exactly one matrix satisfies all four for a given A, which is why the pseudoinverse is well defined even when A is rectangular or singular, and A^+ = V S^+ U^T is that matrix.
  • How does A A^+ relate to the column space of A?
    A A^+ is the orthogonal projector onto the column space of A, so A x = A A^+ b is exactly the projection of b onto the set of vectors A can produce, the closest achievable point. The residual b - A A^+ b is orthogonal to every column of A, which is the geometric statement of the least-squares condition.

saying these in an interview costs you the question

  • Says A^+ equals A inverse whenever A is square
  • Inverts every diagonal entry, including the zeros
  • Claims the least-squares solution is always unique
  • Treats a tiny singular value as safely invertible
  • Presents minimum norm as forced rather than as a chosen rule

context