Why orthogonal projection gives the closest point
7 min read
Short answer
The orthogonal projection of onto a subspace is the closest point of that subspace to , and it is characterized by one fact: the error is perpendicular to the subspace. The Pythagorean theorem turns that perpendicularity into minimality.
Projecting onto a line
Points on the line are . The squared distance to is . Minimizing: , so
At this , the error satisfies : it is perpendicular to the line. Calculus and geometry agree.
Why perpendicular means closest
Let be a point of the subspace with , and let be any other point of . Then , so it is perpendicular to the error, and the Pythagorean theorem gives
Every other point is strictly farther unless . This works in any number of dimensions and for any subspace, which is why projection is the foundation of least squares.
Projecting onto a subspace
For a subspace spanned by the columns of , requiring the error to be perpendicular to every column gives , the normal equations . The projection is with
Two identities describe any projection matrix: (projecting twice changes nothing) and (it is symmetric, which is what makes it orthogonal rather than slanted).
Worked example
Project onto the line through , and find the distance from to the line.
, , so and .
Error: . Check: ✓.
Distance: , so the distance is . Pythagoras check: . ✓
Try it yourself
Project onto the line through and verify the error is perpendicular.
Show the answer
, so and the error is . Its dot product with is , so it is perpendicular.
Keep going with practice
Vidi's projection and least-squares lessons both rest on this perpendicular-error idea.