---
title: The pseudoinverse and minimum-norm solutions
heading: The best answer for any matrix
eyebrow: A7 · Lesson 45 · The pseudoinverse
xp: 40
---

::: hook
Only square matrices with nonzero determinants have inverses. Least squares handled tall matrices with independent columns. That leaves the awkward cases: wide matrices with infinitely many solutions, and rank-deficient ones that have too many and too few at once. The SVD settles all of them with one rule, the **pseudoinverse** $A^+$. It gives the least-squares answer, and among all least-squares answers, the shortest. Circuits obey the same rule: currents split among parallel paths in the way that dissipates the least power.
:::

::: play
- Every point on the line is a solution of $x + 2y = b$. The second dot is one of them; slide it along with $s$.
- Its length is smallest at the point marked $A^+b$, where the arrow from the origin meets the line at a right angle.
- Change $b$. The line moves, and the shortest solution moves with it, always along the direction $(1, 2)$.
:::

```sim plot
view: complex
range: 6
axes: x, y
slider: b = 1..10 step 0.5 = 5
slider: s = -2..6 step 0.1 = 3
curve: (b - 2*u) + j*u | over: u = -4..8 | label: x + 2y = b
arrow: b/5 + j*2*b/5 | label: A⁺b
dot: (b - 2*s) + j*s | label: a solution | color: ch2
readout: length of this solution = sqrt((b - 2*s)^2 + s^2) | digits: 4
readout: length of A⁺b = b/sqrt(5) | digits: 4
```

::: predict
## Which solution of $x + 2y = 5$ is shortest?

- [ ] $(5, 0)$
- [x] $(1, 2)$
- [ ] $(0, 2.5)$
- [ ] $(3, 1)$

::: reveal
$(1, 2)$, with length $\sqrt5 = 2.24$. The others have lengths 5, 2.5 and 3.16. The shortest solution is the one perpendicular to the line of solutions, which means it lies along the row $(1, 2)$: it's in the row space, with no part in the null space.
:::
:::

::: nameit
## Definition

Write the SVD as $A = U\Sigma V^T$, with $r$ nonzero singular values. The pseudoinverse inverts the nonzero ones and leaves the zeros alone:

$$A^+ = V\Sigma^+U^T, \qquad \Sigma^+ = \text{diag}\left(\frac{1}{\sigma_1}, \ldots, \frac{1}{\sigma_r}, 0, \ldots, 0\right)$$

## What $A^+\mathbf{b}$ is

$\mathbf{x}^+ = A^+\mathbf{b}$ minimizes $|A\mathbf{x} - \mathbf{b}|$, and among all minimizers it has the smallest length. It lies in the row space of $A$, and $A\mathbf{x}^+$ is the projection of $\mathbf{b}$ onto the column space.

Three special cases:
- **invertible $A$:** $A^+ = A^{-1}$;
- **independent columns** (tall, rank $n$): $A^+ = (A^TA)^{-1}A^T$, the least-squares formula;
- **independent rows** (wide, rank $m$): $A^+ = A^T(AA^T)^{-1}$, the minimum-norm solution of an underdetermined system.

## Small singular values

A singular value near zero turns into a huge $1/\sigma$, so noise in $\mathbf{b}$ along that direction is amplified enormously. Two fixes:
- **truncation:** treat $\sigma$ below a threshold as zero;
- **Tikhonov regularization** (ridge): minimize $|A\mathbf{x} - \mathbf{b}|^2 + \lambda|\mathbf{x}|^2$, which replaces $\frac1\sigma$ with $\frac{\sigma}{\sigma^2 + \lambda}$. Large singular values are hardly changed, and small ones are damped by the factor $\frac{\sigma^2}{\sigma^2 + \lambda}$.

## Circuits minimize power

Maxwell showed that the currents in a resistor network are the ones that, among all current patterns obeying KCL, dissipate the least power $\sum R_ki_k^2$. That's a weighted minimum-norm problem. For two parallel resistors sharing a current $I$, minimizing $R_1i_1^2 + R_2i_2^2$ with $i_1 + i_2 = I$ gives the current divider $i_1 = \frac{R_2}{R_1 + R_2}I$.
:::

