An orthogonal basis makes inner products and coordinates easy to compute, but a basis usually arrives as an arbitrary linearly independent list. Gram-Schmidt turns that list into an orthogonal one by removing, at each stage, the part already explained by earlier directions. The order of the input matters: changing it can change the output, although the resulting list still spans the same subspace.
The projection idea
First consider one nonzero vector and a vector . To remove a multiple of and leave a perpendicular remainder, choose so that
Since , the denominator is positive and this coefficient is unique. With several mutually orthogonal directions, subtracting one such component does not change the inner products with the others.
Suppose are already nonzero and mutually orthogonal, and let . The coefficient of the component of along is
Thus the part left after removing all earlier orthogonal directions is
The denominators are legal because an orthogonal set contains no zero vector. When , the sum is empty and . This empty case is useful for the zero subspace, but it never asks us to normalize the zero vector.
Theorem
Orthogonal remainder theorem
Let be an orthogonal subset of , and let . Define
Then for every .
For a fixed , expansion gives
All terms with vanish. The remaining term is . If , the formula says that was already in the earlier span; for an arbitrary vector that can happen. Gram-Schmidt avoids this zero remainder by requiring an independent input list.
Projection and membership
For an orthogonal list , the same formula gives a useful membership test. Define
The orthogonal remainder theorem gives . Also,
The forward implication is immediate from the projection formula. Conversely, if , taking the inner product with gives because the cross terms vanish; substitution gives . Thus a nonzero remainder records exactly the part of outside the current span.
Proof
Projection plus an orthogonal remainder
Let and set
Then , and the orthogonal remainder theorem gives for every generator. By linearity, , so . If is empty, the sum is , , and the same statement reads .
Suppose also with and . Then belongs to and is perpendicular to . Consequently , so ; hence and . The decomposition into a part in and an orthogonal remainder is therefore unique.
This decomposition gives a precise meaning to “remove the old directions.” The vector is the part reconstructed from the available orthogonal generators, and is the part that no linear combination of them can explain. If , the membership criterion says , so the projection is all of . If , then and it supplies a new direction perpendicular to every direction already in . In the Gram-Schmidt induction, this is why the next independent input cannot disappear: a zero residual would put it in the earlier span. The uniqueness argument also matters computationally. It says that two different lists of coefficients cannot produce two different “orthogonal parts” of the same vector while both satisfying the defining conditions. The condition forces that ambiguity to vanish, because a real inner product is positive definite. This is the exact geometric content behind the coefficient formula, while the worked calculations show how to evaluate it without relying on a picture.
The Gram-Schmidt process
Theorem
Gram-Schmidt orthogonalization process
Let and let be a linearly independent list in . Define
and, for ,
Then every is nonzero, the vectors are pairwise orthogonal, and for every ,
The empty input list is handled separately: its span is the zero subspace , and its output is the empty orthogonal list. There is no to define and no vector to normalize in that case.
The algorithm must use the constructed orthogonal vectors in the subtractions. The original generally are not orthogonal, so subtracting their projections independently does not remove the correct component.
Proof
The three invariants in the induction
We prove simultaneously at stage that (i) the new vector is nonzero, (ii) the constructed vectors are orthogonal, and (iii) the partial spans are equal. The base case is ; both spans are the same line.
Assume all three statements through . The earlier are nonzero, so every denominator in the definition of is valid. The orthogonal remainder theorem gives for every , proving the new orthogonality.
The defining equation writes as a combination of and earlier , so the new -span is contained in the new -span. Rearranging gives
which gives the reverse inclusion. Finally, if , this equation places in , contradicting input independence. Thus the new vector is nonzero, and all three assertions follow without assuming the conclusion in advance.
This is why orthogonality means more than a list of zero dot products: an orthogonal set also excludes zero vectors. The nonzero check makes normalization legal.
Subtract old directions in three dimensions
Worked example
Three independent vectors in
Take the ordered list
The determinant of the matrix with these columns is , so the input is independent. First,
For the second vector,
For the third, both constructed directions matter:
so
The squared norms are , and direct products give
The span invariant is visible:
Thus the output spans exactly the same as the input.
The arithmetic at the third stage can be audited before accepting the answer: and . The subtraction therefore removes , leaving ; this explains the negative first coordinate rather than treating it as a sign to be guessed.
Counterexample mode
Why original w-vectors cannot replace v-vectors
A tempting but incorrect third step is
This vector has dot product with , so it is not orthogonal to the first direction. The repair is to subtract projections onto and , which gives the correct . The input and constructed lists are different even though their partial spans agree.
Keep fractional projection coefficients exact
Here the projection coefficients are fractions. Keep them exact through each subtraction, then check orthogonality and the equality of spans.
Worked example
Fractional projections in three dimensions
Start with
| Step | Projection data | New orthogonal vector | Span preserved |
|---|---|---|---|
| none | |||
| , |
The input determinant is , so these columns are independent. In particular, the final residual must be nonzero. Here and ; hence the second coefficient in the third row is . The resulting has squared norm , and direct products give .
Normalization and boundary cases
Theorem
From an orthogonal basis to an orthonormal basis
If is an orthogonal basis, define
Every has norm , and scaling preserves pairwise orthogonality. The result is an orthonormal basis of the same subspace.
Worked example
Normalize the first output
For the first example,
Therefore
This uses the first output, not the distinct table input.
Because each norm is positive, keeps the orientation of ; multiplying by recovers the exact vector rather than its negative.
For the unit checks, , , and . Moreover, , so each is recovered from by scaling; both directions of every span equality are preserved.
Worked example
An orthonormal basis from a constraint in
Let
Writing shows that has the basis
These vectors are independent: if , then coordinates 2, 3, and 4 force . The constraint already shows that they lie in .
The process gives
Here and , giving the coefficient . Also , while and , giving . Thus
Their squared norms are . Hence
For example, and ; the displayed scaling factors make all three norms equal to . Each vector has coordinate sum zero and each pair has dot product zero. Since , each is recovered from by scaling, so normalization preserves both directions of every span equality. The nullspace has dimension , so these vectors form an orthonormal basis of .
The arithmetic also verifies the span claim in both directions. From the three definitions,
Conversely, each displayed is built from the corresponding and previous vectors. Thus the change from to is triangular with diagonal coefficient , so no direction is lost. The normalized vectors stay in : for the coordinate sum is , for it is , and for it is . Their squared lengths are respectively , , and , all equal to . These coordinate checks certify the constraint and the normalization independently of the orthogonality calculation.
Theorem
Every finite-dimensional subspace has an orthonormal basis
Every subspace of has a finite basis. In positive dimension, Gram-Schmidt gives a nonzero orthogonal basis, and normalization gives an orthonormal basis. The zero subspace has the empty basis, already orthogonal and orthonormal by the empty-list convention; no division by a norm occurs.
Common mistake
Dependent input creates a zero remainder
If and , then
The next normalization would be undefined. Remove redundant vectors first; Gram-Schmidt is designed for an independent ordered list.
Quick checks
Checkpoint
What is the first Gram-Schmidt vector ?
Read the first line of the recursive definition.
Solution · Answer
It is ; the first input direction is retained.
Checkpoint
What property does Gram-Schmidt preserve besides orthogonality?
Use the partial-span equality.
Solution · Answer
It preserves every partial span: .
Checkpoint
How do you turn an orthogonal basis into an orthonormal basis?
Use the norm of each constructed vector.
Solution · Answer
For every nonzero , divide by its norm: .
Checkpoint
Apply the first two steps to and .
Compute , then the single projection coefficient.
Solution · Guided solution
, and the projection coefficient is . Hence
Check . Also , so the old and new pairs span the same plane.
Checkpoint
Why is a zero remainder a warning for an independent input list?
Relate a zero remainder to the earlier span.
Solution · Guided solution
The remainder is zero exactly when the current vector lies in the earlier span, which contradicts independence.
Checkpoint
Suppose orthogonal vectors have norms 3 and 4. What are the corresponding unit vectors?
Normalize each vector separately.
Solution · Guided solution
They are and ; both have norm and remain orthogonal.
Related notes
Read 9.2 Orthogonal sets and orthonormal bases first, because Gram-Schmidt uses the orthogonal coefficient formula. The constraint-space example also uses the nullspace and basis methods from 6.2 Subspaces and 6.5 Basis and dimension.
The next note, 9.4 Cauchy-Schwarz and triangle inequalities, develops inequalities that bound these inner-product calculations.