Current task: —

E-023b-mzero-boxcover.py

Experiments: E-023b · script updated 08-27-2026

E-023b-mzero-boxcover.csv — 410 bytes, updated 08-27-2026

page 1 of 1 · 500/page · 10 rows
# quantityvalue
2 grid_max_upper 1.3329998534172773361206054687500000000
3 grid_argmax 0.8495500000000001
4 series_tail [8.036139000659258592860484308733579139e-7 +/- 4.72e-44]
5 certified_max [1.3330006570311774020464647547984308734 +/- 4.80e-38]
6 target 1.3352
7 headroom [0.00219934296882259795353524520156912664 +/- 7.98e-39]
8 coverage 10.000000000001068
9 box_evaluations 17570
10 boxes_recorded 16813
11 all_checks_pass True

E-023b-mzero-boxcover.json — 2.0 KB, updated 08-27-2026

JSON sidecar (click to expand)
{
  "experiment": "E-023b",
  "task": "MZeroProp interval-rigorous certification (ii'-7 follow-up, user directive session 043)",
  "script": "research/numerics/scripts/E-023b-mzero-boxcover.py",
  "method": "adaptive Arb box cover of the segment: FE log-derivative evaluated boxwise in ball arithmetic (128-bit) with the psi(s/2) pole shift psi(w)=psi(w+3)-1/w-1/(w+1)-1/(w+2), Dirichlet series N=400 with certified integral tail; x10 subdivision above the pass level; symmetry t<->-t",
  "parameters": {
    "prec_bits": 128,
    "coarse_half_width": 0.0005,
    "min_half_width": 5e-07,
    "max_depth": 4,
    "pass_level": "[1.3330000000000000000000000000000000000 +/- 5.00e-39]",
    "series_N": 400,
    "box_evaluations": 17570,
    "boxes_recorded": 16813
  },
  "checks": {
    "V1_fe_vs_mpmath_max_absdiff_lt_2e-6": true,
    "V2_boxes_cover_[0,10]_exactly": true,
    "V3_certified_max_le_target": true,
    "V4_consistent_with_E023_sampled_1.33237": true
  },
  "key_values": {
    "grid_max_upper": "1.3329998534172773361206054687500000000",
    "grid_argmax": 0.8495500000000001,
    "series_tail": "[8.036139000659258592860484308733579139e-7 +/- 4.72e-44]",
    "certified_max": "[1.3330006570311774020464647547984308734 +/- 4.80e-38]",
    "target": "1.3352",
    "headroom": "[0.00219934296882259795353524520156912664 +/- 7.98e-39]",
    "coverage": 10.000000000001068
  },
  "crosscheck_mpmath": [
    {
      "t": 0.0,
      "mpmath": 0.7356802593541504,
      "arb_mid": 0.7356803847465779,
      "absdiff": 1.2539242755238433e-07
    },
    {
      "t": 1.0,
      "mpmath": 1.3176408745556647,
      "arb_mid": 1.3176408304221687,
      "absdiff": 4.413349596887883e-08
    },
    {
      "t": 4.7,
      "mpmath": 0.595836106195707,
      "arb_mid": 0.5958360626300774,
      "absdiff": 4.356562965934785e-08
    },
    {
      "t": 10.0,
      "mpmath": 0.5364627998701963,
      "arb_mid": 0.5364627824386835,
      "absdiff": 1.743151278876809e-08
    }
  ],
  "elapsed_seconds": 3.9
}

Source code

