Gram-Schmidt orthogonalization
Projection subtraction and scaling reshape the columns of A into the orthonormal columns of Q
Open full-size animation
Visual linear algebra
Gram-Schmidt orthogonalization, Givens rotations and Householder reflections applied to the same matrices
Reshape the columns of A into an orthonormal frame, then compute R from QᵀA
Rotate coordinate planes so entries below the diagonal are eliminated one at a time
Reflect across hyperplanes so a whole column tail is eliminated in one step
QR factorization writes a matrix as A = QR, where Q has orthonormal columns and R is upper triangular
The three animations below show the same goal reached by three different geometric actions: column orthogonalization, coordinate-plane rotations and hyperplane reflections
The comparison uses two shared examples for all three algorithms: one full-rank matrix and one flat rank-deficient matrix. Click any animation or summary image to open it full size
In the full-rank case, the original parallelepiped has nonzero volume and the three methods produce an upper triangular R with three nonzero diagonal entries
Projection subtraction and scaling reshape the columns of A into the orthonormal columns of Q
Successive rotations in coordinate planes reorient the figure so selected entries below the diagonal become zero
Successive reflections across hyperplanes reorient the figure so whole column tails below pivots become zero
In the flat case, the columns of A lie in a lower-dimensional shape. QR still separates orthogonal directions from triangular coordinates, but the final diagonal reveals the missing dimension
The residual direction can become zero after projections remove the part already explained by previous directions
Coordinate-plane rotations place the flat shape into triangular position while preserving lengths and angles
Hyperplane reflections place the same flat shape into triangular position by larger orthogonal steps
The same factorization can be viewed from two complementary directions: Gram-Schmidt transforms the column figure into Q, while Givens and Householder transformations move A into R
The methods differ in what each step does geometrically, what factor appears first and what computational behavior is expected
| Question | Gram-Schmidt orthogonalization | Givens rotations | Householder reflections |
|---|---|---|---|
| Transforms A into | Q | R | R |
| Remaining factor computed as | R = QᵀA | Q = (Gₖ ··· G₁)⁻¹ | Q = (Hₖ ··· H₁)⁻¹ |
| Algebraic step operation | Right-multiplication by scaling and shear matrices | Left-multiplication by rotation matrices | Left-multiplication by reflection matrices |
| Geometric step operation | Subtracts projections onto previous directions and normalizes the remaining component | Rotates in a coordinate plane | Reflects across a hyperplane |
| Full-rank A: geometric behavior | A is reshaped into an orthonormal frame | A is rotated into triangular position | A is reflected into triangular position |
| Flat rank-deficient A: geometric behavior | One residual direction becomes zero | The flat shape is rotated into place | The flat shape is reflected into place |
| Sign of diagonal entries of R | Non-negative | Whatever sign comes out | Whatever sign comes out |
| Numerical stability | Small residual directions amplify error | Stable | Stable |
| Efficiency | Less efficient | Efficient for sparse A | Preferred for dense A |
For the displayed examples, the Givens and Householder algorithms happen to produce non-negative diagonal entries of R without sign-correction steps. Gram-Schmidt produces non-negative diagonal entries by construction.
Gram-Schmidt builds Q directly from the columns of A. Givens rotations and Householder reflections instead transform A into R, then recover Q from the accumulated orthogonal transformations
The same formula A = QR therefore hides three different geometric stories: orthogonalization, rotation and reflection