Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Decompositions

LU, QR and Cholesky Factorizations

Split a matrix into simple triangular or orthogonal pieces once, then solve, fit and sample fast. These three factorizations sit inside every scientific library, Kalman filter, Gaussian process and SLAM solver.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Break a hard job into easy steps

The number 15 is 3×53\times5. Breaking things into simpler pieces that multiply back together is called factoring. Matrices can be factored too, into pieces that are much easier to work with:

  • Staircase (triangular) matrices, which you can solve one step at a time, like walking down stairs. That’s LU.
  • Pure rotations times a staircase. That’s QR.
  • A “square root” of a matrix, like 16=4×416 = 4\times4. That’s Cholesky.

The beauty is that you do the hard work of factoring once, then answer many questions quickly. It’s like sorting your toolbox once so every later job is fast.

📝 Quick check (Level 0)
0/3 answered
  1. 1. 15 = 3 × ?
  2. 2. The square root of 16 is…
  3. 3. Why factor once?

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

LU: elimination, written down

Gaussian elimination (A2.2-4) records its multipliers in LL and leaves an upper-triangular UU:

(2145)=(1021)⏟L(2103)⏟U\begin{pmatrix}2&1\\4&5\end{pmatrix} = \underbrace{\begin{pmatrix}1&0\\2&1\end{pmatrix}}_{L}\underbrace{\begin{pmatrix}2&1\\0&3\end{pmatrix}}_{U}

The multiplier was 4/2=24/2 = 2, and 5−2⋅1=35 - 2\cdot1 = 3. Watch elimination build UU:

Gaussian elimination, one step at a time
1116
025-4
25-127
Step 1 of 8: Start: the augmented matrix [A | b].

Cholesky: a matrix square root

A positive definite matrix splits as S=LL⊤S = LL^\top, with LL lower triangular:

(4225)=(2012)(2102)\begin{pmatrix}4&2\\2&5\end{pmatrix} = \begin{pmatrix}2&0\\1&2\end{pmatrix}\begin{pmatrix}2&1\\0&2\end{pmatrix}

Here l11=4=2l_{11} = \sqrt4 = 2, l21=2/2=1l_{21} = 2/2 = 1, and l22=5−12=2l_{22} = \sqrt{5 - 1^2} = 2.

QR: orthonormal columns times a staircase

A=QR,Q⊤Q=I, R upper triangularA = QR, \qquad Q^\top Q = I, \ R \text{ upper triangular}

QQ holds an orthonormal version of AA’s columns, made by Gram–Schmidt (A2.4), and RR records how to rebuild the original columns.

📝 Quick check (Level 1)
0/3 answered
  1. 1. LU of [[2, 1], [4, 5]]: u₂₂ = ?
  2. 2. Cholesky of [[4, 2], [2, 5]]: l₂₂ = ?
  3. 3. The columns of Q in QR have length…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Which factorization when?

Factorization Needs Cost (n×nn\times n) Main uses
PA=LUPA = LU square, invertible 23n3\tfrac23n^3 general linear systems, determinants
S=LL⊤S = LL^\top symmetric PD 13n3\tfrac13n^3 (half of LU) covariances, Gaussian processes, Kalman filters, normal equations, sampling
A=QRA = QR any m×nm\times n (m≥nm\ge n) ≈43n3\approx\tfrac43n^3 (Householder, square) least squares, orthonormal bases, eigenvalues (QR algorithm)

After factoring, each new right-hand side costs only O(n2)O(n^2) (two triangular solves).

Least squares with QR

To minimize ∥Ax−b∥\lVert A\mathbf x - \mathbf b\rVert, write A=QRA = QR. Then the solution solves Rx=Q⊤bR\mathbf x = Q^\top\mathbf b. The tempting alternative, the normal equations A⊤Ax=A⊤bA^\top A\mathbf x = A^\top\mathbf b, squares the condition number: κ(A⊤A)=κ(A)2\kappa(A^\top A) = \kappa(A)^2. On a badly conditioned fit, QR keeps about 9 correct digits where the normal equations keep about 1 (Practice Code 3).

🐍 Exercise 1: QR by Gram–Schmidt, and Cholesky by hand
Implement modified Gram–Schmidt QR (positive diagonal) and the Cholesky algorithm, and compare them with NumPy.
Inside a Kalman filter

Navigation filters on spacecraft and drones often store the Cholesky factor of the covariance instead of the covariance itself. These are “square-root” filters. The factor can never lose positive definiteness through rounding, and it keeps about twice the precision. Apollo-era engineers adopted square-root forms for exactly this reason (Bierman, 1977).

📝 Quick check (Level 2)
0/3 answered
  1. 1. Which factorization requires a positive definite matrix?
  2. 2. Cholesky costs roughly ___ of LU.
  3. 3. Why prefer QR over the normal equations?

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Existence and uniqueness

Theorem

(1) Every invertible AA has PA=LUPA = LU, with LL unit lower triangular. (2) Every symmetric PD SS has a unique S=LL⊤S = LL^\top with lii>0l_{ii} > 0. (3) Every A∈Rm×nA\in\mathbb{R}^{m\times n} with independent columns has a unique A=QRA = QR with rii>0r_{ii} > 0.