::: example
## Find the shortest solution of $x + 2y = 5$.

::: solution
1. **Pseudoinverse.** $A = \begin{bmatrix}1 & 2\end{bmatrix}$ has one independent row, so
   $$\begin{aligned} A^+ &= A^T(AA^T)^{-1} \\ &= \frac15\begin{bmatrix}1\\2\end{bmatrix} \end{aligned}$$
2. **Shortest solution.**
   $$\begin{aligned} \mathbf{x}^+ &= \tfrac55(1, 2) \\ &= (1, 2) \end{aligned}$$
3. **Why it's shortest.** Every other solution adds a null-space vector $t(2, -1)$, which is perpendicular to $(1, 2)$, so by Pythagoras it can only add length:
   $$|\mathbf{x}|^2 = 5 + 5t^2$$

**Answer:** the shortest solution is $(1, 2)$.
:::
:::

::: example
## Find $A^+\mathbf{b}$ for $A = \begin{bmatrix}1 & 0\\0 & 0\end{bmatrix}$ and $\mathbf{b} = (3, 4)$.

::: solution
1. **Invert the singular values.** $A$ is already its own SVD, with singular values 1 and 0. Inverting the 1 and keeping the 0 gives
   $$A^+ = \begin{bmatrix}1 & 0\\0 & 0\end{bmatrix}$$
   so $\mathbf{x}^+ = (3, 0)$.
2. **The best residual.** No $\mathbf{x}$ can match $b_2 = 4$, since $A\mathbf{x}$ always has a zero second entry, so the residual is at least 4. Every $(3, y)$ achieves that residual.
3. **The shortest choice.** The pseudoinverse picks $y = 0$, the shortest. It solves what can be solved and sets the rest to zero.

**Answer:** $A^+\mathbf{b} = (3, 0)$.
:::
:::

::: example
## A 3 mA current enters two parallel resistors, 1 kΩ and 2 kΩ. Show that the actual split dissipates the least power.

::: solution
1. **The actual split.** The current divider gives $i_1 = 3 \times \frac{2}{3}$ = 2 mA in the 1 kΩ resistor and 1 mA in the 2 kΩ.
2. **Its power.** Kilohms times milliamps squared give milliwatts:
   $$\begin{aligned} P &= 1 \times 2^2 + 2 \times 1^2 \\ &= 6\ \text{mW} \end{aligned}$$
3. **Any other split.** Take $i_1 = 2 + t$ and $i_2 = 1 - t$:
   $$\begin{aligned} P &= (2 + t)^2 + 2(1 - t)^2 \\ &= 6 + 3t^2\ \text{mW} \end{aligned}$$
   more, for every $t \ne 0$.
4. **An equal split.** That's $t = -0.5$, which costs 6.75 mW.

**Answer:** the actual 2 mA and 1 mA split dissipates 6 mW, and any other split dissipates $6 + 3t^2$ mW, which is more.
:::
:::

::: check
kind: parts
given: a = 1 | 2 | 3; b = 1 | 4; c = 5 | 10

## Find the shortest solution of $\given{a}x + \given{b}y = \given{c}$.

::: part
answer: a*c/(a^2 + b^2)
tolerance: 0.5%

### What is $x$?

::: misses
- [c/a] That solution sets $y = 0$; it isn't the shortest.
- [any] $\mathbf{x}^+ = \frac{c}{a^2 + b^2}(a, b)$.
:::
:::

::: part
answer: b*c/(a^2 + b^2)
tolerance: 0.5%

### What is $y$?

::: misses
- [any] The shortest solution points along the row $(a, b)$.
:::
:::
:::

::: check
given: a = 1 | 2; b = 3 | 5
answer: b/(a^2 + b^2)
tolerance: 0.5%

## $A$ is the single column $(\given{a}, \given{b})$. What is the second entry of $A^+$, a 1 × 2 row?

::: right
Right. $A^+ = \frac{A^T}{A^TA}$, so the entry is $\frac{b}{a^2 + b^2}$ = {answer}.
:::

