← Session 13 — Phase 4 completion + draft.tex author block
thinking (955 chars)
Now E-028: verify the traced constants numerically and recompute N₀/margins. Script: adapt E-023. Components:
- V-R: compute R(s) at sample points σ ∈ {−2.5, 0.5, 2}, t ∈ {10, 50, 100, 500, 1000} and check |R(s)| ≤ 6.0 log(t+2) + 40 (expect ~5.9 max from E-021's max 4.75 at A=0.9 — huge slack). R(s) computed via zeta_logder (xi route, mpmath dps 30) minus Σ_{|γ−t|<1} 1/(s−ρ) using zeros from E-027 cache (to 3080 — covers t=1000 fine).
- V5: certified Z₂ ≤ 0.5699 (compute partial sum Σ_{n≤10^4} Λ(n)/n² + tail (log N + 1)/N — need Λ(n): sympy or mpmath... compute via factorization of n ≤ 10⁴ — trivial sieve).
- Margin rerun: A = 6.0, B₀ = 40, I_I length 2(√n+1): N₀ new, contiguity, convexity grid, margin at refs, N₁.
- Reuse M₀ = 1.3352 from E-023 JSON (don't recompute the short segment).
Output E-028-traced-margin.csv/.json. Runtime: zeta_logder 15 points at dps 30 — each maybe a second (mp.diff + zeta) — fine, foreground.
Write the script.
Now E-028 — verification of the traced R-bound and margin rerun with the new constants.
tool: Write
input
{
"content": "\"\"\"E-028 \u2014 task 4.5a support: D-056 traced R-bound verification + margin rerun.\n\nComponents:\n V-R. Verify the traced reference-point R-bound (D-056 Theorem R)\n |R(s)| <= 6.0 log(|t|+2) + 40, sigma in [-5/2, 3], |t| >= 10\n at sample points sigma in {-2.5, 0.5, 2}, t in {10,50,100,500,1000}\n (R(s) = zeta'/zeta(s) - sum_{|gamma-t|<1} 1/(s-rho), zeta'/zeta\n via the E-021 xi-route at dps 30; zeros from the E-027 cache).\n V5. Certified Z2 = -zeta'/zeta(2) <= 0.5699: partial sum to 1e4 plus\n tail bound (log N + 1)/N.\n S3'. Margin rerun with the TRACED constants A = 6.0, B0 = 40 (was:\n measured 0.9/1.0, first-estimate 2.0/2.0) and the I_I length fix\n 2(sqrt(n)+1). Recompute N0, contiguity to 4e5, convexity grid to\n N1, margin references. M0 = 1.3352 imported from E-023 (S1).\n\nOutputs: research/numerics/data/E-028-traced-margin.csv (+ .json)\n\"\"\"\nimport csv as csvmod\nimport json\nimport sys\nimport time\nfrom pathlib import Path\n\nimport mpmath as mp\nimport numpy as np\n\nREPO = Path(__file__).resolve().parents[3]\nDATA = REPO / \"research\" / \"numerics\" / \"data\"\nE021 = DATA / \"E-021-sinf-sf-curve.csv\"\nE023J = DATA / \"E-023-assembly.json\"\nZCACHE = DATA / \"E-027-zeros-cache.npy\"\nCSV = DATA / \"E-028-traced-margin.csv\"\nJSON = DATA / \"E-028-traced-margin.json\"\n\nGAMMA = 0.577215664901532860606512090082402431\nC1L = (GAMMA - 1 - np.log(2 * np.pi)) / 2 - GAMMA / 2\nA_TR, B0_TR = 6.0, 40.0\nT0_PLATT = 3.0e12\n\n\ndef zeta_logder(s):\n sm = mp.mpc(s.real, s.imag)\n\n def xi_mp(u):\n return 0.5 * u * (u - 1) * mp.pi ** (-u / 2) * mp.gamma(u / 2) \\\n * mp.zeta(u)\n\n xi_log = mp.diff(xi_mp, sm) / xi_mp(sm)\n return complex(xi_log - 1 / sm - 1 / (sm - 1)\n + mp.mpf(0.5) * mp.log(mp.pi)\n - mp.mpf(0.5) * mp.digamma(sm / 2))\n\n\ndef check_R_bound(zeros):\n mp.mp.dps = 30\n out = []\n for sigma in (-2.5, 0.5, 2.0):\n for t in (10.0, 50.0, 100.0, 500.0, 1000.0):\n s = complex(sigma, t)\n val = zeta_logder(s)\n near = [g for g in zeros if abs(g - t) < 1.0]\n r = val - sum(1.0 / (s - complex(0.5, g)) for g in near)\n bound = 6.0 * np.log(t + 2) + 40.0\n out.append({\"sigma\": sigma, \"t\": t, \"abs_R\": abs(r),\n \"bound\": bound, \"holds\": bool(abs(r) <= bound)})\n return out\n\n\ndef certified_Z2(N=10 ** 4):\n \"\"\"-zeta'/zeta(2) = sum Lambda(n)/n^2; partial sum + tail.\"\"\"\n lam = np.zeros(N + 1)\n sieve = np.zeros(N + 1)\n for p in range(2, N + 1):\n if sieve[p] == 0:\n for m in range(p, N + 1, p):\n sieve[m] = p\n for n in range(2, N + 1):\n p = sieve[n]\n if p > 0 and abs(p ** round(np.log(n) / np.log(p)) - n) < 0.5:\n lam[n] = np.log(p)\n part = float(np.sum(lam[2:] / np.arange(2, N + 1) ** 2))\n tail = (np.log(N) + 1) / N\n return part, tail, part + tail\n\n\ndef F_count(T):\n return (T / (2 * np.pi)) * np.log(T / (2 * np.pi)) - T / (2 * np.pi) \\\n + 7 / 8\n\n\ndef S_bound(T):\n return 0.137 * np.log(T) + 0.443 * np.log(np.log(T)) + 1.588\n\n\ndef C0(t):\n return (F_count(t + 1) - F_count(t)) + S_bound(t + 1) + S_bound(t)\n\n\ndef H_bound(T):\n return 3 * C0(T) ** 2 + A_TR * np.log(T + 2) + B0_TR\n\n\ndef B_bound(n, m0):\n n = float(n)\n T = np.sqrt(n) + 1.0\n twoN = 2 * (F_count(T) + S_bound(T))\n I3_long = 4 * T * ((2 / 3) * C0(T) + A_TR * np.log(T + 2) + B0_TR)\n I3_short = 40.0 * m0\n I24 = 2 * (np.e ** 4 + 1) * (7 * H_bound(T) + 3.3)\n r = np.sqrt(n)\n # I_I length fix: 2T = 2(sqrt(n)+1)\n logI1 = np.log(2 * (r + 1) * 0.5699) + r / 2 - (2 * r - 2) * np.log(2)\n I1 = np.exp(logI1) if logI1 > -700 else 0.0\n return twoN + I3_long + I3_short + I24 + I1 + 1.0\n\n\ndef margin(n, m0):\n n = np.asarray(n, dtype=np.float64)\n return 0.5 * n * np.log(n) + C1L * n - 4.0 - B_bound(n, m0) + 1.0\n\n\ndef main() -> int:\n if JSON.exists() and \"--force\" not in sys.argv:\n print(f\"cached: {JSON} (use --force to recompute)\")\n return 0\n t0 = time.time()\n\n m0 = json.loads(E023J.read_text())[\"key_values\"][\"M0_use\"]\n print(f\"M0 imported from E-023: {m0}\")\n\n print(\"V-R: traced R-bound verification ...\", flush=True)\n zeros = np.load(ZCACHE)\n rpts = check_R_bound(zeros)\n vr = all(p[\"holds\"] for p in rpts)\n worst = max(rpts, key=lambda p: p[\"abs_R\"] / p[\"bound\"])\n print(f\" all {len(rpts)} points hold: {vr}; worst ratio \"\n f\"{worst['abs_R']/worst['bound']:.3f} at \"\n f\"sigma={worst['sigma']}, t={worst['t']}\", flush=True)\n\n print(\"V5: certified Z2 ...\", flush=True)\n part, tail, z2 = certified_Z2()\n v5 = bool(z2 <= 0.5699)\n print(f\" partial {part:.6f} + tail {tail:.6f} = {z2:.6f} \"\n f\"<= 0.5699: {v5}\", flush=True)\n\n print(\"S3': margin rerun with traced constants ...\", flush=True)\n ngrid = np.arange(20, 400001)\n marg = margin(ngrid, m0)\n pos = ngrid[(marg > 0) & (np.gradient(marg, ngrid) > 0)]\n N0 = int(pos[0]) if len(pos) else -1\n cont = bool(np.all(marg[ngrid >= N0] > 0)) if N0 > 0 else False\n margN0 = float(marg[ngrid == N0][0]) if N0 > 0 else float(\"nan\")\n print(f\" N0 (traced 6.0/40) = {N0} (contiguous to 4e5: {cont}, \"\n f\"margin(N0) = {margN0:.1f})\", flush=True)\n\n logn = np.unique(np.logspace(np.log10(max(N0, 20)), np.log10(9e24),\n 4000).astype(np.float64))\n bmarg = margin(logn, m0)\n conv = bool(np.all(np.diff(bmarg, 2) > -1e-6 * bmarg[:-2].max()))\n\n N1 = int(3_000_000_000_000 - 1) ** 2\n refs = {int(n): float(margin(n, m0)) for n in\n [N0, 100000, 500000, 10 ** 6, 10 ** 9, 10 ** 12, 10 ** 18,\n N1]}\n for k, v in refs.items():\n print(f\" margin({k:.3e}) = {v:.4e}\", flush=True)\n v2 = bool(N0 > 0 and cont and conv and N0 < 500000)\n print(f\" convexity grid: {conv}; N0 < 5e5 (MV coverage): \"\n f\"{N0 < 500000}\", flush=True)\n\n with open(CSV, \"w\", newline=\"\") as f:\n w = csvmod.writer(f)\n w.writerow([\"n\", \"margin_traced_6_40\"])\n for n in range(20, 400001, 20):\n w.writerow([n, f\"{float(margin(n, m0)):.6f}\"])\n\n meta = {\n \"experiment\": \"E-028\",\n \"task\": \"4.5a support: D-056 traced R-bound verification + \"\n \"margin rerun with A=6.0, B0=40\",\n \"script\": \"research/numerics/scripts/E-028-traced-margin.py\",\n \"checks\": {\n \"V_R_traced_bound_holds\": {\"pass\": vr, \"points\": rpts},\n \"V5_Z2_certified\": {\"pass\": v5, \"partial\": part,\n \"tail\": tail, \"bound\": z2},\n \"V2_margin_positive_convex\": v2,\n },\n \"key_values\": {\n \"M0_from_E023\": m0,\n \"N0_traced_6_40\": N0,\n \"margin_N0\": margN0,\n \"overlap_factor_vs_MV_5e5\": 500000 / N0 if N0 > 0 else None,\n \"margin_at\": {str(k): v for k, v in refs.items()},\n \"N1\": N1,\n },\n \"elapsed_seconds\": round(time.time() - t0, 1),\n }\n JSON.write_text(json.dumps(meta, indent=2))\n print(f\" wrote {CSV.name}, {JSON.name}; elapsed \"\n f\"{meta['elapsed_seconds']}s\")\n return 0 if (vr and v5 and v2) else 1\n\n\nif __name__ == \"__main__\":\n sys.exit(main())\n",
"file_path": "D:\\Python\\Quantum\\research\\numerics\\scripts\\E-028-traced-margin.py"
}
raw content_json (database row)
[{"type":"thinking","thinking":"Now E-028: verify the traced constants numerically and recompute N₀/margins. Script: adapt E-023. Components:\n- V-R: compute R(s) at sample points σ ∈ {−2.5, 0.5, 2}, t ∈ {10, 50, 100, 500, 1000} and check |R(s)| ≤ 6.0 log(t+2) + 40 (expect ~5.9 max from E-021's max 4.75 at A=0.9 — huge slack). R(s) computed via zeta_logder (xi route, mpmath dps 30) minus Σ_{|γ−t|<1} 1/(s−ρ) using zeros from E-027 cache (to 3080 — covers t=1000 fine).\n- V5: certified Z₂ ≤ 0.5699 (compute partial sum Σ_{n≤10^4} Λ(n)/n² + tail (log N + 1)/N — need Λ(n): sympy or mpmath... compute via factorization of n ≤ 10⁴ — trivial sieve).\n- Margin rerun: A = 6.0, B₀ = 40, I_I length 2(√n+1): N₀ new, contiguity, convexity grid, margin at refs, N₁.\n- Reuse M₀ = 1.3352 from E-023 JSON (don't recompute the short segment).\n\nOutput E-028-traced-margin.csv/.json. Runtime: zeta_logder 15 points at dps 30 — each maybe a second (mp.diff + zeta) — fine, foreground.\n\nWrite the script.","signature":""},{"type":"text","text":"Now E-028 — verification of the traced R-bound and margin rerun with the new constants."},{"type":"tool_use","id":"Write_142","name":"Write","input":{"content":"\"\"\"E-028 — task 4.5a support: D-056 traced R-bound verification + margin rerun.\n\nComponents:\n V-R. Verify the traced reference-point R-bound (D-056 Theorem R)\n |R(s)| <= 6.0 log(|t|+2) + 40, sigma in [-5/2, 3], |t| >= 10\n at sample points sigma in {-2.5, 0.5, 2}, t in {10,50,100,500,1000}\n (R(s) = zeta'/zeta(s) - sum_{|gamma-t|<1} 1/(s-rho), zeta'/zeta\n via the E-021 xi-route at dps 30; zeros from the E-027 cache).\n V5. Certified Z2 = -zeta'/zeta(2) <= 0.5699: partial sum to 1e4 plus\n tail bound (log N + 1)/N.\n S3'. Margin rerun with the TRACED constants A = 6.0, B0 = 40 (was:\n measured 0.9/1.0, first-estimate 2.0/2.0) and the I_I length fix\n 2(sqrt(n)+1). Recompute N0, contiguity to 4e5, convexity grid to\n N1, margin references. M0 = 1.3352 imported from E-023 (S1).\n\nOutputs: research/numerics/data/E-028-traced-margin.csv (+ .json)\n\"\"\"\nimport csv as csvmod\nimport json\nimport sys\nimport time\nfrom pathlib import Path\n\nimport mpmath as mp\nimport numpy as np\n\nREPO = Path(__file__).resolve().parents[3]\nDATA = REPO / \"research\" / \"numerics\" / \"data\"\nE021 = DATA / \"E-021-sinf-sf-curve.csv\"\nE023J = DATA / \"E-023-assembly.json\"\nZCACHE = DATA / \"E-027-zeros-cache.npy\"\nCSV = DATA / \"E-028-traced-margin.csv\"\nJSON = DATA / \"E-028-traced-margin.json\"\n\nGAMMA = 0.577215664901532860606512090082402431\nC1L = (GAMMA - 1 - np.log(2 * np.pi)) / 2 - GAMMA / 2\nA_TR, B0_TR = 6.0, 40.0\nT0_PLATT = 3.0e12\n\n\ndef zeta_logder(s):\n sm = mp.mpc(s.real, s.imag)\n\n def xi_mp(u):\n return 0.5 * u * (u - 1) * mp.pi ** (-u / 2) * mp.gamma(u / 2) \\\n * mp.zeta(u)\n\n xi_log = mp.diff(xi_mp, sm) / xi_mp(sm)\n return complex(xi_log - 1 / sm - 1 / (sm - 1)\n + mp.mpf(0.5) * mp.log(mp.pi)\n - mp.mpf(0.5) * mp.digamma(sm / 2))\n\n\ndef check_R_bound(zeros):\n mp.mp.dps = 30\n out = []\n for sigma in (-2.5, 0.5, 2.0):\n for t in (10.0, 50.0, 100.0, 500.0, 1000.0):\n s = complex(sigma, t)\n val = zeta_logder(s)\n near = [g for g in zeros if abs(g - t) < 1.0]\n r = val - sum(1.0 / (s - complex(0.5, g)) for g in near)\n bound = 6.0 * np.log(t + 2) + 40.0\n out.append({\"sigma\": sigma, \"t\": t, \"abs_R\": abs(r),\n \"bound\": bound, \"holds\": bool(abs(r) <= bound)})\n return out\n\n\ndef certified_Z2(N=10 ** 4):\n \"\"\"-zeta'/zeta(2) = sum Lambda(n)/n^2; partial sum + tail.\"\"\"\n lam = np.zeros(N + 1)\n sieve = np.zeros(N + 1)\n for p in range(2, N + 1):\n if sieve[p] == 0:\n for m in range(p, N + 1, p):\n sieve[m] = p\n for n in range(2, N + 1):\n p = sieve[n]\n if p > 0 and abs(p ** round(np.log(n) / np.log(p)) - n) < 0.5:\n lam[n] = np.log(p)\n part = float(np.sum(lam[2:] / np.arange(2, N + 1) ** 2))\n tail = (np.log(N) + 1) / N\n return part, tail, part + tail\n\n\ndef F_count(T):\n return (T / (2 * np.pi)) * np.log(T / (2 * np.pi)) - T / (2 * np.pi) \\\n + 7 / 8\n\n\ndef S_bound(T):\n return 0.137 * np.log(T) + 0.443 * np.log(np.log(T)) + 1.588\n\n\ndef C0(t):\n return (F_count(t + 1) - F_count(t)) + S_bound(t + 1) + S_bound(t)\n\n\ndef H_bound(T):\n return 3 * C0(T) ** 2 + A_TR * np.log(T + 2) + B0_TR\n\n\ndef B_bound(n, m0):\n n = float(n)\n T = np.sqrt(n) + 1.0\n twoN = 2 * (F_count(T) + S_bound(T))\n I3_long = 4 * T * ((2 / 3) * C0(T) + A_TR * np.log(T + 2) + B0_TR)\n I3_short = 40.0 * m0\n I24 = 2 * (np.e ** 4 + 1) * (7 * H_bound(T) + 3.3)\n r = np.sqrt(n)\n # I_I length fix: 2T = 2(sqrt(n)+1)\n logI1 = np.log(2 * (r + 1) * 0.5699) + r / 2 - (2 * r - 2) * np.log(2)\n I1 = np.exp(logI1) if logI1 > -700 else 0.0\n return twoN + I3_long + I3_short + I24 + I1 + 1.0\n\n\ndef margin(n, m0):\n n = np.asarray(n, dtype=np.float64)\n return 0.5 * n * np.log(n) + C1L * n - 4.0 - B_bound(n, m0) + 1.0\n\n\ndef main() -> int:\n if JSON.exists() and \"--force\" not in sys.argv:\n print(f\"cached: {JSON} (use --force to recompute)\")\n return 0\n t0 = time.time()\n\n m0 = json.loads(E023J.read_text())[\"key_values\"][\"M0_use\"]\n print(f\"M0 imported from E-023: {m0}\")\n\n print(\"V-R: traced R-bound verification ...\", flush=True)\n zeros = np.load(ZCACHE)\n rpts = check_R_bound(zeros)\n vr = all(p[\"holds\"] for p in rpts)\n worst = max(rpts, key=lambda p: p[\"abs_R\"] / p[\"bound\"])\n print(f\" all {len(rpts)} points hold: {vr}; worst ratio \"\n f\"{worst['abs_R']/worst['bound']:.3f} at \"\n f\"sigma={worst['sigma']}, t={worst['t']}\", flush=True)\n\n print(\"V5: certified Z2 ...\", flush=True)\n part, tail, z2 = certified_Z2()\n v5 = bool(z2 <= 0.5699)\n print(f\" partial {part:.6f} + tail {tail:.6f} = {z2:.6f} \"\n f\"<= 0.5699: {v5}\", flush=True)\n\n print(\"S3': margin rerun with traced constants ...\", flush=True)\n ngrid = np.arange(20, 400001)\n marg = margin(ngrid, m0)\n pos = ngrid[(marg > 0) & (np.gradient(marg, ngrid) > 0)]\n N0 = int(pos[0]) if len(pos) else -1\n cont = bool(np.all(marg[ngrid >= N0] > 0)) if N0 > 0 else False\n margN0 = float(marg[ngrid == N0][0]) if N0 > 0 else float(\"nan\")\n print(f\" N0 (traced 6.0/40) = {N0} (contiguous to 4e5: {cont}, \"\n f\"margin(N0) = {margN0:.1f})\", flush=True)\n\n logn = np.unique(np.logspace(np.log10(max(N0, 20)), np.log10(9e24),\n 4000).astype(np.float64))\n bmarg = margin(logn, m0)\n conv = bool(np.all(np.diff(bmarg, 2) > -1e-6 * bmarg[:-2].max()))\n\n N1 = int(3_000_000_000_000 - 1) ** 2\n refs = {int(n): float(margin(n, m0)) for n in\n [N0, 100000, 500000, 10 ** 6, 10 ** 9, 10 ** 12, 10 ** 18,\n N1]}\n for k, v in refs.items():\n print(f\" margin({k:.3e}) = {v:.4e}\", flush=True)\n v2 = bool(N0 > 0 and cont and conv and N0 < 500000)\n print(f\" convexity grid: {conv}; N0 < 5e5 (MV coverage): \"\n f\"{N0 < 500000}\", flush=True)\n\n with open(CSV, \"w\", newline=\"\") as f:\n w = csvmod.writer(f)\n w.writerow([\"n\", \"margin_traced_6_40\"])\n for n in range(20, 400001, 20):\n w.writerow([n, f\"{float(margin(n, m0)):.6f}\"])\n\n meta = {\n \"experiment\": \"E-028\",\n \"task\": \"4.5a support: D-056 traced R-bound verification + \"\n \"margin rerun with A=6.0, B0=40\",\n \"script\": \"research/numerics/scripts/E-028-traced-margin.py\",\n \"checks\": {\n \"V_R_traced_bound_holds\": {\"pass\": vr, \"points\": rpts},\n \"V5_Z2_certified\": {\"pass\": v5, \"partial\": part,\n \"tail\": tail, \"bound\": z2},\n \"V2_margin_positive_convex\": v2,\n },\n \"key_values\": {\n \"M0_from_E023\": m0,\n \"N0_traced_6_40\": N0,\n \"margin_N0\": margN0,\n \"overlap_factor_vs_MV_5e5\": 500000 / N0 if N0 > 0 else None,\n \"margin_at\": {str(k): v for k, v in refs.items()},\n \"N1\": N1,\n },\n \"elapsed_seconds\": round(time.time() - t0, 1),\n }\n JSON.write_text(json.dumps(meta, indent=2))\n print(f\" wrote {CSV.name}, {JSON.name}; elapsed \"\n f\"{meta['elapsed_seconds']}s\")\n return 0 if (vr and v5 and v2) else 1\n\n\nif __name__ == \"__main__\":\n sys.exit(main())\n","file_path":"D:\\Python\\Quantum\\research\\numerics\\scripts\\E-028-traced-margin.py"},"extra_content":null}]