Exact arithmetic, and what it costs instead

An order found once knows what the rows know

Searching for a fraction-free elimination's least-cost row order costs forty to two hundred and sixty times the elimination, so it can only pay if one order serves a whole family. The prediction was that it cannot: the best order depends on which rows happen to have short entries, so a reused order should do no better than the natural one. On independent entries and on a shared zero pattern that holds — another member's best order is an ordinary order, at the middle of the 40,320. On a family that shares its row scales it fails completely: another member's order costs a median 1.13 of the least where the natural order costs 1.88. But on every family, including that one, the rule that just takes the smallest pivot entry is cheaper than any reused or trained order — 1.24, 1.08 and 1.01. What an order carries from one matrix to the next is what the family shares — and only when that is a particular matrix, not a visible structure, does an order trained on the family beat the rule.

Worth reading first: An answer with no error in it · The order the products are taken in.

What reading the next pivot buys found the least-cost row order of a fraction-free elimination by looking ahead — an elimination whose every intermediate is a minor of the original, as every intermediate is a minor showed, so that its cost is set by how long those minors grow. In a Bareiss elimination over the integers every pivot multiplies every entry of its own step and divides every entry of the next, and with each multiplication charged at the product of its operands’ bit lengths, a rule that reads three pivots ahead reproduces the least of all 40,320 row orders on thirteen of twenty-four 8 × 8 matrices. It also measured the price: the look-ahead’s simulated steps cost forty to two hundred and sixty times the elimination it chooses for. On one matrix the search can never pay for itself.

Its last section asked whether it could pay across many. “If the order found on one matrix is within a few per cent of the least on matrices drawn from the same family — the same size, the same entry distribution, or the same sparsity — the search is paid once and amortised. The prediction with a sign is that it is not: on these matrices the least-cost order depends on which rows happen to have short entries in which columns, and a reused order should do no better than the natural order’s 1.733.”

The prediction is right about the matrices it was made on and wrong about families in general. What decides it is a question the prediction did not ask: what made the order best in the first place, and whether the next matrix shares it.

Three families, every order costed

Each family has twelve members of order 8 with integer entries from −6-6 to 66, drawn from seeded streams and kept when nonsingular. The first family has independent entries, as the earlier essays’ matrices did. The second shares a pattern of zeros: the same 40 per cent of positions are zero in every member, and the rest independent. The third shares its row scales: row ii of every member is multiplied by 2si2^{s_i}, with the same scales s=(4,0,3,3,3,0,1,3)s = (4, 0, 3, 3, 3, 0, 1, 3) throughout — the kind of family a sequence of systems from one model produces, where each equation keeps its units from one solve to the next.

For every member, every one of the 40,320 row orders is run as a Bareiss elimination and costed. That table holds everything: the least cost and the order that reaches it; the natural order’s cost; the cost of any other member’s least-cost order on this member; and, for each member, the order whose total cost over the other eleven members is least — an order trained on the family and tested on a member it never saw. Two cheap rules from the earlier essays are run beside them: the smallest nonzero pivot entry in the column, and the row norms of the original matrix taken in increasing order.

A reused order is a random order — when nothing is shared

Six ways of choosing a fraction-free elimination's row order on four families of 8 by 8 integer matrices, as the median member's cost over the least any order reachesTwelve members a family, entries from minus six to six, every one of the 40,320 row orders costed with each multiplication charged at the product of its operands' bit lengths. independent entries: natural order 1.600, the median order 1.717, another member's best 1.540, best over the other eleven 1.458, rows by their norms 1.495, smallest pivot entry 1.240. a shared zero pattern: natural order 1.652, the median order 1.716, another member's best 1.592, best over the other eleven 1.361, rows by their norms 1.349, smallest pivot entry 1.076. shared row scales: natural order 1.884, the median order 1.860, another member's best 1.126, best over the other eleven 1.156, rows by their norms 1.049, smallest pivot entry 1.014. one matrix, two entries redrawn: natural order 1.280, the median order 1.511, another member's best 1.155, best over the other eleven 1.070, rows by their norms 1.421, smallest pivot entry 1.136.1.01.21.41.61.82.0median member's cost over the least any row order reachesindependent entriesa shared zero patternshared row scalesone matrix, two entries redrawnnatural order1.60the median order1.72another member's best1.54best over the other eleven1.46rows by their norms1.49smallest pivot entry1.24natural order1.65the median order1.72another member's best1.59best over the other eleven1.36rows by their norms1.35smallest pivot entry1.08natural order1.88the median order1.86another member's best1.13best over the other eleven1.16rows by their norms1.05smallest pivot entry1.01natural order1.28the median order1.51another member's best1.16best over the other eleven1.07rows by their norms1.42smallest pivot entry1.14dashed: the least cost of all 40,320 ordersthe rule wins wherever the rows show why
Fig. 1 The median member’s fraction-free cost over its own least, for each way of choosing the row order, on the four families of related matrices.