Python script (click to expand)
"""E-023b — MZeroProp INTERVAL-RIGOROUS certification (ii'-7 follow-up,
user directive session 043).

CERTIFY:  |zeta'/zeta(-5/2 + i t)| <= 1.3352  for ALL  |t| <= 10
(the Lean perimeter hypothesis MZeroProp, LiContour.lean:163).

Method (no sampled ingredient anywhere):
  The segment [0, 10] (symmetry |f(conj s)| = |f(s)| covers [-10, 0])
  is covered by an ADAPTIVE family of t-boxes. On each box
  s = -5/2 + i*[tc +/- hw] we evaluate the functional-equation form
      f(s) := zeta'/zeta(s)
            = log pi - (1/2) psi((1-s)/2) - (1/2) psi(s/2)
              + sum_{n>=1} Lambda(n) n^{s-1},
  (from zeta(s) = chi(s) zeta(1-s); the Dirichlet series converges at
  1-s = 7/2 - i t, Re = 7/2 > 1) ENTIRELY in Arb ball arithmetic
  (python-flint, 128 bits), so the output ball rigorously encloses the
  range of f over the box. The psi(s/2) argument (Re -5/4, near the
  digamma pole at -1) is shifted before box evaluation:
      psi(w) = psi(w+3) - 1/w - 1/(w+1) - 1/(w+2)      (w = s/2),
  the reciprocals being exact ball operations on zero-free denominator
  balls. The Dirichlet series is truncated at N = 400 with a certified
  integral tail bound (added once globally).
  A box whose |f|-upper exceeds the pass level is subdivided x10;
  coverage of [0, 10] by the recorded boxes is checked exactly.

Checks:
  V1. FE implementation (incl. the +3 shift) vs mpmath diff-based
      logDeriv at 4 probe points (cross-check only; mpmath is NOT part
      of the certificate).
  V2. Recorded boxes cover [0, 10] exactly (sum of widths = 10).
  V3. certified_max = max box |f|.upper + series tail <= 1.3352.
  V4. Agreement with E-023's independent sampled maximum 1.33237
      (sanity, |certified_max_grid - 1.33237| small).

Dual storage: CSV summary + JSON sidecar (research/numerics/data/),
registered in research.db. Cached: rerun with --force to recompute.
"""
import json
import math
import sys
import time
from pathlib import Path

from flint import acb, arb, ctx

ctx.prec = 128

DATA = Path(__file__).resolve().parent.parent / "data"
CSV = DATA / "E-023b-mzero-boxcover.csv"
JSON = DATA / "E-023b-mzero-boxcover.json"

TARGET = arb("1.3352")
PASS_LEVEL = arb("1.3330")   # boxes at/below this are recorded, not split
N_SERIES = 400               # Dirichlet series truncation
COARSE_HW = 5e-4             # coarse box half-width (10 000 boxes)
MIN_HW = 5e-7                # subdivision floor
MAX_DEPTH = 4


def sieve_mangoldt(n):
    lam = [0.0] * (n + 1)
    sieve = [True] * (n + 1)
    for p in range(2, n + 1):
        if sieve[p]:
            lp = math.log(p)
            k = p
            while k <= n:
                lam[k] = lp
                for m in range(k, n + 1, k):
                    sieve[m] = False
                k *= p
    return lam


LAM = sieve_mangoldt(N_SERIES)
LOGPI = arb.pi().log()
HALF = acb("0.5")
PPOWS = [(n, LAM[n]) for n in range(2, N_SERIES + 1) if LAM[n] != 0.0]


def series_tail_bound(sigma_arb, N):
    """Certified upper bound for sum_{n>N} (log n) n^{-sigma}, sigma > 1:
    <= [(log N)/(sigma-1) + 1/(sigma-1)^2] N^{-(sigma-1)} + (log N) N^{-sigma}
    (integral comparison, integral evaluated exactly)."""
    s1 = sigma_arb - 1
    lnN = arb(N).log()
    main = (lnN / s1 + 1 / (s1 * s1)) * (arb(N) ** (-s1))
    edge = lnN * (arb(N) ** (-sigma_arb))
    return main + edge


TAIL = series_tail_bound(arb("3.5"), N_SERIES)


def f_box(tc, hw):
    """acb ball rigorously enclosing f(-5/2 + i t) for
    t in [tc - hw, tc + hw]."""
    s = acb(arb("-2.5"), arb(repr(tc), repr(hw)))
    w1 = (1 - s) / 2
    w2 = s / 2
    psi1 = acb.digamma(w1)
    psi2 = (acb.digamma(w2 + 3) - 1 / w2 - 1 / (w2 + 1) - 1 / (w2 + 2))
    tot = acb(0)
    sm1 = s - 1
    for n, ln in PPOWS:
        tot += acb(repr(ln)) * (acb(n) ** sm1)
    return LOGPI - HALF * psi1 - HALF * psi2 + tot


def f_point(t):
    """Point ball (half-width 0) for cross-checks."""
    return f_box(t, 0.0)


def mpmath_crosscheck():
    import mpmath as mp
    mp.mp.dps = 30
    rows = []
    for t in [0.0, 1.0, 4.7, 10.0]:
        s = mp.mpc(-2.5, t)
        ref = abs(mp.diff(mp.zeta, s) / mp.zeta(s))
        ball = abs(f_point(t))
        mid = float(ball.mid())
        rows.append((t, float(ref), mid, abs(float(ref) - mid)))
    return rows


