"""Job #4554 (first look, route 175). QUESTION: does B(s) = sum_{h>=1}(F(h)-1) h^{-s} have a branch point at s = 0 (route 175, from #2038's fitted exponent theta = 0.733 / 0.744), a simple pole (route 175's next step: M(H) ~ c ln H), or the double pole that #1834's expansion predicts (sum_r sigma(r) r^{-s} = zeta(1+s)^2 G(s), G(0) = 1/(2C_2))? OBJECT (#1834 reduction2669.md; A = 2C_2): F(h) = S_4(h)/A^2 = prod_p f_p(h), f_2(h) = 2*1[2|h], odd p: f_p(h) = (1 - nu_p(h)/p)/(1 - 2/p)^2, nu_p(h) = #{0,2,h,h+2 mod p}. f_3(h) = 3 if 3|h else 0. For p >= 5: f_p = p/(p-2) if p|h, p(p-3)/(p-2)^2 if p|h-2 or p|h+2, and the GENERIC factor g_p = p(p-4)/(p-2)^2 = 1 - 4/(p-2)^2 otherwise -- every prime p > h+2 contributes g_p, which is not 1. Hence, exactly, F_b(h) = [6|h] * 6 K5 * prod_{p>=5, p|h} (p-2)/(p-4) * prod_{p>=5, p|h^2-4} (p-3)/(p-4), K5 = prod_{p>=5} p(p-4)/(p-2)^2 (route 107's object), F_a(h) = [3|h] * 3 K5 * (the same products) = the p>2 product over ALL h, the convention of #2038's dirichlet.py (no f_2). #2038's dirichlet.py multiplies f_p only for p <= h+2 (`if p > h + 2: break`), i.e. uses F_trunc(h) = F_a(h) / prod_{p>h+2} g_p. M(H) = sum_{1<=h<=H} (F(h) - 1). S(R) = sum_{r<=R} sigma(r), sigma multiplicative on squarefree r, sigma_2 = 1, sigma_p = 2/(p-2) (#1834 Lemma 1). HEURISTIC PREDICTION (derived in the report): for each squarefree q > 1 the periodic mean-zero piece w_q = prod_{p|q}(f_p - 1) is even in h, so its partial sums over h <= H have mean value -w_q(0)/2 = -sigma(q)/2; hence M_b(H) = -(S(H) - 1)/2 + (lower order), and M_b(H) ~ -(1/(8 C_2)) ln^2 H (double pole of B_b at 0 with Laurent coefficient -1/(4C_2) on s^-2), M_a(H) ~ -(1/(16 C_2)) ln^2 H with S_a over odd r. PRE-REGISTERED. G1: K5 and C_2 to < 1e-12 relative (prime product to 2e7 plus exponential-integral tail). G2: F_b reproduces #1315's published defect column D/(A^2 H) = 1 - (2/H) sum_{t= 1e5, and likewise for (a). P2: a free fit M = alpha ln^2 H + beta ln H + gamma over H in [1e4, 1e7] gives alpha_b within 15% of -0.18935. P3: the simple-pole fit M = beta ln H + gamma has max residual >= 5x the ln^2 fit. P4: with the TRUE F_a, the theta fit of #2038's procedure at N = 12000 moves (|theta - 0.7443| > 0.05), and a PURE double-pole model M(t) = -(1/(16C_2)) ln^2 t fed through the same finite-N procedure gives theta in [0.4, 1.2]: a double pole reads as theta < 1 in this window. FALSIFIERS: G2 or G3 failing (a different object); P1 failing (M_b not tracking -(S-1)/2 at ln^2 order); M_b bounded or ~ c ln H (route 175's next-step branch). Stdout: ledger + tables + VERDICT; deterministic, no timing on stdout.""" import sys, json, math from fractions import Fraction as Fr import numpy as np import mpmath as mp mp.mp.dps = 30 led = [] def check(tag, ok, detail): led.append(f"{'PASS' if ok else 'FAIL'} {tag} :: {detail}"); print(led[-1], file=sys.stderr, flush=True) def sieve(n): s = np.ones(n + 1, dtype=bool); s[:2] = False for i in range(2, int(n ** 0.5) + 1): if s[i]: s[i * i::i] = False return np.flatnonzero(s) HMAX = 10 ** 7; PC = 2 * 10 ** 7 PR = sieve(PC) # ---- G1 constants p5 = PR[PR >= 5].astype(np.float64); po = PR[PR >= 3].astype(np.float64) logK5 = math.fsum(np.log1p(-4.0 / (p5 - 2) ** 2)) - 4 * float(mp.e1(mp.log(PC))) # tail sum_{p>P} log(1-4/(p-2)^2) ~ -4 E1(ln P) logC2 = math.fsum(np.log1p(-1.0 / (po - 1) ** 2)) - float(mp.e1(mp.log(PC))) K5 = math.exp(logK5); C2 = math.exp(logC2) tailK = 4 * float(mp.e1(mp.log(PC))) check('G1_constants', abs(C2 - 0.6601618158468696) < 1e-12, f'C_2 = {C2:.15f} (OEIS A005597 0.660161815846869573927812110014...), K5 = {K5:.15f}; K5 tail term {tailK:.3e} (second-order correction < 1e-15)') P2c = 10 ** 7; p5b = p5[p5 <= P2c] logK5b = math.fsum(np.log1p(-4.0 / (p5b - 2) ** 2)) - 4 * float(mp.e1(mp.log(P2c))) led.append(f"INFO G1 cross-check: K5 from primes <= 1e7 plus tail = {math.exp(logK5b):.15f}, from <= 2e7 plus tail = {K5:.15f}, relative gap {abs(math.exp(logK5b) / K5 - 1):.1e}") aB = -1 / (8 * C2); aA = -1 / (16 * C2) # ---- exact F on h = 3k, k = 1..HMAX/3 NK = HMAX // 3 + 2 logr = np.zeros(NK + 1) # index k (h = 3k); index 0 unused for p in PR[(PR >= 5) & (PR <= 3 * NK + 2)].tolist(): inv3 = pow(3, -1, p) logr[p::p] += math.log((p - 2) / (p - 4)) # p | h <=> p | k c = math.log((p - 3) / (p - 4)) k0 = (2 * inv3) % p; k1 = (-2 * inv3) % p # h = 3k = +2, -2 mod p logr[k0::p] += c logr[k1::p] += c if k0 == 0 or k1 == 0: raise SystemExit('unexpected class collision') k = np.arange(NK + 1); h = 3 * k Fa = 3 * K5 * np.exp(logr); Fa[0] = 0.0 # value at h = 3k Fb = np.where(h % 2 == 0, 2 * Fa, 0.0) # G4 direct product P1e5 = [int(q) for q in PR[PR <= 100000] if q >= 3] tail1e5 = math.exp(math.fsum(np.log1p(-4.0 / (p5[p5 > 100000] - 2) ** 2)) - 4 * float(mp.e1(mp.log(PC)))) def Fdirect(hh): v = Fr(1) for q in P1e5: nu = len({0, 2 % q, hh % q, (hh + 2) % q}); v *= Fr(q - nu, q) / Fr(q - 2, q) ** 2 return float(v) * tail1e5 worst = max(abs(Fdirect(3 * kk) - Fa[kk]) / Fa[kk] for kk in range(1, 101) if Fa[kk] > 0) nonmult3 = [Fdirect(hh) for hh in (1, 2, 4, 5, 7, 8)] check('G4_direct_product_h<=300', worst < 1e-12 and all(v == 0 for v in nonmult3), f'max relative error {worst:.2e} over h = 3..300 step 3; F(h) = 0 for 3 not dividing h (checked h = 1,2,4,5,7,8)') # ---- M(H) for all H <= HMAX: cumulative sums over h def Mcurve(Fk): c = np.cumsum(Fk) # c[k] = sum_{h = 3j <= 3k} F return c Ca = Mcurve(Fa); Cb = Mcurve(Fb) def M_at(C, H): return float(C[H // 3]) - H # sigma sums (float64 cumulative; checked with fsum at the end point) logs = np.zeros(HMAX + 1); sqf = np.ones(HMAX + 1, dtype=bool); sqf[0] = False for p in PR[PR <= HMAX].tolist(): if p > 2: logs[p::p] += math.log(2 / (p - 2)) if p * p <= HMAX: sqf[p * p::p * p] = False sig = np.where(sqf, np.exp(logs), 0.0); sig[0] = 0.0 odd = np.arange(HMAX + 1) % 2 == 1 S_b = np.cumsum(sig); S_a = np.cumsum(np.where(odd, sig, 0.0)) fs_check = abs(math.fsum(sig.tolist()) - S_b[-1]) / S_b[-1] # G2 against #1315 (D/(A^2 H) = 1 - (2/H) sum_{t=1}^{H-1} M_b(t)); M_b(t) for all t via step function tt = np.arange(HMAX + 1) Mb_all = Cb[tt // 3] - tt; Mb_all[0] = 0.0 cumMb = np.cumsum(Mb_all) pub1315 = {1000: 34.05608983135955, 2000: 39.66459640533038, 5000: 46.78616469554142, 10000: 53.01705346022922, 20000: 59.432046755998336, 50000: 68.35204336105849, 100000: 75.89055253722776, 200000: 83.43023626555812, 500000: 94.21521645136544, 1000000: 102.67626806448327} g2 = {H: 1 - 2 / H * float(cumMb[H - 1]) for H in pub1315} g2err = max(abs(g2[H] - v) for H, v in pub1315.items()) check('G2_reproduces_1315_defect_column', g2err < 1e-6, f'max |ours - #1315| = {g2err:.2e} over the ten published lengths (e.g. H = 1e6: {g2[1000000]:.6f} vs 102.676268)') K1315 = 0.3968803565232836 # ssum2549.out "C4" d = K1315 / K5 - 1 # exact recomputation with #1315's constant: F scales by (1+d), so sum_{t= 5) & (PR <= 2 * 10 ** 7)]] # T(y) = prod_{p > y} g_p = K5 / prod_{5 <= p <= y} g_p lg = np.log1p(-4.0 / (np.array(pr_all, dtype=np.float64) - 2) ** 2); cumlg = np.cumsum(lg); parr = np.array(pr_all) def T_above(y): i = int(np.searchsorted(parr, y, side='right')) return math.exp(logK5 - (float(cumlg[i - 1]) if i > 0 else 0.0)) def F_a_int(hh): return float(Fa[hh // 3]) if hh % 3 == 0 else 0.0 ss = [0.02, 0.05, 0.1, 0.2, 0.4, 0.8] def Btable(Ffun, NN): hs = np.arange(2, NN + 1, dtype=np.float64); vals = np.array([Ffun(int(x)) for x in hs]) - 1.0 return [float(np.sum(vals * hs ** (-s))) for s in ss] def theta(Bs): xs = [-math.log(s) for s in ss]; ys = [math.log(-b) for b in Bs]; n = len(xs) sx, sy = sum(xs), sum(ys); sxx = sum(x * x for x in xs); sxy = sum(x * y for x, y in zip(xs, ys)) return (n * sxy - sx * sy) / (n * sxx - sx * sx) Ftr = lambda hh: F_a_int(hh) / T_above(hh + 2) Btr = Btable(Ftr, N); pub2038 = [-8.0286, -6.8315, -5.2691, -3.2547, -1.4518, -0.4849] th_tr = theta(Btr); th_tr4000 = theta(Btable(Ftr, 4000)) check('G3_truncation_reproduces_2038', max(abs(a - b) for a, b in zip(Btr, pub2038)) < 1e-3 and abs(th_tr - 0.7443) < 1e-3 and abs(th_tr4000 - 0.7330) < 1e-3, f'truncated-product B(s) at N = 12000: {[round(b, 4) for b in Btr]} vs published {pub2038}; theta {th_tr:.4f} (published 0.7443), N = 4000 theta {th_tr4000:.4f} (published 0.7330)') Bok = Btable(F_a_int, N); th_ok = theta(Bok) trunc_bias = sum(Ftr(hh) - F_a_int(hh) for hh in range(2, N + 1)) # ---- checkpoints and tests HS = [10 ** 3, 2 * 10 ** 3, 5 * 10 ** 3, 10 ** 4, 2 * 10 ** 4, 5 * 10 ** 4, 10 ** 5, 2 * 10 ** 5, 5 * 10 ** 5, 10 ** 6, 2 * 10 ** 6, 5 * 10 ** 6, 10 ** 7] rows = [] for H in HS: L = math.log(H); Mb = M_at(Cb, H); Ma = M_at(Ca, H) Db = Mb + (float(S_b[H]) - 1) / 2; Da = Ma + (float(S_a[H]) - 1) / 2 rows.append({'H': H, 'lnH': L, 'M_b': Mb, 'M_a': Ma, 'S_b': float(S_b[H]), 'S_a': float(S_a[H]), 'Delta_b': Db, 'Delta_a': Da, 'M_b/ln2': Mb / L ** 2, 'M_a/ln2': Ma / L ** 2, 'Delta_b/ln2': Db / L ** 2, 'Delta_a/ln2': Da / L ** 2, 'Delta_b/lnH': Db / L}) big = [r for r in rows if r['H'] >= 10 ** 5] check('P1_M_tracks_minus_half_S_at_ln2_order', all(abs(r['Delta_b/ln2']) < 0.02 and abs(r['Delta_a/ln2']) < 0.02 for r in big), '; '.join(f"H={r['H']:.0e}: M_b={r['M_b']:.3f} -(S-1)/2={-(r['S_b'] - 1) / 2:.3f} Delta_b/ln2={r['Delta_b/ln2']:+.4f} Delta_a/ln2={r['Delta_a/ln2']:+.4f}" for r in big)) fitH = [r for r in rows if r['H'] >= 10 ** 4] def lsq(cols, y): A = np.array(cols).T; sol, *_ = np.linalg.lstsq(A, np.array(y), rcond=None); res = np.array(y) - A @ sol; return sol, float(np.max(np.abs(res))) Ls = [r['lnH'] for r in fitH] (solb, resb) = lsq([[l * l for l in Ls], Ls, [1.0] * len(Ls)], [r['M_b'] for r in fitH]) (sola, resa) = lsq([[l * l for l in Ls], Ls, [1.0] * len(Ls)], [r['M_a'] for r in fitH]) (solb1, resb1) = lsq([Ls, [1.0] * len(Ls)], [r['M_b'] for r in fitH]) (sola1, resa1) = lsq([Ls, [1.0] * len(Ls)], [r['M_a'] for r in fitH]) check('P2_free_ln2_fit_alpha', abs(solb[0] / aB - 1) < 0.15 and abs(sola[0] / aA - 1) < 0.15, f'alpha_b = {solb[0]:.5f} (pred {aB:.5f}, ratio {solb[0] / aB:.4f}), beta_b = {solb[1]:.4f}, gamma_b = {solb[2]:.4f}, max resid {resb:.4f}; alpha_a = {sola[0]:.5f} (pred {aA:.5f}, ratio {sola[0] / aA:.4f}), max resid {resa:.4f}') check('P3_simple_pole_fit_rejected', resb1 >= 5 * resb and resa1 >= 5 * resa, f'ln-only fit max resid: (b) {resb1:.4f} vs ln2 fit {resb:.4f} (x{resb1 / resb:.1f}); (a) {resa1:.4f} vs {resa:.4f} (x{resa1 / resa:.1f})') # P4: theta under the true F, and theta of a pure double-pole model through the same finite-N procedure def B_model(alpha, beta, gamma, NN): out = [] for s in ss: # sum_{h=2}^{NN} (M(h) - M(h-1)) h^{-s} with M(t) = alpha ln^2 t + beta ln t + gamma (continuous-t), M(1) = gamma f = lambda t: (2 * alpha * mp.log(t) + beta) / t * t ** (-s) out.append(float(mp.quad(f, [1.5, 10, 100, 1000, NN + 0.5]))) return out th_pure = theta(B_model(aA, 0.0, 0.0, N)); th_fit = theta(B_model(sola[0], sola[1], sola[2], N)) check('P4_theta_is_a_window_statistic', abs(th_ok - 0.7443) > 0.05 and 0.4 <= th_pure <= 1.2, f'true-F B(s) at N = 12000: {[round(b, 4) for b in Bok]}, theta {th_ok:.4f} (truncated 0.7443); pure double-pole model -(1/(16C_2)) ln^2 t through the same N = 12000 procedure: theta {th_pure:.4f}; fitted (a) model: theta {th_fit:.4f}; truncation bias sum_{{h<=12000}}(F_trunc - F) = {trunc_bias:+.4f}') Hs_s = [H for H in smooth if H >= 10 ** 4]; Lss = [math.log(H) for H in Hs_s] (sb_s, rb_s) = lsq([[l * l for l in Lss], Lss, [1.0] * len(Lss)], [smooth[H][0] for H in Hs_s]) (sa_s, ra_s) = lsq([[l * l for l in Lss], Lss, [1.0] * len(Lss)], [smooth[H][1] for H in Hs_s]) (sb_s1, rb_s1) = lsq([Lss, [1.0] * len(Lss)], [smooth[H][0] for H in Hs_s]) (sa_s1, ra_s1) = lsq([Lss, [1.0] * len(Lss)], [smooth[H][1] for H in Hs_s]) led.append(f"POSTHOC_smoothed_fits (Cesaro mean Mbar(H) = (1/H) sum_{{t<=H}} M(t), H in [1e4, 1e7], not pre-registered): alpha_b = {sb_s[0]:.5f} (pred {aB:.5f}, ratio {sb_s[0] / aB:.4f}), max resid {rb_s:.4f}; ln-only resid {rb_s1:.4f} (x{rb_s1 / rb_s:.1f}); alpha_a = {sa_s[0]:.5f} (pred {aA:.5f}, ratio {sa_s[0] / aA:.4f}), max resid {ra_s:.4f}; ln-only resid {ra_s1:.4f} (x{ra_s1 / ra_s:.1f})") led.append("POSTHOC_smoothed_Delta: " + '; '.join(f"H={H:.0e}: Mbar_b={smooth[H][0]:.3f} vs -(Sbar_b-1)/2={smooth[H][2]:.3f} (Delta {smooth[H][0] - smooth[H][2]:+.3f}); Mbar_a={smooth[H][1]:.3f} vs {smooth[H][3]:.3f} (Delta {smooth[H][1] - smooth[H][3]:+.3f})" for H in smooth if H >= 10 ** 4)) mean_b = M_at(Cb, HMAX) / HMAX led.append(f"INFO mean check: M_b(1e7)/1e7 = {mean_b:.2e}; S fsum/cumsum relative gap {fs_check:.1e}; S_b(1e7) = {float(S_b[HMAX]):.4f}; #1834 (I) expansion (1/(4C2)) ln^2 R + 2.281060 ln R at 1e7: {(1/(4*C2))*math.log(HMAX)**2 + 2.281060*math.log(HMAX):.4f} (+c1)") print('\n'.join(led)) print('TABLE H lnH M_b -(S_b-1)/2 Delta_b Delta_b/lnH M_a -(S_a-1)/2 Delta_a') for r in rows: print(f"{r['H']:>9d} {r['lnH']:7.4f} {r['M_b']:10.4f} {-(r['S_b'] - 1) / 2:10.4f} {r['Delta_b']:+9.4f} {r['Delta_b/lnH']:+8.4f} {r['M_a']:10.4f} {-(r['S_a'] - 1) / 2:10.4f} {r['Delta_a']:+9.4f}") print('VERDICT ' + json.dumps({'all_pass': all(l.startswith(('PASS', 'INFO', 'POSTHOC')) for l in led), 'C2': C2, 'K5': K5, 'alpha_b': solb[0], 'alpha_b_pred': aB, 'alpha_a': sola[0], 'alpha_a_pred': aA, 'theta_trunc': th_tr, 'theta_trueF': th_ok, 'theta_pure_double_pole_model': th_pure, 'M_b_1e7': rows[-1]['M_b'], 'Delta_b_1e7': rows[-1]['Delta_b']})) json.dump({'rows': rows, 'B_trunc': Btr, 'B_true': Bok, 'fit_b': list(map(float, solb)), 'fit_a': list(map(float, sola)), 'fit_b_ln': list(map(float, solb1)), 'ledger': led}, open('fresh4554.json', 'w'), indent=1)