🧮Linear Systems: Direct Methods
Gaussian Elimination and LU Factorisation
Row operations, triangular systems, A = LU, operation counts and many right-hand sides
Teddington, 1946
The Mathematics Division of Britain's National Physical Laboratory, a few months after the war. A system of 18 linear equations in 18 unknowns arrives to be solved. There is no electronic computer yet; the Division's tools are desk calculating machines, cranked by hand.
Leslie Fox, Charles Goodwin and the young James Wilkinson — with Alan Turing, by some accounts, taking part — set to work with Gaussian elimination. It takes them about two weeks. Fox later recalled it as one of the experiences that convinced them to build an automatic computer.
Two years later Turing published Rounding-off Errors in Matrix Processes. It recast elimination as the factorisation of a matrix into triangular pieces and introduced a term every engineer now uses: the condition number.
Today a laptop solves those 18 equations in a few microseconds, and a structural model with a million unknowns overnight. The algorithm is the same one. What changed is that we now understand exactly what it costs, and exactly how accurate it is. (Cleve Moler tells the story.)
Linear systems are everywhere in engineering because linearity is the first approximation to everything. Nodal analysis of a circuit, the stiffness method for a truss, a finite-difference grid for heat flow, the Newton step of the last unit — all end in
with an matrix of known coefficients, the loads or sources, and the unknown voltages, displacements or temperatures. Cramer's rule, taught in school, needs about operations: for , longer than the age of the universe. Elimination needs about .
Gaussian elimination. Use row 1 to put zeros below the first diagonal entry: subtract times row 1 from each row . Then use the new row 2 to clear column 2 below the diagonal, and so on. After stages the matrix is upper triangular, , and the right-hand side has been transformed the same way into .
A triangular system is solved from the bottom up — back substitution:
Back substitution costs about n² operations — trivial next to the elimination that produced U.
💡Elimination is a factorisation: A = LU
Keep the multipliers instead of throwing them away, and put them in a unit lower-triangular matrix (ones on the diagonal, in position ). Then, exactly,
Elimination is the computation of and . Solving then splits into two triangular solves: (forward substitution) and (back substitution). The polish astronomer Tadeusz Banachiewicz used triangular factorisations for hand computation in 1938; Turing's 1948 paper made the connection with elimination the standard way to think about it.
Derivation
Why the multipliers are exactly
Each stage of elimination is a multiplication on the left by a simple matrix. For a matrix, stage 1 subtracts times row 1 from row 2 and times row 1 from row 3:
Undoing a stage means adding the rows back, so each inverse is the same matrix with the signs of the multipliers flipped. Multiply both sides by :
In this order the product does no arithmetic at all: every multiplier simply lands in its own position. That is why storing the multipliers is computing , and it holds for any .
With , the system is solved in two triangular steps. First from the top down — forward substitution, and (no division, since has ones on its diagonal). Then from the bottom up, by the back substitution formula above.
📐A resistor network
Four nodes, each joined to its neighbours and to ground by 1 Ω resistors, 1 A injected at node 1. Kirchhoff's current law gives with conductance matrix
The first stage uses multipliers ; the second ; the last . The pivots — the diagonal of — are . Back substitution gives node voltages V. The two middle voltages are equal, as the symmetry of the network demands.
We can only see a short distance ahead, but we can see plenty there that needs to be done.
Counting operations. At stage there are rows to update, each with about entries, at one multiply and one subtract each. Summing,
Doubling n multiplies the factorisation cost by 8 and the solve cost by 4. For n = 1000: about 7 × 10⁸ operations to factorise, 2 × 10⁶ to solve — a fraction of a second, then microseconds.
Derivation
Adding up the operations
At stage the rows below the pivot are — that is rows — and each needs its entries in columns updated: another numbers, one multiplication and one subtraction each. Substitute and use the formula for a sum of squares:
(The multipliers themselves cost one division per row, only about in total.) A triangular solve is cheaper: row of back substitution needs multiplications and additions, and . Two triangular solves: about .
⚠Never compute the inverse
is notation, not an algorithm. Forming costs about operations — three times an LU — and multiplying by it is less accurate than two triangular solves. For a sparse matrix it is far worse: is generally completely full even when is almost empty. In NumPy use
np.linalg.solve, or scipy.linalg.lu_factor and lu_solve when the matrix is reused.🕰Older than Gauss
Chapter eight of The Nine Chapters on the Mathematical Art, a Chinese text parts of which date to about 150 BC, solves systems of up to five equations by exactly this sequence of row operations on a counting board. Gauss used the method in the early 1800s to fit the orbit of the asteroid Pallas by least squares, and his name stuck to it in the twentieth century.
💡Where you will use this
Structures and Geotechnics: the stiffness method assembles and factorises once for every load case. Electrical circuits and Power Systems: nodal analysis and every Newton step of a load-flow solution. Attitude Control and GNSS Navigation: Kalman filters solve small dense systems thousands of times per second, where the count decides what fits on the flight computer.
📚Further reading
- Lloyd N. Trefethen and David Bau, Numerical Linear Algebra (SIAM, 1997), Lecture 20, 'Gaussian Elimination' — elimination as a product of lower-triangular matrices, exactly as derived here.
- Michael Heath, Scientific Computing: An Introductory Survey (2nd ed.; SIAM Classics 2018), chapter 2, 'Systems of Linear Equations'.
- Alan Turing, 'Rounding-off errors in matrix processes', Quarterly Journal of Mechanics and Applied Mathematics 1, 287–308 (1948) — the paper that named the LU decomposition and the condition number.
↓But there is a problem
Elimination divides by the pivot at every stage. Nothing in the algorithm checks how big it is.
Try . The answer is almost exactly . Elimination as written returns .
In 1943 the statistician Harold Hotelling estimated that rounding errors in elimination could grow so fast that large systems would be hopeless. He was wrong — but the reason he was wrong took twenty years to understand.