Exact arithmetic, and what it costs instead

A bound on every intermediate at once

Fraction-free elimination's intermediates are minors of the original, which is a theorem about exactness. It is also a bound: Hadamard's inequality applies to every minor, so one inequality bounds the whole run before it starts. The bound on the k-th step is the one on (k+1)×(k+1) minors, not the one on the whole matrix — and on a 10×10 with entries in ±6 the difference is ten bits, with the run reaching 2.7 bits a step against the bound's 3.4.

Worth reading first: Every intermediate is a minor · An answer with no error in it.

Every intermediate is a minor established the theorem the whole fraction-free construction rests on. At step k of Bareiss’s elimination each entry of the trailing submatrix is a (k+1)×(k+1) minor of the original matrix — not approximately, and not for these entries — and the division by the previous pivot is exact because Sylvester’s identity says the numerator has that pivot as a factor.

The essay used the theorem for what it is usually used for, which is exactness: the division leaves no remainder, so the elimination stays in the integers and the fractions that would otherwise appear never do. That is the whole reason the method exists.

It buys a second thing that the exactness argument does not mention. A minor is a determinant, determinants have a bound, and the bound applies to every intermediate the elimination will ever produce — before a single division is done.

How far a fraction-free elimination's intermediates grow, against the bound on the minors they areBit lengths against the elimination step, over 12 random 10×10 integer matrices with entries between −6 and 6. The lower curve is the longest intermediate after each step; the upper one is Hadamard's bound on a minor of that size, taken over the largest rows of the original. Every intermediate is a minor of the original, so the upper curve bounds the lower at every step and does. The last step's entry is the determinant, at 27 bits against Hadamard's 36 for the whole matrix — a median slack of 10 bits.10×10, ±6determinant, bits27Hadamard's bound36median slack10024680510152025303540elimination stepbitsHadamard, on the minorsthe intermediatesevery intermediate is a minor of the originalso a bound on the minors bounds the run
Fig. 1 The longest intermediate after each step, against the bound that applies to minors of that size. The upper curve is known before the elimination starts.

The bound that applies is not the bound that is quoted

The answer is longer than the question is where this field’s central quantity — the length of an exact answer — is measured, and the bound below is where it comes from. Hadamard’s inequality says detAiai|\det A| \le \prod_i \|a_i\| over the rows. The standard statement about fraction-free elimination quotes it for the whole matrix and concludes that the intermediates cannot exceed the determinant’s length.

That is true and it is loose everywhere except the last step. At step k the entries are (k+1)×(k+1) minors, and the largest such minor is bounded by the product of the k+1 largest row norms — a shorter product, and a much smaller number. On a 10×10 with entries between −6 and 6 the two bounds read

step 1 2 3 4 5 6 7 8 9 10
per step 5 9 12 16 19 23 26 30 33 36
whole 36 36 36 36 36 36 36 36 36 36

and the elimination actually reaches 3, 6, 8, 11, 14, 17, 20, 22, 24 and 27 bits.

So the quoted bound is out by a factor of twelve at the first step and by ten bits at the last. The per-step bound is out by two to nine bits and is out in the same direction at every step, which is what a bound that is being approached rather than attained looks like.

It is worth separating three statements that the phrase “the intermediates are bounded” runs together.

The first is that they are bounded at all, which is the theorem: a minor of an integer matrix is an integer and Hadamard bounds it. Without the fraction-free step there is no such statement — the rational elimination’s entries are quotients of products of previous entries and nothing bounds them except by tracking the arithmetic.

The second is that the bound is computable before the run, which follows because it depends on the original matrix’s rows and nothing else. That is what makes it useful to an implementation rather than to a proof.

The third is that the bound applies per step rather than once, which is the part the standard statement drops. It drops it for a good reason — the theorem people want is about the worst case, and the worst case is the last step — and the consequence is a bound that is out by an order of magnitude for most of the run.

Both bounds are checked, at every step

What is checked behind the figure is not that the growth looks bounded. It checks, for twelve random 10×10 matrices and for every one of the ten steps, that the longest intermediate is inside the bound on minors of that step’s size — one hundred and twenty comparisons — and separately that the determinant is inside Hadamard’s bound on the whole matrix.

It also checks that the second bound is never attained. The median slack between Hadamard’s bound on the whole matrix and the determinant’s actual length is ten bits, and the smallest over the twelve draws is positive. A bound attained by a random matrix would be a bound about the wrong thing: Hadamard’s is attained exactly when the rows are orthogonal, and random integer rows in ten dimensions are nearly orthogonal but not exactly, so the gap is small and never zero.

