Definition · The swept familyFor an integer k, the needle at 2ᵏ is the triple a = (0, 0), b = (2ᵏ + 1, 2ᵏ), c = (2ᵏ, 2ᵏ − 1). Its exact orientation determinant is −1 for every k, so every member of the family is the same right turn. The lab sweeps k from 20 to 48 and reports, for each one, the exact determinant, the double determinant, and whether the two signs agree.
The arithmetic is worth doing once by hand. With a at the origin the determinant is bx·cy − by·cx, which is (2ᵏ + 1)(2ᵏ − 1) − 2ᵏ·2ᵏ. The first product is a difference of squares, 2²ᵏ − 1, and the second is 2²ᵏ. Subtract and everything cancels but the −1.
Theorem · The threshold, and the countIn IEEE double precision the needle at 2ᵏ is evaluated correctly for k ≤ 26 and reports 0 for k ≥ 27. Over the 29 magnitudes from 20 to 48 the double predicate is therefore wrong on 22 of them, every one from 2²⁷ upward, and right on the seven below.
A double holds a significand of 53 bits, so every integer up to 2⁵³ is representable, and in the interval from 2ᵉ⁻¹ to 2ᵉ the representable numbers are spaced 2^(e − 53) apart.
The two products are 2²ᵏ − 1 and 2²ᵏ. For 2k ≤ 53 both are at most 2⁵³ and so are represented exactly, their difference is computed exactly, and the answer is −1. That is k ≤ 26.
For 2k ≥ 54, the representable numbers just below 2²ᵏ are spaced 2^(2k − 53) ≥ 2 apart, so 2²ᵏ − 1 is not one of them: its neighbours are 2²ᵏ − 2^(2k − 53) and 2²ᵏ, and it is at least as close to the second as to the first. Where 2k = 54 the two are equidistant and round-to-nearest breaks the tie towards the even significand, which is 2²ᵏ; where 2k > 54 the second is strictly nearer. Either way both products become the same double, their difference is exactly 0, and the subtraction introduces no further error. That is k ≥ 27. The sweep from 20 to 48 is 29 values, of which 27 through 48 is 22.
□
Nothing in that argument is an estimate and nothing in it is a rule of thumb. The lab does not quote the threshold either — it evaluates both routes at all 29 magnitudes and counts, and the count it reports is 22 with the first failure at 2²⁷. Move the slider to highlight a row and the corresponding triple appears in the upper table with all three routes beside one another.
Example · The two magnitudes either side of the thresholdAt k = 26 the points are (0, 0), (67108865, 67108864), (67108864, 67108863). The products are 4503599627370495 and 4503599627370496, both under 2⁵³, both exact, and the difference is −1: the double agrees. At k = 27 the points are (0, 0), (134217729, 134217728), (134217728, 134217727). The products are 18014398509481983 and 18014398509481984, the first of which is not representable, and both become 18014398509481984. The double determinant is 0 and the predicate calls a right turn collinear. One power of two apart, and the answer changes from right to wrong.
That pair is the reason the preset list on this page has both of them in it. Switching between the two worked examples changes one bit of the input and flips the verdict of a predicate that most textbooks present without qualification, which is a more convincing argument than any amount of prose about machine epsilon.
The failure is one-sided, and that is provable
Theorem · A collapse, never a flipLet a, b, c have integer coordinates whose pairwise differences are at most 2⁵³ in absolute value. If the double-precision evaluation of orient(a, b, c) disagrees in sign with the exact one, then the double-precision sign is 0. It is never the opposite nonzero sign.
The four differences bx − ax, cy − ay, by − ay, cx − ax are integers of magnitude at most 2⁵³, so each is represented exactly and the subtractions that produce them introduce no error at all. The only rounding happens in the two products and in the final subtraction.
Write the two exact products as P and Q, so the exact determinant is P − Q. IEEE multiplication returns the representable number nearest its exact result, and round-to-nearest is monotone: if P ≤ Q then fl(P) ≤ fl(Q). Suppose the exact determinant is negative, so P < Q; then fl(P) ≤ fl(Q), so fl(P) − fl(Q) ≤ 0, and the final subtraction of two doubles cannot change the sign of a nonpositive quantity. The computed determinant is therefore ≤ 0: it can be the right sign or it can be 0, and it cannot be positive. The case P > Q is the same argument with the inequalities reversed.
□
This is a theorem and not a measurement, but the lab supplies the measurement beside it: across the swept family every one of the 22 failures is the double reporting 0, and the arithmetic checker that runs over this kit throws thirty thousand random near-collinear triples at 2²⁶ and above at both routes. On those thirty thousand the two routes disagree 1,258 times, and not once does the double report the opposite turn.
What a count on 29 magnitudes is and is not
The count is a measurement on one family. It says nothing about a triple chosen some other way, and in particular “22 of 29” is not a failure rate for double-precision geometry in general — the family was constructed to fail, which is the only honest way to find the threshold. What generalises is the theorem above it: the 53-bit argument applies to any integer input, and the one-sidedness applies to any input at all.
That distinction is the whole method of this path. A lab can run an algorithm on an input; it cannot quantify over inputs. Here the two happen to line up unusually well, because the threshold the sweep finds by measurement is the same 2k > 53 the proof gives, and a reader can check one against the other on the page.