Elimination, and the swap

The bound that is never attained

Partial pivoting's stability guarantee permits the entries to double at every step — a factor of 5.5·10¹¹ at n = 40. The measured growth on random matrices of that size is about three. The gap is eleven orders of magnitude, and the guarantee is still worth having.

Worth reading first: Elimination is a sequence of choices · The swap that is not optional.

The backward stability of Gaussian elimination rests on one quantity. Not the condition number, which belongs to the problem; not the multipliers, which pivoting bounds by one; but the growth factor — the ratio of the largest entry appearing anywhere in U to the largest entry of A.

The error analysis says: the backward error is bounded by roughly n²·ρ·u, where ρ is the growth factor. Everything else in that expression is known. n is the size of the matrix and u is the unit roundoff, and neither is a surprise. ρ is the one that has to be argued about.

Partial pivoting bounds it by 2ⁿ⁻¹, because with multipliers at most one, no single step can more than double the largest entry present. At n = 40 that bound is 5.5·10¹¹, which multiplied by u gives 1.2·10⁻⁴ — a backward error of one part in ten thousand, from a method described as backward stable.

The measured growth factor of a random forty-by-forty matrix is about three.

Growth factor under partial pivoting to n = 40: the bound, the worst case, and realityGrowth factor against matrix size on a logarithmic vertical axis. The two-to-the-n bound rises as a straight line; Wilkinson's matrix sits exactly on it; random matrices stay near one.0816243240110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴matrix size ngrowth factor max|u| / max|a|the 2ⁿ⁻¹ boundworst of 30 randommedian randomWilkinson's matrix sits on the bound30 Gaussian matrices per sizeat n = 40: bound 5.5·10¹¹, worst 4.8
Fig. 1 Growth factor against matrix size. The 2ⁿ⁻¹ bound rises as a straight line on the logarithmic axis; Wilkinson’s matrix sits exactly on it at every size; thirty random Gaussian matrices at each size give a median near three and a worst case under five. The gap at n = 40 is eleven orders of magnitude, and it is measured rather than described.

The one matrix that attains it

The bound is not loose because it is badly derived. It is attained, exactly, by a matrix anyone can write down from memory: ones on the diagonal, −1 everywhere below it, and a column of ones down the right-hand edge.

For that matrix, at every size tested from four to twenty, the growth factor is exactly 2ⁿ⁻¹ — not approximately, not asymptotically. The check on every build is an equality to twelve digits rather than an inequality, because the value is known in closed form.

Wilkinson's 7×7 matrix and its upper triangular factorThe matrix on the left has ones on the diagonal, minus ones below it and a column of ones at the right. On the right, its U factor, whose last column doubles down the rows to 64 — which is 2^6, exactly the growth bound partial pivoting permits at this size, and it is reached with 0 row interchanges and a residual of 0.1·····1-11····1-1-11···1-1-1-11··1-1-1-1-11·1-1-1-1-1-111-1-1-1-1-1-11A1·····1·1····2··1···4···1··8····1·16·····132······64U‖PA − LU‖/‖A‖0growth factor64the 2ⁿ⁻¹ bound64Row interchanges performed: 0.Partial pivoting had nothing to choose.every entry is 0, 1 or −1the bound is attained here
Fig. 2 Wilkinson’s matrix and its upper triangular factor, side by side. Every entry of A is 0, 1 or −1. The last column of U doubles down the rows, and the residual badge reports that the factorisation is nonetheless exact to rounding — the growth is real, and it did not break anything here.

One matrix at one size attains the bound. Whether it attains it because it is that size is answered by turning the size.

Wilkinson's 4×4 matrix and its upper triangular factorThe matrix on the left has ones on the diagonal, minus ones below it and a column of ones at the right. On the right, its U factor, whose last column doubles down the rows to 8 — which is 2^3, exactly the growth bound partial pivoting permits at this size, and it is reached with 0 row interchanges and a residual of 0.1··1-11·1-1-111-1-1-11A1··1·1·2··14···8U‖PA − LU‖/‖A‖0growth factor8the 2ⁿ⁻¹ bound8Row interchanges performed: 0.Partial pivoting had nothing to choose.every entry is 0, 1 or −1the bound is attained here
Fig. 3 Four by four. Growth 8, which is 2³ — exactly the bound — with zero row interchanges and a residual of exactly 0.

