The Gram-Schmidt Process
Suppose you have a list of linearly independent vectors in an inner product space. They are neither orthogonal nor of unit length. Can you systematically rebuild them into an orthonormal list? The goal is to do this without losing any geometric information they encode. This is the question the Gram–Schmidt process answers. It does so with a striking guarantee. At every intermediate step, a key property holds. The span of the first new orthonormal vectors equals the span of the first original vectors. The importance of this cannot be overstated. Orthonormal bases are the setting where coordinates, norms, and inner products all take their simplest form. A vector's coordinates are just inner products with basis vectors. The Pythagorean theorem also holds in full generality. But arbitrary bases arising "in the wild" are almost never orthonormal. These arise from solving differential equations, from data, or from a change of coordinates. Gram–Schmidt is the bridge between these cases. It is an explicit, constructive algorithm. It converts any linearly independent list into an orthonormal one. It uses only the inner product itself. The big picture is that this single procedure is important. It is the engine behind several landmark facts in linear algebra. It proves that every finite-dimensional inner product space has an orthonormal basis. It underlies the QR factorization of a matrix. This factorization is a computational cornerstone of numerical linear algebra. It gives the theoretical construction of orthogonal projections onto subspaces. It is also the machinery behind least-squares approximation. This article gives the precise construction. It proves the fundamental theorem with full rigor. That theorem is orthonormality plus span-preservation at every stage. The article also works through the subtleties. It considers what changes if the input vectors are only spanning, not independent. It examines what happens over the real numbers versus the complex numbers. Finally, it shows where the process is used. This includes applications across mathematics, statistics, and engineering.
- Gram–Schmidt converts a linearly independent list into an orthonormal list .
- At every stage , — this is the defining feature, not an afterthought.
- The construction is recursive: subtract off the projection onto the span so far, then normalize.
- It proves every finite-dimensional inner product space has an orthonormal basis.
- Applied to the columns of a matrix, it produces the QR factorization used in numerical computation.
- Key idea: orthogonalize by subtracting projections onto everything built so far, one vector at a time.
Where this lives today
The Gram–Schmidt process is the theoretical proof, and a practical algorithm, behind the QR factorization of a matrix: writing with orthogonal (or unitary) and upper triangular, used to solve least-squares problems, compute eigenvalues via the QR algorithm, and stabilize numerical linear algebra computations. In statistics, orthogonalizing regressors via Gram–Schmidt underlies sequential (Type I) sums of squares and the construction of orthogonal polynomial regression bases. In numerical analysis and approximation theory, applying the process to the monomials on an interval with a weighted inner product produces classical families of orthogonal polynomials, such as Legendre and Chebyshev polynomials. In quantum mechanics and more broadly in the theory of Hilbert spaces, Gram–Schmidt constructs orthonormal bases of state spaces from convenient but non-orthogonal spanning sets. In signal processing and coding theory, orthogonalizing a set of basis signals or codewords (as in some lattice reduction and precoding schemes) relies on the same recursive projection-and-subtract idea, and modified variants of the algorithm are used for numerically stable orthogonalization in large-scale linear algebra software.
Ask the tutor: How does the Gram-Schmidt process change if I only need an orthogonal (not orthonormal) list, and why might I prefer to skip normalization until the end?
Let be an inner product space over (where or ), with inner product conjugate-linear in the second slot (or linear, if ) and norm . Let be a linearly independent list of vectors in . Define vectors recursively as follows. Set
Having defined for some , set
The list produced by this recursion is called the Gram–Schmidt orthonormalization of .
Intuition
Picture building an orthonormal list one vector at a time, always working inside the growing subspace spanned by the vectors processed so far. The first vector only needs rescaling: divide by its length to make it a unit vector . This changes nothing about direction. The second vector is not generally orthogonal to . But we can decompose into a piece parallel to and a piece orthogonal to it: the parallel piece is the orthogonal projection , and subtracting it off leaves the orthogonal remainder . Normalizing gives , a unit vector orthogonal to and lying in . The pattern repeats: at stage , subtract from its projection onto the entire subspace spanned by the previously constructed orthonormal vectors . What remains, , is orthogonal to all of by construction, and it is nonzero precisely because was not already in — this is exactly where linear independence is used. Normalizing produces . The crucial invariant, illustrated below, is that no information about the span is ever lost: always equals , so the new orthonormal list "sits inside" the old flag of subspaces at every stage.
Let be an inner product space over and let be a linearly independent list in . Let be the list produced by the Gram–Schmidt process applied to . Then: 1. (Well-definedness) At every stage , the vector (and hence ) is well defined, meaning , so division by never divides by zero. 2. (Orthonormality) The list is orthonormal: for all , and for . 3. (Span preservation) For every ,
4. (Triangularity of coefficients) For every , with
so that is an explicit linear combination of with the coefficient of equal to .
We prove all four claims simultaneously by strong induction on , using the technique of induction with a compound inductive hypothesis: at stage we assume claims (1)–(3) hold for all indices less than , and deduce them for .
Base case . Since is linearly independent, in particular (a list containing the zero vector is linearly dependent). Hence and is well defined. Clearly , giving orthonormality of the singleton list (there are no distinct pairs to check). Since is a nonzero scalar multiple of , . Finally since (using conjugate-linearity in the second slot, and that ). This establishes (1)–(4) for .
Inductive step. Fix with , and assume (1)–(4) hold for all indices ; in particular is a well-defined orthonormal list with
Step A: is well defined, i.e. . By definition,
The sum is a linear combination of , hence lies in by the inductive hypothesis. If were , then would equal this sum, and thus . But then would be a linear combination of , contradicting the linear independence of (a linearly independent list has no vector in the span of the others). Hence , so and is well defined. Step B: orthogonality of with each , . Fix . Using linearity of the inner product in the first slot and the inductive orthonormality of (so for and ):
Since is a positive scalar multiple of , we get . Combined with the inductive orthonormality of , this shows is orthonormal — every pairwise inner product among indices vanishes, and . This proves (2) for . Step C: span preservation. We show the two inclusions. () Each for lies in by the inductive hypothesis. Also,
is a linear combination of and of (each of which is in ), hence . Since every , , lies in , so does their span: . () Each for lies in by the inductive hypothesis. Rearranging the definition of ,
which exhibits as a linear combination of , so . Hence every , , lies in , giving . Together these inclusions give , proving (3) for . Step D: the explicit formula (4). The equation displayed at the end of Step C,
is exactly the claimed formula with coefficient of equal to (check: , using Step B's orthogonality). This is positive by Step A, and exactly. This proves (4) for . By induction, claims (1)–(4) hold for every , completing the proof.
∎Every finite-dimensional inner product space with has an orthonormal basis.
Since , has some basis , which is in particular a linearly independent list. Apply the Gram–Schmidt process to obtain an orthonormal list with, by part (3) of the theorem (at ), . An orthonormal list is automatically linearly independent (a standard fact: if , taking the inner product with gives for each ), so is a linearly independent spanning list of size , hence a basis.
∎Worked examples
Example 1: an asymmetric list in . Let with the standard inner product, and let
First check linear independence: the matrix with these as rows,
has determinant , so is linearly independent.
Step 1. , so
Step 2. Compute . Then
Check orthogonality directly: . Good. Now , so
Step 3. Compute , and . Then
Compute each piece: , and . So
Converting to thirds: , , sum . Similarly . And . So
Sanity check: should be : . ✓. And . ✓ Now , so
Final answer:
One can verify by checking both (immediate from the recursion) and vice versa.
Example 2: a complex inner product space, . Let with (linear in the first slot, conjugate-linear in the second). Take
Check independence: if then and ; substituting into the second gives , forcing (since ) and then . So the list is independent.
Step 1. , so and
Step 2. Compute . Compute . So the bracket is . Thus
Then
Compute (since ). So
Check orthogonality: should vanish. Using linearity in the first slot and conjugate-linearity in the second, since we already engineered this, we trust the algebra but verify numerically:
Compute . Sum: . ✓ Now compute . So and
This example illustrates the extra bookkeeping care required with the conjugate: the inner product is generally a complex number, and one must remember which slot is conjugate-linear when computing both the projection coefficient and its conjugate appearing in later verifications.
The hypothesis that is linearly independent is not a convenience — it is exactly what guarantees at every stage (Step A of the proof). Drop it, and the process can fail outright. Let with the standard inner product, and consider the list
This list is linearly dependent (), so it fails the theorem's hypothesis. Attempt the process anyway:
Then
Here , so requires dividing by zero — the process is undefined at stage 2, not merely "orthonormal but span-violating." This is precisely the failure mode ruled out by Step A of the proof, which used linear independence in an essential, non-circumventable way: without it there is no contradiction available to conclude . If one instead modifies the algorithm to simply discard whenever (a standard fix used when orthonormalizing a spanning but dependent list, in order to extract a basis), the resulting shorter list is still orthonormal, but the clean statement " for every " as stated in the theorem no longer holds for the original indexing — the theorem as proved genuinely requires independence of the full list.
Scope, edge cases & common traps
| Situation | What happens |
|---|---|
| linearly independent | Theorem applies exactly as stated; orthonormal, spans preserved at every stage. |
| linearly dependent | Process breaks down (division by zero) at the first index where . |
| infinite-dimensional, list still finite | Theorem still applies verbatim — nothing in the proof used finite-dimensionality of , only finiteness of the list. |
| Works identically, but inner-product coefficients are complex; care needed with conjugate-linear slot conventions. | |
| Order of the list changed | A different permutation of generally produces a genuinely different orthonormal list (though always spanning the same total space) — span preservation is about initial segments, which depend on order. |
| Applying to columns of a matrix | Produces the factorization with having orthonormal columns and upper triangular with positive diagonal, directly from part (4) of the theorem. |
The mathematician behind it
Origins · 1 minJørgen Pedersen Gram and how this was discovered
Jørgen Pedersen Gram worked as an actuary for a Danish insurance company and pursued mathematics largely outside formal academic institutions, publishing on probability, numerical analysis, and number theory (he made early computations related to the Riemann zeta function's zeros). Independently, Erhard Schmidt (1876–1959), a student of David Hilbert and a founder of modern functional analysis, formalized and popularized the orthogonalization procedure in his 1907 work on integral equations, where it became a foundational tool for what would become Hilbert space theory.
Does Gram-Schmidt require the vector space to be finite-dimensional?
No. The process only requires the input list to be finite and linearly independent; it makes no reference to the dimension of the ambient space , which may be infinite-dimensional, as in many Hilbert spaces of functions. The proof, being an induction on the finite index , goes through unchanged. What does require finite-dimensionality is the corollary that every orthonormal basis of can be reached this way — in infinite dimensions, orthonormal bases require additional care (Zorn's-lemma-type arguments or completeness conditions), which is beyond the scope of the finite-list version treated here.
Does the order of the input vectors matter?
Yes, substantially. Gram–Schmidt applied to versus generally produces different orthonormal lists, even though both span the same two-dimensional subspace. The theorem's span-preservation guarantee is specifically about initial segments in the given order: for that particular ordering. Reordering the input list changes which intermediate subspaces are preserved, and generally changes every except when (the full span is order-independent).
What happens if two of the vectors are equal, or nearly parallel?
If two vectors are literally equal, the list is linearly dependent and the process breaks down exactly as in the counterexample: some becomes zero and division by zero occurs. If two vectors are merely nearly parallel (but the list remains independent), the process is still mathematically well defined, but in floating-point computation, catastrophic cancellation can occur when subtracting nearly equal quantities, causing severe loss of orthogonality in practice. This numerical instability is why the "classical" Gram–Schmidt described here is often replaced computationally by the mathematically equivalent but numerically superior "modified Gram–Schmidt" algorithm.
How does Gram-Schmidt relate to QR factorization?
If is an matrix with linearly independent columns , applying Gram–Schmidt to these columns produces orthonormal vectors . Part (4) of the theorem gives exactly , which assembled into matrix form reads , where has columns (orthonormal) and is upper triangular with entries for and diagonal entries . This is precisely the QR factorization, and the theorem's triangularity claim is the algebraic content that makes it upper triangular.
Is the orthonormal list produced by Gram-Schmidt unique?
Given a fixed ordered independent list , the Gram–Schmidt recursion as defined here — with the convention that each is a positive multiple of — produces a unique orthonormal list. If one instead allowed to be any unit scalar multiple of (e.g. , or in the complex case for any ), one would get equally valid orthonormal lists with the same span-preservation property, so uniqueness genuinely depends on fixing a sign/phase convention, which is exactly the positivity requirement built into the theorem's formula for the diagonal coefficients.
Can Gram-Schmidt be used on a spanning list that is not independent, to extract a basis?
Yes, with a modification: process the vectors in order, and whenever the current vector's remainder turns out to be zero, simply discard that vector and move to the next one without incrementing the orthonormal list. The vectors kept form a linearly independent sublist (since discarding happens exactly when the current vector is in the span of the earlier kept ones), and the final orthonormal list spans the same space as the whole original list. This variant is a standard tool for pruning a spanning set down to a basis while simultaneously orthonormalizing it, though it is a modification of, not identical to, the theorem as stated for independent lists.