Introduction
Projecting onto a line generalises to projecting onto any subspace — a plane, or an -dimensional subspace of . The recipe is the same: the error must be orthogonal to the subspace. The result is one formula that powers least-squares fitting, linear regression and PCA reconstruction.