# draft2-checks.py -- the recomputations behind the numbers Draft 2 of the anchored note changes or adds (paper anchored-note, # job #1423). Inputs are the exact S(x), E(x), Var(x) of the research note's tables (paper/anchored-note.md sections 2 and 3); # everything else is computed here from primes and the primorials. No producer is replayed. Standard library only. import math, bisect g = 0.5772156649015329 def primes(n): s = [True] * (n + 1); s[0] = s[1] = False for i in range(2, int(n ** .5) + 1): if s[i]: for j in range(i * i, n + 1, i): s[j] = False return [i for i in range(n + 1) if s[i]] P = primes(20_000_000) def primorial(x): return math.prod(p for p in P if p <= x) def y_of(W): return P[bisect.bisect_right(P, math.isqrt(W)) - 1] # 1. Chebyshev shortfall against the rotation-ensemble threshold 1/W at the nine levels with computed variance tab = {7: (6.92, 1.05), 11: (39.27, 10.06), 13: (304.28, 91.13), 17: (3245.51, 1060.54), 19: (41441.19, 14392.59), 23: (669028.80, 243740.37), 29: (14063617.40, 5307862.63), 31: (328601798.62, 127363168.00), 37: (9377228928.8, 3711451136)} print('1. eps = Var/E^2 and the shortfall factor eps*W (deciding the anchor needs eps*W < 1)') for x, (E, V) in tab.items(): W = primorial(x); eps = V / E ** 2 print(f' x={x:2d} eps={eps:.3e} eps*W={eps * W:8.2f} ln^2 W={math.log(W) ** 2:8.2f} (eps*W)/ln^2 W={eps * W / math.log(W) ** 2:.4f}') # 2. theta(y) > y/2, the scour product against W, and sqrt(W)/4 against 2 ln W print('2. cardinality of the rotation ensemble: prod of scour primes >= W iff theta(y) - ln W >= ln W') for x in [7, 11, 13, 17, 19, 23, 29, 31, 37, 41]: W = primorial(x); y = y_of(W); th = sum(math.log(p) for p in P if p <= y) print(f' x={x:2d} y={y:9d} theta(y)={th:.3f} > y/2={y / 2:.1f}: {th > y / 2}; log prod scour={th - math.log(W):.3f} vs ln W={math.log(W):.3f}: prod>=W {th - math.log(W) >= math.log(W)}; sqrt(W)/4={math.sqrt(W) / 4:.2f} vs 2 ln W={2 * math.log(W):.2f}: {math.sqrt(W) / 4 > 2 * math.log(W)}') # 3. the effective constant of Lemma 1 (report #67 item 3.1) against the exact means cp = (8 / 3) * math.exp(-2 * g) * (1 - 1 / math.log(13) ** 2) ** 2 Es = {7: 6.92, 11: 39.27, 13: 304.28, 17: 3245.51, 19: 41441.19, 23: 669028.80, 29: 14063617.40, 31: 328601798.62, 37: 9377228928.8, 41: 303627067641.7} C2 = 0.6601618158 print(f"3. c' = (8/3) e^(-2 gamma) (1 - 1/ln^2 13)^2 = {cp:.6f}; asymptotic ratio (16/3) C2 e^(-2 gamma) / c' = {(16 / 3) * C2 * math.exp(-2 * g) / cp:.4f}") for x, E in Es.items(): W = primorial(x); b = cp * W / math.log(W) ** 2; print(f" x={x:2d} E={E:.6g} c'W/ln^2W={b:.6g} E/bound={E / b:.3f}") # 4. the mirror counterexample of report #67 item 1.1 at x = 11, q = 13 W = 2310; q = 13 pair = lambda t: sorted({t % q, (t - 2) % q}) print(f'4. x=11 q=13: strike pair at t=0 {pair(0)}, at the mirror phase W {pair(W)} -> fixed {pair(0) == pair(W)}; at t=W/2=1155 {pair(1155)} vs mirror {pair(W - 1155)} -> fixed {pair(1155) == pair(W - 1155)}') comb = [r for r in range(W) if r % 30 in (11, 17) and all(r % p not in (0, p - 2) for p in (7, 11))] def S_at(t): ys = [p for p in P if 11 < p <= 47] return sum(1 for r in comb if all((r - t) % p not in (0, p - 2) for p in ys)) print(f' |comb|={len(comb)}; 167 in comb: {167 in comb}, 2141 in comb: {2141 in comb}; 13 strikes 167 at t=0: {167 % 13 in (0, 11)}, strikes 2141 at t=0: {2141 % 13 in (0, 11)}; S(0)={S_at(0)} S(W)={S_at(W)} S(3)={S_at(3)} S(W+3)={S_at(W + 3)}') # 5. the residual ladder against the classical series, with the exact constant c = math.exp(2 * g) / 4 S = {7: 8, 11: 45, 13: 307, 17: 3099, 19: 38380, 23: 597475, 29: 12307838, 31: 283449187, 37: 7998394865, 41: 256725962834} Eex = {7: 6.9230769, 11: 39.27359, 13: 304.2822, 17: 3245.51, 19: 41441.19, 23: 669028.80, 29: 14063617.40, 31: 328601798.62, 37: 9377228928.8, 41: 303627067641.7} print(f'5. e^(2 gamma)/4 = {c:.12f}') res = {} for x in S: W = primorial(x); L = math.log(W); b = S[x] / Eex[x]; res[x] = b - c * (1 + 2 / L + 6 / L ** 2) print(f' x={x:2d} beta={b:.6f} residual={res[x]:+.6f}') print(f' gap (c - beta(41)) / residual(41) = {(S[41] / Eex[41] - c) / res[41]:.4f}') # 6. OLS intercepts of beta on 1/ln W import statistics def ols(xs, ys): mx, my = statistics.mean(xs), statistics.mean(ys); sl = sum((a - mx) * (b - my) for a, b in zip(xs, ys)) / sum((a - mx) ** 2 for a in xs); ic = my - sl * mx rms = math.sqrt(statistics.mean([(b - (ic + sl * a)) ** 2 for a, b in zip(xs, ys)])); return ic, rms xs = [1 / math.log(primorial(x)) for x in S]; ys = [S[x] / Eex[x] for x in S] ic4, r4 = ols(xs[-4:], ys[-4:]); ic10, r10 = ols(xs, ys) print(f'6. OLS beta on 1/ln W: last four intercept={ic4:.4f} rms={r4:.4f}; all ten intercept={ic10:.4f} rms={r10:.4f}')