def main():
    if JSON.exists() and "--force" not in sys.argv:
        print(f"cached: {JSON}")
        return 0
    t0 = time.time()
    checks = {}

    # V1: implementation cross-check (mpmath NOT part of certificate)
    xrows = mpmath_crosscheck()
    checks["V1_fe_vs_mpmath_max_absdiff_lt_2e-6"] = all(
        r[3] < 2e-6 for r in xrows)

    # adaptive box cover of [0, 10]
    n_coarse = int(round(10.0 / (2 * COARSE_HW)))
    queue = [((k + 0.5) * 2 * COARSE_HW, COARSE_HW, 0)
             for k in range(n_coarse)]
    recorded = []   # (lo, hi, |f|.upper)
    n_evals = 0
    max_upper = arb(0)
    argmax = None
    while queue:
        tc, hw, depth = queue.pop()
        v = abs(f_box(tc, hw)).abs_upper()
        n_evals += 1
        if v <= PASS_LEVEL or depth >= MAX_DEPTH:
            recorded.append((tc - hw, tc + hw, v))
            if v > max_upper:
                max_upper = v
                argmax = tc
        else:
            hw10 = hw / 10
            for j in range(10):
                queue.append((tc - hw + (2 * j + 1) * hw10, hw10, depth + 1))
        if n_evals % 20000 == 0:
            print(f"  evals {n_evals}, recorded {len(recorded)}, "
                  f"queue {len(queue)}, max {float(max_upper):.6f} @ {argmax}",
                  flush=True)

    # V2: exact coverage of [0, 10]
    cover = sum(hi - lo for lo, hi, _ in recorded)
    checks["V2_boxes_cover_[0,10]_exactly"] = abs(cover - 10.0) < 1e-9

    certified_max = max_upper + TAIL
    headroom = TARGET - certified_max
    checks["V3_certified_max_le_target"] = bool(certified_max <= TARGET)
    checks["V4_consistent_with_E023_sampled_1.33237"] = bool(
        abs(float(max_upper) - 1.3323650421270834) < 5e-3)

    deepest_fail = None
    key = {
        "experiment": "E-023b",
        "task": "MZeroProp interval-rigorous certification "
                "(ii'-7 follow-up, user directive session 043)",
        "script": "research/numerics/scripts/E-023b-mzero-boxcover.py",
        "method": "adaptive Arb box cover of the segment: FE log-derivative "
                  "evaluated boxwise in ball arithmetic (128-bit) with the "
                  "psi(s/2) pole shift psi(w)=psi(w+3)-1/w-1/(w+1)-1/(w+2), "
                  "Dirichlet series N=400 with certified integral tail; "
                  "x10 subdivision above the pass level; symmetry t<->-t",
        "parameters": {
            "prec_bits": 128,
            "coarse_half_width": COARSE_HW,
            "min_half_width": MIN_HW,
            "max_depth": MAX_DEPTH,
            "pass_level": str(PASS_LEVEL),
            "series_N": N_SERIES,
            "box_evaluations": n_evals,
            "boxes_recorded": len(recorded),
        },
        "checks": checks,
        "key_values": {
            "grid_max_upper": str(max_upper),
            "grid_argmax": argmax,
            "series_tail": str(TAIL),
            "certified_max": str(certified_max),
            "target": "1.3352",
            "headroom": str(headroom),
            "coverage": cover,
        },
        "crosscheck_mpmath": [
            {"t": r[0], "mpmath": r[1], "arb_mid": r[2], "absdiff": r[3]}
            for r in xrows
        ],
        "elapsed_seconds": round(time.time() - t0, 1),
    }

    DATA.mkdir(parents=True, exist_ok=True)
    with open(CSV, "w", newline="") as fh:
        fh.write("quantity,value\n")
        for k, v in key["key_values"].items():
            fh.write(f"{k},{v}\n")
        fh.write(f"box_evaluations,{n_evals}\n")
        fh.write(f"boxes_recorded,{len(recorded)}\n")
        fh.write(f"all_checks_pass,{all(checks.values())}\n")
    with open(JSON, "w") as fh:
        json.dump(key, fh, indent=2)

    print(f"box evaluations: {n_evals}, recorded boxes: {len(recorded)}")
    print(f"max |f| upper = {float(max_upper):.6f} @ t ~ {argmax}")
    print(f"certified_max = {float(certified_max):.6f} vs target 1.3352 "
          f"(headroom {float(headroom):.6f})")
    print("ALL CHECKS PASS" if all(checks.values()) else f"CHECKS FAILED: {checks}")
    return 0 if all(checks.values()) else 1


if __name__ == "__main__":
    sys.exit(main())