The figure above is the whole comparison, as the median member’s cost over its own least. On independent entries the natural order costs 1.600 and the median of all 40,320 orders 1.717. Another member’s least-cost order costs 1.540, and the order trained on eleven members 1.458. Neither is the “within a few per cent” the amortisation needed; both are ordinary orders.

Where another member's least-cost order falls among all 40,320 row orders of the member it is reused on, as the share of orders cheaper than itEach dot is one member eliminated in another member's least-cost order; zero would be the least-cost order itself and a half a typical one. independent entries: median 0.346; a shared zero pattern: median 0.313; shared row scales: median 0.014; one matrix, two entries redrawn: median 0.016. A second family of 24 members with independent entries puts the reused order at a median of 0.446 and a mean of 0.472 over 493 pairs.share of orders cheaperindependent entries: median0.35a shared zero pattern: median0.31shared row scales: median0.014one matrix, two entries redrawn: median0.016independent, 24 members: mean0.4700.20.40.60.81share of all orders cheaper than the reused oneindependentshared zerosshared row scalestwo entries redrawna typical orderdashed: half the orders cheapera reused order is a random one unless the rows say otherwise
Fig. 2 Where another member’s least-cost order falls among all 40,320 row orders of the member it is reused on, as the share of orders cheaper than it, for each family. The dashed line is a typical order.

The percentile figure says so more directly. Among each member’s 40,320 orders, another member’s best order sits at a median of the 35th percentile on independent entries — better than a typical order, which would sit at the 50th. That is a sampling effect and not a transfer. Rows of an independent-entry matrix are exchangeable, so a fixed order costs a member, on average, exactly what a random order does; and a second independent family of twenty-four members, drawn from other seeds, puts the reused order at a mean of the 47th percentile over 493 pairs. With twelve members a few lucky orders move the median; with twenty-four they do not.

The shared zero pattern does no better. Another member’s best order costs 1.592 and sits at the 31st percentile, and 39 of the 132 reuses cannot be run at all: they meet a zero pivot that the member they were found on did not have. A zero pattern does change which orders are legal — the distinction a prime that divides the answer drew between a pivot that is zero and one that merely looks so — but it says almost nothing about which legal order is cheap, because in a Bareiss elimination the zeros disappear after the first step or two — every later entry is a minor, and minors are rarely zero — while the cost is in the bit lengths those minors grow to.

And transfers completely when the rows carry it

Each member of the family with shared row scales eliminated in each other member's least-cost row order, as cost over its own leastTwelve members; row i, column j is member i's cost in member j's least-cost order over member i's least; the diagonal is one, and a blank cell is an order that meets a zero pivot on that member. Median 1.126, worst 1.458, 29 of 132 orders unusable; the natural order's median is 1.884.1.11.11.11.11.11.11.21.11.11.01.31.01.21.11.11.41.21.31.21.21.11.11.01.31.11.21.11.11.11.11.21.51.11.01.11.01.11.11.11.11.01.11.21.11.01.11.11.11.11.11.21.01.11.11.31.21.11.41.11.21.21.31.21.21.21.41.11.31.41.21.11.11.21.01.11.21.31.21.21.21.31.11.11.11.21.11.21.01.11.11.11.21.11.11.11.11.01.01.21.11.11.01.0least-cost order of membermemberwithin a tenthwithin two fifthswithin four fifthsmoreeach cell: cost over the member's own leastan order travels as far as its reason
Fig. 3 Each member of a family eliminated in each other member’s least-cost order, as cost over its own least: row i, column j is member i in member j’s order. The dial sets the family.

On the family with shared row scales the natural order costs 1.884 of the least and the median order 1.860 — scaled rows make an arbitrary order dearer than on independent entries, because a row multiplied by sixteen carries four extra bits into every product it touches, and a bound on every intermediate at once is the account of how far those bits can grow. Another member’s least-cost order costs 1.126, at the 1st percentile of the 40,320; the worst of the 132 reuses costs 1.458, which is still cheaper than the natural order on the median member. The trained order costs 1.156. On the dial’s other two families the grid is a patchwork of values between 1.1 and 2.3; on this one almost every cell is pale.

The reason is visible in the orders themselves.

