# split2548.py -- job #2548: the tile's share of the Hardy-Littlewood variance defect. With rho_H^(<=x) the singular-series # sum truncated to primes <= x (c_x(h)/d_x^2 = prod_{p<=x} (1-nu_p/p)/(1-nu2_p/p)^2, exact per h, no tile scan needed), the # defect 1 - rho_H^(<=x) equals (1 - Var_w[A]/E[A]) / E[A] for the tile T_x (identity checked in tilevar2548.py to 1e-12 at # x = 13, 19), and the full defect 1 - rho_H (all primes; ssum2549.json / #1302) splits as tile part + large-prime remainder. # Prints, for H in {2310, 30030} and x in {13, 17, 19, 23, 29, 31, 37}: 1 - rho^(<=x), the full 1 - rho_H, the tile share. import json, math import numpy as np from importlib.machinery import SourceFileLoader vr = SourceFileLoader("vr", "../job2656/var2656.py").load_module() C2 = vr.C2 def primes_to(n): b = np.ones(n + 1, dtype=bool); b[:2] = False for q in range(2, int(n ** .5) + 1): if b[q]: b[q * q::q] = False return [int(p) for p in np.flatnonzero(b)] def trunc_defect(H, x): ps = primes_to(x); d2 = 1.0 for p in ps: d2 *= (1 - (1 if p == 2 else 2) / p) hs = np.arange(1, H); ratio = np.zeros(H - 1) even = hs % 2 == 0 r = np.ones(H - 1) for p in ps: nu2 = 1 if p == 2 else 2 res = np.stack([np.zeros(H - 1, dtype=np.int64), np.full(H - 1, 2 % p), hs % p, (hs + 2) % p]) nu = np.array([len(set(col)) for col in res.T]) r *= (1 - nu / p) / (1 - nu2 / p) ** 2 ratio[even] = r[even] # odd h: zero # 1 - rho^(<=x) = 1 - sum_{h != 0} (H-|h|) c(h) / (H^2 d^2) = 1 - 2 sum_{h=1}^{H-1} (H-h) ratio(h) / H^2 return 1 - 2 * float(((H - hs) * ratio).sum()) / (H * H) full = {2310: 1 - 0.9822650, 30030: 1 - 0.9978900} # from ssum2549 / var2656 (all primes, Euler product to 1e6) primes_all = [int(p) for p in vr.bg.primes_to(10 ** 6)] out = {} for H in (2310, 30030): s, _ = vr.singular_sum(H, primes_all); full[H] = 1 - s / (H * H * (2 * C2) ** 2) out[str(H)] = {"full_defect": full[H], "levels": {}} for x in (13, 17, 19, 23, 29, 31, 37): t = trunc_defect(H, x); out[str(H)]["levels"][str(x)] = {"tile_defect": t, "share": t / full[H], "remainder": full[H] - t} print(f"H={H} x={x:>2}: tile defect 1-rho^(<=x) = {t:.6f} full 1-rho = {full[H]:.6f} share = {t / full[H]:.3f} remainder = {full[H] - t:.6f}", flush=True) json.dump(out, open('split2548.json', 'w'), indent=1)