How far a fraction-free elimination's intermediates grow, against the bound on the minors they areBit lengths against the elimination step, over 12 random 6×6 integer matrices with entries between −6 and 6. The lower curve is the longest intermediate after each step; the upper one is Hadamard's bound on a minor of that size, taken over the largest rows of the original. Every intermediate is a minor of the original, so the upper curve bounds the lower at every step and does. The last step's entry is the determinant, at 14 bits against Hadamard's 20 for the whole matrix — a median slack of 5 bits.6×6, ±6determinant, bits14Hadamard's bound20median slack502405101520elimination stepbitsHadamard, on the minorsthe intermediatesevery intermediate is a minor of the originalso a bound on the minors bounds the run
Fig. 2 The same measurement at 6×6, where there are fewer steps and the same two slopes. Both curves are sums of row logarithms, so both are straight in the step count.

Why both curves are straight

The shape is the easiest part of the picture to over-read, so it is worth saying where it comes from.

Hadamard’s bound on a (k+1)×(k+1) minor is a sum of k+1 row log-norms, so the bound is exactly linear in k with a slope equal to the typical row’s log-norm — 3.4 bits a step for rows of ten entries in ±6, which is ½·log₂(10·36) ≈ 4.2 minus the effect of taking the largest rows first.

The growth is also nearly linear, at 2.7 bits a step, and its linearity has a different cause. A (k+1)×(k+1) minor of a random matrix is a sum of (k+1)! signed products, and its typical size is governed by a central-limit cancellation rather than by the worst case — so it grows like the geometric mean of the rows rather than like the product of their norms, which is the same linear form with a smaller constant.

Two straight lines with different slopes: the bound rising 26 per cent faster than the thing it bounds, which is why the gap opens from two bits to nine over ten steps rather than staying fixed.

An answer with no error in it is where this field’s economics are set out — an exact answer costs what it costs because the answer is longer than the question — and the per-step curve is that statement made continuous. The answer’s length is the last point of the curve; every earlier point is how much of it the elimination has accumulated by then.

What a bound before the run is for

Knowing the length of the longest intermediate before doing the elimination is not a curiosity. It is what lets an exact code allocate.

A fraction-free elimination over the integers has entries whose length changes at every step, and an implementation either allocates for the worst case or grows its numbers dynamically. Growing dynamically costs an allocation and a copy at every promotion; allocating for the worst case costs memory proportional to the bound. The per-step bound makes a third option available — allocate per step, at the length that step’s minors can reach — which is a factor of the number of steps smaller than the worst case in total.

Whether that is worth doing is a question about an implementation this field does not have. What the measurement supplies is the number the decision would need: the per-step bound is tight to within two to nine bits, so an allocation made from it is never wrong and is never wasteful by more than a word.

Three exact eliminations of the same random matrix, and the widest number each one formsEvery route here returns the same determinant exactly, so there is no error to plot and the y-axis is the length of the intermediates in bits. At n = 11 the answer itself is 33 bits and Hadamard's bound allows 47. Fraction-free elimination never forms a number wider than 35 bits, because each of its intermediates is a minor of the original matrix. Rational elimination that reduces every fraction to lowest terms reaches 35 bits and pays a gcd on every arithmetic operation to stay there. Rational elimination that does not reduce reaches 341287 bits — 9750 times the width of the fraction-free route and 10300 times the width of the answer. All three are correct.34567891011110¹10²10³10⁴10⁵nwidest intermediate, in bitsrationals, not reducedfraction-free · rationals reduced · the answerone answer, three widthsn11answer33Hadamard bound47fraction-free35reduced rationals35unreduced3.4·10⁵the error is zero on every curvethe cost is the length of the numbers
Fig. 3 The field’s opening measurement, for scale: the three routes’ intermediate lengths on the same problem. Bareiss is the middle curve and this essay is about why it is where it is.

And what the bound does not say

The bound is about the intermediates and the intermediates are not the cost.

The answer is longer than the question is the standing measurement of what the growth costs, and the cost of an integer multiplication is not linear in the length of its arguments — so a run whose entries reach twenty-seven bits does not cost twenty-seven times a run whose entries reach one. The bound says how many bits, and a cost model says what a bit is worth, and the two are separate.

Nor does the bound distinguish the elimination from the alternatives. The determinant’s length is a property of the matrix: every exact method that computes it must produce an integer of that length, so 27 bits is a floor on the output of Bareiss, of the rational elimination, and of the modular route. What distinguishes the three is what they produce on the way there, and that is what the per-step curve is a statement about.