Eight is a small number and 2³ is a small bound, so the four-by-four on its own proves only that the two coincide once. Five sizes further up:

Wilkinson's 9×9 matrix and its upper triangular factorThe matrix on the left has ones on the diagonal, minus ones below it and a column of ones at the right. On the right, its U factor, whose last column doubles down the rows to 256 — which is 2^8, exactly the growth bound partial pivoting permits at this size, and it is reached with 0 row interchanges and a residual of 0.1·······1-11······1-1-11·····1-1-1-11····1-1-1-1-11···1-1-1-1-1-11··1-1-1-1-1-1-11·1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-11A1·······1·1······2··1·····4···1····8····1···16·····1··32······1·64·······1128········256U‖PA − LU‖/‖A‖0growth factor256the 2ⁿ⁻¹ bound256Row interchanges performed: 0.Partial pivoting had nothing to choose.every entry is 0, 1 or −1the bound is attained here
Fig. 4 Nine by nine: growth 256 = 2⁸, zero interchanges, residual 0.

Two sizes, two exact hits, and in both cases partial pivoting has declined to swap anything at all — which is the second half of what makes this family a witness, and needs the same treatment as the first.

Wilkinson's 11×11 matrix and its upper triangular factorThe matrix on the left has ones on the diagonal, minus ones below it and a column of ones at the right. On the right, its U factor, whose last column doubles down the rows to 1024 — which is 2^10, exactly the growth bound partial pivoting permits at this size, and it is reached with 0 row interchanges and a residual of 0.1·········1-11········1-1-11·······1-1-1-11······1-1-1-1-11·····1-1-1-1-1-11····1-1-1-1-1-1-11···1-1-1-1-1-1-1-11··1-1-1-1-1-1-1-1-11·1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-11A1·········1·1········2··1·······4···1······8····1·····16·····1····32······1···64·······1··128········1·256·········1512··········1024U‖PA − LU‖/‖A‖0growth factor1024the 2ⁿ⁻¹ bound1024Row interchanges performed: 0.Partial pivoting had nothing to choose.every entry is 0, 1 or −1the bound is attained here
Fig. 5 Eleven: growth 1,024 = 2¹⁰.
Wilkinson's 13×13 matrix and its upper triangular factorThe matrix on the left has ones on the diagonal, minus ones below it and a column of ones at the right. On the right, its U factor, whose last column doubles down the rows to 4096 — which is 2^12, exactly the growth bound partial pivoting permits at this size, and it is reached with 0 row interchanges and a residual of 0.1···········1-11··········1-1-11·········1-1-1-11········1-1-1-1-11·······1-1-1-1-1-11······1-1-1-1-1-1-11·····1-1-1-1-1-1-1-11····1-1-1-1-1-1-1-1-11···1-1-1-1-1-1-1-1-1-11··1-1-1-1-1-1-1-1-1-1-11·1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-11A1···········1·1··········2··1·········4···1········8····1·······16·····1······32······1·····64·······1····128········1···256·········1··512··········1·1024···········12048············4096U‖PA − LU‖/‖A‖0growth factor4096the 2ⁿ⁻¹ bound4096Row interchanges performed: 0.Partial pivoting had nothing to choose.every entry is 0, 1 or −1the bound is attained here
Fig. 6 And thirteen, the largest the two grids fit at: growth 4,096 = 2¹². Still zero interchanges, still an exact factorisation.
n growth 2ⁿ⁻¹ row interchanges residual
4 8 0 0
7 64 2⁶ 0 0
9 256 2⁸ 0 0
11 1,024 2¹⁰ 0 0
13 4,096 2¹² 0 0

Five sizes and five exact hits. Not “close to the bound” and not “within a constant of it” — the growth is 2ⁿ⁻¹, and the generator asserts it as an equality through two independent routes rather than checking an inequality. The bound is attained, and it is attained at every size, so the family is a genuine witness rather than a small-n curiosity.

And the residual is exactly zero at every size. That is the part worth sitting with. A growth factor of four thousand and a factorisation that is not merely accurate but exact — every entry of L and U is an integer, so there is nothing for the arithmetic to round. The growth is real and its consequences are not: on this matrix the thing the bound is a bound on costs nothing at all.

