Skip to content

Projection onto a subspace

Project b onto the column space of A by solving AᵀA x̂ = Aᵀb, build P = A(AᵀA)⁻¹Aᵀ, check P² = P and Pᵀ = P, and split b = p + e with e orthogonal to the subspace.

It opens on

The plane of all combinations of (1, 0, 1) and (0, 1, 1) does not contain (3, 0, 0); which point of the plane is nearest to it, and how do we find it with one formula?

Why it matters

A system Ax = b with no solution still has a best answer, the point of the column space nearest b; this projection is exactly what least squares computes.

Good to know first

  • Projection onto a line: p = x̂a with the error orthogonal to a
  • Orthogonal vectors and subspaces: the complement of a column space is N(Aᵀ)
  • The inverse matrix: the 2 × 2 inverse formula (1/det)[[d, −b], [−c, a]]

Step by step

  1. Find the foot in the plane

    Solve AᵀA x̂ = Aᵀb for A with columns (1, 0, 1) and (0, 1, 1), and compute p = Ax̂ and e = b − p.

    For A = [[1, 0], [0, 1], [1, 1]] and b = (3, 0, 0): AᵀA = [[2, 1], [1, 2]] and Aᵀb = (3, 0).

    A common mix-up

    Project onto each column separately and add the results.

    In fact: That works only when the columns are orthogonal; here a₁·a₂ = 1, and the sum of the two single-line projections is not p.

  2. The projection matrix

    Build P = A(AᵀA)⁻¹Aᵀ for the thread and verify Pb = p, P² = P and Pᵀ = P.

    AᵀA = [[2, 1], [1, 2]] has determinant 3, so (AᵀA)⁻¹ = (1/3)[[2, −1], [−1, 2]].

    A common mix-up

    P = A(AᵀA)⁻¹Aᵀ simplifies to AA⁻¹Aᵀ⁻¹Aᵀ = I.

    In fact: A is 3 × 2 and has no inverse, so (AᵀA)⁻¹ cannot be split; P is not I.

  3. Splitting b into p and e

    Write b = p + e with p in the column space and e orthogonal to it, find the matrix I − P, and see when AᵀA fails to be invertible.

    For the thread p = (2, −1, 1) and e = (1, 1, −1), and p + e = (3, 0, 0) = b.

    A common mix-up

    P is invertible, since it is a nice symmetric matrix.

    In fact: P sends the normal direction to 0, so it has rank 2 and no inverse.

Try it

Project b = (2, 0, 4) onto the plane spanned by (1, 0, 0) and (1, 1, 1).Answer

p = (2, 2, 2) with x̂ = (0, 2)

Hint: AᵀA = [[1, 1], [1, 3]] and Aᵀb = (2, 6)

Find the projection matrix onto the plane spanned by (1, 1, 0) and (0, 0, 1), and apply it to (4, 0, 5).Answer

P = [[1/2, 1/2, 0], [1/2, 1/2, 0], [0, 0, 1]] and P(4, 0, 5) = (2, 2, 5)

Hint: The columns are orthogonal, so AᵀA = [[2, 0], [0, 1]]

For P = (1/3)[[2, −1, 1], [−1, 2, 1], [1, 1, 2]], explain why P(1, 1, −1) = 0.Answer

(1, 1, −1) is the plane's normal, orthogonal to both columns, so its projection onto the plane is 0

Hint: Compute the row sums with the entries (1, 1, −1)

Check that e is orthogonal to both columns: what are a₁·e and a₂·e?Answer

1 − 1 = 0 and 1 − 1 = 0.

What does P do to a₁ = (1, 0, 1), a vector already in the plane?Answer

(1/3)(2 + 1, −1 + 1, 1 + 2) = (1, 0, 1): it stays put.

Projection onto a subspace

30 minutes every month. No card.