Gram-Schmidt in 2D
The two columns are orthogonalized and normalized to form Q directly.
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 is a basic tool behind least-squares fitting and many stable numerical algorithms. Yet the same formula A = QR, where Q has orthonormal columns and R is upper triangular, can be reached through three very different geometric actions: column orthogonalization, coordinate-plane rotations and hyperplane reflections
Applying all three methods to the same full-rank and rank-deficient matrices makes their common goal—and their essential differences—visible
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 two dimensions, the three methods are almost minimal, which makes their different motions easiest to see. Gram-Schmidt reshapes the two columns into an orthonormal pair. Givens rotations and Householder reflections instead move A into triangular position by an orthogonal transformation. In higher dimensions, Givens repeats rotations one entry at a time, while Householder reflections can eliminate a whole column tail at once.
One detail worth noticing: Gram-Schmidt, in its standard form, produces non-negative diagonal entries in R. Givens and Householder versions may produce different signs depending on rotation or reflection sign choices. This is normal: QR is unique only after an extra sign convention is imposed, such as requiring non-negative diagonal entries in R.
The two columns are orthogonalized and normalized to form Q directly.
A single rotation places the first column on the horizontal axis, eliminating the lower-left entry.
A single reflection places the first column on the horizontal axis in one orthogonal step.
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