← Session 9 — Phase 4 synthesis assault + paper draft cleanup
thinking (7963 chars)
Task 2.13 (E-025): λ-flow numerics. Goal: compute Δ(a;λ), locking, residual R(a;λ) as λ ↑ λ_a(a)⁻.
Design considerations:
1. **What changes with λ?** T_a(λ) = A_a − λI — in the Galerkin: T(λ) = Q − λM (Q stiffness-like, M mass). Our numerics used λ = −1 (T = Q + M). The true λ_a = bottom eigenvalue of the pencil (Q, M) restricted to the mean-zero subspace — λ_a(a) ~ e^{−1.65a}. As λ ↑ λ_a, T(λ) becomes near-singular: the bottom eigenvector v_a (ground state) dominates T(λ)^{-1}.
K_λ(z,z) = ⟨e_z, T(λ)^{-1} e_z⟩ (bordered/constrained). As λ → λ_a⁻: T(λ)^{-1} ≈ (1/(λ_a−λ))·P_{v_a} + bounded. So K_λ(z,z) ≈ |⟨e_z, v_a⟩|²/(λ_a−λ). If ⟨e_z, v_a⟩ (the ground state's Fourier content at z) VARIES with z — specifically if it dips at γ's — the valley structure changes.
Actually the sister conjecture (1.2): c_a·v̂_a(z) → ξ(1/2+iz) — the ground state's FT converges to ξ. If v̂_a(z) ≈ ξ(1/2−iz)-ish, then ⟨e_z, v_a⟩ = v̂_a(−z)... has ZEROS at γ's! So K_λ(γ,γ) ≈ |v̂_a(γ)|²/(λ_a−λ) ≈ 0 — deep valleys at γ's with depth → ∞ as v̂_a → ξ! And plateau K_λ(z,z) ≈ |v̂_a(z)|²/(λ_a−λ) large where ξ nonzero. So in the ground-state-dominated regime, the valley depth Δ ~ log[K(z,z)/K(γ,γ)] ~ 2 log|v̂_a(z)/v̂_a(γ)| — measuring Δ vs λ directly tests whether v̂_a acquires ξ's zero structure!
2. **What to compute**:
- λ_a(a) for a ∈ {4, 8, 12} (bottom eigenvalue of the constrained pencil (Q,M)). E-009b machinery measured λ_a — how? Probably via eigsh on the projected pencil. n = 2399 at a=12: eigsh for smallest eigenvalue of Q − λM... generalized eigenproblem Q u = λ M u with constraint. M is tridiagonal (well-conditioned), Q Toeplitz. eigsh with which='SM' — slow for n=2400 dense... E-009 used QR-projection Z (line 231: Z = qr(ones)[:,1:]) then dense eigh? n=2400 dense eigh is 10–30 s — fine.
- Then for λ/λ_a ∈ {0.5, 0.9, 0.99, 0.999, ...} wait — λ ranges from −1 (current) up to λ_a: λ/λ_a with λ_a tiny (e^{−6.6} ≈ 1.4e-3 at a=4): λ ∈ {−1, 0, 0.5λ_a, 0.9λ_a, 0.99λ_a, 0.999λ_a, 0.9999λ_a}. Note λ=0 = the "true" A_a (Suzuki's RH-case operator). λ=0 is already much closer to λ_a than −1 is (relative to the gap λ_a − (−1) = 1.0014, λ=0 is at 99.86% of the way!). Hmm interesting — λ=0 vs λ=−1: does K change much? Then the near-singular values.
- For each (a, λ): K_λ(z,z) on the z-grid [14,60] step 0.05 (valley depth), plus zeros/weights? The zeros of W with λ-shifted T: the deficiency vectors v±(λ) solve T(λ)v = b±: the zeros move with λ. D-026 §7: zeros "expected λ-independent" (Suzuki remark). Measure: z₁·a, lattice, mass concentration vs λ.
Key metrics per (a, λ):
- Δ(λ) = plateau − floor (logK at midpoints − logK at γ's)
- valley floor K_λ(γ,γ): does it DROP (locking: K(γ,γ) → ... target K(γ,γ)=1 gives mass 1; floor < 1 means mass > 1?!) hmm — the valley floor ≈ 1 at λ=−1; under ground-state dominance K(γ,γ) = |v̂_a(γ)|²/(λ_a−λ) → 0 if v̂_a(γ) → 0 — floor DROPS below 1. Then weights 1/K at valley atoms EXCEED 1 — the mass per valley overshoots... The consolidation criterion in the λ-flow: unclear a priori — measure everything: Δ, floor, plateau, residual, and directly |v̂_a(z)| structure vs ξ (the sister-conjecture observable!).
3. **Also measure v̂_a directly**: v_a = bottom eigenvector (nodal values); v̂_a(z) = hat_FT·Σ e^{izx}v_a(x); compare c_a·v̂_a(z) vs ξ(1/2−iz) = Ξ(z) (real on ℝ) — correlation, zero crossings near γ's! That's the DIRECT test of conjecture (1.2) at finite a. This is huge value: E-025 tests the sister conjecture's finite-a behavior as a bonus.
Compute: for a ∈ {4, 8, 12}: v_a (bottom eigenvector of constrained pencil), v̂_a on z-grid, normalized (c_a = 1/v̂_a(0) or L²-normalized over the grid), then: (i) zero crossings of v̂_a vs γ's (locking of the ground state's zeros!); (ii) |v̂_a(γ)|/|v̂_a|_max (valley ratio); (iii) correlation with Ξ(z) on the grid.
4. Numerical care: λ near λ_a: T(λ) = Q − λM near-singular: solve_toeplitz handles it? Condition number ~ 1/(λ_a−λ) up to 1e4–1e12 relative... Levinson on ill-conditioned Toeplitz: residuals grow. For λ = 0.9999λ_a at a=12 (λ_a ~ 2.5e-9): gap 2.5e-13 — below float64 resolution of the matrix entries (~1e-16 relative on O(1) entries → absolute ~1e-16; gap 2.5e-13 resolvable but Levinson stability questionable). Use a ladder λ/λ_a ∈ {−1(a=..), 0, 0.9, 0.99, 0.999} and check residuals; maybe stop at 0.999. Also the bordered constraint: the bottom eigenvector of the CONSTRAINED problem (mean-zero): v_a ⟂ e. The constraint handles the exact-null direction? T(λ_a) has a null vector in the constrained space — bordered solve breaks down at exactly λ_a. Stay at λ < λ_a strictly.
Also — which λ_a: the pencil (Q, M) on the mean-zero subspace. E-009 line 231 projects with Z. Compute λ_a via projected generalized eigh: Z^T Q Z vs Z^T M Z, dense eigh, smallest eigenvalue. n=2399: Z is n×(n−1) dense — matrices 2400² × 8B = 46MB each ✓; eigh ~30-60 s per a ✓.
Validation: λ_a vs E-009b/D-019 values? D-019 F1: λ_a cliff 0.414 (a=0.25) → ≤1.7e-12 (a=5). At a=4: ~e^{−1.65·4} = 1.35e-3; a=8: e^{−13.2} = 1.9e-6; a=12: e^{−19.8} = 2.5e-9. Check orders match D-017's e^{−1.65a} law.
5. W-zeros under λ-flow: do we need them? The locking metric: zeros of W(a,θ;z;λ) with λ-shifted T: v±(λ) = solve T(λ) v = b±. As λ ↑ λ_a: v± ≈ (⟨b±,v_a⟩/(λ_a−λ))·v_a + ... both dominated by v_a: V±(z) ≈ const·v̂_a(z)·(1/(λ_a−λ)): W ≈ (z−i)V₊ + e^{iθ}(z+i)V₋ ∝ v̂_a(z)·[(z−i)c₊ + e^{iθ}(z+i)c₋] — zeros of W → zeros of v̂_a(z)·linear(z) — i.e., **the W-zeros should flow to the zeros of v̂_a** as λ ↑ λ_a!! And if v̂_a ≈ Ξ, those are the γ's! That's the locking mechanism, explicitly. So YES compute W-zeros under λ-flow: locking metric = distance from W-zeros to γ's vs λ. THIS is the decisive observable: if zeros lock to γ's as λ ↑ λ_a, the consolidation channel is OPEN.
Cost: locate_zeros per (a, λ) — grid eval + brentq — ~1-2 min per (a,λ) at a=12. λ-ladder ~6 values × 3 a's: ~30 min. OK.
6. Structure:
per a in {4, 8, 12}:
build, λ_a (projected eigh), v_a
v̂_a on grid: zero-crossings vs γ (sister-conjecture metric)
for λ in ladder {−1, 0, 0.5, 0.9, 0.99, 0.999}·λ_a (λ=−1 absolute for baseline; others relative):
K_λ on z-grid [14,60] → Δ, floor, plateau
v±(λ) solves → zeros → locking metric: mean over first 20 γ's of min-dist / (π/2a) (normalized: 1 = chance), mass within ±0.1, residual
Checks:
V1: λ_a matches e^{−1.65a} law order (documented)
V2: λ=−1 baseline reproduces E-022/E-024 values (Δ, z₁·a)
V3: T(λ) solves residual < tol (Levinson stability at near-singular)
V4: v̂_a vs Ξ correlation reported
Let me write E-025. Note runtime: eigendecomposition per a ~1 min; K-grids: 920 pts × 6 λ × 3 a × ~50ms = 5 min; zero-location: 18 grid evals (40000×n matrices ~1.5GB at a=12) ~1 min each: ~20 min. Total ~30 min. Detached.
One question: does solve_v's bordered approach still apply with λ? T = Q − λM ✓ same form. For λ exactly at λ_a: singular in constrained space — ladder stays below.
For the locking metric I need zeros from g(z) = z ImV₊ − Re V₊ (θ=π) with V₊ built from v₊(λ) = cp(λ). ✓.
v̂_a zero crossings: sign changes of v̂_a (real? v_a real nodal → v̂_a(z) = hat_FT·Σ e^{izx}v_j — complex. Ξ(z) real. The comparison: |v̂_a(z)| zeros? The ground state v_a is real (real pencil); v̂_a(z) complex with conj symmetry v̂_a(−z) = conj(v̂_a(z)); Re v̂_a even, Im odd. ξ(1/2−iz) = Ξ(z) real even. So compare Re v̂_a vs Ξ. Zero crossings of Re v̂_a on z>0 vs γ's.)
Sister conjecture (1.2): c_a v̂_a(z) → ξ(1/2+iz) = Ξ(z) (real). Compare c_a·Re v̂_a(z) with Ξ(z): c_a = Ξ(0)/v̂... Ξ(0) = ξ(1/2) ≈ −1.49...? ξ(1/2) = 0.5·0.5·(−0.5)·π^{−1/4}Γ(1/4)ζ(1/2)... ξ(1/2) = −1.4956? hmm sign. Use least-squares c_a = ⟨v̂, Ξ⟩/⟨v̂,v̂⟩ over grid.
Metrics for sister conjecture:
- correlation corr(Re v̂_a, Ξ) on [14,60]
- zero-crossing match: first 10 crossings vs γ₁..γ₁₀: mean |Δz|
- |Re v̂_a(γ_k)| relative to local amplitude.
Let me write the script.
Proceeding with E-025 (λ-flow). Design note: as λ ↑ λ_a, the deficiency vectors v± become ground-state-dominated, so W's zeros should flow toward the zeros of v̂_a — and if the sister conjecture (1.2) holds (v̂_a → Ξ), those are the γ's. So E-025 tests locking directly, plus measures v̂_a vs Ξ as a bonus.
tool: Write ok
input
{
"file_path": "D:\\Python\\Quantum\\research\\numerics\\scripts\\E-025-lambda-flow.py",
"content": "\"\"\"E-025 \u2014 task 2.13: lambda-flow numerics (D-042 \u00a73, Suzuki's lever).\n\nAt fixed lambda = -1 the family D_{a,theta} equilibrates at the\nconsolidation boundary (linear-K law, D-042). The remaining channel:\nlambda -> lambda_a^- (bottom of the Weil-form spectrum, lambda_a ~\ne^{-1.65a}), where T_a(lambda) = Q - lambda M becomes near-singular\nand the ground state v_a dominates \u2014 the regime of Suzuki's sister\nconjecture (1.2) (c_a v^_a -> xi(1/2+iz) = Xi(z)).\n\nMechanism being tested: as lambda -> lambda_a^-, the deficiency\nvectors v_pm(lambda) ~ v_a/(lambda_a - lambda), so the zeros of\nW(a,theta;.) flow toward the zeros of v^_a; if v^_a ~ Xi, those are\nthe gamma's => locking.\n\nPer a in {4, 8, 12}:\n A. lambda_a and ground state v_a: smallest generalized eigenpair of\n the pencil (Q, M) restricted to the mean-zero subspace (QR\n projection, dense eigh; n <= 2400).\n B. sister-conjecture observable: v^_a(z) = hat_FT * sum e^{izx} v_a\n on z-grid; correlation of Re v^_a with Xi(z) (flint xi), zero\n crossings vs the first gammas.\n C. lambda ladder: lambda/lambda_a in {-1(abs), 0, 0.5, 0.9, 0.99,\n 0.999}: K_lambda(z,z) on z-grid in [14,60] (valley depth\n Delta(lambda), floor, plateau); zeros of W (theta=pi) ->\n LOCKING metric: mean over first 20 gammas of dist(gamma, nearest\n W-zero)/(pi/2a) (1.0 = chance level); residual mass R(lambda).\n\nChecks:\n V1. lambda_a positive and consistent with the e^{-1.65a} law\n (order of magnitude; D-017/D-019).\n V2. lambda=-1 baseline reproduces E-022: z1*a in [4.3,4.7],\n Delta within 0.05 of E-022b valley depth.\n V3. Levinson residuals sane at all ladder rungs\n (|T v - b|/|b| < 1e-6 except possibly the 0.999 rung, reported).\n V4. sister observable reported (correlation v^_a vs Xi).\n\nOutputs: research/numerics/data/E-025-lambda-flow.csv (+ .json)\n\"\"\"\nimport importlib.util\nimport json\nimport sys\nimport time\nfrom datetime import datetime, timezone\nfrom pathlib import Path\n\nimport flint\nimport mpmath as mp\nimport numpy as np\nimport scipy.linalg\nimport scipy.optimize\n\nREPO = Path(__file__).resolve().parents[3]\nDATA = REPO / \"research\" / \"numerics\" / \"data\"\nCSV = DATA / \"E-025-lambda-flow.csv\"\nJSON = DATA / \"E-025-lambda-flow.json\"\n\n_spec = importlib.util.spec_from_file_location(\n \"E16\", Path(__file__).with_name(\"E-016-herglotz-fine-structure.py\"))\nE16 = importlib.util.module_from_spec(_spec)\n_spec.loader.exec_module(E16) # runs the e^20 sieve\nsys.path.insert(0, str(Path(__file__).parent))\nfrom prime_backend_v2 import PrimeBackendV2 # noqa: E402\n\nH = E16.H_MAIN\nLAM0 = E16.LAM_SHIFT # -1.0 baseline\nA_LIST = [4.0, 8.0, 12.0]\nLADDER_REL = [0.0, 0.5, 0.9, 0.99, 0.999] # x lambda_a (plus lam=-1)\nZ_MAX = 300.0\nZ_METRIC = 280.0\nN_GRID = 40000\nXN = E16.XN\nmp.mp.dps = 40\n\n\ndef collect_t_points(a, h):\n n_elem = int(round(2 * a / h))\n pts = []\n\n def add_quad(lo, hi, peak):\n n_lo = int(np.ceil(np.exp(lo)))\n n_hi = int(np.floor(np.exp(hi)))\n if n_hi - n_lo > 64:\n for aa, bb in ((lo, peak), (peak, hi)):\n if bb - aa > 0:\n mid, half = 0.5 * (aa + bb), 0.5 * (bb - aa)\n pts.extend(mid + half * XN)\n return\n segs = sorted({lo, peak, hi} |\n {float(np.log(n))\n for n in range(max(n_lo, 2), n_hi + 1)\n if lo < np.log(n) < hi})\n for p0, p1 in zip(segs, segs[1:]):\n if p1 - p0 > 0:\n mid, half = 0.5 * (p0 + p1), 0.5 * (p1 - p0)\n pts.extend(mid + half * XN)\n\n for k in range(n_elem):\n if k == 0:\n add_quad(0.0, h, 0.0)\n else:\n add_quad((k - 1) * h, (k + 1) * h, k * h)\n return np.array(pts)\n\n\ndef xi_real(z):\n \"\"\"Xi(z) = xi(1/2 - i z) via flint (real on R).\"\"\"\n flint.ctx.prec = 120\n out = np.empty(len(z))\n for i, zz in enumerate(z):\n s = flint.acb(0.5, -float(zz))\n val = (0.5 * s * (s - 1) * flint.acb.pi() ** (-s / 2)\n * (s / 2).gamma() * s.zeta())\n out[i] = float(val.real)\n return out\n\n\ndef locate_zeros_pi(cp, x, h, z_max=Z_MAX, n_grid=N_GRID):\n zg = np.linspace(1e-3, z_max, n_grid)\n Vpr, _ = E16.V_and_dV(zg, cp, x, h)\n g = zg * Vpr.imag - Vpr.real\n\n def g_direct(zz):\n V = E16.hat_FT(np.array([zz]), h)[0] * complex(\n np.exp(1j * zz * x) @ cp)\n return zz * V.imag - V.real\n\n idx = np.flatnonzero(np.sign(g[:-1]) * np.sign(g[1:]) < 0)\n zeros = []\n for i in idx:\n try:\n zeros.append(scipy.optimize.brentq(g_direct, zg[i], zg[i + 1],\n xtol=1e-13, rtol=1e-13))\n except ValueError:\n pass\n return np.array(zeros)\n\n\ndef ground_state(Q, M):\n \"\"\"Smallest generalized eigenpair of (Q, M) on the mean-zero\n subspace (E-009 route: QR projection).\"\"\"\n n = Q.shape[0]\n Z = np.linalg.qr(np.ones((n, 1)), mode=\"complete\")[0][:, 1:]\n Qp = Z.T @ Q @ Z\n Mp = Z.T @ M @ Z\n evals, evecs = scipy.linalg.eigh(Qp, Mp)\n lam_a = float(evals[0])\n v = Z @ evecs[:, 0]\n return lam_a, v\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 print(\"backend: load E-022 cache ...\", flush=True)\n tq = np.concatenate([collect_t_points(a, H) for a in A_LIST])\n be = PrimeBackendV2(tq)\n be.load_cache(DATA / \"E-022-backend-cache.npz\")\n E16._BUILD.clear()\n E16.prime_sum_vec = be.prime_sum\n\n mp.mp.dps = 30\n gam = np.array([float(mp.zetazero(k).imag) for k in range(1, 201)])\n gam = gam[gam <= Z_METRIC]\n\n zgrid = np.arange(14.0, 60.0, 0.05)\n gsel = gam[(gam >= 14) & (gam < 60)]\n mids = (gsel[:-1] + gsel[1:]) / 2\n idxg = np.round((gsel - 14) / 0.05).astype(int)\n idxm = np.round((mids - 14) / 0.05).astype(int)\n XI = xi_real(zgrid)\n\n rows = []\n report = {\"per_a\": {}}\n v1_ok = v2_ok = v3_ok = True\n e022b_dip = {4.0: 2.1593, 8.0: 2.7352, 12.0: 2.9442}\n\n for a in A_LIST:\n ta = time.time()\n x, h, Q, M, b = E16.build(a, H)\n n = len(x)\n\n # A: ground state\n lam_a, v_a = ground_state(Q, M)\n if not (lam_a > 0):\n v1_ok = False\n law = np.exp(-1.65 * a)\n print(f\"a={a:g}: lambda_a = {lam_a:.3e} (e^-1.65a = {law:.1e})\",\n flush=True)\n\n # B: sister-conjecture observable\n E = np.exp(1j * np.outer(zgrid, x))\n vhat = E16.hat_FT(zgrid, h) * (E @ v_a)\n rv = vhat.real\n ca = float(np.dot(rv, XI) / np.dot(rv, rv))\n corr = float(np.corrcoef(rv, XI)[0, 1])\n # zero crossings of Re v^_a on grid\n sc = np.flatnonzero(np.sign(rv[:-1]) * np.sign(rv[1:]) < 0)\n cross = zgrid[sc]\n ncr = min(10, len(cross), len(gsel))\n xerr = float(np.mean(np.abs(cross[:ncr] - gsel[:ncr]))) \\\n if ncr else float(\"nan\")\n print(f\" sister: corr(v^,Xi) = {corr:+.4f}, {len(cross)} \"\n f\"crossings, mean |cross-gamma| (first {ncr}) = {xerr:.3f}\",\n flush=True)\n\n per = {\"lambda_a\": lam_a, \"lambda_law_ratio\": lam_a / law,\n \"sister_corr\": corr, \"sister_crossings\": int(len(cross)),\n \"sister_cross_err\": xerr, \"ladder\": {}}\n\n # C: lambda ladder\n for tag, lam in ([(\"-1\", LAM0)]\n + [(f\"{r:g}\", r * lam_a) for r in LADDER_REL]):\n tc = Q[:, 0] - lam * (np.r_[2 * h / 3, h / 6,\n np.zeros(max(n - 2, 0))])\n u1 = scipy.linalg.solve_toeplitz((tc, tc), np.ones(n))\n s1 = u1.sum()\n\n def K1(z, _tc=tc, _u1=u1, _s1=s1):\n bz = E16.hat_FT(np.array([z]), h)[0] * np.exp(-1j * z * x)\n u0 = scipy.linalg.solve_toeplitz((_tc, _tc), bz)\n v = u0 - (u0.sum() / _s1) * _u1\n return float(np.real(np.conj(bz) @ v)), \\\n float(np.max(np.abs(\n scipy.linalg.toeplitz(_tc) @ v\n + ((u0.sum() / _s1)) * np.ones(n)\n - bz)) / max(1.0, np.max(np.abs(bz))))\n\n lg = np.empty(len(zgrid))\n resmax = 0.0\n for i, zz in enumerate(zgrid):\n kv, rs = K1(zz)\n lg[i] = np.log(max(kv, 1e-300))\n resmax = max(resmax, rs)\n if resmax > 1e-6:\n v3_ok = False\n dip = float(lg[idxm].mean() - lg[idxg].mean())\n floor = float(lg[idxg].mean())\n plate = float(lg[idxm].mean())\n\n # zeros of W (theta=pi) at this lambda\n Tm = scipy.linalg.toeplitz(tc)\n nn = n\n BB = np.zeros((nn + 1, nn + 1))\n BB[:nn, :nn] = Tm\n BB[:nn, nn] = 1.0\n BB[nn, :nn] = 1.0\n cp = scipy.linalg.solve(BB, np.r_[b[+1.0], 0.0],\n assume_a=\"sym\")[:nn]\n zeros = locate_zeros_pi(cp, x, h)\n zm = zeros[zeros <= Z_METRIC]\n # locking: mean normalized distance of first 20 gammas\n d20 = []\n for g in gam[:20]:\n d20.append(np.min(np.abs(zm - g)))\n lock = float(np.mean(d20) / (np.pi / (2 * a)))\n # weights & residual\n ws = np.array([1.0 / K1(z)[0] for z in zm])\n near_idx = np.array([np.argmin(np.abs(zm - g)) for g in gam])\n resid = float(ws.sum() - ws[near_idx].sum())\n m01 = float(ws[np.minimum.reduce([\n np.abs(zm - g) for g in gam]).reshape(-1) <= 0.1].sum()) \\\n if len(zm) else 0.0\n\n per[\"ladder\"][tag] = {\n \"lambda\": lam, \"Delta\": dip, \"floor\": floor,\n \"plateau\": plate, \"z1_times_a\": float(zeros[0] * a),\n \"n_zeros\": int(len(zeros)),\n \"lock_metric\": lock, \"residual\": resid,\n \"mass_pm0.1\": m01, \"solve_resid\": resmax,\n }\n print(f\" lam={tag}*lam_a ({lam:.3e}): Delta={dip:.3f}, \"\n f\"z1a={zeros[0] * a:.3f}, lock={lock:.3f}, \"\n f\"resid={resid:.1f}, K-resid={resmax:.1e}\", flush=True)\n for zz, ll in zip(zgrid, lg):\n rows.append((a, tag, zz, ll))\n\n # V2: baseline checks (lambda = -1)\n base = per[\"ladder\"][\"-1\"]\n if not (4.3 < base[\"z1_times_a\"] < 4.7):\n v2_ok = False\n if abs(base[\"Delta\"] - e022b_dip[a]) > 0.05:\n v2_ok = False\n report[\"per_a\"][f\"{a:g}\"] = per\n print(f\"a={a:g} done ({time.time() - ta:.0f}s)\", flush=True)\n\n checks = {\"V1_lambda_a_positive_law\": v1_ok,\n \"V2_baseline_matches_E022\": v2_ok,\n \"V3_solve_residuals\": v3_ok,\n \"V4_sister_reported\": True}\n\n import csv as csvmod\n with open(CSV, \"w\", newline=\"\") as f:\n w = csvmod.writer(f)\n w.writerow([\"a\", \"lambda_tag\", \"z\", \"logK\"])\n for a, tag, zz, ll in rows:\n w.writerow([f\"{a:g}\", tag, f\"{zz:.3f}\", f\"{ll:.6f}\"])\n\n meta = {\n \"experiment\": \"E-025\",\n \"task\": \"2.13: lambda-flow numerics (ground-state channel)\",\n \"script\": \"research/numerics/scripts/E-025-lambda-flow.py\",\n \"parameters\": {\"a_list\": A_LIST, \"ladder_rel\": LADDER_REL,\n \"z_max\": Z_MAX},\n \"checks\": checks,\n \"key_values\": report[\"per_a\"],\n \"elapsed_seconds\": round(time.time() - t0, 1),\n \"timestamp_utc\": datetime.now(timezone.utc).isoformat(),\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\", flush=True)\n return 0 if all(checks.values()) else 1\n\n\nif __name__ == \"__main__\":\n sys.exit(main())\n"
}
result 2026-08-19 18:33:13Z → 2026-08-28 23:44:19Z
{
"type": "create",
"filePath": "D:\\Python\\quantum-deploy\\probe.cgi",
"content": "#!/opt/alt/python311/bin/python3.11\n\"\"\"One-off diagnostic: dump the CGI environment for symbol-URL debugging.\nDELETE FROM SERVER AFTER USE.\"\"\"\nimport json\nimport os\nimport sys\n\nprint(\"Content-Type: text/plain; charset=utf-8\")\nprint()\nprint(\"PATH_INFO :\", repr(os.environ.get(\"PATH_INFO\")))\nprint(\"REQUEST_URI :\", repr(os.environ.get(\"REQUEST_URI\")))\nprint(\"SCRIPT_NAME :\", repr(os.environ.get(\"SCRIPT_NAME\")))\nprint(\"QUERY_STRING :\", repr(os.environ.get(\"QUERY_STRING\")))\nprint(\"LANG/LC_ALL :\", os.environ.get(\"LANG\"), \"/\", os.environ.get(\"LC_ALL\"))\nprint(\"fs encoding :\", sys.getfilesystemencoding())\nprint(\"PATH_INFO utf8:\", (os.environ.get(\"PATH_INFO\") or \"\").encode(\n \"utf-8\", \"surrogateescape\"))\n",
"structuredPatch": [],
"originalFile": null
}
raw content_json (database row)
[{"type":"thinking","thinking":"Task 2.13 (E-025): λ-flow numerics. Goal: compute Δ(a;λ), locking, residual R(a;λ) as λ ↑ λ_a(a)⁻.\n\nDesign considerations:\n\n1. **What changes with λ?** T_a(λ) = A_a − λI — in the Galerkin: T(λ) = Q − λM (Q stiffness-like, M mass). Our numerics used λ = −1 (T = Q + M). The true λ_a = bottom eigenvalue of the pencil (Q, M) restricted to the mean-zero subspace — λ_a(a) ~ e^{−1.65a}. As λ ↑ λ_a, T(λ) becomes near-singular: the bottom eigenvector v_a (ground state) dominates T(λ)^{-1}.\n\n K_λ(z,z) = ⟨e_z, T(λ)^{-1} e_z⟩ (bordered/constrained). As λ → λ_a⁻: T(λ)^{-1} ≈ (1/(λ_a−λ))·P_{v_a} + bounded. So K_λ(z,z) ≈ |⟨e_z, v_a⟩|²/(λ_a−λ). If ⟨e_z, v_a⟩ (the ground state's Fourier content at z) VARIES with z — specifically if it dips at γ's — the valley structure changes.\n\n Actually the sister conjecture (1.2): c_a·v̂_a(z) → ξ(1/2+iz) — the ground state's FT converges to ξ. If v̂_a(z) ≈ ξ(1/2−iz)-ish, then ⟨e_z, v_a⟩ = v̂_a(−z)... has ZEROS at γ's! So K_λ(γ,γ) ≈ |v̂_a(γ)|²/(λ_a−λ) ≈ 0 — deep valleys at γ's with depth → ∞ as v̂_a → ξ! And plateau K_λ(z,z) ≈ |v̂_a(z)|²/(λ_a−λ) large where ξ nonzero. So in the ground-state-dominated regime, the valley depth Δ ~ log[K(z,z)/K(γ,γ)] ~ 2 log|v̂_a(z)/v̂_a(γ)| — measuring Δ vs λ directly tests whether v̂_a acquires ξ's zero structure!\n\n2. **What to compute**:\n - λ_a(a) for a ∈ {4, 8, 12} (bottom eigenvalue of the constrained pencil (Q,M)). E-009b machinery measured λ_a — how? Probably via eigsh on the projected pencil. n = 2399 at a=12: eigsh for smallest eigenvalue of Q − λM... generalized eigenproblem Q u = λ M u with constraint. M is tridiagonal (well-conditioned), Q Toeplitz. eigsh with which='SM' — slow for n=2400 dense... E-009 used QR-projection Z (line 231: Z = qr(ones)[:,1:]) then dense eigh? n=2400 dense eigh is 10–30 s — fine.\n - Then for λ/λ_a ∈ {0.5, 0.9, 0.99, 0.999, ...} wait — λ ranges from −1 (current) up to λ_a: λ/λ_a with λ_a tiny (e^{−6.6} ≈ 1.4e-3 at a=4): λ ∈ {−1, 0, 0.5λ_a, 0.9λ_a, 0.99λ_a, 0.999λ_a, 0.9999λ_a}. Note λ=0 = the \"true\" A_a (Suzuki's RH-case operator). λ=0 is already much closer to λ_a than −1 is (relative to the gap λ_a − (−1) = 1.0014, λ=0 is at 99.86% of the way!). Hmm interesting — λ=0 vs λ=−1: does K change much? Then the near-singular values.\n - For each (a, λ): K_λ(z,z) on the z-grid [14,60] step 0.05 (valley depth), plus zeros/weights? The zeros of W with λ-shifted T: the deficiency vectors v±(λ) solve T(λ)v = b±: the zeros move with λ. D-026 §7: zeros \"expected λ-independent\" (Suzuki remark). Measure: z₁·a, lattice, mass concentration vs λ.\n \n Key metrics per (a, λ):\n - Δ(λ) = plateau − floor (logK at midpoints − logK at γ's)\n - valley floor K_λ(γ,γ): does it DROP (locking: K(γ,γ) → ... target K(γ,γ)=1 gives mass 1; floor < 1 means mass > 1?!) hmm — the valley floor ≈ 1 at λ=−1; under ground-state dominance K(γ,γ) = |v̂_a(γ)|²/(λ_a−λ) → 0 if v̂_a(γ) → 0 — floor DROPS below 1. Then weights 1/K at valley atoms EXCEED 1 — the mass per valley overshoots... The consolidation criterion in the λ-flow: unclear a priori — measure everything: Δ, floor, plateau, residual, and directly |v̂_a(z)| structure vs ξ (the sister-conjecture observable!).\n\n3. **Also measure v̂_a directly**: v_a = bottom eigenvector (nodal values); v̂_a(z) = hat_FT·Σ e^{izx}v_a(x); compare c_a·v̂_a(z) vs ξ(1/2−iz) = Ξ(z) (real on ℝ) — correlation, zero crossings near γ's! That's the DIRECT test of conjecture (1.2) at finite a. This is huge value: E-025 tests the sister conjecture's finite-a behavior as a bonus.\n\n Compute: for a ∈ {4, 8, 12}: v_a (bottom eigenvector of constrained pencil), v̂_a on z-grid, normalized (c_a = 1/v̂_a(0) or L²-normalized over the grid), then: (i) zero crossings of v̂_a vs γ's (locking of the ground state's zeros!); (ii) |v̂_a(γ)|/|v̂_a|_max (valley ratio); (iii) correlation with Ξ(z) on the grid.\n\n4. Numerical care: λ near λ_a: T(λ) = Q − λM near-singular: solve_toeplitz handles it? Condition number ~ 1/(λ_a−λ) up to 1e4–1e12 relative... Levinson on ill-conditioned Toeplitz: residuals grow. For λ = 0.9999λ_a at a=12 (λ_a ~ 2.5e-9): gap 2.5e-13 — below float64 resolution of the matrix entries (~1e-16 relative on O(1) entries → absolute ~1e-16; gap 2.5e-13 resolvable but Levinson stability questionable). Use a ladder λ/λ_a ∈ {−1(a=..), 0, 0.9, 0.99, 0.999} and check residuals; maybe stop at 0.999. Also the bordered constraint: the bottom eigenvector of the CONSTRAINED problem (mean-zero): v_a ⟂ e. The constraint handles the exact-null direction? T(λ_a) has a null vector in the constrained space — bordered solve breaks down at exactly λ_a. Stay at λ < λ_a strictly.\n\n Also — which λ_a: the pencil (Q, M) on the mean-zero subspace. E-009 line 231 projects with Z. Compute λ_a via projected generalized eigh: Z^T Q Z vs Z^T M Z, dense eigh, smallest eigenvalue. n=2399: Z is n×(n−1) dense — matrices 2400² × 8B = 46MB each ✓; eigh ~30-60 s per a ✓.\n\n Validation: λ_a vs E-009b/D-019 values? D-019 F1: λ_a cliff 0.414 (a=0.25) → ≤1.7e-12 (a=5). At a=4: ~e^{−1.65·4} = 1.35e-3; a=8: e^{−13.2} = 1.9e-6; a=12: e^{−19.8} = 2.5e-9. Check orders match D-017's e^{−1.65a} law.\n\n5. W-zeros under λ-flow: do we need them? The locking metric: zeros of W(a,θ;z;λ) with λ-shifted T: v±(λ) = solve T(λ) v = b±. As λ ↑ λ_a: v± ≈ (⟨b±,v_a⟩/(λ_a−λ))·v_a + ... both dominated by v_a: V±(z) ≈ const·v̂_a(z)·(1/(λ_a−λ)): W ≈ (z−i)V₊ + e^{iθ}(z+i)V₋ ∝ v̂_a(z)·[(z−i)c₊ + e^{iθ}(z+i)c₋] — zeros of W → zeros of v̂_a(z)·linear(z) — i.e., **the W-zeros should flow to the zeros of v̂_a** as λ ↑ λ_a!! And if v̂_a ≈ Ξ, those are the γ's! That's the locking mechanism, explicitly. So YES compute W-zeros under λ-flow: locking metric = distance from W-zeros to γ's vs λ. THIS is the decisive observable: if zeros lock to γ's as λ ↑ λ_a, the consolidation channel is OPEN.\n\n Cost: locate_zeros per (a, λ) — grid eval + brentq — ~1-2 min per (a,λ) at a=12. λ-ladder ~6 values × 3 a's: ~30 min. OK.\n\n6. Structure:\n per a in {4, 8, 12}:\n build, λ_a (projected eigh), v_a\n v̂_a on grid: zero-crossings vs γ (sister-conjecture metric)\n for λ in ladder {−1, 0, 0.5, 0.9, 0.99, 0.999}·λ_a (λ=−1 absolute for baseline; others relative):\n K_λ on z-grid [14,60] → Δ, floor, plateau\n v±(λ) solves → zeros → locking metric: mean over first 20 γ's of min-dist / (π/2a) (normalized: 1 = chance), mass within ±0.1, residual\n Checks:\n V1: λ_a matches e^{−1.65a} law order (documented)\n V2: λ=−1 baseline reproduces E-022/E-024 values (Δ, z₁·a)\n V3: T(λ) solves residual < tol (Levinson stability at near-singular)\n V4: v̂_a vs Ξ correlation reported\n\nLet me write E-025. Note runtime: eigendecomposition per a ~1 min; K-grids: 920 pts × 6 λ × 3 a × ~50ms = 5 min; zero-location: 18 grid evals (40000×n matrices ~1.5GB at a=12) ~1 min each: ~20 min. Total ~30 min. Detached.\n\nOne question: does solve_v's bordered approach still apply with λ? T = Q − λM ✓ same form. For λ exactly at λ_a: singular in constrained space — ladder stays below.\n\nFor the locking metric I need zeros from g(z) = z ImV₊ − Re V₊ (θ=π) with V₊ built from v₊(λ) = cp(λ). ✓.\n\nv̂_a zero crossings: sign changes of v̂_a (real? v_a real nodal → v̂_a(z) = hat_FT·Σ e^{izx}v_j — complex. Ξ(z) real. The comparison: |v̂_a(z)| zeros? The ground state v_a is real (real pencil); v̂_a(z) complex with conj symmetry v̂_a(−z) = conj(v̂_a(z)); Re v̂_a even, Im odd. ξ(1/2−iz) = Ξ(z) real even. So compare Re v̂_a vs Ξ. Zero crossings of Re v̂_a on z>0 vs γ's.)\n\nSister conjecture (1.2): c_a v̂_a(z) → ξ(1/2+iz) = Ξ(z) (real). Compare c_a·Re v̂_a(z) with Ξ(z): c_a = Ξ(0)/v̂... Ξ(0) = ξ(1/2) ≈ −1.49...? ξ(1/2) = 0.5·0.5·(−0.5)·π^{−1/4}Γ(1/4)ζ(1/2)... ξ(1/2) = −1.4956? hmm sign. Use least-squares c_a = ⟨v̂, Ξ⟩/⟨v̂,v̂⟩ over grid.\n\nMetrics for sister conjecture:\n- correlation corr(Re v̂_a, Ξ) on [14,60]\n- zero-crossing match: first 10 crossings vs γ₁..γ₁₀: mean |Δz|\n- |Re v̂_a(γ_k)| relative to local amplitude.\n\nLet me write the script.","signature":""},{"type":"text","text":"Proceeding with E-025 (λ-flow). Design note: as λ ↑ λ_a, the deficiency vectors v± become ground-state-dominated, so W's zeros should flow toward the zeros of v̂_a — and if the sister conjecture (1.2) holds (v̂_a → Ξ), those are the γ's. So E-025 tests locking directly, plus measures v̂_a vs Ξ as a bonus."},{"type":"tool_use","id":"Write_166","name":"Write","input":{"file_path":"D:\\Python\\Quantum\\research\\numerics\\scripts\\E-025-lambda-flow.py","content":"\"\"\"E-025 — task 2.13: lambda-flow numerics (D-042 §3, Suzuki's lever).\n\nAt fixed lambda = -1 the family D_{a,theta} equilibrates at the\nconsolidation boundary (linear-K law, D-042). The remaining channel:\nlambda -> lambda_a^- (bottom of the Weil-form spectrum, lambda_a ~\ne^{-1.65a}), where T_a(lambda) = Q - lambda M becomes near-singular\nand the ground state v_a dominates — the regime of Suzuki's sister\nconjecture (1.2) (c_a v^_a -> xi(1/2+iz) = Xi(z)).\n\nMechanism being tested: as lambda -> lambda_a^-, the deficiency\nvectors v_pm(lambda) ~ v_a/(lambda_a - lambda), so the zeros of\nW(a,theta;.) flow toward the zeros of v^_a; if v^_a ~ Xi, those are\nthe gamma's => locking.\n\nPer a in {4, 8, 12}:\n A. lambda_a and ground state v_a: smallest generalized eigenpair of\n the pencil (Q, M) restricted to the mean-zero subspace (QR\n projection, dense eigh; n <= 2400).\n B. sister-conjecture observable: v^_a(z) = hat_FT * sum e^{izx} v_a\n on z-grid; correlation of Re v^_a with Xi(z) (flint xi), zero\n crossings vs the first gammas.\n C. lambda ladder: lambda/lambda_a in {-1(abs), 0, 0.5, 0.9, 0.99,\n 0.999}: K_lambda(z,z) on z-grid in [14,60] (valley depth\n Delta(lambda), floor, plateau); zeros of W (theta=pi) ->\n LOCKING metric: mean over first 20 gammas of dist(gamma, nearest\n W-zero)/(pi/2a) (1.0 = chance level); residual mass R(lambda).\n\nChecks:\n V1. lambda_a positive and consistent with the e^{-1.65a} law\n (order of magnitude; D-017/D-019).\n V2. lambda=-1 baseline reproduces E-022: z1*a in [4.3,4.7],\n Delta within 0.05 of E-022b valley depth.\n V3. Levinson residuals sane at all ladder rungs\n (|T v - b|/|b| < 1e-6 except possibly the 0.999 rung, reported).\n V4. sister observable reported (correlation v^_a vs Xi).\n\nOutputs: research/numerics/data/E-025-lambda-flow.csv (+ .json)\n\"\"\"\nimport importlib.util\nimport json\nimport sys\nimport time\nfrom datetime import datetime, timezone\nfrom pathlib import Path\n\nimport flint\nimport mpmath as mp\nimport numpy as np\nimport scipy.linalg\nimport scipy.optimize\n\nREPO = Path(__file__).resolve().parents[3]\nDATA = REPO / \"research\" / \"numerics\" / \"data\"\nCSV = DATA / \"E-025-lambda-flow.csv\"\nJSON = DATA / \"E-025-lambda-flow.json\"\n\n_spec = importlib.util.spec_from_file_location(\n \"E16\", Path(__file__).with_name(\"E-016-herglotz-fine-structure.py\"))\nE16 = importlib.util.module_from_spec(_spec)\n_spec.loader.exec_module(E16) # runs the e^20 sieve\nsys.path.insert(0, str(Path(__file__).parent))\nfrom prime_backend_v2 import PrimeBackendV2 # noqa: E402\n\nH = E16.H_MAIN\nLAM0 = E16.LAM_SHIFT # -1.0 baseline\nA_LIST = [4.0, 8.0, 12.0]\nLADDER_REL = [0.0, 0.5, 0.9, 0.99, 0.999] # x lambda_a (plus lam=-1)\nZ_MAX = 300.0\nZ_METRIC = 280.0\nN_GRID = 40000\nXN = E16.XN\nmp.mp.dps = 40\n\n\ndef collect_t_points(a, h):\n n_elem = int(round(2 * a / h))\n pts = []\n\n def add_quad(lo, hi, peak):\n n_lo = int(np.ceil(np.exp(lo)))\n n_hi = int(np.floor(np.exp(hi)))\n if n_hi - n_lo > 64:\n for aa, bb in ((lo, peak), (peak, hi)):\n if bb - aa > 0:\n mid, half = 0.5 * (aa + bb), 0.5 * (bb - aa)\n pts.extend(mid + half * XN)\n return\n segs = sorted({lo, peak, hi} |\n {float(np.log(n))\n for n in range(max(n_lo, 2), n_hi + 1)\n if lo < np.log(n) < hi})\n for p0, p1 in zip(segs, segs[1:]):\n if p1 - p0 > 0:\n mid, half = 0.5 * (p0 + p1), 0.5 * (p1 - p0)\n pts.extend(mid + half * XN)\n\n for k in range(n_elem):\n if k == 0:\n add_quad(0.0, h, 0.0)\n else:\n add_quad((k - 1) * h, (k + 1) * h, k * h)\n return np.array(pts)\n\n\ndef xi_real(z):\n \"\"\"Xi(z) = xi(1/2 - i z) via flint (real on R).\"\"\"\n flint.ctx.prec = 120\n out = np.empty(len(z))\n for i, zz in enumerate(z):\n s = flint.acb(0.5, -float(zz))\n val = (0.5 * s * (s - 1) * flint.acb.pi() ** (-s / 2)\n * (s / 2).gamma() * s.zeta())\n out[i] = float(val.real)\n return out\n\n\ndef locate_zeros_pi(cp, x, h, z_max=Z_MAX, n_grid=N_GRID):\n zg = np.linspace(1e-3, z_max, n_grid)\n Vpr, _ = E16.V_and_dV(zg, cp, x, h)\n g = zg * Vpr.imag - Vpr.real\n\n def g_direct(zz):\n V = E16.hat_FT(np.array([zz]), h)[0] * complex(\n np.exp(1j * zz * x) @ cp)\n return zz * V.imag - V.real\n\n idx = np.flatnonzero(np.sign(g[:-1]) * np.sign(g[1:]) < 0)\n zeros = []\n for i in idx:\n try:\n zeros.append(scipy.optimize.brentq(g_direct, zg[i], zg[i + 1],\n xtol=1e-13, rtol=1e-13))\n except ValueError:\n pass\n return np.array(zeros)\n\n\ndef ground_state(Q, M):\n \"\"\"Smallest generalized eigenpair of (Q, M) on the mean-zero\n subspace (E-009 route: QR projection).\"\"\"\n n = Q.shape[0]\n Z = np.linalg.qr(np.ones((n, 1)), mode=\"complete\")[0][:, 1:]\n Qp = Z.T @ Q @ Z\n Mp = Z.T @ M @ Z\n evals, evecs = scipy.linalg.eigh(Qp, Mp)\n lam_a = float(evals[0])\n v = Z @ evecs[:, 0]\n return lam_a, v\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 print(\"backend: load E-022 cache ...\", flush=True)\n tq = np.concatenate([collect_t_points(a, H) for a in A_LIST])\n be = PrimeBackendV2(tq)\n be.load_cache(DATA / \"E-022-backend-cache.npz\")\n E16._BUILD.clear()\n E16.prime_sum_vec = be.prime_sum\n\n mp.mp.dps = 30\n gam = np.array([float(mp.zetazero(k).imag) for k in range(1, 201)])\n gam = gam[gam <= Z_METRIC]\n\n zgrid = np.arange(14.0, 60.0, 0.05)\n gsel = gam[(gam >= 14) & (gam < 60)]\n mids = (gsel[:-1] + gsel[1:]) / 2\n idxg = np.round((gsel - 14) / 0.05).astype(int)\n idxm = np.round((mids - 14) / 0.05).astype(int)\n XI = xi_real(zgrid)\n\n rows = []\n report = {\"per_a\": {}}\n v1_ok = v2_ok = v3_ok = True\n e022b_dip = {4.0: 2.1593, 8.0: 2.7352, 12.0: 2.9442}\n\n for a in A_LIST:\n ta = time.time()\n x, h, Q, M, b = E16.build(a, H)\n n = len(x)\n\n # A: ground state\n lam_a, v_a = ground_state(Q, M)\n if not (lam_a > 0):\n v1_ok = False\n law = np.exp(-1.65 * a)\n print(f\"a={a:g}: lambda_a = {lam_a:.3e} (e^-1.65a = {law:.1e})\",\n flush=True)\n\n # B: sister-conjecture observable\n E = np.exp(1j * np.outer(zgrid, x))\n vhat = E16.hat_FT(zgrid, h) * (E @ v_a)\n rv = vhat.real\n ca = float(np.dot(rv, XI) / np.dot(rv, rv))\n corr = float(np.corrcoef(rv, XI)[0, 1])\n # zero crossings of Re v^_a on grid\n sc = np.flatnonzero(np.sign(rv[:-1]) * np.sign(rv[1:]) < 0)\n cross = zgrid[sc]\n ncr = min(10, len(cross), len(gsel))\n xerr = float(np.mean(np.abs(cross[:ncr] - gsel[:ncr]))) \\\n if ncr else float(\"nan\")\n print(f\" sister: corr(v^,Xi) = {corr:+.4f}, {len(cross)} \"\n f\"crossings, mean |cross-gamma| (first {ncr}) = {xerr:.3f}\",\n flush=True)\n\n per = {\"lambda_a\": lam_a, \"lambda_law_ratio\": lam_a / law,\n \"sister_corr\": corr, \"sister_crossings\": int(len(cross)),\n \"sister_cross_err\": xerr, \"ladder\": {}}\n\n # C: lambda ladder\n for tag, lam in ([(\"-1\", LAM0)]\n + [(f\"{r:g}\", r * lam_a) for r in LADDER_REL]):\n tc = Q[:, 0] - lam * (np.r_[2 * h / 3, h / 6,\n np.zeros(max(n - 2, 0))])\n u1 = scipy.linalg.solve_toeplitz((tc, tc), np.ones(n))\n s1 = u1.sum()\n\n def K1(z, _tc=tc, _u1=u1, _s1=s1):\n bz = E16.hat_FT(np.array([z]), h)[0] * np.exp(-1j * z * x)\n u0 = scipy.linalg.solve_toeplitz((_tc, _tc), bz)\n v = u0 - (u0.sum() / _s1) * _u1\n return float(np.real(np.conj(bz) @ v)), \\\n float(np.max(np.abs(\n scipy.linalg.toeplitz(_tc) @ v\n + ((u0.sum() / _s1)) * np.ones(n)\n - bz)) / max(1.0, np.max(np.abs(bz))))\n\n lg = np.empty(len(zgrid))\n resmax = 0.0\n for i, zz in enumerate(zgrid):\n kv, rs = K1(zz)\n lg[i] = np.log(max(kv, 1e-300))\n resmax = max(resmax, rs)\n if resmax > 1e-6:\n v3_ok = False\n dip = float(lg[idxm].mean() - lg[idxg].mean())\n floor = float(lg[idxg].mean())\n plate = float(lg[idxm].mean())\n\n # zeros of W (theta=pi) at this lambda\n Tm = scipy.linalg.toeplitz(tc)\n nn = n\n BB = np.zeros((nn + 1, nn + 1))\n BB[:nn, :nn] = Tm\n BB[:nn, nn] = 1.0\n BB[nn, :nn] = 1.0\n cp = scipy.linalg.solve(BB, np.r_[b[+1.0], 0.0],\n assume_a=\"sym\")[:nn]\n zeros = locate_zeros_pi(cp, x, h)\n zm = zeros[zeros <= Z_METRIC]\n # locking: mean normalized distance of first 20 gammas\n d20 = []\n for g in gam[:20]:\n d20.append(np.min(np.abs(zm - g)))\n lock = float(np.mean(d20) / (np.pi / (2 * a)))\n # weights & residual\n ws = np.array([1.0 / K1(z)[0] for z in zm])\n near_idx = np.array([np.argmin(np.abs(zm - g)) for g in gam])\n resid = float(ws.sum() - ws[near_idx].sum())\n m01 = float(ws[np.minimum.reduce([\n np.abs(zm - g) for g in gam]).reshape(-1) <= 0.1].sum()) \\\n if len(zm) else 0.0\n\n per[\"ladder\"][tag] = {\n \"lambda\": lam, \"Delta\": dip, \"floor\": floor,\n \"plateau\": plate, \"z1_times_a\": float(zeros[0] * a),\n \"n_zeros\": int(len(zeros)),\n \"lock_metric\": lock, \"residual\": resid,\n \"mass_pm0.1\": m01, \"solve_resid\": resmax,\n }\n print(f\" lam={tag}*lam_a ({lam:.3e}): Delta={dip:.3f}, \"\n f\"z1a={zeros[0] * a:.3f}, lock={lock:.3f}, \"\n f\"resid={resid:.1f}, K-resid={resmax:.1e}\", flush=True)\n for zz, ll in zip(zgrid, lg):\n rows.append((a, tag, zz, ll))\n\n # V2: baseline checks (lambda = -1)\n base = per[\"ladder\"][\"-1\"]\n if not (4.3 < base[\"z1_times_a\"] < 4.7):\n v2_ok = False\n if abs(base[\"Delta\"] - e022b_dip[a]) > 0.05:\n v2_ok = False\n report[\"per_a\"][f\"{a:g}\"] = per\n print(f\"a={a:g} done ({time.time() - ta:.0f}s)\", flush=True)\n\n checks = {\"V1_lambda_a_positive_law\": v1_ok,\n \"V2_baseline_matches_E022\": v2_ok,\n \"V3_solve_residuals\": v3_ok,\n \"V4_sister_reported\": True}\n\n import csv as csvmod\n with open(CSV, \"w\", newline=\"\") as f:\n w = csvmod.writer(f)\n w.writerow([\"a\", \"lambda_tag\", \"z\", \"logK\"])\n for a, tag, zz, ll in rows:\n w.writerow([f\"{a:g}\", tag, f\"{zz:.3f}\", f\"{ll:.6f}\"])\n\n meta = {\n \"experiment\": \"E-025\",\n \"task\": \"2.13: lambda-flow numerics (ground-state channel)\",\n \"script\": \"research/numerics/scripts/E-025-lambda-flow.py\",\n \"parameters\": {\"a_list\": A_LIST, \"ladder_rel\": LADDER_REL,\n \"z_max\": Z_MAX},\n \"checks\": checks,\n \"key_values\": report[\"per_a\"],\n \"elapsed_seconds\": round(time.time() - t0, 1),\n \"timestamp_utc\": datetime.now(timezone.utc).isoformat(),\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\", flush=True)\n return 0 if all(checks.values()) else 1\n\n\nif __name__ == \"__main__\":\n sys.exit(main())\n"},"extra_content":null}]