# triage2635.py -- the three cheap checks behind the triage of route 104 (return #1276), job #2635. # (1) The bond-witness arithmetic the paper states twice with opposite signs: lambda(30047) lambda(30049). # (2) The F_n = lambda(n)lambda(n+1)lambda(n+2)lambda(n+3) census to 3e6, which the paper reports as +1: 1,500,908 / # -1: 1,499,092 and a peer check (channel message 2448) reported as +1: 1,499,902 / -1: 1,500,098 (a digit # transposition apart); an independent count settles which. Liouville via a linear smallest-prime-factor sieve; # control: sum_{n<=N} lambda(n) for small N against the known values (L(10) = 0, L(100) = -2, L(1000) = -14). # (3) Conjecture P1's weight: for a fixed rho > 0, |S(X)| <= sum_{n>=1} e^{-rho sqrt(n+1)} < 2/rho^2 + 1, a bound # independent of X, so the pre-registered threshold X^{1/2+delta} is unreachable once X^{1/2} exceeds that # constant; tabulated for a few rho, together with the null band X^{1/2} log X and the threshold X^{1/2+delta} # at X = 1e6 and 1e7 (the two are inconsistent for delta < log log X / log X). import math, json, sys import numpy as np def liouville_upto(N): spf = np.zeros(N + 1, dtype=np.int64) for i in range(2, int(N ** .5) + 1): if spf[i] == 0: block = spf[i * i::i]; mask = block == 0; block[mask] = i; spf[i * i::i] = block lam = np.ones(N + 1, dtype=np.int8); lam[0] = 0 for n in range(2, N + 1): p = spf[n] if spf[n] else n lam[n] = -lam[n // p] return lam out = {} # (1) def omega(n): c = 0; d = 2 while d * d <= n: while n % d == 0: n //= d; c += 1 d += 1 return c + (1 if n > 1 else 0) w = {m: omega(m) for m in (11, 13, 221, 223, 17, 19, 30047, 30049)} lam_w = {m: (-1) ** w[m] for m in w} out['witnesses'] = dict(Omega=w, lambda_products={'(11,13)': lam_w[11] * lam_w[13], '(221,223)': lam_w[221] * lam_w[223], '(17,19)': lam_w[17] * lam_w[19], '(30047,30049)': lam_w[30047] * lam_w[30049]}, factor_30049=(151 * 199 == 30049), is_prime_30047=(w[30047] == 1)) # (2) N = 3_000_000 + 3 lam = liouville_upto(N) out['control_L'] = {str(n): int(lam[1:n + 1].sum()) for n in (10, 100, 1000)} F = lam[1:N - 2] * lam[2:N - 1] * lam[3:N] * lam[4:N + 1] # F_n for n = 1..3e6 plus = int((F == 1).sum()); minus = int((F == -1).sum()) out['F_census_to_3e6'] = dict(n_from=1, n_to=3_000_000, plus=plus, minus=minus, paper=dict(plus=1500908, minus=1499092), peer_msg_2448=dict(plus=1499902, minus=1500098)) byres = {} for r in range(4): sel = F[r::4] if r else F[3::4] # n = 1.. ; n mod 4 == r (n = index+1) idx = np.arange(1, N - 2); m = (idx % 4 == r) byres[str(r)] = dict(plus=int((F[m] == 1).sum()), minus=int((F[m] == -1).sum())) out['F_by_n_mod_4'] = byres # (3) def weight_sum_bound(rho): return 2.0 / rho ** 2 + 1.0 tab = {} for rho in (1.0, 0.1, 0.01, 0.001): tab[str(rho)] = dict(sum_bound=weight_sum_bound(rho), numeric_sum_to_1e7=float(np.exp(-rho * np.sqrt(np.arange(1, 10_000_001) + 1.0)).sum())) scales = {} for X in (10 ** 6, 10 ** 7): scales[str(X)] = dict(sqrtX=X ** .5, null_band_sqrtX_logX=X ** .5 * math.log(X), threshold={str(d): X ** (.5 + d) for d in (0.01, 0.05, 0.1, 0.17, 0.2)}, delta_where_threshold_equals_null_band=math.log(math.log(X)) / math.log(X)) out['P1_weight_bounds'] = tab; out['P1_scales'] = scales json.dump(out, open('triage2635.json', 'w'), indent=1) print(json.dumps(out, indent=1))