The Gram–Schmidt Process
You can turn any basis into an orthogonal one by taking the vectors one at a time and removing from each the parts that point along the directions you've already built. What's left is perpendicular to all of them, because removing a projection always leaves a perpendicular leftover.
What the symbols mean
- Next orthogonal vector
What's left of x₂ after removing the part along v₁.
What the symbols mean
- Orthonormal columns
The normalized Gram–Schmidt vectors.
- Upper triangular
Records how to rebuild A's columns from Q's.
Explanation
The Gram–Schmidt process is simply a recipe for straightening out a basis: you start with vectors that point in slanted directions and replace them, one at a time, with perpendicular vectors that span the same space. The name isn't descriptive; it's just the two mathematicians it's named after, Jørgen Gram and Erhard Schmidt. What it's good for: the last two lessons kept saying "with an orthogonal basis," and this is how you get one. All we're really saying here is that is just , is minus its shadow on , and is minus its shadows on and . Each fraction in the formula is the same projection weight you've been using since the orthogonal sets lesson. The formula looks long, but it's one move (subtract a shadow) repeated; bear with it.
Think about why it works. Back in the orthogonal sets lesson, you saw that minus its projection onto is perpendicular to . Gram–Schmidt just uses that over and over. Subtracting from its shadow on leaves something perpendicular to . Subtracting from its shadows on and leaves something perpendicular to both. In other words, is minus its projection onto the plane of and , from the last lesson.
So each step keeps only the new direction a vector adds. Nothing is lost along the way: the 's span the same subspaces as the 's at every stage, since each is plus a combination of earlier vectors.
A common mistake. When you compute , it's tempting to subtract its projections onto the original and , because those are the vectors you were given. That doesn't work: you project onto the new and . Adding up shadows only gives the right answer when the vectors you project onto are orthogonal, and the 's usually aren't.
Normalize at the end (divide each by its length) to get an orthonormal basis.
QR factorization packages the process: holds the orthonormal vectors and . That formula for comes from : multiply on the left by . is upper triangular because each column of only needs to rebuild it. It's the numerically stable way to solve least squares and the core of eigenvalue algorithms.
There's an animation further down that shows one Gram–Schmidt step as swings around.
See it
Worked examples
Apply Gram–Schmidt to , .
- 1
Keep the first vector as it is: .
Practice
Type your answer and check it. Solve them all to complete the lesson.
Apply Gram–Schmidt to and . Give .
Normalize .
In for those columns, what is (the length of )?
Apply Gram–Schmidt to , . Give .
Do the Gram–Schmidt vectors span the same subspace as the originals?
A robot's two sensors measure along the directions and . They aren't perpendicular, so their readings overlap. Use Gram–Schmidt to find the second direction that carries only new information.
The hardest one here. Get it, and you've got this lesson.
Functions can be orthogonalized too. With the inner product , apply Gram–Schmidt to . Find , the part of orthogonal to both and .
Where it's used
Numerical libraries use QR factorization (Gram–Schmidt's stable cousins) for least squares, and quantum chemistry orthogonalizes orbitals with the same process.