Zero interchanges at every size, too, which is why the matrix is a witness rather than a hazard. Partial pivoting is not being fooled into a bad choice; every diagonal entry already is the largest in its column, so the rule has nothing to do and does nothing. The bound describes what pivoting permits, and this family shows that what it permits is reachable — by a matrix nobody would ever hand a solver.

The detail that makes it interesting: partial pivoting performs no row interchanges at all. Every candidate pivot is already the largest entry in its column, so the strategy has nothing to choose, does exactly what it is supposed to, and the entries double anyway. This is not a case of the algorithm being defeated by a pathological input it fails to notice. It is a case of the algorithm working perfectly and the bound being tight.

All the growth is in the final column. Every other entry of U is unchanged from A, which is checked separately — it is the sort of claim that is easy to make from a picture and easy to be wrong about.

Why nobody worries

Two reasons, and they are different in kind.

The empirical one. Growth factors above ten are essentially never observed on matrices arising from applications, and matrices constructed to produce large growth have to be constructed. Trefethen and Schreiber measured the average growth for random matrices as roughly n2/3n^{2/3}, which at n = 1000 is a hundred — large, and eight orders of magnitude below 2⁹⁹⁹. The measurement in the figure above agrees in spirit: median growth rises slowly with n, from 1.13 at n = 5 to 3.23 at n = 40.

What the sweep says about that exponent

It agrees in spirit and not in the exponent, which is worth saying because this site’s own figure is the measurement the citation is standing in for. Two hundred Gaussian matrices per size, medians, fitted in the logarithm:

n 5 8 12 20 30 40 60 80
median ρ 1.14 1.39 1.66 2.04 2.53 3.19 3.93 4.81

The fitted exponent is 0.52. The two candidate laws are not equally good and the discriminating statistic is the constant rather than the fit: ρ/√n runs from 0.51 to 0.54 across a sixteenfold range of n, while ρ/n^(2/3) falls from 0.51 to 0.29. A model whose constant halves across its own range is a model with the wrong exponent in it.

Extended by hand to n = 240 the fit moves to 0.55, so the exponent does drift upwards with n and this range cannot say where it settles; ⅔ may well be the asymptote. What the measurement can say is that over every size this collection draws, the growth is √n and not n^(2/3), and that a figure in an essay should carry the law its own data supports.

The dropped constant is the larger of the two errors and the easier one to make. It is about 0.5, so quoting n2/3n^{2/3} bare over-predicts threefold before the exponent is argued about at all, and “a hundred at n = 1000” is nearer twenty. Neither correction changes the argument — twenty is still eight orders under 2⁹⁹⁹, and the essay’s point survives untouched. That is precisely why the number was never checked, and it is the shape this collection keeps finding: a figure quoted in support of a conclusion that does not depend on it is a figure nobody has an incentive to measure.

One more thing falls out of the same two hundred samples, and it is the reassuring half of the picture. Fitting the worst of the two hundred at each size rather than the median gives an exponent of 0.43 — the tail grows more slowly than the middle. The ratio of the worst observed growth to the typical one is 2.02 at n = 5 and 1.71 at n = 80, so the distribution concentrates as the matrices get larger rather than spreading out.

That matters more than the exponent does. A growth factor whose mean is small is not by itself grounds for relying on partial pivoting; what a user needs is that the unlucky matrix is not much worse than the typical one, and that is a statement about the tail. Over the range measured here the tail is tightening. It is still not a theorem, and it is still only two hundred matrices at each of eight sizes drawn from one distribution — but it is the quantity the empirical argument actually rests on, stated as a number rather than as a reassurance.

The structural one. For several important classes the growth factor is bounded by a small constant, provably. A symmetric positive definite matrix needs no pivoting at all and has ρ ≤ 1. A diagonally dominant matrix likewise. A totally nonnegative matrix has ρ = 1. Many real problems fall into one of those classes, and for them the worst case is not merely unlikely, it is impossible.

Neither reason is a proof about the general case, and that is the honest position: Gaussian elimination with partial pivoting has a worst-case bound nobody relies on and an observed behaviour everybody relies on, and the gap between them has been an open question for seventy years.

