LU and Cholesky Factorization in Practice
Gaussian elimination, read as a factorization A = LU, turns a linear system into two triangular solves. A single near-zero pivot wrecks it, so partial pivoting reorders rows to pick the largest available pivot and makes the method work for every invertible matrix.
╌╌╌╌
Solving by hand means Gaussian elimination: clear the first column, clear the second, and so on until the matrix is triangular, then back-substitute. Von Neumann and Goldstine observed in 1947 that this is really two separate operations, first decompose into a product of triangular matrices, then solve by substitution, and that separating them is what lets one factorization serve any number of right-hand sides.1 The decomposition is , and once it is in hand the system reduces to two triangular solves.
Reading elimination as a factorization
To solve , substitute and split it in two:
so that . When a normalized decomposition exists, both factors are unique: if , then is at once unipotent-lower and upper triangular, forcing it to equal .1
The factors are built one row and column at a time by a recursion that peels off the first row and column at each step. Partition
Multiplying out the second block row gives and , so provided the pivot ,
The updated block , the Schur complement of , is the input to the next step. The pivots end up on the diagonal of , which yields the exact condition for existence.
The cost is dominated by the rank-one update, flops at step , so the full factorization costs
and the two substitutions that follow add only . The factorization is the expensive part; once is stored, any number of right-hand sides is cheap. Because is read once and overwritten in place by and , the efficiency ratio is , so a Level-3 BLAS implementation runs near peak performance.
Small pivots and instability
Existence fails the instant a pivot is zero. The invertible matrix
has and no normalized at all. The deeper problem is that a pivot close to zero is nearly as damaging as an exact zero, once arithmetic is rounded. Take
On a machine carrying sixteen significant digits, rounds to : the subtraction of falls below the resolution of the representation. The computed factor is the exact factorization of a different matrix, one with the entry silently changed from to . Solving with the rounded factors returns against the true : a one-hundred-percent error in the first component from a matrix that is perfectly well-behaved.
Partial pivoting
The fix uses a freedom in the problem: the row order of a system is arbitrary. Before eliminating column , scan it and move the entry of largest absolute value into the pivot position.
Each row swap is a transposition , and their accumulated product is a permutation matrix . The arithmetic of each step is identical to the unpivoted recursion; only the row selection changes. The result is a factorization of the row-permuted matrix.
The proof is an induction showing each Schur complement stays invertible, so its first column is never entirely zero and a nonzero pivot always exists. The bound is the payoff of choosing the largest pivot: the multipliers can never blow up, which is what keeps the rounded factorization close to a true one.
Nothing about the solve changes: becomes , so one permutes the right-hand side and runs the same forward and back substitution.
- 1permutation record
- 2for to do
- 3choose maximizingpivot search
- 4swap rows and of and entries of
- 5for to do
- 6multiplier , stored below the diagonal
- 7end for
- 8Schur update
- 9end for
- 10return
Partial pivoting is the default dense solver everywhere; it is what a call to
A\b or LAPACK's xGETRF runs underneath.
Cholesky for symmetric positive-definite systems
A large class of systems — least-squares normal equations, covariance matrices, stiffness matrices in mechanics — carry extra structure that a general solver wastes. These are the symmetric (Hermitian) positive-definite matrices.
For s.p.d. matrices the factorization can be made symmetric, and no pivoting is ever needed because every leading principal submatrix inherits the s.p.d. property and so is invertible.
The factor is built row by row. Partitioning and matching blocks gives, for row ,
Positive definiteness of the principal submatrix guarantees , so the square root is real and the diagonal stays positive. The name reads as a matrix square root: Cholesky is to s.p.d. matrices what is to positive numbers.2
- 1for to do
- 2forward substitution
- 3
- 4fails (root of ) if is not s.p.d.
- 5end for
- 6return
Only the lower half of is touched, and only one triangular factor is stored, so Cholesky costs
half the cost of a general , with the same efficiency ratio and the same near-peak Level-3 BLAS performance. The square root also doubles as a test: if the argument is ever nonpositive, was not positive definite, and the algorithm reports it.
Choosing a solver
| Situation | Method | Cost (flop) | Pivoting |
|---|---|---|---|
| General invertible | pivoted , | partial (rows) | |
| Symmetric positive-definite | Cholesky, | none needed | |
| Many right-hand sides, fixed | factor once, substitute per | per solve | reuse the factors |
The recurring pattern is to factor once and then answer each new right-hand side with two triangular solves. How much error a solve inherits from the matrix is set by its conditioning; whether the algorithm reaches that floor is the question of stability, where pivoted turns out to be, in the backward sense, as accurate as the problem allows.
Footnotes
╌╌ END ╌╌