Elimination, and the swap

One step ahead is one step short

Partial pivoting takes the largest entry in the column and, on Wilkinson's matrix, walks into growth of 2^(n−1) that a cyclic shift of the rows avoids entirely. A rule that chose instead the pivot whose elimination leaves the smallest trailing submatrix was expected to see the good order at the first step. It sees nothing there: every first pivot leaves a largest entry of exactly 2, and with the ties broken by 10⁻¹² it prefers the greedy row by 10⁻¹². It attains 2^(n−1) at every size. Looking two eliminations ahead, the greedy row scores 4 and every other row 2, and the growth is 2 at every size up to 24. On random matrices one step of look-ahead helps below n = 16 and is worse than greedy on more than half of them by n = 32.

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

The order the greedy rule cannot choose scored every row ordering of Wilkinson’s matrix and found that the growth factor of 2n−12^{n-1} partial pivoting attains on it is not the matrix’s. A single cyclic shift of the rows — pivot on row 2, then 3, and so on, and on row 1 last — gives growth 2 at every size, with no multiplier above one. The greedy rule takes the largest entry in each column; every entry in Wilkinson’s first column has magnitude one; the rule takes the first of the tied rows, and that choice doubles the last column at every subsequent step. Break the ties by 10−1210^{-12} in the diagonal’s favour and every tie-break the greedy rule could use takes the doubling path.

That essay ended by proposing the obvious repair. The greedy rule reads one number per candidate row, the size of its entry in the pivot column. A rule that performed the elimination step with each candidate and kept the one leaving the smallest largest entry in the trailing submatrix would read the quantity the growth factor is actually a maximum of. It would cost n−kn - k trial eliminations at step kk — about 3n/43n/4 times the whole factorisation’s work — and, the essay said, it “would see exactly the information the good ordering needs at step 1 of Wilkinson’s matrix”.

It would not. What it sees at step 1 is a tie.

The rule, and a second one

Two rules are measured. The one-step rule, at each column, tries every row with a nonzero entry as the pivot, measures the largest entry of the active submatrix that elimination leaves, and keeps the row with the smallest. The two-step rule scores each candidate by the best it can do over two eliminations: for each first pivot it tries every second pivot, and scores the first by the smaller of the pair’s worse largest entry. Both break exact ties in favour of the lower row index, as the greedy rule does, so that none of the differences below comes from a tie-break.

The one-step rule costs about ∑k(n−k)3≈n4/4\sum_k (n-k)^3 \approx n^4/4 operations against elimination’s n3/3n^3/3. The two-step rule costs a factor of nn more again, about n5/5n^5/5. Neither is a practical pivot rule on a large dense matrix, and neither is proposed as one. The question is whether looking ahead finds what the greedy rule misses, and how far ahead it has to look.

Wilkinson’s matrix, one step ahead

Wilkinson's matrix with its ties broken by 10⁻¹², under the greedy rule and under pivot rules that look one and two eliminations aheadThe growth factor on a logarithmic axis against the matrix size, from 4 to 24. The greedy rule attains 2^(n−1): 8, 32, 128, 2048, 32768, 8388608. A rule that chooses the pivot whose elimination leaves the smallest largest entry attains exactly the same: 8, 32, 128, 2048, 32768, 8388608. A rule that looks two eliminations ahead attains 2.000, 2.000, 2.000, 2.000, 2.000, 2.000.ties broken by 10⁻¹²one step ahead, n = 248.4·10⁶two steps ahead, n = 2424812162024110¹10²10³10⁴10⁵10⁶10⁷matrix size ngrowth factorgreedyone step aheadtwo steps aheadone step ahead lies exactly on greedythe damage is done a step before it shows
Fig. 1 Wilkinson’s matrix with its ties broken by 10⁻¹², from n = 4 to 24: the growth factor under the greedy rule, one step ahead and two steps ahead.

The one-step rule attains 2n−12^{n-1} at every size: 8, 32, 128, 2,048, 32,768 and 8,388,608 at n = 4, 6, 8, 12, 16 and 24, exactly the greedy rule’s numbers. It does not merely fail to find the good ordering. It chooses the greedy ordering, row for row.