Every boxed entry is a 2 × 2 minor of the matrix beside itA 5 × 5 random matrix and its state after 1 step of fraction-free elimination. Each of the 16 boxed entries was formed as (pivot × entry − column × row) divided by the previous pivot, and every one of those 16 divisions came out exact. The reason is that the entry at (i, j) is exactly the 2 × 2 minor of the ORIGINAL matrix on rows 0…0 and i, columns 0…0 and j — checked here against a cofactor expansion of A rather than against a second elimination. The widest number anywhere in the picture is 6 bits.1-2-6-7-474-26-12-5-8-524-394151435A, the matrix as given1-2-6-7-40184055270-1491005333217011343825after 1 fraction-free step2 × 2 minors16 divisions, all exactthe intermediates are minorswhich is why the divisions come out whole
Fig. 4 The theorem the bound rests on, drawn: every boxed entry after one elimination step is a 2×2 minor of the matrix beside it, checked by cofactor expansion.

The bound that is a floor

One thing the last point of the curve is, and the earlier points are not, is a floor as well as a ceiling.

The determinant of an integer matrix is an integer and its length is whatever it is. Any exact method that produces it must produce that many bits — Bareiss, the rational elimination, the modular route with enough primes — so 27 bits is not a cost the fraction-free algorithm incurs, it is a cost the problem has. An exact answer to a measured problem is the essay about when that cost is worth paying at all, and three orders and one last entry is the measurement that no pivot rule reduces it.

What the curve says is that Bareiss pays it gradually: 3 bits after one step, 14 after five, 27 at the end. A method whose intermediates jumped to 27 bits immediately would do the same total arithmetic on longer numbers, and a method whose intermediates exceeded 27 would be carrying length the answer does not need. The rational elimination is the second kind, which is what the field’s opening figure shows and why the middle curve is the interesting one.

So the per-step bound is not only an allocation aid. It is the statement that the fraction-free elimination’s intermediates are as short as any method’s could be at each stage, up to the gap between a minor’s typical size and its Hadamard bound — because they are minors, and a minor of that size is what any method must have in hand to produce the determinant.

What must fail for any of this to be wrong

Three claims. That every step’s longest intermediate is inside the bound on minors of that step’s size, checked at every step of every draw. That the determinant is inside Hadamard’s bound on the whole matrix. And that the bound is never attained, with a median slack of ten bits, which is what makes it a bound about a worst case rather than a description.

The bound is computed by two routes that agree by construction: one sums the row log-norms of the whole matrix, and the per-step bound sums the largest k+1k+1 of them. The second reduces to the first at k = n−1, which is the check that they are the same inequality applied to different sets.

Reading the two slopes as a prediction

The gap between the two curves opens linearly, at 0.7 bits a step on the 10×10, and that is a number worth turning into a prediction because it is the one thing in the measurement that would fail loudly if the mechanism proposed above were wrong.

If the bound rises at the typical row’s log-norm and the growth rises at something smaller because of cancellation inside the minor, then both slopes should scale together with the entry range and neither should depend much on the size. Doubling the range of the entries adds one bit to every row’s log-norm, so both slopes should rise by about one, and the ratio 2.7 : 3.4 should stay where it is.

Changing the size should change neither slope, only the number of steps — which is what the 6×6 figure shows: the same two straight lines, cut short.

Neither prediction is swept here and both are one parameter away. What the figure does show is the second of them at two sizes, which is the cheaper half, and it holds.

The prediction that would be most informative is the negative one. A matrix family whose rows are nearly parallel has a Hadamard bound far above its determinant — the inequality is attained only for orthogonal rows — so the gap between the two curves should be much wider and the per-step bound correspondingly less useful. The scaled Hilbert family this library builds is exactly that, and running the same comparison on it is the measurement that would say whether “tight to within two to nine bits” is a property of the bound or of random matrices.

Three pivot rules for an exact elimination, and one determinantThe longest intermediate after each step, as a median over 20 random 10×10 integer matrices, for three pivot rules: swap only when the pivot is zero, take the largest available, take the smallest nonzero. The three make 0, 7 and 7 row exchanges and reach the same peak of 29 bits, because the last entry of the elimination is the determinant and the determinant does not depend on the order. The area under the three profiles is 162, 167 and 156 bit-steps.20 matricespeak, every rule29the determinant's own length29area, smallest ÷ natural0.9602468051015202530elimination stepbits, longest entrythe determinant: 29 bitsswap only on a zerolargest pivotsmallest nonzero pivotthree orders, three sequences of minorsand one last entry they all arrive at
Fig. 5 Three pivot orders on the same matrices, all under the same bound. The bound is a statement about minors and every order produces minors, so none of the three can escape it.