The least-cost row order of each member of the family with shared row scales, every row drawn with its scaleRows are scaled by two to the power 4, 0, 3, 3, 3, 0, 1, 3 in every member. Each line is one member's least-cost order, left to right; the shade of a cell is its row's scale. The orders take the unscaled rows first and the most heavily scaled row last or nearly last; the number of pairs taken out of scale order is 1, 1, 4, 1, 1, 2, 2, 2, 2, 1, 1, 7 of a possible 28.267458136275431826715834627534186273841567285413264758132657831427643815627358142678431562381547member 1member 2member 3member 4member 5member 6member 7member 8member 9member 10member 11member 12position in the elimination orderscale two to the 0scale two to the 1scale two to the 3scale two to the 4numbers: the row taken; shade: its scalesmall rows first, every time
Fig. 4 The scaled family’s least-cost orders, one member a line, each row drawn with its scale: the rows taken left to right in the order that costs least.

Every member’s least-cost order starts with one of the two unscaled rows, 2 and 6, and ten of the twelve start with both, in one order or the other; most take the row scaled by two third or fourth; and ten put row 1, the one scaled by sixteen, second from last. The scales decide the shape of the order and the entries decide the details within each group of equally scaled rows. A member’s best order is therefore close to every other member’s best order at the level the scales fix, and different only in the details, which cost a few per cent. That is exactly what the reuse grid measures.

The rule that searches nothing wins anyway

Here the prediction’s reasoning returns, sharpened. The order transfers on the scaled family because the rows’ sizes decide it, and the rows’ sizes are visible. A rule that reads them should do as well as any reused order without having searched.

Member by member, the smallest-pivot rule's cost over the least against the cost of the order trained on the other eleven membersEach dot is one member: across, the cost of the row order that is cheapest in total over the other eleven members of its family; up, the cost of choosing each pivot as the smallest nonzero entry of its column. Below the diagonal the rule is cheaper. independent entries: the rule is cheaper on 7 of 10 members; a shared zero pattern: the rule is cheaper on 9 of 11 members; shared row scales: the rule is cheaper on 10 of 11 members; one matrix, two entries redrawn: the rule is cheaper on 4 of 12 members.smallest pivot against the trained orderindependent entries: rule cheaper on7a shared zero pattern: rule cheaper on9shared row scales: rule cheaper on10one matrix, two entries redrawn: rule cheaper on411.21.41.61.8211.21.41.61.82trained order's cost over the leastsmallest pivot's cost over the leastindependentshared zerosshared row scalestwo entries redrawnbelow the diagonal: the rule that reads the matrix winsa search amortised is still beaten
Fig. 5 Member by member, the smallest-pivot rule’s cost over the least against the cost of the order trained on the other eleven members, for the three families. Below the diagonal the rule is cheaper.

It does better. On the scaled family the smallest-pivot rule costs a median 1.014 of the least and the norm rule 1.049, against 1.126 for a reused order and 1.156 for a trained one. On the zero-pattern family the smallest-pivot rule costs 1.076 against the reused order’s 1.592. On independent entries it costs 1.240 against 1.540. Member by member, the rule is cheaper than the trained order on 7 of 10 members with independent entries, 9 of 11 with the shared zeros and 10 of 11 with the shared scales — the members missing from each count being those on which the trained order meets a zero pivot. The pivot is in every product found the smallest-pivot rule at 1.165 of the least on its matrices and asked whether anything cheap could close the rest; reusing an order, even one trained on eleven matrices of the same family, is not that thing.

The smallest-pivot rule reads more than the row scales: it reads, at every step, which entry of the current column is shortest, and in a Bareiss elimination that is the entry that will multiply everything at this step and divide everything at the next. A reused order fixes the sequence of rows before the elimination has produced any of the minors whose lengths decide the cost. On the scaled family the two agree about the first few steps, because the scales dominate the first minors’ lengths; later, the rule reads lengths the scales no longer determine, and the reused order cannot.

Where the shared structure is the entries themselves

The three families above share something a rule can see, or nothing at all. A fourth shares something no rule can see: one base matrix, the same in every member, with two of its sixty-four entries redrawn at random. The members are nearly the same matrix, and the earlier essay’s Still-open question — whether an order found once could be reused — has its most favourable case here.

It is not favourable in the way expected. Another member’s least-cost order costs a median 1.155 of the least on this family, worse than on the scaled family, even though the members differ in two entries and the scaled family’s in all sixty-four. Two redrawn entries are enough to move a member’s least-cost order: of the twelve members’ least-cost orders only one occurs more than once — four members share it — and the other eight are all different, because near the least there are many orders within a few per cent of each other and a small change to the matrix reshuffles which of them comes first. A single member’s best order is a noisy sample of the family’s best.

