← Session 3 — Project kickoff: RH blueprint, staged workflow + archive design
thinking (594 chars)
Now write the E-001 verification script per the numerics conventions (deterministic, CSV+JSON output, db registration). Task 0.4: verify R(ψ₀)=4/3 and R(ψ_MT)=½+(1/√2)cot(1/√2) symbolically.
Script: research/numerics/scripts/E-001-window-constants.py
- Symbolic: define R(ψ) quotient; compute for ψ₀ and ψ_MT via sympy integration; assert equality with 4/3 and ½+(1/√2)cot(1/√2).
- Numeric: mpmath high-precision values of 2−R and (3−R)/2.
- Output CSV: window, R symbolic, R numeric, 2−R, (3−R)/2.
- JSON sidecar with metadata.
Then run, register experiment in db, commit. Also mark 0.4 [x].
Stack installed. Writing the 0.4 verification script following the numerics conventions (deterministic, CSV+JSON dual output).
tool: Write ok
input
{
"file_path": "D:\\Python\\Quantum\\research\\numerics\\scripts\\E-001-window-constants.py",
"content": "\"\"\"E-001 \u2014 Task 0.4: symbolic + numeric verification of window constants.\n\nR(psi) := [\u222b\u03c8\u00b2 + \u222c|u\u2212v|\u03c8(u)\u03c8(v)dudv] / (\u222b\u03c8)\u00b2 on [\u22121/2, 1/2], \u03c8 even.\n\nClaims verified (paper Lemma 5.6; hand-derived in D-004 \u00a77):\n R(\u03c8\u2080) = 4/3 (\u03c8\u2080 = indicator)\n R(\u03c8_MT) = 1/2 + (1/\u221a2)cot(1/\u221a2) (\u03c8_MT = cos(\u221a2 s))\nand the certificates 2 \u2212 R(\u03c8), (3 \u2212 R(\u03c8))/2.\n\nOutputs: research/numerics/data/E-001-window-constants.csv (+ .json sidecar)\n\"\"\"\nimport json\nimport sys\nfrom datetime import datetime, timezone\nfrom pathlib import Path\n\nimport mpmath as mp\nimport sympy as sp\n\nREPO = Path(__file__).resolve().parents[3]\nDATA = REPO / \"research\" / \"numerics\" / \"data\"\nDPS = 50\n\nu, v = sp.symbols(\"u v\", real=True)\nhalf = sp.Rational(1, 2)\n\n\ndef R_symbolic(psi):\n \"\"\"Compute R(\u03c8) symbolically for even \u03c8 on [-1/2, 1/2].\"\"\"\n num1 = sp.integrate(psi**2, (u, -half, half))\n # \u222c|u\u2212v|\u03c8(u)\u03c8(v) = 2\u222b_{u>v}(u\u2212v)\u03c8(u)\u03c8(v) (integrand symmetric)\n inner = sp.integrate((u - v) * psi.subs(u, v), (v, -half, u))\n num2 = 2 * sp.integrate(sp.simplify(psi * inner), (u, -half, half))\n den = sp.integrate(psi, (u, -half, half)) ** 2\n return sp.simplify((num1 + num2) / den)\n\n\ndef main() -> int:\n mp.mp.dps = DPS\n ok = True\n\n psi0 = sp.Integer(1)\n psiMT = sp.cos(sp.sqrt(2) * u)\n\n R0 = R_symbolic(psi0)\n RMT = R_symbolic(psiMT)\n RMT_claim = sp.Rational(1, 2) + sp.cot(1 / sp.sqrt(2)) / sp.sqrt(2)\n\n checks = []\n checks.append((\"R(psi0) == 4/3\",\n sp.simplify(R0 - sp.Rational(4, 3)) == 0, R0))\n checks.append((\"R(psiMT) == 1/2 + (1/sqrt2)cot(1/sqrt2)\",\n sp.simplify(RMT - RMT_claim) == 0, RMT))\n\n rows = []\n for name, R in [(\"psi0\", sp.Rational(4, 3)), (\"psiMT\", RMT_claim)]:\n Rm = mp.mpf(sp.N(R, 60))\n rows.append({\n \"window\": name,\n \"R_exact\": str(R),\n \"R_numeric\": mp.nstr(Rm, 30),\n \"2_minus_R\": mp.nstr(2 - Rm, 30),\n \"distinct_(3-R)/2\": mp.nstr((3 - Rm) / 2, 30),\n })\n\n for label, passed, val in checks:\n print(f\"[{'PASS' if passed else 'FAIL'}] {label} (got {val})\")\n ok &= passed\n\n print(\"\\nCertificates:\")\n for r in rows:\n print(f\" {r['window']:>6}: R = {r['R_numeric']}\")\n print(f\" 2 - R = {r['2_minus_R']} (3-R)/2 = {r['distinct_(3-R)/2']}\")\n\n csv_path = DATA / \"E-001-window-constants.csv\"\n json_path = DATA / \"E-001-window-constants.json\"\n if csv_path.exists() and \"--force\" not in sys.argv:\n print(f\"\\ncached: {csv_path} exists (use --force to recompute)\")\n return 0 if ok else 1\n\n with csv_path.open(\"w\", encoding=\"utf-8\", newline=\"\") as f:\n f.write(\",\".join(rows[0].keys()) + \"\\n\")\n for r in rows:\n f.write(\",\".join(r.values()) + \"\\n\")\n\n meta = {\n \"experiment\": \"E-001\",\n \"task\": \"0.4\",\n \"description\": \"Symbolic+numeric verification of R(psi0)=4/3 and \"\n \"R(psiMT)=1/2+(1/sqrt(2))cot(1/sqrt(2)); certificates \"\n \"2-R and (3-R)/2\",\n \"script\": \"research/numerics/scripts/E-001-window-constants.py\",\n \"parameters\": {\"windows\": [\"psi0\", \"psiMT\"], \"dps\": DPS},\n \"symbolic_checks\": {label: passed for label, passed, _ in checks},\n \"timestamp_utc\": datetime.now(timezone.utc).isoformat(),\n \"row_count\": len(rows),\n }\n json_path.write_text(json.dumps(meta, indent=2), encoding=\"utf-8\")\n print(f\"\\nwrote {csv_path.name}, {json_path.name}\")\n return 0 if ok else 1\n\n\nif __name__ == \"__main__\":\n raise SystemExit(main())\n"
}
result 2026-08-17 18:45:43Z → 2026-08-18 01:26:18Z
File created successfully at: D:\Python\Quantum\research\numerics\scripts\E-001-window-constants.py
raw content_json (database row)
[{"type":"thinking","thinking":"Now write the E-001 verification script per the numerics conventions (deterministic, CSV+JSON output, db registration). Task 0.4: verify R(ψ₀)=4/3 and R(ψ_MT)=½+(1/√2)cot(1/√2) symbolically.\n\nScript: research/numerics/scripts/E-001-window-constants.py\n- Symbolic: define R(ψ) quotient; compute for ψ₀ and ψ_MT via sympy integration; assert equality with 4/3 and ½+(1/√2)cot(1/√2).\n- Numeric: mpmath high-precision values of 2−R and (3−R)/2.\n- Output CSV: window, R symbolic, R numeric, 2−R, (3−R)/2.\n- JSON sidecar with metadata.\n\nThen run, register experiment in db, commit. Also mark 0.4 [x].","signature":""},{"type":"text","text":"Stack installed. Writing the 0.4 verification script following the numerics conventions (deterministic, CSV+JSON dual output)."},{"type":"tool_use","id":"Write_78","name":"Write","input":{"file_path":"D:\\Python\\Quantum\\research\\numerics\\scripts\\E-001-window-constants.py","content":"\"\"\"E-001 — Task 0.4: symbolic + numeric verification of window constants.\n\nR(psi) := [∫ψ² + ∬|u−v|ψ(u)ψ(v)dudv] / (∫ψ)² on [−1/2, 1/2], ψ even.\n\nClaims verified (paper Lemma 5.6; hand-derived in D-004 §7):\n R(ψ₀) = 4/3 (ψ₀ = indicator)\n R(ψ_MT) = 1/2 + (1/√2)cot(1/√2) (ψ_MT = cos(√2 s))\nand the certificates 2 − R(ψ), (3 − R(ψ))/2.\n\nOutputs: research/numerics/data/E-001-window-constants.csv (+ .json sidecar)\n\"\"\"\nimport json\nimport sys\nfrom datetime import datetime, timezone\nfrom pathlib import Path\n\nimport mpmath as mp\nimport sympy as sp\n\nREPO = Path(__file__).resolve().parents[3]\nDATA = REPO / \"research\" / \"numerics\" / \"data\"\nDPS = 50\n\nu, v = sp.symbols(\"u v\", real=True)\nhalf = sp.Rational(1, 2)\n\n\ndef R_symbolic(psi):\n \"\"\"Compute R(ψ) symbolically for even ψ on [-1/2, 1/2].\"\"\"\n num1 = sp.integrate(psi**2, (u, -half, half))\n # ∬|u−v|ψ(u)ψ(v) = 2∫_{u>v}(u−v)ψ(u)ψ(v) (integrand symmetric)\n inner = sp.integrate((u - v) * psi.subs(u, v), (v, -half, u))\n num2 = 2 * sp.integrate(sp.simplify(psi * inner), (u, -half, half))\n den = sp.integrate(psi, (u, -half, half)) ** 2\n return sp.simplify((num1 + num2) / den)\n\n\ndef main() -> int:\n mp.mp.dps = DPS\n ok = True\n\n psi0 = sp.Integer(1)\n psiMT = sp.cos(sp.sqrt(2) * u)\n\n R0 = R_symbolic(psi0)\n RMT = R_symbolic(psiMT)\n RMT_claim = sp.Rational(1, 2) + sp.cot(1 / sp.sqrt(2)) / sp.sqrt(2)\n\n checks = []\n checks.append((\"R(psi0) == 4/3\",\n sp.simplify(R0 - sp.Rational(4, 3)) == 0, R0))\n checks.append((\"R(psiMT) == 1/2 + (1/sqrt2)cot(1/sqrt2)\",\n sp.simplify(RMT - RMT_claim) == 0, RMT))\n\n rows = []\n for name, R in [(\"psi0\", sp.Rational(4, 3)), (\"psiMT\", RMT_claim)]:\n Rm = mp.mpf(sp.N(R, 60))\n rows.append({\n \"window\": name,\n \"R_exact\": str(R),\n \"R_numeric\": mp.nstr(Rm, 30),\n \"2_minus_R\": mp.nstr(2 - Rm, 30),\n \"distinct_(3-R)/2\": mp.nstr((3 - Rm) / 2, 30),\n })\n\n for label, passed, val in checks:\n print(f\"[{'PASS' if passed else 'FAIL'}] {label} (got {val})\")\n ok &= passed\n\n print(\"\\nCertificates:\")\n for r in rows:\n print(f\" {r['window']:>6}: R = {r['R_numeric']}\")\n print(f\" 2 - R = {r['2_minus_R']} (3-R)/2 = {r['distinct_(3-R)/2']}\")\n\n csv_path = DATA / \"E-001-window-constants.csv\"\n json_path = DATA / \"E-001-window-constants.json\"\n if csv_path.exists() and \"--force\" not in sys.argv:\n print(f\"\\ncached: {csv_path} exists (use --force to recompute)\")\n return 0 if ok else 1\n\n with csv_path.open(\"w\", encoding=\"utf-8\", newline=\"\") as f:\n f.write(\",\".join(rows[0].keys()) + \"\\n\")\n for r in rows:\n f.write(\",\".join(r.values()) + \"\\n\")\n\n meta = {\n \"experiment\": \"E-001\",\n \"task\": \"0.4\",\n \"description\": \"Symbolic+numeric verification of R(psi0)=4/3 and \"\n \"R(psiMT)=1/2+(1/sqrt(2))cot(1/sqrt(2)); certificates \"\n \"2-R and (3-R)/2\",\n \"script\": \"research/numerics/scripts/E-001-window-constants.py\",\n \"parameters\": {\"windows\": [\"psi0\", \"psiMT\"], \"dps\": DPS},\n \"symbolic_checks\": {label: passed for label, passed, _ in checks},\n \"timestamp_utc\": datetime.now(timezone.utc).isoformat(),\n \"row_count\": len(rows),\n }\n json_path.write_text(json.dumps(meta, indent=2), encoding=\"utf-8\")\n print(f\"\\nwrote {csv_path.name}, {json_path.name}\")\n return 0 if ok else 1\n\n\nif __name__ == \"__main__\":\n raise SystemExit(main())\n"},"extra_content":null}]