::: misses
- [1/b] The pseudoinverse doesn't invert entries one at a time.
- [a/(a^2 + b^2)] That's the first entry.
- [any] Not yet. For one independent column, $A^+ = (A^TA)^{-1}A^T$.
:::
:::

::: check
given: s = 0.001 | 0.01; e = 0.001 | 0.01
answer: e/s
tolerance: 0.5%

## A matrix's smallest singular value is {s}. Noise of size {e} in $\mathbf{b}$ along the matching $\mathbf{u}$ direction changes $A^+\mathbf{b}$ by how much?

::: right
Right. $\frac{e}{\sigma}$ = {answer}: a small singular value amplifies noise.
:::

::: misses
- [e*s] Divide by $\sigma$: $A^+$ inverts it.
- [any] Not yet. Along $\mathbf{u}_i$, $A^+$ multiplies by $1/\sigma_i$.
:::
:::

::: check
given: s = 0.01 | 0.1 | 0.5; l = 0.0001 | 0.01
answer: s^2/(s^2 + l)
tolerance: 0.5%

## Tikhonov regularization with $\lambda$ = {l} is applied. By what factor is the singular value {s}'s contribution scaled, compared with the plain pseudoinverse?

::: right
Right. $\frac{\sigma^2}{\sigma^2 + \lambda}$ = {answer}.
:::

::: misses
- [s/(s^2 + l)] That's the replacement for $1/\sigma$; compare it with $1/\sigma$.
- [any] Not yet. The factor is $\frac{\sigma/(\sigma^2 + \lambda)}{1/\sigma}$.
:::
:::

::: check
given: I = 2 | 5; R1 = 1 | 2.2; R2 = 3.3 | 4.7
answer: I*R2/(R1 + R2)
unit: mA
tolerance: 0.5%

## {I} mA divides between {R1} kΩ and {R2} kΩ in parallel so as to dissipate the least power. How much flows in the {R1} kΩ resistor?

::: right
Right. The minimum-power split is the current divider, $\frac{R_2}{R_1 + R_2}I$ = {answer}.
:::

::: misses
- [I*R1/(R1 + R2)] More current takes the smaller resistance.
- [I/2] An equal split dissipates more unless the resistors are equal.
- [any] Not yet. Minimize $R_1i_1^2 + R_2(I - i_1)^2$.
:::
:::

::: check
kind: derivation
vars: p = 0.5..3, q = 0.5..3, c = 1..10

## Find the minimum-norm solution of $px + qy = c$ from $A^+ = A^T(AA^T)^{-1}$.

::: step
answer: p^2 + q^2

### What is $AA^T$?
:::

::: step
answer: p*c/(p^2 + q^2)

### What is $x$?
:::

::: step
answer: c/sqrt(p^2 + q^2)

### What is the length of the solution?
:::

::: right
Right. The shortest solution's length is $\frac{|c|}{\sqrt{p^2 + q^2}}$, the distance from the origin to the line.
:::
:::

::: explain
## Why is the minimum-norm solution the one in the row space?

::: model
Every solution of $A\mathbf{x} = \mathbf{b}$ is one particular solution plus a null-space vector, and the row space and the null space are perpendicular. So any solution splits into a row-space part and a null-space part, and the row-space part is the same for all of them, because two solutions differ only by a null-space vector. By Pythagoras, the length squared is the row-space part squared plus the null-space part squared. The shortest solution has no null-space part at all. The pseudoinverse builds its answer from the $\mathbf{v}_i$ with nonzero $\sigma_i$, which span the row space, so it gives that solution directly.
:::
:::

::: practice

::: check
given: a = 0.5..5; b = 0.5..5; c = 1..20
answer: a*c/(a^2 + b^2)
tolerance: 0.5%

## Shortest solution of $\given{a}x + \given{b}y = \given{c}$: its $x$?

::: misses
- [any] $\frac{ac}{a^2 + b^2}$.
:::
:::

::: check
given: s = 0.001..1; l = 0.00001..0.1
answer: s^2/(s^2 + l)
tolerance: 0.5%

## Tikhonov factor for $\sigma$ = {s}, $\lambda$ = {l}?

::: misses
- [any] $\frac{\sigma^2}{\sigma^2 + \lambda}$.
:::
:::
:::
