Gram–Schmidt and QR Factorization
Construct an orthonormal basis and use triangular equations to recover coordinates.
Builds on Dot Products and Orthogonal Projection
The bigger question: What is the closest answer when an exact fit is impossible?
On this page
Remove directions already represented
Gram–Schmidt turns an independent list into orthonormal vectors spanning the same successive subspaces. First set . At step , remove projections onto earlier directions:
If the input columns are dependent, a residual becomes zero and cannot be normalized. This reveals redundancy rather than a new basis direction.
Visual guide
- Projection direction
Worked example: two columns
Let and . Then and . Subtracting gives , with norm . Hence .
Check and both norms equal one. These checks catch arithmetic mistakes before using the basis in later calculations.
Try it yourself.
Choose an answer and explain your reasoning to yourself. Use a hint if you get stuck.
Hint 1 · Find a starting point
The columns of Q are orthonormal.
Hint 2 · Take the next step
Their pairwise dot products are 1 with themselves and 0 with each other.
Show the reasoning
Answer: The identity matrix
Those dot products form the identity matrix, enabling the triangular system R x=Qᵀb.
Before moving on: what would make one of the other answers wrong? Saying why is part of understanding.
Worked example: read the factorization
Stack the orthonormal vectors as columns of . The coefficients used above give
The matrix has size and satisfies . But is a projection onto the two-dimensional column space, not the identity. This distinction matters for rectangular matrices.
For full column rank, a least-squares solution satisfies . Solve this triangular system instead of explicitly inverting . In numerical libraries, Householder QR is generally preferred to classical Gram–Schmidt because it better preserves orthogonality under rounding; modified Gram–Schmidt also improves on the classical algorithm.
Practice
- Apply Gram–Schmidt to .
- What occurs for ?
- If has three orthonormal columns in , what are the shapes of and ?
Show worked solutions
- , residual , so .
- The second residual is zero, revealing dependent inputs.
- is the identity; is a projection of rank three.
Pause before the next idea.
Can you explain how the visualization connects to this lesson’s goal? If a step still feels uncertain, put this lesson on your review list and try the check again another day.