The order trained on eleven members averages the noise away. It costs a median 1.070 of the least on the member it never saw — and the smallest-pivot rule costs 1.136. On this family, and only on this one, an order found by search and reused beats the rule that reads the matrix. The rule reads the current column’s shortest entry, which is the right thing to read when the rows differ in kind; when every member is the same matrix give or take two entries, what matters is the one ordering that is good for the base matrix, and the rule, reading one column at a time, does not find it. The trained order does, because the base matrix is what the eleven training members have in common.

The percentile figure shows the same thing from the other side. On the family of perturbations a reused order sits at a median of the 2nd percentile of the member’s 40,320 orders — nearly as good, by rank, as on the scaled family — and still costs fifteen per cent over the least. On these matrices the cheapest orders are crowded: on four members of the family the hundredth-best order is four to nine per cent over the best, and the order at the 2nd percentile — about the six-hundred-and-fiftieth — nine to nineteen per cent over, so a reused order that lands there is both excellent by rank and mediocre by cost. The scaled and independent families’ bottoms look the same. Rank and cost tell different stories whenever the bottom of the distribution is flat, which is why the figures report both.

That is the general shape completed. An order found once carries what its family shares. When that is visible in the rows — their scales, their lengths — a rule reads it directly and wins. When it is invisible to any rule, because it is the particular entries of a particular matrix, the trained order is the only way to get it, and it pays: here, seven per cent of the least against the rule’s fourteen. What does not pay, on any family, is one member’s best order taken alone.

What amortising a search would need

The earlier essay’s look-ahead costs forty to two hundred and sixty eliminations to run, and the exhaustive search that found every least-cost order here costs 40,320. For any of it to pay through reuse, the reused order would have to beat the cheapest rule by enough to recover that cost over the family’s members. One member’s best order, reused, beats the rule on no family. An order trained on eleven members beats it on one family of four — the one whose shared structure is a particular matrix — by seven hundredths of the least, which is a real saving per elimination and would repay the search only over a family of thousands of members.

So the search is not amortised over these families, and the reason is not the one the prediction gave. It is not that orders fail to transfer. On the scaled family an order transfers because something visible in the rows decides it, and a rule that reads the rows gets that something for nothing, and more besides. On the family of perturbations what transfers is invisible to a rule, and there — only there — the trained order is worth having.

That shape is worth stating in general. An optimisation done once and reused across a family carries the family’s shared structure and nothing else, since anything else was particular to the member it was found on. If the shared structure can be observed, a rule that observes it does at least as well as the reuse; if it cannot be observed, the reuse is the only way to get it, and the case in which searching once is worth its price. The answer is longer than the question put a floor under the cost of the output that no ordering can move; every ordering here moves only the part above that floor, and an answer with no error in it is the reminder that over the integers that part is all there is to choose — there is no accuracy to trade for it, only bits.

What the families do not show

The cost is the schoolbook one, each multiplication charged at the product of its operands’ bit lengths and each exact division at the product of the dividend’s and the divisor’s; a fast multiplication would charge long products less, flatten the differences between orders, and so make every choice above matter less without changing which choice wins. Three families of twelve 8 × 8 members, entries of three bits, a single scaling pattern and a single zero pattern. A family whose shared structure is in the columns — the same columns scaled in every member — would put the structure into every row equally, and a row order could not carry it; the prediction is that there a reused order is a random order again. The family of perturbations was perturbed in two entries; with one, the members would share more, and with eight, less, and the crossover at which the trained order stops beating the rule is not located here. At order 8 the exhaustive search is affordable and the least is known; at order 20 neither is, which is where an amortised search would matter if it ever mattered, and where this measurement cannot follow.

Still open: a family of perturbations, and the columns’ scales

How many members a trained order needs. On the family of perturbations the trained order used eleven members and beat the rule by seven hundredths. A trained order averages the members’ noise, so its excess over the base matrix’s own best should fall roughly as one over the number of members. The prediction with a sign is that three members already put the trained order below the rule on the median member, and that one member — a single reused order — does not, as measured above.

Scales on the columns instead of the rows. Multiplying column jj of every member by 2tj2^{t_j} adds tjt_j bits to every entry in that column, in every row alike, so it changes which column is expensive and not which row is. The prediction is that a reused row order is then a random order — at the 50th percentile, give or take the sampling seen above — while the cost of every order rises by the same few bits, so that the natural order’s ratio to the least is the independent family’s.

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.

Arithmetic costBit lengthCombinatorial searchElimination orderExact arithmeticFraction-free eliminationHeuristicRow scaling