Proof sketch of (2). Match entries of LL⊤=SLL^\top = S in order. Column 1 gives l11=s11l_{11} = \sqrt{s_{11}} and li1=si1/l11l_{i1} = s_{i1}/l_{11}. The remaining block must equal the Schur complement S22−ll⊤S_{22} - \mathbf l\mathbf l^\top, which is again PD (A2.3-3), so induction finishes. Every square root taken is of a positive number. If SS isn’t PD, some step needs negative\sqrt{\text{negative}}. That’s why trying Cholesky is the fastest practical PD test.

Householder reflections

A Householder reflector H=I−2vv⊤/(v⊤v)H = I - 2\mathbf v\mathbf v^\top/(\mathbf v^\top\mathbf v) is symmetric, orthogonal, and its own inverse. With v=a+sign⁡(a1)∥a∥e1\mathbf v = \mathbf a + \operatorname{sign}(a_1)\lVert\mathbf a\rVert\mathbf e_1, it maps a\mathbf a to −sign⁡(a1)∥a∥e1-\operatorname{sign}(a_1)\lVert\mathbf a\rVert\mathbf e_1, zeroing a whole column at once. Applying nn of them gives Hn⋯H1A=RH_n\cdots H_1A = R, so Q=H1⋯HnQ = H_1\cdots H_n. Because each step is an exact orthogonal map, the computed QQ is orthogonal to machine precision. Classical Gram–Schmidt doesn’t have this property.

Stability matters

Mathematically, classical Gram–Schmidt, modified Gram–Schmidt and Householder all give the same QQ. Numerically, on a Vandermonde matrix with κ≈108\kappa\approx10^8:

Method ∥Q⊤Q−I∥\lVert Q^\top Q - I\rVert
classical Gram–Schmidt about 2 (orthogonality completely lost)
modified Gram–Schmidt about 10−910^{-9}
Householder (LAPACK) about 10−1510^{-15}

You’ll reproduce this in Exercise 2.

Exercise 3.1: Show that a Householder reflector has determinant −1

HH fixes the (n−1)(n-1)-dimensional hyperplane perpendicular to v\mathbf v (eigenvalue 1, n−1n - 1 times) and sends v↦−v\mathbf v\mapsto-\mathbf v (eigenvalue −1). So det⁡H=(1)n−1(−1)=−1\det H = (1)^{n-1}(-1) = -1.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Cholesky fails on a symmetric matrix exactly when it is…
  2. 2. A Householder reflector H satisfies H² = …
  3. 3. κ(AᵀA) = ?

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Factorizations at the heart of applications

  • Gaussian processes. Prediction needs K−1yK^{-1}\mathbf y and log⁡det⁡K\log\det K. Both come from one Cholesky factor: log⁡det⁡K=2∑log⁡lii\log\det K = 2\sum\log l_{ii}. That’s O(n3)O(n^3), which is why GPs on large data need sparse or approximate methods (I2). Practice Code 5 builds a tiny GP.
  • SLAM and bundle adjustment. Each Gauss–Newton step solves a sparse least-squares problem by sparse Cholesky or QR. iSAM2 updates the factorization incrementally as new measurements arrive, instead of refactoring from scratch (T3).
  • Recursive least squares and adaptive control. QR updates (Givens rotations) let estimates be refreshed one measurement at a time with guaranteed stability.
  • Eigenvalues. The QR algorithm repeatedly factors Ak=QkRkA_k = Q_kR_k and sets Ak+1=RkQkA_{k+1} = R_kQ_k. These are similar matrices that converge to triangular form, revealing the eigenvalues (A2.3-1).
🐍 Exercise 2 (research): stability of three QR algorithms
Orthogonalize the columns of an ill-conditioned Vandermonde matrix with classical GS, modified GS and Householder (np.linalg.qr), and measure the loss of orthogonality.

Research directions

  • Communication-avoiding and randomized factorizations. On modern hardware, moving data costs more than arithmetic. Tall-skinny QR (TSQR) and randomized QR/LU with sketching (Martinsson and Tropp, 2020) minimize data movement and scale to huge matrices.
  • Mixed precision. Factor in fast low precision on tensor cores, then refine (A2.2-4). The same idea is now used to accelerate scientific simulations and GP training.

References

  1. A.-L. Cholesky (c. 1910, published by Benoît 1924). “Note sur une méthode de résolution des équations normales…” Bulletin Géodésique, 2.
  2. A. S. Householder (1958). “Unitary triangularization of a nonsymmetric matrix.” Journal of the ACM, 5(4).
  3. G. Golub (1965). “Numerical methods for solving linear least squares problems.” Numerische Mathematik, 7.
  4. G. Bierman (1977). Factorization Methods for Discrete Sequential Estimation. Academic Press.
  5. M. Kaess et al. (2012). “iSAM2: Incremental smoothing and mapping using the Bayes tree.” IJRR, 31(2).
  6. P.-G. Martinsson and J. Tropp (2020). “Randomized numerical linear algebra: Foundations and algorithms.” Acta Numerica, 29.
  7. L. Trefethen and D. Bau (1997). Numerical Linear Algebra. SIAM. Lectures 7–11, 20–23.