What to do with a useless bound

This is the part worth thinking about, because it recurs everywhere in computing and is usually handled badly.

The bound is not useless in the sense of being wrong. It is tight — Wilkinson’s matrix proves it — and it cannot be improved without additional hypotheses. What is useless is using it to decide anything, because it is nowhere near what happens.

The three available responses:

Measure and report the growth. It costs one comparison per step to track max|u| while factorising, and it converts an untestable worry into a number. LAPACK does not return it by default, which is a pity; when it is available it is the first thing to look at if a solve behaves oddly.

Use a strategy with a better bound where it is required. Complete pivoting has growth bounded by roughly n14lognn^{\frac14 \log n}, which is polynomial. It costs O(n³) comparisons — the same order as the arithmetic — and essentially nobody pays that for a guarantee they will never invoke.

Rely on the empirical behaviour, and say so. This is what everyone does, and the only thing wrong with it is doing it silently. “Gaussian elimination with partial pivoting is backward stable in practice” is a true and useful sentence; dropping the last three words makes it false.

The measurement, and what it required

The figure is a measurement rather than a citation, which meant deciding several things that a citation would have hidden.

Thirty matrices per size, not one. The growth factor of a single random matrix is a random variable, and its spread is not negligible — at n = 20 the thirty values run from about 1.4 to 2.8. Plotting one would have produced a jagged line that a reader would reasonably interpret as structure. The figure draws the median solid and the worst of the thirty dashed above it, so the spread is visible rather than averaged away.

Gaussian entries, and saying so. Growth statistics depend on the distribution the matrices are drawn from. These are independent standard normals, which is the usual choice; matrices from other distributions behave differently, and a figure that said only “random matrices” would be hiding a decision. One matrix is an anecdote is the seeded-generator habit this site carries from its sibling, and it is exactly what makes a claim like “about three” supportable.

A refusal. The measurement must be able to see large growth, or the finding that growth is always small is a property of the measurement rather than of the matrices. So on every build the growth routine is shown Wilkinson’s matrix at n = 20 and required to report a value above a hundred. Without that, a bug that clamped or mis-scaled the ratio would produce exactly the reassuring figure above and nothing would notice.

Growth and the backward error, connected

It is worth closing the loop, because the growth factor is not interesting in itself — it is interesting because it appears in a bound on something that is.

Across the sweep of conditioning in a small residual is not a small error, the backward error of every solve sits below 10⁻¹⁴ regardless of the condition number. That flat line is the growth factor being small, expressed in the quantity that matters. If growth were behaving like 2ⁿ⁻¹, the line would rise with n and the whole framework would collapse: an algorithm whose backward error depends on the problem is not backward stable, and the separation between the algorithm’s fault and the problem’s would not exist.

So the empirical smallness of the growth factor is load-bearing for this entire site. It is the reason the flat line is flat. It is also, uncomfortably, the one thing here that rests on observation rather than on proof.

The classes where the worst case is impossible

The empirical argument is the weaker of the two reasons nobody worries, and it is worth setting out the stronger one because it covers a great deal of real computation.

Symmetric positive definite. Cholesky needs no pivoting and has growth factor at most 1. Every covariance matrix, every stiffness matrix from a finite element model, every Gram matrix falls here.

Diagonally dominant. If each diagonal entry exceeds the sum of the absolute values of the others in its row, the growth factor under no pivoting at all is at most 2. Discretised diffusion problems and many Markov chains are diagonally dominant by construction.

Totally nonnegative. Every minor nonnegative, growth factor exactly 1. Rarer, but it includes some interpolation matrices.

Upper Hessenberg. One subdiagonal, growth factor at most n. This matters because the QR algorithm reduces matrices to Hessenberg form first, so every step of the standard eigenvalue routine is operating in a regime with a linear bound.

For matrices in any of those classes the 2ⁿ⁻¹ worry is not merely unlikely, it cannot happen. The open question concerns only the general dense case, which in practice means matrices whose structure is unknown rather than absent.

How the growth factor enters the error bound

The chain is worth writing out once, because the growth factor is otherwise a quantity with no visible consumer.