The first pivot choice on Wilkinson's matrix at n = 8, scored one elimination ahead and twoFor each of the eight rows as the first pivot, the largest entry the elimination leaves in the active submatrix, and the smallest such largest entry after the best second pivot. One step ahead every row scores 2: row 1, the greedy rule's choice, scores 2 exactly and the others 2 plus a few units in the twelfth decimal, from the perturbation that broke the ties — so a rule reading one step ahead prefers row 1, by 10⁻¹². Two steps ahead row 1 scores 4.000 and every other row 2.row 1, one step ahead2row 1, two steps ahead4row 2, one step ahead2.000000000001row 2, two steps ahead2.000000000001row 3, one step ahead2.000000000001row 3, two steps ahead2.000000000001row 4, one step ahead2.000000000001row 4, two steps ahead2.000000000001row 5, one step ahead2.000000000001row 5, two steps ahead2.000000000001row 6, one step ahead2.000000000001row 6, two steps ahead2.000000000001row 7, one step ahead2.000000000001row 7, two steps ahead2.000000000001row 8, one step ahead2.000000000002row 8, two steps ahead2.000000000002the scale starts at zero; one step ahead the bars are equaltwo steps ahead row 1 is twice the rest
Fig. 2 Each of the eight rows of Wilkinson’s matrix as the first pivot at n = 8: the largest entry its elimination leaves, and the smallest largest entry the best second pivot then leaves.

The first step shows why. Pivot on row 1, the greedy rule’s choice: every other row has −1 in the first column and 1 in the last, and adding row 1 to it makes the last entry 2. Pivot on row 2 instead, the good ordering’s choice: row 1 subtracts a multiple of row 2 and its last entry becomes 2 as well; the rows below subtract row 2, which empties their last column and makes their second-column entries −2. Every choice of first pivot leaves the same largest entry. The 10⁻¹² perturbation that breaks the column ties breaks this tie too, by the same amount: the greedy row leaves exactly 2 and every other row leaves 2 plus a unit or two in the twelfth decimal. So the one-step rule, reading honestly, prefers the greedy row by 10−1210^{-12} — and the damage it cannot see is a factor of two that arrives at the next step.

The damage arrives a step late

The largest entry left in the active submatrix after each step of Wilkinson's matrix, n = 16, along the greedy order and the order two steps ahead choosesOn a logarithmic axis against the elimination step. Along the greedy order — which is also the one-step look-ahead's — the largest active entry doubles every step: 2, 4, 8, 16, 32 and so on to 32768. Along the order the two-step rule chooses it is 2 after the first step and stays there, 2 after the last. Both orders leave 2 after the first step; they differ from the second on.n = 16greedy, after step 153.3·10⁴two ahead, after step 152123456789101112131415110¹10²10³10⁴after elimination steplargest active entrygreedy, one aheadtwo steps aheadidentical after the first stepthe difference appears one step later
Fig. 3 The largest entry left in the active submatrix after each step of Wilkinson’s matrix at n = 16, along the greedy order — which is also the one-step rule’s — and along the order the two-step rule chooses.

Traced step by step at n = 16, the two orders leave the same largest entry after the first elimination, 2. After the second they have parted: the greedy order’s is 4 and the good order’s 2. From there the greedy order doubles every step, to 32,768 after the fifteenth, and the good order stays at 2 throughout. The first step is where the decision is made and the second is where its consequence becomes visible, and a rule that looks one step ahead is standing on the first.

The two-step rule is standing on the second. Scored over two eliminations, row 1 is 4 — its best continuation cannot avoid the doubling it set up — and every other row is 2. It takes row 2. At every later step the same reading picks the good continuation, and the growth is 2.000 at every size from 4 to 24. That is the growth the exhaustive search found possible at n = 7, reached by a rule that never looks more than two eliminations into the future.

