Given a set of N linearly independent vectors ∣V1⟩,∣V2⟩,...
from a Hilbert space,
the Gram-Schmidt method is an algorithm that turns them
into an orthonormal set ∣n1⟩,∣n2⟩,... as follows
(in Dirac notation):
Take the first vector ∣V1⟩ and normalize it to get ∣n1⟩:
∣n1⟩=⟨V1∣V1⟩∣V1⟩
Begin loop. Take the next input vector ∣Vj⟩, and
subtract from it its projection onto every already-processed vector:
This leaves only the part of ∣Vj⟩
that is orthogonal to all previous ∣nk⟩.
This why the input vectors must be linearly independent;
otherwise ∣gj⟩ could become zero.
On a computer, the resulting ∣gj⟩ will
not be perfectly orthogonal due to rounding errors.
The above description of step #2 is particularly bad.
A better approach is:
In other words, instead of projecting ∣Vj⟩ directly onto all ∣nk⟩,
we instead project only the part of ∣Vj⟩ that has already been made orthogonal
to all previous ∣nm⟩ with m<k.
This is known as the modified Gram-Schmidt method.
Normalize the resulting orthogonal vector ∣gj⟩ to make it orthonormal:
∣nj⟩=⟨gj∣gj⟩∣gj⟩
Loop back to step 2, taking the next vector ∣Vj+1⟩,
until all N have been processed.
References
R. Shankar,
Principles of quantum mechanics, 2nd edition,
Springer.