Gram-Schmidt straightens a slanted set of columns into a perpendicular, unit-length
frame Q, remembering exactly how it did so in an upper-triangular
R. The result: every matrix with independent columns factors as
\(A = QR\) — orthonormal times triangular.
1The recipe
Keep the first direction; make each next one perpendicular to all the earlier ones.
Gram-Schmidt — each new column loses its shadow on the earlier \(\mathbf q\)'s, then is normalized
Edit A. Its slanted columns a₁a₂a₃ become the perpendicular unit frame q₁q₂q₃.
drag / one finger: orbit · scroll / pinch: zoom
A (columns a₁ a₂ a₃)
Q (orthonormal)
\(Q^{\mathsf T}Q = I\) ✓
R (upper triangular)
build it step by step
view
show
R is upper triangular because \(\mathbf q_i\) is built
only from \(\mathbf a_1,\dots,\mathbf a_i\) and is perpendicular to all of \(\mathbf a_1,\dots,\mathbf a_{i-1}\) — so
\(r_{ij} = \mathbf q_i^{\mathsf T}\mathbf a_j = 0\) whenever \(i > j\). The diagonal entries
\(r_{ii}\) are the lengths left after removing the earlier shadows.
4Geometric reading — R stretches, Q rotates
Read \(A = QR\) right to left: R deforms the cube, Q rotates it into place.
Q is orthonormal, so as a map it is a pure rotation (or rotation + reflection): rigid, no
stretching, lengths and angles preserved. All the shape change lives in R,
which is a stretch-and-shear:
R is upper triangular = scale + skew
$$\begin{aligned}
\text{diagonal}\quad & \textcolor{#ffd166}{r_{ii}} = \lVert \mathbf a_i - \text{shadows}\rVert &&{\small\text{how far to stretch along each axis (leftover after removing shadows)}}\\[4pt]
\text{off-diagonal}\quad & \textcolor{#ffd166}{r_{ij}} = \mathbf q_i^{\mathsf T}\mathbf a_j \;(i<j) &&{\small\text{how much later columns lean on earlier directions}}
\end{aligned}$$
So the unit cube goes: R turns it into an axis-aligned sheared box
(the grey R-box), then Qrotates that box into the
real parallelepiped of A's columns (the blue A-box). Toggle both in the 3-D panel —
same shape and volume, just rotated.
volume: Q adds none (it only rotates)
$$\det A = \det \textcolor{#7ee787}{Q}\cdot\det \textcolor{#ffd166}{R} = (\pm 1)\cdot(\textcolor{#ffd166}{r_{11}\,r_{22}\,r_{33}})
\qquad\text{volume} = \lvert\det A\rvert = \text{product of } R\text{'s diagonal}$$
Why it matters: to solve \(A\mathbf x = \mathbf b\) (or least squares), \(A = QR\) turns it into
\(R\mathbf x = Q^{\mathsf T}\mathbf b\) — first rotate \(\mathbf b\) back with \(Q^{\mathsf T}\), then back-substitute up the triangular
R. No \((A^{\mathsf T}A)^{-1}\), and numerically stable — the standard QR solver.