A note on measuring bits

matBits returns the longest entry of a matrix in bits, and “bits” here means the number of binary digits the integer’s magnitude needs, which for a BigInt is what its string length in base two reports. It is not a memory figure: an implementation stores in words, so an entry of 27 bits and one of 32 occupy the same space and one of 65 occupies three words rather than two.

That matters for the allocation argument above and it does not matter for the bound. The bound is about the integers and the words are about a machine, and the conversion is a ceiling division by the word size — which is why the per-step curve’s usefulness to an allocator depends on the step at which it crosses a word boundary rather than on its value.

On the 10×10 measured, the curve crosses 32 bits nowhere: every intermediate fits in one 32-bit word and the whole question is moot. At 20×20 with the same entry range the determinant would be about 60 bits and the crossing would happen around step 11, which is where a per-step allocator would first differ from a worst-case one. Neither size is measured here and the arithmetic is the linear slope above.

What this does not settle

Random integer matrices with entries in a fixed range, at four sizes. A matrix whose rows have very different norms would separate the per-step bound from a naive one more sharply, and a matrix whose rows are nearly parallel would make both loose.

The bound is on bit lengths and the measurement is of matBits, the longest entry of the whole trailing submatrix at each step. The typical entry is shorter, and an implementation allocating per entry rather than per step would want the distribution rather than the maximum.

No structured families: the Hilbert-like, Pascal and unitriangular families this field builds elsewhere have minors with very different behaviour, and the unitriangular one has no growth at all by construction.

And nothing here is about the rational route’s growth, which is the comparison the field opens on and is governed by a different mechanism — products of previous numerators and denominators rather than minors of the original.

How far a fraction-free elimination's intermediates grow, against the bound on the minors they areBit lengths against the elimination step, over 12 random 12×12 integer matrices with entries between −6 and 6. The lower curve is the longest intermediate after each step; the upper one is Hadamard's bound on a minor of that size, taken over the largest rows of the original. Every intermediate is a minor of the original, so the upper curve bounds the lower at every step and does. The last step's entry is the determinant, at 33 bits against Hadamard's 45 for the whole matrix — a median slack of 9 bits.12×12, ±6determinant, bits33Hadamard's bound45median slack9024681005101520253035404550elimination stepbitsHadamard, on the minorsthe intermediatesevery intermediate is a minor of the originalso a bound on the minors bounds the run
Fig. 6 The same two curves at 12×12, where there are twelve steps and the same two slopes. Both are sums of row logarithms and neither’s gradient depends on the size.

What the exactness argument and the length argument share

The two things the minor theorem buys are worth setting side by side, because they are the same fact read twice and only one of the two is ever put to work.

Exactness: the numerator at step k is a (k+1)×(k+1) minor and has the previous pivot — a k×k minor — as a factor, so the division leaves no remainder. That is Sylvester’s identity, it is what the first of these essays checks against cofactor expansion, and it is a statement about divisibility.

Length: the same entry is a (k+1)×(k+1) minor, so Hadamard bounds it. That is a statement about magnitude and it uses nothing about divisibility.

Both follow from one identification of the intermediate with a minor, and neither implies the other — an algorithm could produce minors without exact division, and an algorithm with exact division could produce quantities that are not minors. What Bareiss does is arrange for the intermediates to be minors, and then both statements arrive at once.

That is the shape of argument this field keeps meeting. A construction is justified by one property and turns out to carry a second, and the second is invisible because the first is what the construction was for. One number that has to be right is the same shape in the orthogonality field: one fact about a unit vector, two consequences, and only one of them in the derivation.

Still open: the distribution, the structured families, and what the bound is worth to an implementation

The distribution rather than the maximum. Every number above is the longest entry at each step. An allocator would want the median and the tail, and the gap between them says whether per-step allocation is nearly free or mostly wasted.

The families with structure. A Hilbert-like matrix’s minors are tiny and its rational elimination’s are enormous, which is the opposite extreme from a random integer matrix. Running the same per-step comparison on the three families this library builds would say whether the 26 per cent slope gap is a property of random matrices or of the bound.

What the bound is worth in seconds. The per-step bound would let a code allocate exactly, and whether that beats growing dynamically depends on an allocator this field does not have. It is the one open question here that cannot be answered by a measurement of integers.

And whether the pivot order moves any of it. The elimination above swaps rows only when the pivot is zero. A different order produces a different sequence of minors, and whether the per-step bound is reached more or less closely under one is the next essay.

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.

Bit lengthDeterminantExact arithmeticExact ground truthFlop countFraction-free eliminationGaussian eliminationHadamard boundMinorSylvesters identity