#!/usr/bin/env python3 """verify659.py -- independent recomputation of the numbers in return #154 (job #20). Exact rational arithmetic for the exponent chain of the D obligation and the A2 block arithmetic; floats only where the object is a real density (C_2, A_2) or where the return itself reports real values (the Maynard exceptional mass at named log x). Definitions are taken from the return's own section 2 and from the served documents it cites: sigma = 1/20, a = 14/25, b = 1/2, E = x^(9/20), Q = x^sigma, A = MN/x = x^(3/50), C_2 = prod_{p>2}(1-1/(p-1)^2), A_2 = prod_{p>2}(1-1/(p(p-1))).""" from fractions import Fraction as F import math ok = [] def chk(name, got, want, note=""): good = (got == want) ok.append(good) print(" %-58s %-14s %-14s %s" % (name, got, want, "OK" if good else "MISMATCH " + note)) print("== D: the top sector ==") sig, a, b = F(1, 20), F(14, 25), F(1, 2) E = b - sig # E = N/Q = x^(b-sigma) Qe = F(3, 2) # the q-aspect Q^{3/2} chk("Q^(3/2) E^3", Qe * sig + 3 * E, F(57, 40)) A = a + b - 1 # A = MN/x chk("A = MN/x", A, F(3, 50)) chk("Lemma H tail Q^2 A^(-1/2) E^3", 2 * sig - A / 2 + 3 * E, F(142, 100)) MQ = a + sig chk("Cauchy factor MQ", MQ, F(61, 100)) chk("block (m,q) Cauchy", (MQ + F(57, 40)) / 2, F(407, 400)) chk("target moment", 2 - MQ, F(139, 100)) chk("required saving", F(57, 40) - F(139, 100), F(7, 200)) chk("large-gcd branch j > x^(7/300)", F(3, 2) * F(7, 300), F(7, 200)) chk("k>=2 sector at Weil", sig + 3 * E, F(7, 5)) chk("k>=2 sector at Weil = 140/100", F(7, 5), F(140, 100)) def block(kappa): return (MQ + (F(7, 5) + kappa / 20)) / 2 chk("block(kappa) constant term", block(F(0)), F(201, 200)) chk("block(kappa) slope", (block(F(1, 40)) - block(F(0))) / F(1, 40), F(1, 40)) chk("block(kappa) at kappa=1/2 = 407/400", block(F(1, 2)), F(407, 400)) chk("block(0), tail not improved", (MQ + F(142, 100)) / 2, F(203, 200)) chk("kappa root of block(kappa)=1", -(F(201, 200) - 1) * 40, F(-1, 5)) chk("target moment minus Q^(3/2)E^3 at kappa=0", F(139, 100) - F(7, 5), F(-1, 100)) print("== D: the reframing (Cauchy in m alone) ==") Ml = a chk("Cauchy factor M (m alone)", Ml, F(56, 100)) chk("required moment", 2 - Ml, F(144, 100)) same_q_block = (Ml + F(57, 40)) / 2 chk("same-q block", same_q_block, F(397, 400)) chk("same-q slack", 1 - same_q_block, F(3, 400)) dist_q_block = (Ml + F(3, 2)) / 2 chk("distinct-q block (moment N^3)", dist_q_block, F(103, 100)) chk("saving needed in the moment", F(3, 2) - (2 - Ml), F(6, 100)) chk("per prime-power aspect (two aspects)", (F(3, 2) - (2 - Ml)) / 2, F(3, 100)) chk("q^(3/5) with q = x^(1/20)", (F(3, 100)) / sig, F(3, 5)) chk("Q the (m,q) Cauchy pays = MQ/M", (MQ - Ml), F(5, 100)) print("== A2: the Maynard band ==") eps = F(1, 60) L2 = math.log(2) def mass(logx, ep=eps): K = float(ep) * logx / L2 return 18 * (L2 / logx) * K * (K + 1) / 2 coef = 9 / L2 print(" %-58s %.4f 12.98 %s" % ("asymptotic coefficient 9/log 2", coef, "OK" if abs(coef - 12.98) < 0.005 else "MISMATCH")) ok.append(abs(coef - 12.98) < 0.005) for lx, want in ((26.3, 0.245), (100.0, 0.51), (183.0, 0.81)): got = mass(lx) print(" mass at log x = %-6s = %.4f x return #154: %.2f x %s" % (lx, got, want, "OK" if abs(got - want) < 0.006 else "MISMATCH")) ok.append(abs(got - want) < 0.006) C2 = 0.6601618158468696 allow = C2 - 1 / 200 print(" allowance C_2 - 1/200 = %.6f" % allow) def bisect(lo, hi): for _ in range(200): mid = (lo + hi) / 2 if mass(mid) < allow: lo = mid else: hi = mid return (lo + hi) / 2 cross = bisect(10.0, 200.0) print(" crossing of the allowance: log x = %.1f -> x = 10^%.1f" % (cross, cross / math.log(10))) print(" mass at log x = 150: %.4f x = 10^%.1f (return #154: 'crosses near log x = 150, x near 10^65')" % (mass(150.0), 150 / math.log(10))) print(" mass at x = 10^65.1: %.4f x" % mass(150.0)) print("== A2: the densities and the (T2) => (T1) margin ==") # C_2 = prod_{p>2}(1 - 1/(p-1)^2), A_2 = prod_{p>2}(1 - 1/(p(p-1))) N = 2 * 10 ** 6 sieve = bytearray(N + 1) primes = [] for i in range(2, N + 1): if not sieve[i]: primes.append(i) for j in range(i * i, N + 1, i): sieve[j] = 1 c2 = 1.0 a2 = 1.0 for p in primes: if p > 2: c2 *= 1 - 1 / (p - 1) ** 2 a2 *= 1 - 1 / (p * (p - 1)) print(" C_2 (to 2e6) = %.7f A_2 = %.7f 1 - A_2 = %.7f" % (c2, a2, 1 - a2)) print(" return #154: C_2(1-A_2) = 0.166419, C_2 A_2 = 0.493743, inside (33/200 = %.3f, 21/125 = %.3f)" % (33 / 200, 21 / 125)) print(" computed: C_2(1-A_2) = %.6f C_2 A_2 = %.6f ratio to 4/25 = %.2f" % (c2 * (1 - a2), c2 * a2, c2 * a2 / (4 / 25))) print(" (T2) => (T1) at c_0 = 1/200 requires C_2 A_2 <= C_2 - 1/200 - 4/25 = %.6f ; C_2 A_2 = %.6f %s" % (allow - 4 / 25, c2 * a2, "OK (margin %.6f)" % (allow - 4 / 25 - c2 * a2))) print(" trivial bound on M/x quoted by the corpus: 0.374 ; needed: %.4f %s" % ((allow - 4 / 25) / (2 * c2), "OK" if 0.374 <= (allow - 4 / 25) / (2 * c2) else "FAILS")) print() print("verdict:", "every checked figure reproduces" if all(ok) else "some figures differ (see MISMATCH)")