Orthogonality and Projection
- Compute the orthogonal projection of a vector onto a line and verify that the residual is perpendicular to the line
- Apply Gram-Schmidt orthogonalisation to produce an orthonormal basis from an arbitrary spanning set
- Build the projection matrix P = QQ^T for a subspace and verify it is idempotent and symmetric
- Derive the least-squares solution via the normal equations A^T A x = A^T b and interpret the residual geometrically
- Interpret the hat matrix H = A(A^T A)^{-1} A^T as an orthogonal projector and explain what it means for fitted values and residuals
Orthogonality
Two vectors are orthogonal if their dot product is zero:
The norm (length) of a vector is . A unit vector has ; any nonzero vector can be normalized: .
A set is orthonormal if (1 if , 0 otherwise). Orthonormal sets are automatically linearly independent.
Orthogonal Projection onto a Line
Given a line through the origin spanned by , the orthogonal projection of onto this line is the point on the line closest to :
The scalar is the signed component of along . The error (residual) is orthogonal to — this is the defining geometric property of orthogonal projection.
As a matrix: for a unit vector , the projection is . The matrix is the rank-1 projection matrix onto the line. It satisfies (idempotent) and (symmetric).
Gram-Schmidt Orthogonalization
Gram-Schmidt converts any basis into an orthonormal basis spanning the same space:
Step 1: , then
Step (for ): subtract the projections onto all previous :
Each is the component of orthogonal to the subspace spanned by .
QR decomposition: Gram-Schmidt applied to the columns of produces where has orthonormal columns and is upper triangular. This is used in least-squares solvers and eigenvalue algorithms.
Projection into a Subspace
Let be a subspace of with orthonormal basis . The orthogonal projection of onto is:
where . The projection matrix satisfies:
- (projecting twice does nothing)
- (it is symmetric)
The complement is orthogonal to every vector in .
Least Squares: The Geometry
When the system has no solution (as happens in overdetermined systems with more equations than unknowns), the best we can do is find minimizing .
Geometrically: is the projection of onto the column space of . The residual must be orthogonal to all columns of :
These are the normal equations. When has full column rank, is invertible and the unique least-squares solution is:
The matrix is the projection matrix onto the column space of — the hat matrix familiar from regression. This is the linear algebra foundation of ordinary least squares, and by extension of any optimization problem whose solution is a projection.