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.

A matrix factorization rewrites a matrix as a product of simpler, structured matrices whose actions are easy to invert or analyze. The LU decomposition expresses a square matrix as where is unit lower triangular and is upper triangular; it is Gaussian elimination recorded as matrix multiplication. The QR decomposition writes where has orthonormal columns and is upper triangular; it orthogonalizes the columns of . Both turn the hard problem of solving general linear systems into a sequence of trivial triangular solves or orthogonal multiplications. A surprising fact: although Gaussian elimination dates to antiquity, the realization that it is a factorization — and that this view explains its numerical behavior — came only with Turing's 1948 analysis.

The Core Insight

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

LU Decomposition

Let . An LU decomposition is a factorization

1

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.

⟳count degrees of freedom — has entries; contributes free entries, contributes , summing to .

QR Decomposition

Let with . A QR decomposition is

2

where is orthogonal () and is upper triangular. The reduced (thin) QR uses with orthonormal columns and upper triangular, so .

⟳apply Gram–Schmidt to the columns ; the orthonormal outputs form , and the projection coefficients fill .

Existence and Uniqueness

(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.

LU exists when leading minors are nonzero

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,
3
⟳each clears column below the pivot; the product is upper-triangularization.
Step 4. Each is unit lower triangular, so its inverse is too, and
4
⟳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 .

QR via Gram–Schmidt

Let be the columns of full-rank .

Step 1. Set , with . Step 2. For , subtract projections onto previous :
5
⟳ 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.

Classical Gram–Schmidt is numerically unstable

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.

Alan Turing | 1912–1954

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.

LU and QR as compositions of simpler maps

Two factorizations of A acting on a unit square A = L U (shear ∘ shear/scale) I →U→ U·□ →L→ LU·□ = A·□ A = Q R (shear, then rigid rotation) I →R→ R·□ →Q→ QR·□ = A·□ (lengths preserved by Q)

Worked Examples

LU decomposition and solving a system

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: ✓

QR decomposition by Gram–Schmidt

Given.
Step 1. , , so and . Step 2. . Projection coefficient .
Step 3. , so and Result.
Check: reproduces , and the columns of are orthonormal. ✓

Common Misconceptions

Pivoting is not optional

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.

Why classical Gram–Schmidt fails

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

  1. Circuit simulation (SPICE). Each Newton iteration solves for nodal voltages; sparse LU with pivoting is the standard solver.
  2. Structural / finite-element analysis. Stiffness matrices are symmetric positive-definite — Cholesky (a specialized LU) solves for displacements.
  3. Statistics / least squares. Fitting uses QR of the design matrix to solve the normal equations stably without forming .
  4. Computer graphics & robotics. QR (via Householder/Givens) orthonormalizes drifting rotation matrices and solves inverse-kinematics linearizations.
  5. Eigenvalue computation. The shifted QR algorithm repeatedly factors and recombines , the basis of LAPACK's dgeev.
  6. Geodesy and GPS. Overdetermined positioning systems are solved by QR least squares.
  7. Recommender systems / data compression. Low-rank approximations begin with QR (column-pivoted QR) to reveal numerical rank before refining with SVD.

Historical Development

  • c. 179 CE — The Chinese Nine Chapters on the Mathematical Art describes elimination-style solution of linear systems.
  • 1809–1810 — Gauss systematizes elimination while computing the orbit of Ceres (least squares), giving the method its modern name.
  • 1888 — Wilhelm Jordan popularizes the Gauss–Jordan variant.
  • 1907 — Erhard Schmidt formalizes the orthogonalization process (with roots in Gram, 1883).
  • 1948 — Alan Turing publishes the first rounding-error analysis, framing elimination as the factorization and introducing matrix condition numbers.
  • 1948 — Alston Householder and others develop systematic matrix-computation theory.
  • 1958 — Householder introduces reflection-based QR, the stable standard.
  • 1958–1961 — John Francis and Vera Kublanovskaya independently invent the QR algorithm for eigenvalues — one of the top algorithms of the 20th century.
  • 1965 — James Wilkinson's The Algebraic Eigenvalue Problem consolidates backward-error analysis of LU and QR.

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

Before this

Where this leads