Gram-Schmidt Process
The Gram--Schmidt process is an algorithm that takes any linearly independent set of vectors and produces an orthogonal (or orthonormal) set spanning the same subspace. It guarantees the existence of orthonormal bases in every finite-dimensional inner product space and is the constructive backbone of many algorithms in numerical linear algebra.
Statement
Let be an inner product space and a linearly independent set. Define recursively:
Then is an orthogonal set with for each .
Normalizing: gives an orthonormal set.
At each step, subtracts the component of in the previously constructed orthogonal directions, leaving only the component perpendicular to all previous vectors. Since (linear independence), this perpendicular component is nonzero.
Worked examples
Input: , , .
Step 1: .
Step 2: .
Check: β.
Step 3: .
, , .
.
Check: β, β.
Normalize: , , .
Input: , .
, .
.
.
The ONB is .
with , starting from .
, .
(since ).
.
These are (up to normalization) the Legendre polynomials: , , .
QR decomposition
Every matrix with linearly independent columns can be factored as , where:
- is an matrix with orthonormal columns,
- is an upper triangular matrix with positive diagonal entries.
The columns of are the orthonormalized versions of the columns of (via Gram--Schmidt), and records the coefficients.
.
Column 1: , , .
Column 2: , , .
, .
, .
.
, . , , .
, . When already has orthogonal columns (in the first column direction), QR is trivial.
For : , , so .
, .
Applications
The least-squares solution to (overdetermined system) is , which is numerically more stable than the normal equations .
For , : using the QR from before, , then solve .
Starting from any basis , Gram--Schmidt produces an ONB . This proves:
Every finite-dimensional inner product space has an orthonormal basis.
This existence theorem is nonconstructive in the sense that the result depends on the choice of starting basis, but the algorithm itself is fully constructive.
To find where : first orthonormalize to via Gram--Schmidt, then:
For and : after Gram--Schmidt, , .
.
Numerical stability
The classical Gram--Schmidt algorithm can suffer from numerical instability due to floating-point errors. The modified Gram--Schmidt algorithm orthogonalizes against each previously computed vector one at a time (rather than computing all projections simultaneously), and is significantly more stable:
For : set , then for : update .
Mathematically equivalent, but numerically superior. Householder reflections provide even better stability for the QR decomposition.
Summary
The Gram--Schmidt process is the algorithmic heart of inner product space theory:
- It proves existence of orthonormal bases.
- It computes the QR factorization, used in solving least-squares problems and eigenvalue algorithms.
- It connects the abstract theory (inner product, orthogonality) to computational practice.
- The process preserves the "progressive spans": for all .