There is a general statement hiding in the particular one. Wilkinson’s construction is built so that a pivot decision’s cost is deferred: the first elimination copies the last column into every row without changing its size, and the doubling needs a second elimination to happen. A look-ahead of depth dd sees consequences that arrive within dd steps, and any construction whose decisions pay off later than that defeats it in the same way. Whether there is a Wilkinson-like matrix built to defer by two steps — and so defeat the two-step rule as completely as this one defeats the one-step rule — is not answered here, and the argument suggests there is.

Forty small matrices, searched exhaustively

Wilkinson’s matrix is one construction, chosen to defeat the greedy rule. The more ordinary question is what looking ahead does on matrices nobody built. At n = 6 and 8 every row ordering can be scored — 720 and 40,320 of them — so each rule’s growth can be compared with the least growth any ordering allows.

How many of forty random matrices each pivot rule eliminates with the least growth any ordering allows, at n = 6 and 8Every row ordering scored exhaustively — 720 at n = 6 and 40,320 at n = 8 — on forty standard Gaussian matrices at each size. At n = 6 the greedy rule attains the minimum on 18, one step ahead on 26, two steps ahead on 33; the medians over the best are 1.049, 1.050 and 1.023. At n = 8 the greedy rule attains the minimum on 10, one step ahead on 17, two steps ahead on 22; the medians over the best are 1.075, 1.037 and 1.024.n = 6, greedy18 of 40n = 6, one step ahead26 of 40n = 6, two steps ahead33 of 40n = 8, greedy10 of 40n = 8, one step ahead17 of 40n = 8, two steps ahead22 of 40the least growth of every ordering, found by searcheach step of look-ahead finds it on more matrices
Fig. 4 On forty standard Gaussian matrices at n = 6 and at n = 8, how many each rule eliminates with the least growth of every ordering.

At n = 6 the greedy rule attains the exhaustive minimum on 18 of 40 matrices, the one-step rule on 26 and the two-step rule on 33. At n = 8 the counts are 10, 17 and 22. Each step of look-ahead finds the minimum on five to eight more matrices of forty. The medians move less: at n = 8 the greedy rule’s median growth is 1.075 times the best ordering’s median, the one-step rule’s 1.037 and the two-step rule’s 1.024. On a random matrix the greedy rule is rarely far from optimal, which which of the choices is doing the work had already found from the other side — removing a single decision barely moves the median — and looking ahead mostly converts near-misses into hits.

But not always. The one-step rule grows more than greedy on 7 of the 40 matrices at n = 6 and 10 at n = 8, and its worst at n = 8 is 2.96 against greedy’s 2.18. A rule that picks the smallest next submatrix will sometimes pick a pivot far smaller than the column’s largest — its largest multiplier on these matrices reaches 5.1 — and a large multiplier is a cost that the next submatrix does not show and a later one does. It is the same deferral as Wilkinson’s, arriving from the rule’s own choices.

As the matrices grow

The growth factor's median and ninetieth percentile against n, for the greedy rule and pivot rules one and two steps aheadStandard Gaussian matrices, forty at n = 6 and 8 and a hundred at n = 12, 16, 24, 32, on logarithmic axes. Medians for greedy, one step ahead and two steps ahead: n = 6: 1.140, 1.141, 1.111; n = 8: 1.362, 1.313, 1.297; n = 12: 1.704, 1.628, 1.499; n = 16: 1.865, 1.754, 1.674; n = 24: 2.356, 2.241, 2.025; n = 32: 2.670, 2.719, 2.563. At n = 32 the ninetieth percentiles are 3.759, 3.659 and 3.110.growth factorgreedy median, n = 322.7two ahead median2.610¹1matrix size ngrowth factorgreedy, medianone ahead, mediantwo ahead, mediangreedy, 90thtwo ahead, 90thsolid: the median matrix; dashed: one in tenone step's advantage is gone by n = 32
Fig. 5 The median and ninetieth-percentile growth factor against n, for the greedy rule and the two look-ahead rules, on forty matrices at n = 6 and 8 and a hundred at each larger size.

