Least squares

When $A\mathbf{x} = \mathbf{b}$ has no solution, the best $\hat{\mathbf{x}}$ makes $A\hat{\mathbf{x}}$ the projection of $\mathbf{b}$ onto the column space, so the residual is perpendicular to every column and $A^TA\hat{\mathbf{x}} = A^T\mathbf{b}$; fitting a line to data is the classic case.

From Linear Algebra.