Gram-Schmidt Process
Gram-Schmidt Process is an algorithm that converts any linearly independent set of vectors into an orthonormal set spanning the same subspace. Key result: given , it produces with and for every . Applies in: any inner product space (Euclidean spaces, function spaces, ). Who/when: named for Jørgen Pedersen Gram (1883) and Erhard Schmidt (1907), though Laplace and Cauchy used the idea earlier.
To make a vector orthogonal to a subspace, subtract its orthogonal projection onto that subspace. Doing this sequentially — projecting each new vector onto the span of all already-orthogonalized vectors and removing that component — guarantees the leftover is orthogonal to everything before it. Normalizing then fixes the length. The whole algorithm is just "project, subtract, normalize," repeated.
Formal Statement
Let be a real or complex vector space equipped with an inner product , which induces the norm . A set is orthonormal if
Derivation hint: is the Kronecker delta; orthogonality is the off-diagonal condition, unit length the diagonal condition. The orthogonal projection of a vector onto a nonzero vector is
Derivation hint: seek scalar so that ; impose and solve for .
Given linearly independent vectors , define orthogonal vectors and orthonormal vectors recursively:
Derivation hint: the first vector needs no orthogonalization; only normalization.
Derivation hint: subtract from its projections onto each previously found orthogonal direction ; the remainder is orthogonal to all of them. Equivalently, using the already-normalized (cleaner since ):
Derivation hint: substitute into [4]; the in the denominator cancels, leaving inner products against unit vectors.
If are linearly independent, then the vectors produced by [3]–[5] are orthonormal and satisfy
Derivation hint: prove span-preservation by induction; linear independence guarantees each so normalization is valid.
Why It Holds / Derivation
We prove by induction on that is orthonormal and spans the same space as .
Step 1 (Base case). since the are independent, so is well-defined and . Clearly .
Step 2 (Inductive hypothesis). Assume is orthonormal and spans .
Step 3 ( is orthogonal to each earlier ). For , take the inner product of [5] with :
Derivation hint: by orthonormality , so the sum collapses to the single term.
Step 4 (). If , then [5] would express as a linear combination of , hence of (inductive hypothesis), contradicting linear independence. So and is well-defined with .
Step 5 (Span preservation). From [5], , so and conversely . Combined with the inductive hypothesis, . This closes the induction.
∎A German mathematician and student of David Hilbert, Schmidt is a founding figure of functional analysis. In his 1907 work on integral equations he introduced the orthogonalization procedure now bearing his name, applying it to function spaces — the setting that became Hilbert space theory. The "Gram" in the name credits Jørgen Pedersen Gram, a Danish actuary and mathematician whose 1883 paper on least-squares series expansions used the same construction. Historically, the underlying idea appears even earlier in the work of Laplace and Cauchy. Schmidt also co-founded the Berlin school of applied mathematics and contributed to the spectral theory of compact operators.
Building Intuition
Picture standing at the origin holding several arrows pointing in generic directions. You want to replace them with a clean set of mutually perpendicular unit arrows covering exactly the same flat region. Take the first arrow and just shrink it to length one — that's your first axis. For the second arrow, its shadow (projection) onto the first axis is the part you don't want; cut it off, keep the perpendicular leftover, shrink to length one. For the third arrow, remove its shadows on both established axes; the remainder points straight out of the plane they span. Each step strips away everything that "leans" toward earlier directions, leaving a fresh perpendicular component. The order matters: always points exactly along , and the process never looks ahead — it only cleans up against what came before.
Worked Examples
Given the linearly independent vectors
using the standard dot product.
Step 1. , with , so
Step 2. , and .
, so
Step 3. and .
Compute: , .
, so .
Boxed answer (orthonormal basis):
(Check: each has unit length and pairwise dot products vanish, e.g. .)
Given the functions on with the inner product
We orthogonalize (without normalizing, to match standard Legendre conventions).
Step 1. , with .
Step 2. , so no subtraction:
Here .
Step 3. and .
Boxed answer:
These are proportional to the Legendre polynomials (up to the normalization , giving ). Gram-Schmidt on with this inner product generates the entire Legendre family.
Common Misconceptions
The textbook recursion [4] — called Classical Gram-Schmidt (CGS) — suffers severe loss of orthogonality in floating-point arithmetic when the input vectors are nearly linearly dependent. Rounding errors accumulate, and the computed can fail to be orthogonal. The fix is Modified Gram-Schmidt (MGS), which subtracts projections sequentially and re-orthogonalizes against each as it is computed rather than all at once. MGS is mathematically identical to CGS in exact arithmetic but vastly more stable numerically. For maximum robustness, Householder reflections or Givens rotations are preferred for QR factorization. Never use CGS for ill-conditioned problems.
The output depends on the ordering of the input vectors: permuting generally gives a different orthonormal basis. Also, a common slip is dividing by when using the normalized in the formula — if you use unnormalized you must keep the denominator [4]; if you use the denominator is [5]. Mixing the two leads to wrong projections.
If the input vectors are not linearly independent, Gram-Schmidt fails. Take , in . Then
Here , so involves division by zero. This is exactly the situation Step 4 of the proof rules out under independence. In practice, encountering a (near-)zero is how one detects linear dependence — the process doubles as a rank test.
Connections
Gram-Schmidt is woven through linear algebra and analysis:
- <a class="wiki-link" href="/wiki/qr-decomposition">QR Decomposition</a>: applying Gram-Schmidt to the columns of a matrix yields , where has the orthonormal as columns and is upper triangular with entries and .
- <span class="wiki-link-missing">Orthogonal Projection</span>: each step is literally subtracting an orthogonal projection onto a subspace; the algorithm is projection applied repeatedly.
- <span class="wiki-link-missing">Inner Product Space</span>: the whole construction lives in any space with an inner product, real or complex (with conjugation in the Hermitian case).
- <span class="wiki-link-missing">Orthogonal Polynomials</span>: Gram-Schmidt on monomials with a weighted inner product generates Legendre, Chebyshev, Hermite, and Laguerre families.
- <span class="wiki-link-missing">Least Squares Approximation</span>: an orthonormal basis turns the normal equations into trivial coordinate computations.
- <span class="wiki-link-missing">Spectral Theorem</span>: the existence of orthonormal eigenbases for symmetric/Hermitian operators is often established via Gram-Schmidt on eigenspaces.
Real-World Applications
Historical Development
Subtleties & Limits
Several refinements remain active in numerical linear algebra. The precise conditions under which a single reorthogonalization step suffices ("Kahan–Parlett twice-is-enough") are understood for well-separated cases but become delicate near breakdown. Block Gram-Schmidt variants for tall-skinny matrices on parallel/GPU architectures face a tension between communication efficiency and orthogonality quality, an area of ongoing algorithm design. In infinite-dimensional Hilbert spaces, Gram-Schmidt always terminates on countable independent sets but the resulting orthonormal sequence's completeness (whether it spans the whole space) is a separate analytic question tied to density. Finally, generalizing stable orthogonalization to non-standard or indefinite inner products (e.g., Minkowski/Lorentzian "inner products" in relativity, where can be negative or zero) requires modified algorithms, since vectors can be null or "imaginary-length," and the classical normalization step breaks down.
See Also
QR Decomposition · Orthogonal Projection · Inner Product Space · Orthogonal Polynomials · Least Squares Approximation · Householder Transformation · Spectral Theorem · Linear Independence