On a hundred random matrices at each size to n = 32 the one-step rule’s advantage shrinks and then reverses. Its median growth is 1.628 against greedy’s 1.704 at n = 12, 1.754 against 1.865 at 16, 2.241 against 2.356 at 24 — four to six per cent better — and 2.719 against 2.670 at n = 32, two per cent worse. The two-step rule holds its advantage longer: 1.499, 1.674, 2.025 and 2.563 at the same sizes, twelve, ten, fourteen and four per cent below greedy. In the tail it does more: at n = 32 its ninetieth percentile is 3.110 where greedy’s is 3.759.

The share of random matrices on which a look-ahead pivot rule grows more than the greedy rule, against nFor the same matrices as the size sweep, the fraction on which the growth factor under the look-ahead order exceeds the greedy order's. One step ahead: 18% at n = 6, 25% at n = 8, 31% at n = 12, 33% at n = 16, 46% at n = 24, 56% at n = 32. Two steps ahead: 8%, 20%, 24%, 31%, 29%, 31%.worse than greedyone ahead, n = 320.56two ahead, n = 320.3110¹00.10.20.30.40.50.60.7matrix size nshare worse than greedyone step aheadtwo steps aheada myopic rule is still a greedy oneit wins where the future is short
Fig. 6 The share of matrices on which each look-ahead rule grows more than the greedy rule does, against n.

Counted matrix by matrix, the fade is plainer. The one-step rule is worse than greedy on 18 per cent of matrices at n = 6, 33 per cent at 16 and 56 per cent at 32. The two-step rule is worse on 8 per cent at n = 6 and settles near 30 per cent from n = 16 on. A rule that looks a fixed distance ahead sees a fixed fraction of a factorisation whose length is n, and the fraction shrinks as n grows. At n = 6 one step is a fifth of the future; at n = 32 it is a thirty-first, and what the rule cannot see starts to outweigh what it can.

What each rule pays to look

The costs are worth writing out, because they are what any look-ahead has to be weighed against. Elimination itself does about ∑k(n−k)2≈n3/3\sum_k (n-k)^2 \approx n^3/3 multiply–adds. The one-step rule does a trial elimination for each of the n−kn - k candidates at step kk, each costing (n−k)2(n-k)^2, so about ∑k(n−k)3≈n4/4\sum_k (n-k)^3 \approx n^4/4: at n = 32 that is 24 times the factorisation. The two-step rule does a trial elimination for each pair of first and second pivots, about n5/5n^5/5 in all, which at n = 32 is 600 times the factorisation. Partial pivoting’s search, by comparison, is n2/2n^2/2 comparisons, a vanishing fraction of the arithmetic, and complete pivoting’s is n3/3n^3/3 comparisons, the same order as the arithmetic.

So the one-step rule is priced like complete pivoting multiplied by the matrix size, and the two-step rule like complete pivoting multiplied by its square. Neither bought, on random matrices at n = 32, what complete pivoting buys: a median growth well under two. What the look-ahead rules are designed to buy, and nothing else in this list is, is an ordering read from the matrix’s future rather than from its present — on Wilkinson’s matrix, the ordering the exhaustive search found, reached by the two-step rule and by no rule that reads only the current column. Elimination is a sequence of choices put the whole subject in one sentence: there is one decision at every step, and every stability property comes from making it well. The look-ahead rules make it with more information, and the measurements say how much the extra information is worth.

Exact ties, and why the perturbation matters

Everything above uses Wilkinson’s matrix with its ties broken by 10−1210^{-12}, because the unperturbed matrix is a test of tie-breaking rather than of pivoting. With the ties left exact, every candidate at the first step scores exactly 2 one step ahead, and the one-step rule’s choice is whatever its tie-break says — the lowest row index here, which is the greedy row. A rule breaking its ties towards the highest index would take row 8 and, as the essay on the greedy rule found for the backward tie-break, might land on a good ordering by accident. That is not a property of looking ahead. It is the fragility the order the greedy rule cannot choose measured: a result that depends on which of several equal numbers a scan meets first is a result about the scan, and a perturbation of 10−1210^{-12} is the smallest honest way to take the scan out of it.

