Inner products & orthogonality

projection

The projection of a vector onto a line or a subspace is its shadow: imagine the sun straight overhead casting the vector down onto the line. The shadow is the point in that subspace that sits closest to the original vector.

Projecting splits a vector cleanly into two pieces: a part that lies inside the subspace (the shadow) and a leftover part that is perpendicular to it (the error, or residual). Those two pieces add back up to the original vector, and they are orthogonal to each other.

Onto a single direction u, the formula is proj = ((v . u) / (u . u)) * u. Example: projecting v=(3,4) onto the x-axis u=(1,0) gives (3,0) inside the axis, with leftover (0,4) standing straight up.

proj of (3,4) onto (1,0) = ((3,4).(1,0) / (1,0).(1,0)) * (1,0) = (3,0)

The shadow (3,0) plus the perpendicular leftover (0,4) rebuild (3,4).

The leftover part (the error) is always orthogonal to the subspace, which is precisely why the shadow is the closest point.

Also called
orthogonal projectionvector projection正交投影向量投影射影