Numerical Linear Algebra: LU and QR Decompositions
LU and QR decompositions factor a matrix into structured pieces — (lower × upper triangular, via Gaussian elimination) or (orthogonal × upper triangular, via Gram–Schmidt or Householder reflections). LU solves square linear systems efficiently; QR solves least-squares and underpins eigenvalue algorithms. These are the two workhorse factorizations of numerical linear algebra, used everywhere from circuit simulation to statistics. Formalized in the 20th century (Turing, Householder, Givens) on foundations from Gauss.
Every elementary row operation is left-multiplication by a simple matrix. LU collects all the elimination steps into one lower-triangular matrix ; QR replaces "elimination" by "orthogonalization," collecting all the rotations/reflections into an orthogonal . In both cases the right factor (or ) is upper triangular, so the original problem becomes two triangular systems, each solvable in by back/forward substitution. Triangularity is the whole game: it is the structure that makes solving cheap.
Formal Statement
Let . An LU decomposition is a factorization
where is unit lower triangular (, for ) and is upper triangular ( for ). The entries below the diagonal of are the multipliers used in Gaussian elimination; is the row-echelon (upper) result. Derivation hint: count degrees of freedom — has entries; contributes free entries, contributes , summing to .
Let with . A QR decomposition is
where is orthogonal () and is upper triangular. The reduced (thin) QR uses with orthonormal columns and upper triangular, so . Derivation hint: apply Gram–Schmidt to the columns ; the orthonormal outputs form , and the projection coefficients fill .
(LU). If all leading principal minors of are nonzero, then has a unique LU decomposition with unit lower triangular. In general (any nonsingular ), a row permutation exists so that — the LU with partial pivoting.
(QR). Every () has a QR decomposition. If has full column rank, the reduced decomposition is unique once we require the diagonal entries of to be positive.
Proceed by induction / direct elimination.
Step 1. The leading minor is (it equals the first principal minor). Define multipliers for . Subtracting times row 1 from row zeros the first column below the diagonal. This is left-multiplication by an elementary lower-triangular matrix with in its first column.
Step 2. The resulting matrix has the same trailing principal minors structure; its pivot is nonzero exactly because the second leading minor of is nonzero (the minor equals pivot). Repeat: form , then , ..., .
Step 3. After stages,
Derivation hint: each clears column below the pivot; the product is upper-triangularization.
Step 4. Each is unit lower triangular, so its inverse is too, and
Derivation hint: inverse of a product reverses order; each just flips the sign of its off-diagonal multipliers. is unit lower triangular. A clean miracle: 's subdiagonal entries are exactly the multipliers (no interaction between stages), so .
Step 5 (uniqueness). Suppose . Then . The left side is unit lower triangular, the right is upper triangular; a matrix that is both is the identity. Hence .
∎Let be the columns of full-rank .
Step 1. Set , with .
Step 2. For , subtract projections onto previous :
Derivation hint: is the component of orthogonal to .
Step 3. Normalize: , (nonzero by full rank).
Step 4. Rearranging, , which in matrix form is exactly with upper triangular. Orthonormality gives .
Step 5 (uniqueness). If then is both orthogonal and upper triangular with positive diagonal, hence the identity.
∎The algorithm above (classical Gram–Schmidt, CGS) loses orthogonality catastrophically in finite precision when columns are nearly dependent. In practice use Modified Gram–Schmidt (MGS) — subtract projections one at a time, updating immediately — or, better, Householder QR. MGS and Householder are mathematically equivalent to CGS but vastly more accurate.
Turing's 1948 paper "Rounding-off errors in matrix processes" gave the first rigorous error analysis of Gaussian elimination and explicitly framed it as the matrix factorization (he wrote it in terms of triangular factors). He introduced the condition number concept for matrices, quantifying how input errors amplify. This reconceptualization — elimination as factorization — is what allowed the subsequent stability theory of Wilkinson and others. Turing thus turned a centuries-old hand computation into an object of modern numerical mathematics.
Building Intuition
Think of solving as undoing a complicated transformation. LU says: stretches space in a way that decomposes into a "shear" () followed by an "axis-aligned scaling with shear" (). To invert, undo then — each triangular, each cheap.
QR says: 's action equals "first rotate/reflect (), then upper-triangular shear ()." Because is just a rigid motion (), it preserves lengths and angles — it never amplifies error. That is why QR is so stable, and why it shines for least-squares: minimizing becomes minimizing , and a rigid motion of the residual changes nothing.
Worked Examples
Given. Solve with
Step 1 — eliminate column 1. Pivot . Multipliers , .
Step 2 — eliminate column 2. Pivot . Multiplier .
Step 3 — forward solve . ; ; .
Step 4 — back solve . ; ; .
Check: ✓
Given.
Step 1. , , so and .
Step 2. . Projection coefficient .
Step 3. , so and
Result.
Check: reproduces , and the columns of are orthonormal. ✓
Common Misconceptions
A nonzero determinant does not guarantee a stable (or even existing) LU without pivoting. The matrix has no LU factorization at all (its pivot is ), yet it is nonsingular. Even when a pivot is merely small, dividing by it amplifies rounding errors. Partial pivoting — swapping in the largest-magnitude entry of the active column as pivot — keeps all multipliers and is the practical default.
Take, in 3-digit arithmetic, the near-collinear columns
with . After normalizing and subtracting its projection from , the tiny orthogonal component is computed as the difference of two nearly-equal large numbers — catastrophic cancellation destroys it. The resulting can fail to be orthogonal to to working precision. Householder QR avoids this entirely because it never forms such differences; it works with norm-preserving reflections.
Connections
LU is the matrix incarnation of Gaussian Elimination, and its determinant follows instantly: . The symmetric positive-definite specialization is the Cholesky Decomposition , half the cost of LU. QR is built from Orthogonal Projection and the Gram–Schmidt Process, and it is the engine of the QR Algorithm for Eigenvalues and Eigenvectors. Both decompositions are quantitatively governed by the Condition Number, and QR's stability links to the Singular Value Decomposition, the most robust (but costliest) factorization. The least-squares use of QR is the computational core of Linear Regression.
Real-World Applications
Historical Development
Subtleties & Limits
Even partial pivoting can, in pathological cases, exhibit exponential element growth (the Wilkinson matrix), making LU unstable in principle — yet such matrices essentially never arise in practice, and why average-case growth is benign remains incompletely understood (the subject of "smoothed analysis," Sankar–Spielman–Teng, 2006). For sparse matrices, choosing a pivot order that minimizes fill-in while preserving stability is NP-hard, driving ongoing research in heuristic orderings. Communication cost, not arithmetic, now dominates on modern hardware, spurring "communication-avoiding" LU and QR variants (CALU, TSQR) whose stability–performance trade-offs are still being charted.
See Also
Gaussian Elimination · Cholesky Decomposition · Gram–Schmidt Process · Householder Reflections · Givens Rotations · Singular Value Decomposition · QR Algorithm · Condition Number · Least Squares Problems · Linear Regression