The direction of the perturbation is chosen, and that choice matters too. It favours the diagonal, which keeps the greedy rule on its worst path; it is the adversary’s perturbation. A worst case is as fragile as its margin added random noise instead, of 10−1410^{-14} to every entry, and found partial pivoting’s median growth on Wilkinson’s matrix falling to exactly 2, because random noise breaks the ties in random directions and most of them are not the doubling one. Under random noise the one-step rule would presumably share the same luck; that is not measured here. Under the adversary’s perturbation it inherits nothing, which is the test a pivot rule has to pass if it is to be credited with seeing the construction rather than with being shaken off it. A threshold that holds the growth still drew the same line from the other side: under partial pivoting Wilkinson’s growth rests on exact ties, while a threshold rule holds the same growth by row counts that no perturbation of the values reverses — the difference between a result about the matrix and a result about the scan.

The perturbation matters for the two-step rule as well, in the other direction. Its preference for row 2 over row 1 is a factor of two, 4 against 2, not a difference in the twelfth decimal, so no perturbation of that size can move it. The two-step rule’s success on Wilkinson’s matrix is robust in exactly the way the one-step rule’s failure is not accidental: both follow from where the doubling happens, one step after the decision that causes it.

What the search was worth

The measurements put a price on the idea. The one-step rule costs about 3n/43n/4 times the factorisation, and buys nothing on the matrix it was proposed for and a few per cent on small random ones, reversing by n = 32. The two-step rule costs nn times more again and buys the Wilkinson ordering outright and ten to fifteen per cent of median growth at moderate sizes. Neither is a pivot rule anyone would ship for dense factorisation, where a pivot that searches one row and one column keeps the median growth at 2.53 on Gaussian matrices of size 64, against partial pivoting’s 4.06, for a search about three times the column’s — better at twice the size than the two-step rule manages at n = 32, for a small fraction of its cost. Rook pivoting reads a different quantity from either look-ahead: not the future’s size, but whether the chosen entry is also the largest in its own row, which is a statement about the multipliers the next steps will use.

What the measurements say is where the greedy rule’s failures live. They are not in the step’s own numbers, which the greedy rule reads correctly — the largest entry is the safest single pivot. They are in the interaction between successive steps, where a choice that is harmless now sets up a doubling later. The bound that is never attained found that on random matrices the doubling almost never compounds; Wilkinson’s matrix is built so that it always does, and it takes a rule that reads two steps of interaction to see the construction at all.

What this does not settle

Standard Gaussian matrices and one adversarial construction. Matrices with structure — banded, or arising from a boundary-value problem, which the growth a boundary-value problem supplies found supplying large growth under partial pivoting naturally — may reward look-ahead more or less, and are not measured.

Look-ahead of depth two is the deepest measured, because depth dd costs nd+3n^{d+3} and n = 32 at depth two already takes seconds a matrix. Whether depth three buys at n = 32 what depth two bought at n = 16 — whether the useful depth scales with n — is the obvious question and is not asked.

Still open: an adversary for two steps, and a look-ahead that reads the multiplier

A construction that defers by two. The argument above says Wilkinson’s matrix defeats the one-step rule because its damage arrives one elimination late. A matrix whose damage arrives two eliminations late would defeat the two-step rule the same way. Building one — a block version of Wilkinson’s construction, perhaps, in which each doubling needs two eliminations to express — and confirming that the two-step rule attains its bound there while the three-step rule does not would turn the argument into a theorem about what look-ahead of fixed depth can guarantee: nothing, against an adversary allowed to defer.

A one-step rule with a multiplier bound. At n = 32, three in four of the matrices on which the one-step rule loses to greedy used a multiplier above two somewhere, against one in two of those on which it did not. A rule that looks one step ahead only among candidates within a factor of the largest — so that no multiplier exceeds, say, two — was tried alongside and behaves like the unbounded rule on the median, but whether its tail is lighter at n = 32 and beyond, where the unbounded rule’s multipliers reach 6.3, is the measurement that would say whether the reversal is the look-ahead’s or the multipliers’.

What links here

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

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.

Combinatorial searchExact ground truthGaussian eliminationGrowth factorLU factorisationPartial pivotingPermutationPivoting