A rounding chosen once is still repeated
Worth reading first: Orthogonal is a number · The direction the error leans.
A repeated rotation drifts in a straight line multiplied rotations of order three together in binary32 and measured . With a fresh factor at every step the loss walked like the square root of the number of products, slope 0.52 over a million. With one factor repeated, as a fixed-step integrator or an animation loop repeats one incremental rotation, the slope was 1.00 and the loss at a million products was 622,127 units of binary32’s roundoff against 2,404. The reason was one defect met in the same direction every time: the rounded factor is not quite orthogonal, and the product’s departure is that departure times the number of products.
If the drift is the factor’s defect, the factor can be chosen. Each entry of the exact rotation lies between two neighbouring binary32 numbers, so there are matrices with every entry rounded down or up, and one of them has the smallest defect. The essay signed a prediction about that choice: a small search over those neighbours, made once at setup, would reduce the linear rate by a factor of at least ten, from 0.62 units a product to under 0.06, and it would do nothing about the angle’s error, which comes from the factor being a slightly wrong rotation rather than a slightly stretched one.
Both halves fail, and the reason they fail points at the repair that does work.
Five rotations and six ways to round them
The rotations are the earlier essay’s: three small turns about the three axes, each angle drawn below a tenth of a radian, on five seeds. Each is formed exactly in binary64 and then rounded to binary32 in one of six ways. The nearest rounding is what any code does. The best neighbour is the least-defect matrix among the 512 down-or-up roundings. Three greedy searches move one entry at a time by one ulp, accept any move that lowers the defect, and stop when none does, never moving an entry further than 2, 4 or 8 ulps from the exact value. The sixth does not fix a factor at all: at each product, every entry is rounded up or down at random, up with probability equal to the exact value’s distance above the lower neighbour as a share of the gap, so that the rounded factor’s expected value is the exact rotation.
Each factor is multiplied into the running product a million times, in binary32 throughout, and two numbers are read at each decade: the loss of orthogonality, and the distance from the same power of the exact binary64 rotation, which is the angle’s error plus the stretch.
On the first rotation the nearest factor loses 639 units at a thousand products and 622,126 at a million, the earlier essay’s line. The best neighbour lies just under it, 593 and 590,696. The greedy search within eight ulps lies under that, at 275,113 at a million. All three are straight lines of slope one. The factor rounded at random lies two and a half decades below the rest, at 1,717 units at a million, and it is not a straight line at all. The dial shows the same order on all five rotations, with the gap between the three fixed choices varying from nothing to a factor of two.
The grid has no better matrix nearby
The first half of the prediction assumed that among a factor’s neighbours there is one much closer to orthogonal. There is not, and the factors’ own defects show why.
The nearest roundings have defects of 0.39 to 1.02 units on the five rotations. The best of the 512 neighbours improves on that by 0.1 to 2.9 per cent: 0.866 against 0.892 on the first, 0.390 against 0.391 on the fifth. The greedy searches find more on two rotations, reaching 0.56 and 0.43 within eight ulps, and on the other three they find nothing at all, because no single one-ulp move lowers the defect and the search stops where it started.
An inner product with no fixed sign showed how the computed inner product of two nearly orthogonal vectors is a rounding error with no preferred sign, and the entries of are exactly such inner products. The reason no neighbour does much better is in the arithmetic of the defect. is a symmetric matrix with six independent entries, each a sum of products of entries of , and each is shifted by about one unit of roundoff when any entry of moves by one ulp. A matrix within one ulp of the rotation in every entry has a defect of the order of one unit, and every one of the 512 does; to find one with a defect a tenth of that, the six numbers have to cancel to a tenth of their typical size at once, which happens by chance in about one candidate in , not one in 512. A wider box has more candidates, but they are further from the rotation. And an exactly orthogonal binary32 matrix close to a small rotation does not exist: the cosine and sine would have to be dyadic fractions whose squares sum to exactly one, which only zero and one manage.
So the rate barely moves. At a million products the best neighbour’s loss is within 1 to 5 per cent of the nearest rounding’s on every rotation. The loss is the defect times the number of products, to within a factor of 0.5 to 1.2 on both choices and all five rotations, which is the earlier essay’s law with the constant read off. A factor of ten in the rate would need a factor of ten in the defect, and the neighbourhood does not contain one.
A wider search trades the angle for the stretch
Where the greedy search does find a smaller defect, the second half of the prediction is tested, and it fails more instructively than the first.
On the first rotation, widening the search from nothing to 2, 4 and 8 ulps lowers the loss at a million from 622,126 to 543,663, 387,818 and 275,113 units. Over the same widths the distance from the exact rotation’s product rises from 309,435 to 611,955, 1,075,106 and 1,748,475. The second rotation behaves the same way: loss down from 780,361 to 415,212, distance up from 388,836 to 1,983,986. The three rotations on which the search found nothing keep both numbers where they were.
The prediction said the angle’s error “stays where it was” because orthogonalising a factor cannot change the rotation it represents. That is true of a repair applied to the product, which the nearest orthogonal matrix defines as the closest rotation to whatever has accumulated. It is not true of a search over the factor. To lower the defect, the search moves entries away from the exact rotation’s values by several ulps, and a matrix that is more nearly orthogonal and further from the rotation is a more accurate rotation by a different angle. Every ulp of movement is mostly turn rather than stretch, and the turn is repeated a million times exactly as the stretch was. The search exchanges a stretch, which a later repair could remove, for an angle error, which nothing downstream can.
The repetition is the defect
Both failures come from treating the defect as a property of a factor to be minimised, when the earlier essay’s own finding was that the problem is the repetition. A random set of fresh factors has defects of the same size, about one unit each, and walked only 2,404 units in a million products, because their defects point in different directions and partly cancel. The repeated factor’s single defect, however small it is made, adds in one direction for ever.
That suggests not choosing a rounding at all, but drawing a new one every time from the two neighbours of each entry, with the probabilities set so the drawn factor equals the exact rotation on average. This is stochastic rounding applied to a constant. A coin flip that fixes the average measured the same idea on a sum, where rounding to nearest drifts in one direction and stochastic rounding does not, and every equal tail has a cliff found a norm wrong by thousands of units for the same reason as here: one rounding, met every time, added in the same direction.
The randomly rounded factor walks. Its median loss over the five rotations is 15 units at a hundred products, 61 at a thousand, 210 at ten thousand, 858 at a hundred thousand and 2,538 at a million, and the fitted slopes on the five rotations are 0.46 to 0.61, the slope of fresh factors. Its distance from the exact product walks too: a median of 1,381 units at a million, where the nearest factor’s is 309,435 to 388,836. One random choice of neighbour per entry per product has done for the angle what no fixed choice could, because the angle’s error was also a rounding repeated: the nearest factor’s entries are each off in a fixed direction, and so is the rotation they represent.
Why the angle walks as well
The factor rounded at random differs from the exact rotation by a matrix that is new at every product, with each entry’s expected value zero. Its symmetric part stretches the product and its skew part turns it, and both parts now have zero mean and are independent from one product to the next. A sum of a million independent terms of a unit each has a typical size of about a thousand units, and that is what both measurements show: 2,538 for the loss and 1,381 for the distance at the median, in the same ratio of nearly two that the earlier essay found between them, since a stretch of size shows as in .
The nearest factor’s is the same matrix every time, so the same million terms add to a million times one of them. The fixed choices differ only in which they repeat, and every within a few ulps of the rotation has entries of about a unit, so no choice can do better than a few hundred thousand units at a million products. That is the whole of the argument, and it is the argument the direction the error leans made for rounding modes in a sum: an unbiased error grows as the square root of the count, and a biased one, however small its bias, grows as the count.
There is a cost in the other direction, and it is visible at the start. At a hundred products the random rounding’s median loss is 15 units against 58 for the nearest factor on the first rotation, already better, but the first few products of a random walk have no cancellation yet to benefit from, and a short computation, a few dozen products long, gains little. The advantage grows as the square root of the number of products: a factor of about thirty at ten thousand, of two hundred and fifty at a million.
What each approach leaves, side by side
At a million products the six routes span about two and a half decades on every rotation, and the low end of each range is always the random rounding. Its loss is 1,717 to 3,377 units where the fixed choices’ are 270,461 to 780,361, and its distance from the exact product is 906 to 1,769 units where theirs are 145,379 to 1,983,986. The fixed choices differ among themselves by at most a factor of three in the loss, and in the distance the cleverest of them is the worst.
The earlier essay’s repairs belong in this comparison. One polar step on a schedule, an iteration that only multiplies, removed the stretch at any period and left an angle error of about 1,600 units at a hundred thousand products, growing linearly to about sixteen thousand at a million, because no orthogonalisation can touch an angle. The random rounding leaves about a tenth of that angle error with no repair at all, and its loss of 2,538 units is in absolute terms, small enough that a single polar step at the end, or one every hundred thousand products, would remove it. The two are complementary: the random rounding removes the bias that a repair cannot, and a rare repair removes the walk that the rounding leaves.
What it costs, and where it does not apply
Rounding a factor at random costs nine random numbers and nine comparisons a product, against the 27 multiplications and 18 additions of the product itself, and it needs the factor in a higher precision than the one the product is computed in, so that there is something to round from. A code that holds its incremental rotation in binary64 and multiplies in binary32, which is the usual reason for the arithmetic to be binary32 at all, has both. A code whose rotation is computed afresh each step from an angle, rather than held fixed, already has fresh roundings, and the earlier essay’s slope of 0.52 is its law. And a code that can carry its rotation as a product of reflectors avoids the question, since a reflection cannot stop being one in the sense that matters here: it is orthogonal by construction, whatever its rounding.
The measurements are of order three, in binary32, over a million products, on five rotations of small angle. Order eight and binary64 were not repeated here; the earlier essay found the same laws in both, scaled by each format’s roundoff, and there is no mechanism in the argument that depends on the order. The random rounding uses one stream of pseudorandom numbers per run, and a poor pseudorandom source, or one whose period is short against a million products, would reintroduce a repetition. The greedy search is a local one, and a global search over a wider box might find a factor with a much smaller defect; the argument above says it would have to move further from the rotation to do it, and the angle would pay.
What is settled is the shape. A factor’s defect cannot be chosen much below a unit of roundoff from among its neighbours; lowering it further moves the factor off the rotation and buys a smaller stretch with a larger angle error; and refusing to repeat a rounding, by drawing it afresh at random, turns both the stretch and the angle into walks two decades shorter than any fixed choice. Orthogonal is a number supplied the instrument that measured all of it.
Still open: the quaternion, and a deterministic way to stop repeating
A representation with no stretch to lose. The earlier essay’s second question stands: a quaternion carries a rotation in four numbers, and its repeated product scales its norm rather than losing orthogonality. The prediction with a sign is that a unit quaternion multiplied into itself a million times in binary32 drifts in norm linearly at a rate within a factor of three of the matrix’s defect rate, and that rounding its four components at random each product turns that into a walk of slope near a half, exactly as here, so that the representation changes the constant and not the law.
Two roundings, alternated. Randomness is not the only way to stop a rounding repeating. Among the 512 neighbours there are pairs whose defects point in nearly opposite directions. The prediction is that alternating the best such pair, so that every two products have a combined defect below a tenth of a unit, gives a straight line again but with a slope one at a rate ten times lower, and an angle error no better than the nearest factor’s, because the two halves of the pair are both off the rotation by a fixed amount; so that a deterministic cancellation fixes the stretch and not the angle, and only a rounding that is unbiased on average fixes both.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- A mirror decided in the thin directions — both name orthogonality, polar decomposition
- A rotation that comes back mirrored — both name orthogonality, polar decomposition
- A stable block is not a stable basis — both name loss of orthogonality, orthogonality
- A test with no answer in it — both name orthogonality, polar decomposition
- A triangle where the scalar was — both name orthogonality, unit roundoff
- A walk needs a length — both name random walk, unit roundoff
Named objects
A flat tag is an object no other essay names yet.
Binary32Loss of orthogonalityOrthogonalityPolar decompositionRandom walkRounding modesUnit roundoff