Write . Every least-squares solution is for some , while . Decompose using orthogonal projections. Then the Pythagorean identity gives
The first term is independent of , and the second vanishes at exactly one point. Hence the unique nearest least-squares solution is
Geometrically this is the orthogonal projection of onto the closed affine subspace of least-squares solutions.