"""Job #2796 (route 45 rev 3, pursue). QUESTION (return #1406's next step): with the corrected main term, does the carrier's absolute discrepancy sum A(x) = sum_{e <= Q, e odd, squarefree} |(mu*mu)(e)| |psi(x; e, -2) - x/phi(e)|, Q = floor(x/y), y = ceil(x^{12/25}), decay relative to x from x = 10^6 to 10^8, or stay at the 0.15 x that exch1505.py measured at 10^6? DEFINITIONS. psi(t; e, -2) = sum_{1 <= n <= t, n = -2 mod e} Lambda(n) (e = 1: psi(t)); |(mu*mu)(e)| = 2^omega(e) on squarefree e; Delta_e(t) = psi(t; e, -2) - t/phi(e). Reported per x: A/x (odd squarefree support, primary), the full-support variant (odd e with (mu*mu)(e) != 0, i.e. cube-free), the log(x/e)-weighted form, the signed form, the split e <= sqrt(x) vs sqrt(x) < e <= Q (beyond-sqrt part further split prime / composite e), and the Object's own carrier W(x) = sum 2^omega(e) log(x/e) max_{t <= x} |Delta_e(t)| (integer t; the sup over real t differs by < 1/phi(e)). PRE-REGISTERED (route 45 rev 3, before running): F1 A(x)/x falls by at least a factor 2 from 10^6 to 10^8; F2 the beyond-sqrt part is at most half of A(x) at every x. Heuristic stated before running (not a test): a random model with per-class variance x log e/phi(e) gives A/x ~ x^{-0.24} (log x)^{1.5}, a factor ~0.51 over the range. SENSITIVITY: the brief printed Q = 9182 (10^7) and 63096 (10^8), which do not follow from its own definition (Q = 4364, 14452); A at the printed Q is reported as a separate row. A fixed-level series, e.g. Q = floor(x^0.6): python3 carrier2796.py --printed-q 1000000:3981,10000000:15848,100000000:63095 --alt-label level_0.6 CONTROLS: C1 at x = 10^6, exch1505.py's convention (all squarefree d <= Q including even d with main 0, inner sum m <= floor(x/d) i.e. n <= d floor(x/d) - 2, weight log(x/d) on odd d) reproduces 0.15101983970867547, 1.1822036162828824, -0.007428689706679672 and Rs_15 = -196.70413429534474; C2 pi(10^6), pi(10^7), pi(10^8) = 78498, 664579, 5761455; C3 brute-force loops reproduce psi(x; e, -2) and max_t |Delta_e(t)| for sample e. Deterministic, no files written; stdout is the record. RUN: python3 carrier2796.py (about 1.5 GB RAM, a few minutes) """ import argparse, json, math, sys, time import numpy as np ap = argparse.ArgumentParser() ap.add_argument('--xs', default='1000000,10000000,100000000') ap.add_argument('--printed-q', default='10000000:9182,100000000:63096') ap.add_argument('--alt-label', default='printed_Q_sensitivity') a = ap.parse_args() XS = sorted(int(v) for v in a.xs.split(',')) PQ = {int(k): int(v) for k, v in (kv.split(':') for kv in a.printed_q.split(',') if kv)} X = XS[-1]; t0 = time.time(); led = [] def check(tag, ok, detail): led.append(f"{'PASS' if ok else 'FAIL'} {tag} :: {detail}"); print(led[-1], flush=True) def r(v): return float(f'{v:.10g}') def Qdef(x): return x // math.ceil(x ** (12 / 25)) # Lambda to X (float64, dense) s = np.ones(X + 1, dtype=bool); s[:2] = False for p in range(2, math.isqrt(X) + 1): if s[p]: s[p * p::p] = False primes = np.flatnonzero(s) lam = np.zeros(X + 1, dtype=np.float64); lam[primes] = np.log(primes.astype(np.float64)) for p in primes[primes <= math.isqrt(X)]: pk = int(p) * int(p) while pk <= X: lam[pk] = math.log(int(p)); pk *= int(p) pis = {x: int(np.count_nonzero(s[:x + 1])) for x in XS} del s print(f'Lambda done ({time.time() - t0:.1f}s)', file=sys.stderr, flush=True) known_pi = {10**6: 78498, 10**7: 664579, 10**8: 5761455} check('C2_prime_counts', all(pis[x] == known_pi[x] for x in XS if x in known_pi), json.dumps({str(x): pis[x] for x in XS})) # small arithmetic functions to E E = max([Qdef(x) for x in XS] + list(PQ.values()) + [math.isqrt(X)]) mu = np.ones(E + 1, dtype=np.int64); phi = np.arange(E + 1, dtype=np.int64); ghat = np.ones(E + 1, dtype=np.int64) isp = np.ones(E + 1, dtype=bool); isp[:2] = False for p in range(2, math.isqrt(E) + 1): if isp[p]: isp[p * p::p] = False for p in np.flatnonzero(isp): p = int(p) mu[p::p] *= -1; mu[p * p::p * p] = 0 phi[p::p] -= phi[p::p] // p # (mu*mu)(p) = -2, (mu*mu)(p^2) = 1, (mu*mu)(p^k) = 0 for k >= 3 idx = np.arange(p, E + 1, p); v = idx.copy(); k = np.zeros(len(idx), dtype=np.int64) while True: m = v % p == 0 if not m.any(): break v[m] //= p; k[m] += 1 fac = np.where(k == 1, -2, np.where(k == 2, 1, 0)); ghat[idx] *= fac mu[0] = 0; ghat[0] = 0 def psi_q(x, e): # question form: 1 <= n <= x, n = -2 mod e if e == 1: return float(lam[1:x + 1].sum()) st = e - 2 if e > 2 else e - 2 + e return float(lam[st:x + 1:e].sum()) if st <= x else 0.0 def psi_exch(x, d): # exch1505 convention: m = 1..floor(x/d), n = dm - 2 (n = -1 for d = 1 contributes Lambda(x) = 0 at 10^k) if d == 1: return float(lam[0:x - 1].sum()) return float(lam[d - 2:d * (x // d) - 1:d].sum()) def maxdev(e, xs): # max over integer 1 <= t <= x of |psi(t;e,-2) - t/phi(e)|, for each x in xs (sorted) ph = float(phi[e]); st = 1 if e == 1 else e - 2; step = e; Xn = xs[-1] res = {x: (st - 1) / ph for x in xs}; off = 0.0 nK = (Xn - st) // step + 1; CH = 1 << 22 for c0 in range(0, nK, CH): c1 = min(nK, c0 + CH) n = st + step * np.arange(c0, c1, dtype=np.int64) S = np.cumsum(lam[st + step * c0: st + step * (c1 - 1) + 1: step]) + off off = float(S[-1]) d1 = np.abs(S - n / ph); d2 = np.abs(S - (n + (step - 1)) / ph) for x in xs: m1 = int(np.searchsorted(n, x, side='right')) if m1: res[x] = max(res[x], float(d1[:m1].max())) m2 = int(np.searchsorted(n, x - step + 1, side='right')) if m2: res[x] = max(res[x], float(d2[:m2].max())) return res # C1: exch1505 convention at x = 10^6 if 10**6 in XS: x = 10**6; Q = Qdef(x) absE = abswE = RsE = Rs15 = 0.0 for d in range(1, Q + 1): if mu[d] == 0: continue ms = float(x) if d == 1 else (0.0 if d % 2 == 0 else x / float(phi[d])) dev = psi_exch(x, d) - ms absE += abs(int(ghat[d])) * abs(dev); RsE += int(ghat[d]) * dev if d % 2: abswE += abs(int(ghat[d])) * math.log(x / d) * abs(dev) if d <= 15: Rs15 += int(ghat[d]) * dev check('C1_reproduce_exch1505', abs(absE / x - 0.15101983970867547) < 1e-9 and abs(abswE / x - 1.1822036162828824) < 1e-9 and abs(RsE / x + 0.007428689706679672) < 1e-9 and abs(Rs15 + 196.70413429534474) < 1e-6, f'abs_Q/N={absE / x:.15f} absw_Q/N={abswE / x:.15f} Rs_Q/N={RsE / x:.15f} Rs_15={Rs15:.9f}') # main census out = {'instrument': 'carrier2796.py', 'job': 2796, 'rows': []} Qx = {x: Qdef(x) for x in XS} emax_by_x = {x: max(Qx[x], PQ.get(x, 0)) for x in XS} odd_sf = [e for e in range(1, max(emax_by_x.values()) + 1) if e % 2 == 1 and mu[e] != 0] odd_full = [e for e in range(1, max(emax_by_x.values()) + 1) if e % 2 == 1 and ghat[e] != 0] dev_at = {x: {} for x in XS} for x in XS: for e in odd_full: if e > emax_by_x[x]: break dev_at[x][e] = psi_q(x, e) - (x if e == 1 else x / float(phi[e])) print(f'at-x census x={x} done ({time.time() - t0:.1f}s)', file=sys.stderr, flush=True) mx = {x: {} for x in XS} for e in odd_sf: xs_e = [x for x in XS if e <= Qx[x]] if not xs_e: continue for x, v in maxdev(e, xs_e).items(): mx[x][e] = max(v, abs(dev_at[x][e])) print(f'max_t census done ({time.time() - t0:.1f}s)', file=sys.stderr, flush=True) C = math.sqrt(2 / math.pi) def row(x, Q, label, with_max): rt = math.isqrt(x) A = A_lo = A_hi = A_hi_p = A_hi_c = Aw = Sg = Af = M = M_lo = M_hi = 0.0; n_hi = n_hi_p = 0 Wm = Am = 0.0 for e in odd_full: if e > Q: break g = int(ghat[e]); dv = dev_at[x][e] Af += abs(g) * abs(dv) if mu[e] == 0: continue w = abs(g); t = w * abs(dv) A += t; Aw += w * math.log(x / e) * abs(dv); Sg += g * dv mod = C * w * math.sqrt(x * math.log(e) / float(phi[e])) if e > 1 else 0.0 M += mod if e <= rt: A_lo += t; M_lo += mod else: A_hi += t; M_hi += mod; n_hi += 1 if isp[e]: A_hi_p += t; n_hi_p += 1 else: A_hi_c += t if with_max: Am += w * mx[x][e]; Wm += w * math.log(x / e) * mx[x][e] d = {'x': x, 'Q': Q, 'label': label, 'sqrt_x': rt, 'A_over_x': r(A / x), 'A_full_support_over_x': r(Af / x), 'A_le_sqrt_over_x': r(A_lo / x), 'A_beyond_sqrt_over_x': r(A_hi / x), 'beyond_share': r(A_hi / A), 'beyond_prime_e_over_x': r(A_hi_p / x), 'beyond_composite_e_over_x': r(A_hi_c / x), 'n_beyond': n_hi, 'n_beyond_prime': n_hi_p, 'e1_abs_dev': r(abs(dev_at[x][1])), 'logweighted_over_x': r(Aw / x), 'signed_over_x': r(Sg / x), 'model_ratio_A_minus_e1': r((A - abs(dev_at[x][1])) / M), 'model_ratio_le_sqrt': r((A_lo - abs(dev_at[x][1])) / M_lo), 'model_ratio_beyond': r(A_hi / M_hi) if M_hi else None} if with_max: d.update({'Amax_over_x': r(Am / x), 'W_max_logweighted_over_x': r(Wm / x)}) return d for x in XS: out['rows'].append(row(x, Qx[x], 'definition', True)) if x in PQ: out['rows'].append(row(x, PQ[x], a.alt_label, False)) # C3: brute-force spot checks def brute(x, e): ph = int(phi[e]); S = 0.0; best = 0.0 for t in range(1, x + 1): if (t + 2) % e == 0: S += lam[t] best = max(best, abs(S - t / ph)) return S, best spots = [(10**6, 1317), (10**6, 1001), (10**6, 3)] if 10**6 in XS else [] ok = True; det = [] for x, e in spots: S, best = brute(x, e); ok &= abs(S - psi_q(x, e)) < 1e-6 and abs(best - mx[x][e]) < 1e-6 det.append(f'e={e}: psi {S:.6f}/{psi_q(x, e):.6f} max {best:.6f}/{mx[x][e]:.6f}') if 10**7 in XS: x, e = 10**7, 4363 if mu[4363] else 4361 S = sum(float(lam[n]) for n in range(e - 2, x + 1, e)); ok &= abs(S - psi_q(x, e)) < 1e-6; det.append(f'x=1e7 e={e}: psi {S:.6f}/{psi_q(x, e):.6f}') check('C3_bruteforce_spots', ok and bool(det), '; '.join(det)) rows = [z for z in out['rows'] if z['label'] == 'definition'] if len(rows) >= 2: lo, hi = rows[0], rows[-1] ratio = hi['A_over_x'] / lo['A_over_x'] ratio_f = hi['A_full_support_over_x'] / lo['A_full_support_over_x'] slope = math.log(ratio) / math.log(hi['x'] / lo['x']) heur = (hi['x'] / lo['x']) ** (-0.24) * (math.log(hi['x']) / math.log(lo['x'])) ** 1.5 out['F1'] = {'ratio_A_over_x': r(ratio), 'ratio_full_support': r(ratio_f), 'local_exponent': r(slope), 'heuristic_ratio': r(heur), 'holds': ratio <= 0.5, 'holds_full_support': ratio_f <= 0.5} out['F2'] = {'beyond_share': [z['beyond_share'] for z in rows], 'holds': all(z['beyond_share'] <= 0.5 for z in rows)} print(f"F1 {'HOLDS' if out['F1']['holds'] else 'FAILS'} :: A(x)/x ratio {lo['x']}->{hi['x']} = {ratio:.4f} (<= 0.5 needed; full support {ratio_f:.4f}; local exponent {slope:.4f}; heuristic {heur:.3f})") print(f"F2 {'HOLDS' if out['F2']['holds'] else 'FAILS'} :: beyond-sqrt share of A(x) = {out['F2']['beyond_share']} (<= 0.5 needed)") out['ledger'] = led print(json.dumps(out, indent=1)) print(f'done ({time.time() - t0:.1f}s)', file=sys.stderr)