Wilkinson’s analysis says the computed factors satisfy L̂Û = A + E with ‖E‖ ≤ c·n·ρ·u·‖A‖, where c is a small constant. That E is exactly the perturbation the backward error measures: the factorisation is exact for a matrix E away from the one it was given.

So the backward error is proportional to n·ρ·u, and with ρ near 1 and n a few hundred, that is a few hundred roundings — 10⁻¹⁴ or so in double, which is what a small residual is not a small error measures across its whole sweep.

If ρ were 2ⁿ⁻¹ the same expression would give a backward error of order 1 for n above about 50, and Gaussian elimination would be unusable for any matrix larger than a small one. The entire practice of dense linear algebra rests on a quantity nobody can bound usefully and everybody has measured.

What to measure in practice

Three numbers, each one line, and between them they cover most of what can go wrong with a dense solve.

The growth factor: track the largest absolute entry seen during elimination and divide by the largest entry of A. Above ten, look harder; above a thousand, something is unusual about the matrix.

The factorisation residual, ‖PA − LU‖/‖A‖, which is the site’s rule and which catches permutation bugs, indexing errors and the whole class of mistakes that produce a plausible-looking factorisation of the wrong matrix.

A condition estimate, which turns the residual into an error bound and is available from the factorisation for a fraction of its cost.

None of the three is returned by default by most libraries, and all three are cheap. The habit of computing them is most of what separates code that fails loudly from code that fails quietly, and this site’s rule — no decomposition without its residual — is that habit made compulsory for figures.

What this says about worst-case analysis

A closing observation that is not really about matrices.

The 2ⁿ⁻¹ bound is a correct, tight, worst-case result, and it is a bad guide to behaviour. The matrix attaining it is measure-zero in any reasonable sense and does not arise from applications. An engineer who chose an algorithm by comparing worst-case bounds would reject the method the entire scientific computing world uses, in favour of one three times as expensive, on the strength of a scenario that has never occurred.

The lesson is not that worst cases do not matter — in a security setting they matter more than anything, because an adversary chooses the input. It is that a worst-case bound answers the question “what could an adversary do”, and most numerical computing has no adversary. When the inputs come from physics or from measurement rather than from someone trying to break the code, the distribution is the thing to measure, and the bound is a backstop.

Which is precisely why it is worth having both numbers on the same axes, which is what the figure at the top of this essay does. The bound and the behaviour are both true, they differ by eleven orders of magnitude, and knowing only one of them leads to a wrong decision in either direction.

What this field established

Three essays, one algorithm, and a set of facts that the rest of the site leans on.

Elimination is a sequence of choices established what the factorisation records and why the multipliers are bounded by one. The swap that is not optional established what happens when they are not — a backward error of 0.25 on a well-conditioned problem, arrived at silently. And this essay establishes that the bound the whole argument rests on is never approached, which is the empirical fact everything else quietly assumes.

The thing that carries forward is the flat line. Every figure on this site that plots backward error against condition number shows a horizontal line at 10⁻¹⁶, and that line is the growth factor being near one, expressed in the quantity the reader cares about. It is what makes the separation between the algorithm’s fault and the problem’s available at all, and it is the reason a small residual is not a small error can make its argument without qualification.

The open question, stated plainly

It is worth ending on, because it is one of the more surprising gaps in a mature field.

Nobody knows why the growth factor of Gaussian elimination with partial pivoting is small in practice. There is no theorem. There are results for structured classes, there is a large body of empirical measurement, and there is a probabilistic analysis for random matrices under specific distributions — and there is no general statement covering the matrices people actually factorise.

The most widely used numerical algorithm in existence rests, in the general case, on an observation. That is not a scandal; it is what an empirical science looks like when the theory has not caught up. But it is worth knowing, and it is worth knowing that the observation has been made carefully, many times, by people who would have been delighted to find a counterexample.

Which is also the argument for measuring it rather than assuming it. One line, one comparison per step, and the assumption becomes a number.

A quantity with no bound at all

The growth factor has a bound that is never reached, which is a comfortable situation. The comparison worth making is against a route that has no bound of any kind — where the question is not how loose the bound is but whether a theorem of that shape exists.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Average-case behaviourBackward errorGaussian eliminationGrowth factorPartial pivotingResidualWilkinson's matrixWorst-case analysis