#!/usr/bin/env python3 # -*- coding: utf-8 -*- """CORRECTED run for job #2046 (post-hoc; the pre-registered run is frontier.py/frontier.out). WHY A SECOND RUN, stated first because the order matters. frontier.py (pre-registered, DESIGN.md) failed its own two design choices, and the failure is measured, not suspected: (D1) its calibration window was decades 3..ktop-4 of the census. The ratio pi2(x)/(2C2 Li2(x)) is 0.764 at 1e3 and only reaches 1 as x grows, so that window fit the low-x transient and returned c = 0.9766 at 1e19, i.e. a 2.3% "model bias" that does not exist at the scales in question. The 2.3% then propagated into k_emp = 7424 and into W. (D2) its falsifier tested |residual| >= kappa*sigma, which fires on ANY residual -- it fired, on a POSITIVE residual (a surplus), which is the opposite direction to a terminal clearing and therefore says nothing about finiteness. A deficit test must be direction-sensitive. This file therefore runs the same statistic with (i) NO fitted constant, and (ii) yardsticks taken from the residual itself, and reports the frontier for three yardsticks rather than one, so the reader can see which assumption the answer depends on. Everything measured here is a statement about the published counts and about 2C2 Li2(x); no claim is made about which yardstick is TRUE. QUESTION. How large a stop-window W can the published twin census hide? i.e. find the largest W such that a world whose last pair is at x-W is still consistent, at kappa = 3, with the census to x. deficit of F(x-W): D = M(x) - M(x-W) = M'(x) W + O(W^2/x) reject iff D >= kappa * sigma(x), so W = kappa * sigma(x) / M'(x) Three yardsticks, all reported: sigma_poisson = sqrt(M(x)); sigma_resid = |pi2(x) - M(x)| (the model's own measured error at x -- the conservative one, since a model that may be low by that much can hide that much); sigma_detrend = rms of the residual about a smooth trend in log x (the optimistic one). A direction-sensitive falsifier is applied last: a DEFICIT trend. Sources as in frontier.py: A007508 (counts at 10^n, n = 1..19); retained TOS histogram; Wolf arXiv:1107.2809 for the fine-scale sign changes of d2(x). """ import json import math import os import sys import mpmath as mp mp.mp.dps = 40 HERE = os.path.dirname(os.path.abspath(__file__)) C2 = mp.mpf("0.660161815846869573927812110014") KAPPA = 3.0 A007508 = [2, 8, 35, 205, 1224, 8169, 58980, 440312, 3424506, 27412679, 224376048, 1870585220, 15834664872, 135780321665, 1177209242304, 10304195697298, 90948839353159, 808675888577436, 7237518093734545] def li2(x): return mp.quad(lambda t: 1 / mp.log(t) ** 2, [2, x]) def M(x): return 2 * C2 * li2(x) def Mp(x): L = mp.log(x) return 2 * C2 * (1 / L ** 2) * (1 - 2 / L) def main(): out, log = {"tool": "frontier2.py/job2046/", "kappa": KAPPA}, [] def say(s): log.append(s) print(s, flush=True) # 1. the measured phenomenon: the ratio to a constant-free Hardy-Littlewood integral say("(1) MEASURED ratio pi2(10^k) / (2 C2 Li2(10^k)), no fitted constant:") ratio = {} for k in range(3, 20): x = mp.mpf(10) ** k r = mp.mpf(A007508[k - 1]) / M(x) ratio[k] = float(r) d = mp.mpf(A007508[k - 1]) - M(x) say(" 1e%-2d pi2 = %-16s ratio = %.9f residual d = %+.6e (d/pi2 = %+.3e)" % (k, A007508[k - 1], float(r), float(d), float(d / mp.mpf(A007508[k - 1])))) out["ratio"] = ratio # 2. growth of the absolute residual: the empirical fluctuation scale ks = list(range(9, 20)) xs = [float(10.0 ** k) for k in ks] ds = [float(mp.mpf(A007508[k - 1]) - M(mp.mpf(10) ** k)) for k in ks] import numpy as _np lx = _np.log(_np.array(xs)) la = _np.log(_np.abs(_np.array(ds))) slope, icpt = _np.polyfit(lx, la, 1) signs = ["+" if d > 0 else "-" for d in ds] say("(2) MEASURED |d(x)| = |pi2 - 2C2 Li2| fits x^%.4f over 1e9..1e19 (least squares on log|d| " "vs log x): the residual's scale is sqrt(x)-like, one power of x below the count itself." % float(slope)) say(" signs of d over those decades: %s -- it OSCILLATES (Wolf arXiv:1107.2809 counts " "477,118 sign changes below 2^48), so a yardstick must be the oscillation amplitude, " "never a monotone drift." % "".join(signs)) out["residual_growth"] = {"slope": float(slope), "x": xs, "d": ds, "signs": signs} # 3. the corrected frontier under three yardsticks rows = [] for k in range(10, 20): x = mp.mpf(10) ** k Mk, Mpx = M(x), Mp(x) d = abs(mp.mpf(A007508[k - 1]) - Mk) # optimistic yardstick: residual about a smooth trend in log x (fit a cubic in L on ks) rows.append({"k": k, "x": float(x), "M": float(Mk), "residual": float(d), "sigma_poisson": float(mp.sqrt(Mk)), "sigma_resid": float(d), "sigma_detrend": None}) # detrend: residual/last-ratio share, fit c0 + c1/L + c2/L^2 to d(x)/pi2 import numpy as np Ls = np.array([math.log(r["x"]) for r in rows]) fr = np.array([r["residual"] / A007508[r["k"] - 1] for r in rows]) V = np.vstack([np.ones_like(Ls), 1 / Ls, 1 / Ls ** 2]).T coef, *_ = np.linalg.lstsq(V, fr, rcond=None) fit = V @ coef dev = fr - fit for r, dv in zip(rows, dev): r["sigma_detrend"] = abs(float(dv)) * A007508[r["k"] - 1] say("(3) MEASURED trend fit of the residual fraction d/pi2 = %.5f + %.3f/L + %.2f/L^2 " "| max |deviation| = %.3e of pi2" % (coef[0], coef[1], coef[2], float(max(abs(dev))))) say(" frontier W(kappa=3) = kappa*sigma/M'(x), and the invisible stop-window as a " "fraction of the range:") for r in rows: x = mp.mpf(str(r["x"])) Mpx = Mp(x) for tag, key in (("poisson", "sigma_poisson"), ("resid", "sigma_resid"), ("detrend", "sigma_detrend")): sig = mp.mpf(str(r[key])) W = KAPPA * sig / Mpx r["W_" + tag] = float(W) r["eps_" + tag] = float(W / x) say(" 1e%-2d W_poisson=%.4e (eps=%.2e) | W_resid=%.4e (eps=%.2e) | " "W_detrend=%.4e (eps=%.2e)" % (r["k"], r["W_poisson"], r["eps_poisson"], r["W_resid"], r["eps_resid"], r["W_detrend"], r["eps_detrend"])) out["frontier_corrected"] = rows # 4. how the invisible window scales, and what that implies for a census extension ws = [(r["x"], r["W_resid"]) for r in rows] wexp = [math.log(ws[i + 1][1] / ws[i][1]) / math.log(ws[i + 1][0] / ws[i][0]) for i in range(len(ws) - 1)] say("(4) DERIVED the invisible window's own growth: W_resid ~ x^%.4f (per-decade %s)" % (sum(wexp) / len(wexp), " ".join("%.3f" % e for e in wexp))) say(" so W is UNBOUNDED (no census length can exclude a stop in its last W integers) while " "its relative size eps = W/x falls like x^%.4f." % (sum(wexp) / len(wexp) - 1.0)) out["window_growth"] = {"exponent": sum(wexp) / len(wexp), "per_decade": wexp} # 5. direction-sensitive falsifier: a DEFICIT beyond the oscillation yardstick dr = [] for r in rows: k = r["k"] d = mp.mpf(A007508[k - 1]) - M(mp.mpf(10) ** k) yard = mp.mpf(str(r["sigma_detrend"])) dr.append({"k": k, "d": float(d), "sign": "+" if d > 0 else "-", "yardstick": float(yard), "z": float(d / yard) if yard > 0 else 0.0}) trig = [r for r in dr if r["z"] <= -KAPPA] say("(5) FALSIFIER (corrected, direction-sensitive): a terminal clearing would appear as the " "census falling BELOW the constant-free model by more than kappa times the oscillation " "yardstick. Decades with d < 0: %d of %d; with z <= -kappa: %d." % (sum(1 for r in dr if r["d"] < 0), len(dr), len(trig))) for r in dr: say(" 1e%-2d d = %+.4e yardstick = %.4e z = %+.3f" % (r["k"], r["d"], r["yardstick"], r["z"])) say(" VERDICT: the corrected falsifier is %s. The pre-registered falsifier DID trigger " "(frontier.out) and is diagnosed in report.md: it fired on a SURPLUS (d > 0), i.e. the " "opposite direction to a terminal clearing." % ("TRIGGERED" if trig else "not triggered")) out["falsifier_corrected"] = {"triggered": bool(trig), "rows": dr} # 6. sham-stop power under the corrected yardsticks power = [] for r in rows: x = mp.mpf(str(r["x"])) Mk, Mpx = M(x), Mp(x) for stop_k in range(12, r["k"]): X0 = mp.mpf(10) ** stop_k deficit = Mk - M(X0) z = [float(deficit / mp.mpf(str(r["sigma_poisson"]))), float(deficit / mp.mpf(str(r["sigma_resid"]))), float(deficit / mp.mpf(str(r["sigma_detrend"])))] power.append({"census": r["k"], "stop": stop_k, "z": z, "detected_all": all(v >= KAPPA for v in z)}) say("(6) CONTROL sham-stop power under all three yardsticks: %d of %d constructed finite " "worlds detected" % (sum(1 for p in power if p["detected_all"]), len(power))) out["control_sham_stop_corrected"] = {"rows": power, "ok": all(p["detected_all"] for p in power)} out["log"] = log with open(os.path.join(HERE, "frontier2.json"), "w", encoding="utf-8") as fh: json.dump(out, fh, indent=1, default=str) return 0 if __name__ == "__main__": sys.exit(main())