#!/usr/bin/env python3 """Two exact computations about the corner-measurement right prime band. (A) THE FLOAT AUDIT, closed form. band2.py found Tmax float-vs-exact differing only at j = 100, 200, 300 while the prime band never differed. Reason: the script computes E1 = floor(2^(93j/100)); when 100 | j that exponent is an integer, E1 = 2^(93j/100) is an exact power of two, and the float division returns exactly x/E1 = 2^(7j/100) instead of floor((x-2)/(E1+1)) = 2^(7j/100) - 1. The spurious extra integer is therefore 2^(7j/100) -- a power of two, hence composite for j >= 100. So the error is real, is confined to 100 | j, and can never add a prime to the band. Checked here. (B) THE FEASIBILITY FRONTIER that corner-measurement.md section 6 asks for: it says a different finite probe "would need a model with populated bands". The band is (Z, ~Z*x^(2*eta0)] with Z = x^(1/20) fixed by the decomposition, so eta0 is the only knob. For each reachable j, what is the SMALLEST eta0 giving at least k primes? """ from fractions import Fraction import bisect from band import iroot, floor_two_pow, primes_upto, Z_EXP PR = primes_upto(10 ** 7) def cutoffs(j: int, eta0: Fraction, v: Fraction = Z_EXP): """Exact Z, E1, elo, Tmax for the 'eta' mode of corner-measurement.js.""" Z = floor_two_pow(j, v) E1 = floor_two_pow(j, 1 - v - 2 * eta0) elo = max(Z, E1) Tmax = ((1 << j) - 2) // (elo + 1) return Z, E1, elo, Tmax def band_count(j, eta0, v=Z_EXP): Z, _, _, T = cutoffs(j, eta0, v) if T > PR[-1]: return None return bisect.bisect_right(PR, T) - bisect.bisect_right(PR, Z) # ---------------------------------------------------------------- (A) print("=" * 72) print("(A) Float audit: where the script's Math.pow arithmetic moves Tmax") print("=" * 72) import math ETA = Fraction(1, 100) print(f"{'j':>5} | {'Tmax exact':>11} | {'Tmax float':>11} | extra integer | prime?") for j in (100, 200, 300, 400, 500): Ze, E1e, eloe, Te = cutoffs(j, ETA) x = 2.0 ** j E1f = math.floor(math.pow(2.0, j * float(1 - Z_EXP - 2 * ETA))) Tf = math.floor((x - 2) / (E1f + 1)) extra = Tf - Te isp = "n/a" if extra == 0 else ("YES" if Tf in set(PR) else "no (power of 2)") print(f"{j:>5} | {Te:>11} | {Tf:>11} | {extra:>13} | {isp}") print("\n predicted: the float value equals 2^(7j/100) whenever 100 | j") for j in (100, 200, 300, 400, 500): print(f" j={j}: 2^(7j/100) = {2 ** (7 * j // 100)}" f" exact Tmax = {cutoffs(j, ETA)[3]} (differ by 1: " f"{2 ** (7 * j // 100) - cutoffs(j, ETA)[3] == 1})") # ---------------------------------------------------------------- (B) print() print("=" * 72) print("(B) Feasibility frontier: smallest eta0 populating the band at reachable j") print("=" * 72) print("The measured run reached j = 36 (x = 2^36, 1.3e9 integers). The corner") print("decomposition wants eta0 SMALL; the run used 1/100 and 1/40.") print() CANDIDATES = [Fraction(1, d) for d in range(100, 2, -1)] print(f"{'j':>4} | {'eta0 for >=1':>13} | {'>=2':>10} | {'>=3':>10} | {'>=5':>10}") for j in (24, 28, 32, 36, 40, 50, 60, 70): row = [] for k in (1, 2, 3, 5): hit = next((e for e in CANDIDATES if (band_count(j, e) or 0) >= k), None) row.append(str(hit) if hit else "none<=1/3") print(f"{j:>4} | {row[0]:>13} | {row[1]:>10} | {row[2]:>10} | {row[3]:>10}") print() print(" At the run's own eta0 = 1/100, the band has >= 2 primes only from j =", next(j for j in range(20, 200) if (band_count(j, Fraction(1, 100)) or 0) >= 2)) print(" At eta0 = 1/40 (variant B), from j =", next(j for j in range(20, 200) if (band_count(j, Fraction(1, 40)) or 0) >= 2)) print() print(" The band ratio is Tmax/Z ~ 2^(2*eta0*j); by Bertrand's postulate a band with") print(" Tmax >= 2Z is non-empty, i.e. 2*eta0*j >= 1. For eta0 = 1/100 that is j >= 50.") for e in (Fraction(1, 100), Fraction(1, 40), Fraction(1, 20), Fraction(1, 8)): # band_count returns None when Tmax exceeds the sieve limit: that is "not computed # here", NOT "empty". Conflating the two would manufacture a false emptiness claim. cnt = {j: band_count(j, e) for j in range(2, 121)} empt = [j for j in cnt if cnt[j] == 0] unk = [j for j in cnt if cnt[j] is None] print(f" eta0={str(e):>5}: Bertrand guarantee from j >= {1 / (2 * float(e)):.0f};" f" empty j in [2,120]: {empt if empt else 'none'};" f" beyond sieve (not decided): {f'j>={min(unk)}' if unk else 'none'}")