Gram-Schmidt in 2D
The two columns are orthogonalized and normalized to form Q directly.
Open video in a new tab
Visual linear algebra
Gram-Schmidt orthogonalization, Givens rotations, Householder reflections and Direct Rotations 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
Use one proper rotation in a plane tailored to the active column and its target axis
QR factorization decomposes a matrix into the product A = QR, where Q has orthonormal columns and R is upper triangular.
Why is this decomposition important? Two central applications are:
Computing eigenvalues. In the QR algorithm, repeated QR factorizations produce a sequence of matrices similar to A. Under suitable conditions, this sequence approaches an upper-triangular form whose diagonal entries are the eigenvalues of A.
Solving linear systems and least-squares problems. To solve Ax = b, we write QRx = b and multiply by QT:
Rx = QTb.
Because R is upper triangular, the resulting system can be solved efficiently by back substitution. When the original system is inconsistent, the same procedure produces a least-squares solution.
Orthogonal transformations preserve lengths and are numerically well conditioned. In particular, QR methods solve least-squares problems without forming ATA, which can magnify numerical errors.
But there is more than one geometric route from A to its QR factorization. Gram–Schmidt reshapes the columns of A into an orthonormal basis. Givens rotations eliminate entries one at a time. Householder reflections eliminate a whole column tail at once. Direct Rotations also eliminate a whole column tail at once, using one proper rotation in a plane tailored to the active column and its target axis. The animations below show how these four geometric constructions arrive at the same algebraic destination.
The 3D comparison uses two shared examples for all four constructions: one full-rank matrix and one flat rank-deficient matrix. Use the video controls to play, pause or scrub each animation; the links below the videos open them in a new tab
In two dimensions, the three distinct motions are almost minimal, which makes them easiest to compare. 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 2D, the Direct Rotation step is the same single plane rotation as the Givens step. Their difference appears only in higher dimensions, where Givens uses coordinate planes while Direct Rotations uses one plane tailored to the active column and its target axis.
One detail worth noticing: Gram-Schmidt, in its standard form, produces non-negative diagonal entries in R. The orthogonal-transformation constructions may produce different signs depending on their rotation, reflection or target-axis choices.
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 four constructions 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
One proper rotation per active column acts in the plane determined by that column and its target axis, eliminating the whole column tail at once
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
One tailored proper rotation per active column preserves the lower-dimensional shape while placing it into triangular position
This visual summary emphasizes the central split Q ← A → R for the three constructions shown in the image. Direct Rotations joins Givens and Householder on the A → R side, using proper rotations rather than reflections
The comparison table below summarizes where the four routes agree and where their geometric and computational behavior differs.
| Question | Gram–Schmidt orthogonalization | Givens rotation | Householder reflection | Direct rotation |
|---|---|---|---|---|
| Transforms A into | Q | R | R | R |
| Remaining factor computed as | R = QTA | Q = (Gk ··· G1)−1 | Q = (Hk ··· H1)−1 | Q = (Uk ··· U1)−1 |
| Algebraic step operation | right-multiplication by column scaling and shear matrices |
left-multiplication by coordinate-plane rotation matrices |
left-multiplication by reflection matrices |
left-multiplication by plane rotation matrices |
| Geometric step operation | • subtracts projections onto previous orthonormal directions • normalizes the remaining component |
rotates in a coordinate plane |
reflects across a hyperplane |
rotates in the plane spanned by the active column and its target axis |
| Rank-deficient A: geometric behavior |
dependent column ↓ zero residual; Q and R are reduced |
• lower-dimensional shape rotated into place; • full-size R has one or more zeros on the diagonal |
• lower-dimensional shape reflected into place; • full-size R has one or more zeros on the diagonal |
• lower-dimensional shape rotated into place; • full-size R has one or more zeros on the diagonal |
| Sign of diagonal entries R | positive after redundant columns are discarded | convention-dependent | convention-dependent | convention-dependent |
| Dimensions used here for A(m×n, rank r) |
• Q is m×r • R is r×n |
• Q is m×m • R is m×n |
• Q is m×m • R is m×n |
• Q is m×m • R is m×n |
| Numerical stability | classical form can lose orthogonality near dependence |
stable | stable | same as Householder in numerical tests |
| Typical computational use | incremental construction of orthonormal bases |
sparse or structured A; QR updates |
standard choice for dense QR |
geometric interpretation; not standard in software |
The displayed factorizations retain the signs produced by each construction. Multiplying a column of Q and the corresponding row of R by −1 gives an equivalent QR factorization, so the diagonal signs need not match unless a sign convention is imposed.
Direct Rotations are closely aligned with Householder QR: with the corresponding sign adjustment, the two steps produce the same active trailing matrix, although one uses a proper rotation and the other a reflection.
This is a revealing example of geometric reasoning solving an algebraic problem. The same QR decomposition can be constructed through four different geometric routes: orthogonalization, coordinate-plane rotations, hyperplane reflections, and direct plane rotations. In the full-rank cases, their final factorizations agree up to sign choices in the corresponding columns of Q and rows of R.
The closest relationship is also not immediately obvious. Householder reflection and Direct Rotation begin from different geometric ideas, yet they produce nearly identical sequences of intermediate matrices, differing only by signs.