#!/usr/bin/env python3 """Job #2511 statistic: direct measurement of the fixed-endpoint signed discrepancy D^(e1). Pre-registered design (before any run): D^(e1)(x) = sum_{e= 0.16 (=4/25) while total |D_y|/x <= 0.04 (#165) => the fixed-endpoint piece is individually large and D_y is a cancellation => the one-sided signed estimate is binding. Control: random-sign shuffle of mu(n) (seeded) on the same support; |real|/rms >> 1 = detectable. Fast sieves (no per-element factorint). Deterministic, seeded. stdout is the artifact. """ import math, random def build_mu(x): """mu[1..x] via smallest-prime-factor linear sieve (Python).""" mu = [0] * (x + 1) mu[1] = 1 primes = [] is_comp = [False] * (x + 1) for i in range(2, x + 1): if not is_comp[i]: primes.append(i) mu[i] = -1 for p in primes: if i * p > x: break is_comp[i * p] = True if i % p == 0: mu[i * p] = 0 break else: mu[i * p] = -mu[i] return mu, primes def build_lam(x, primes): """lam[1..x] = log p if n = p^k else 0.0 (k>=1, incl. prime powers).""" lam = [0.0] * (x + 1) for p in primes: pk = p lp = math.log(p) while pk <= x: lam[pk] = lp pk *= p return lam def phi_of(e, primes): r = e for p in primes: if p * p > e: break if e % p == 0: r -= r // p while e % p == 0: e //= p if e > 1: r -= r // e return r def D_e1(x, mu, lam, primes, randomize=False, seed=0): e1 = int(x ** 0.52) if randomize: rng = random.Random(seed) mu = [mu[i] * (1 if rng.random() < 0.5 else -1) for i in range(len(mu))] Jlo, Jhi = x // 2 + 1, x M0 = 0.0; M1 = 0.0 for n in range(Jlo, Jhi + 1): f = lam[n - 2] * mu[n] if f: M0 += f M1 += f * math.log(n) total = 0.0 for e in range(1, e1 + 1, 2): me = mu[e] if me == 0: continue phie = phi_of(e, primes) # S1 = -sum_{m: Jlo <= em <= Jhi} lam[em-2]*mu[em]*log m S1 = 0.0 m0 = (Jlo + e - 1) // e m1 = Jhi // e for m in range(m0, m1 + 1): n = e * m f = lam[n - 2] * mu[n] if f: S1 += -f * math.log(m) S2 = math.log(e) * M0 - M1 total += me * (S1 - S2 / phie) return total if __name__ == "__main__": print("job2511_de1_stat.py — D^(e1) direct measurement (fast sieves; exact integer weights)") print("eps=1/50; J=(x/2,x]; falsifier |D^(e1)|/x >= 0.16 vs |D_y|/x <= 0.04 (#165)") for x in (2**14, 2**16, 2**18): mu, primes = build_mu(x) lam = build_lam(x, primes) real = D_e1(x, mu, lam, primes) ctrl = [D_e1(x, mu, lam, primes, randomize=True, seed=s) for s in (1, 2, 3, 4)] rms = math.sqrt(sum(c * c for c in ctrl) / 4) print(f"x=2^{int(math.log2(x)):2d}: D^(e1)/x = {real/x:+.6f} ctrl_rms/x = {rms/x:.6f} |real|/rms = {abs(real)/max(rms,1e-300):.3f} falsifier={abs(real/x) >= 0.16}")