← Session 35 — ii′-6-R: Lagarias 6.1 right-tail re-proof (E-032/D-073)
thinking (40864 chars)
All mission inputs read. Now I understand the full picture. Let me design E-032.
**E-032 design (sub-stage 6-R-0, deliverable D1):**
The goal: compute the TRUE complex horizontal integral I_II at T = √n (zero-avoiding) by direct quadrature, and compare to the E-031 envelope.
What exactly is I_II? In Lagarias's notation (Thm 6.1), the integrand on the horizontal segment (II) at height t = T, for ζ (π = Riemann zeta case):
I_II = ∫ k_n(s)·(−ζ′/ζ(s+1)) ds
Wait — let me get the exact contour convention. From D-071 §4.1: the rectangle is z = −5/2 − iT, w = 2√n + iT; the integrand is the Lagarias-kernel integrand Jlag. From ii′-1b, `rectInt'_Jlag`: RectangleIntegral' (Jlag n) z w = ResW1 n + Σ ... where Jlag is the integrand of the (6.2) integral.
In Lagarias's paper, (6.2): I_2(n) = (1/2πi) ∫_C k_n(s)·(−L′/L(s+1,π)) ds? Actually from the proof passage: "the integrand k_n(s)·(−L′/L(s,π))" with k_n(s) = (1+1/s)ⁿ − 1, on segments where L′/L is evaluated at s+1... Let me look at the details:
- D-072 says: "The contour: integrand k_n(s)·(−L′/L(s+1)), k_n(s) = (1+1/s)ⁿ − 1, on the rectangle σ₀ ∈ (−3,−2), σ₁ = 2√n, im = ±T, T = √n + ε."
- The stepping passage (6.12): |k_n(s+1)+1|/|k_n(s)+1| — the kernel stepping in s. And (6.10) gives |L′/L(σ+1+iT)| halving — so L′/L is evaluated at s+1. Wait, in (6.10) they write |L′/L(s,π)| ≤ 2^{−(σ−2)}|L′/L(2,π)| for σ > 2. And on (II), they step from σ = 3 with |L′/L| = O(1) "since we are in the absolute convergence region". Hmm — in the paper the integrand is k_n(s)·(−L′/L(s+1, π))? Let me check: (6.2) in the paper is
I_2(n) = (1/2πi) ∫ k_n(s) ·(−L′/L(s+1, π)) ds?
Actually from D-072 and the E-031 script: `product(n, sig, c)` computes |k_n(w−1)|·|Σ_{k<300} Λ(k)/k^w| at w = σ+iT. So E-031 models the integrand as k_n(w−1)·ζ′/ζ(w) with w = s+1, i.e., integrand = k_n(s)·L′/L(s+1) where s ranges over σ ∈ [−3-ish, σ₁−1]... Hmm, but the variable substitution: if the integrand is k_n(s)·(−L′/L(s+1)) and we set w = s+1, then the integral is over w from σ₀+1 to σ₁+1. E-031 integrates the envelope over w ∈ [3, 2√n] roughly (actually sig from 3 to 2T).
Wait, actually there's a subtlety. Let me re-read. In Lagarias Thm 6.1, the integral I_2(n) is defined in (6.2). From the proof: "We now consider the integral I_2(n) on the vertical segment (I) having Re(s) = σ₁ = 2√n" and the horizontal segments (II), (IV) at im = ±T, and left vertical (III) at σ₀ ∈ (−3,−2). The integrand: k_n(s)·(−L′/L(s,π))... but then the zeta argument on (II) at the RIGHT end (σ near σ₁ = 2√n) is in the absolute convergence region, and at the LEFT end (σ = −3) it's at L′/L(−3+1)? No wait.
From the stepping passage: "we step across the interval (II) towards the right, in segments of length 1, starting from σ = 3. At the initial point we have |L′/L| = O(1) since we are in the absolute convergence region, and the estimate (6.10) gains a factor of 2 going one unit to the right."
(6.10) is for Re(s) > 2: |L′/L(s)| ≤ 2^{−(σ−2)}|L′/L(2)|. So on (II), the L′/L argument at contour-point s is s+1 (so that at contour σ = 3−1 = 2... hmm no).
Actually the cleanest interpretation, consistent with E-031 and D-071: the integrand is k_n(s)·(−L′/L(s+1)) and stepping starts at contour σ = 2 with L′/L evaluated at 3? Hmm, but D-072 says "starting from σ = 3".
Let me just use the convention from our own Lean work: `rectInt'_Jlag` has integrand Jlag n and the rectangle z = −5/2 − iT, w = 2√n + iT. From ii′-1b, Jlag n = the Lagarias kernel integrand. From D-071 §4.1, the residue sum is at 1 and at zeros ρ with term (1−(ρ/(ρ−1))ⁿ). The kernel k_n(s) = (1+1/s)ⁿ − 1 = ((s+1)/s)ⁿ − 1. The zero term (ρ/(ρ−1))ⁿ = (1 + 1/(ρ−1))ⁿ... So the integrand is Jlag n (w) = k_n(w−1)·(−ζ′/ζ(w))? Let's see: residue at w = ρ: k_n(ρ−1) = (ρ/(ρ−1))ⁿ − 1, times residue of −ζ′/ζ which is −mult. Product's residue: −mult·((ρ/(ρ−1))ⁿ − 1) = mult·(1 − (ρ/(ρ−1))ⁿ). ✓ matches. And at w = 1: k_n(0) = 0ⁿ − 1 = −1 (for n ≥ 1), residue of −ζ′/ζ at 1 is +1, so residue = −1·... hmm, but ResW1 n = Σ_j C(n,j)·lcoeff(j−1). Actually the (w−1)^{n+1} expansion gives more. OK whatever — the key point:
**Integrand on horizontal (II): Jlag n (w) = k_n(w−1)·(−ζ′/ζ(w)), w = σ + iT, σ ∈ [σ₀, σ₁] = [−5/2, 2√n]** (in our variant-B rectangle; Lagarias uses σ₀ ∈ (−3,−2), and we adopted −5/2).
So I_II = ∫_{σ₀}^{σ₁} k_n(σ−1+iT)·(−ζ′/ζ(σ+iT)) dσ (with the (2πi)⁻¹ normalization for RectInt but the per-side bound |I_II| is the raw integral as charged in the paper convention).
E-031 computed the envelope: |k_n(w−1)|·|ζ′/ζ(w)| integrated over σ ∈ [3, 2√n] (the "right tail"), with ζ′/ζ modeled by the Dirichlet series Σ_{k<300} Λ(k)/k^w (valid for Re w > 1, i.e., σ > 1... at σ = 3 it's fine).
**E-032 must compute the TRUE complex integral** I_II (at least its right part [3, 2√n], or the full [σ₀, σ₁]) at T = √n zero-avoiding (T = √n + ε with ε chosen so the line stays away from zeros — for n = 10³, T ≈ 31.6; zeros near 31.6? We'd need to check the zero-avoiding choice. Actually for the diagnostic, we just need T = √n + ε with the horizontal line not hitting a zero; the quadrature is over σ at fixed im = T, and ζ′/ζ is evaluated by mpmath directly (ζ has no zeros on the line im = T as long as T is not exactly a γ). For diagnostic purposes, ε = 0.5 say, after checking no zero within some clearance. Actually simpler: pick ε to maximize clearance from the nearest zero ordinate.
Computation plan:
- For n ∈ {10³, 10⁴} (10⁵ if cheap — likely not: ζ′/ζ at σ up to 2√n = 632 for n=10⁵ with mpmath at dps 40... actually ζ(632+316i) is computable by mpmath but slow-ish; also k_n values involve e^{20} magnitudes; fine. But the quadrature over σ ∈ [3, 632] with an oscillatory integrand — the phase is O(1) rad/unit per D-073, so ~400–700 sample points might suffice with a fine grid. Cost: each ζ′/ζ evaluation at dps 40 via mpmath... mpmath zeta at σ=100+ is via Euler-Maclaurin, reasonably fast. Hmm, but at dps 40 and large σ, ζ(σ+iT) → 1 + 2^{−s} + ..., mpmath handles it. ζ′ similar. Could be maybe 10–100 ms per point → 700 points × 2 n values = fine.
Wait, actually — accuracy concern: mpmath's ζ at high σ is fine (absolutely convergent-ish region, Euler-Maclaurin). The handoff notes say "mpmath complex-ζ OK to ~1e-10" and "mpmath zeta (integer+Hurwitz) UNTRUSTWORTHY beyond ~57 digits at any dps". At dps 40, we're under 57 digits, and complex arguments are OK to ~1e-10 relative. The integrand magnitude ranges over e^{±20}; we need the integral's real part to maybe ~1e-6 relative of the envelope or better. Given values ~1e8–1e10 in the envelope, a 1e-10 relative error per point is fine.
Actually, more careful: mpmath zeta for complex s at dps 40 — the note says OK to ~1e-10 (probably absolute-ish at moderate args). The integrand peak is ~1.3e9 at n=10⁵... but we're not doing n=10⁵ necessarily ("if cheap"). For n=10⁴, peak ~430 (e^{6.05}); envelope integral ~1.05e4. An error of 1e-10 per point × 1000 points ~ 1e-7 — fine to detect whether Re(I) ~ 1e4 or ≪ 1e4.
Validation: D-073 says "validate ζ′/ζ against the Dirichlet series where re > 2". So for σ ≥ 3 (re w ≥ 3... wait re > 2 for (6.10)), compute −ζ′/ζ(w) two ways: mpmath (zeta and zeta derivative, or logDeriv via diff) and the Dirichlet series Σ Λ(k)/k^w truncated with a tail bound. At σ ≥ 3, the tail beyond K is ≤ Σ_{k>K} Λ(k)/k^σ·... ~ small. Use K large enough (e.g., up to where K^{1−σ}·... < 1e-45). At σ = 3, need K ~ maybe 10⁷ for dps 40? Σ_{k>K} Λ(k) k^{-3} ~ (1/2)K^{-2} log K-ish... for 1e-45 need K ~ 1e22 — not feasible. Hmm. But we don't need dps-40 absolute accuracy in the ζ factor — we need the INTEGRAL accurately.
Rethink precision: the integrand magnitude on the right tail: at σ = 3, product ~ O(1) (e^{-0.03} at n=10⁵, similar smaller n). The peak ~ e^{0.066√n} is at σ ≈ 0.36√n: for n = 10³, √n ≈ 31.6, peak at σ ≈ 12, height e^{1.44} ≈ 4.2; for n = 10⁴, peak at σ ≈ 30, height ~430. So the dominant contribution is at σ ≥ 12 (n=10³) / σ ≥ 30 (n=10⁴) where the Dirichlet series converges FAST (2^{-σ} dominated). At σ = 12: Σ_{k>K} Λ(k)/k^{12} ~ tiny for K = 300. At σ = 30: K = 64 already gives 2^{-30}·... So the Dirichlet series with K = a few hundred IS the ζ′/ζ value to extreme precision in the peak region.
So the plan: compute −ζ′/ζ(w) via truncated Dirichlet series Σ_{k≤K} Λ(k)/k^w with K chosen per σ so the tail < 1e-42 (easy for σ ≥ 8; for σ ∈ [3, 8) use more terms or mpmath cross-check), and CROSS-VALIDATE against mpmath's −ζ′/ζ at a sample of points (mpmath diff of zeta or mpmath's `mp.zeta(w, derivative=1)`). The mission says "validate ζ′/ζ against the Dirichlet series where re > 2" — i.e., use mpmath as primary and Dirichlet as check, or vice versa. I'll use the Dirichlet series as primary for σ ≥ 3 (it's exact, fast, controlled tail) and mpmath zeta as the cross-check at sample points.
Quadrature: trapezoidal with adaptive refinement. The phase: k_n(w−1) = ((w)/(w−1))ⁿ = exp(n·log(1+1/(w−1))). Phase ≈ n·Im log(1+1/(w−1)) ≈ −n·T/((σ−1)²+T²)... at T² = n, phase ≈ −nT/(σ²+n) ~ O(√n)?? Wait D-073 says "phase O(1) rad/unit" — the DERIVATIVE of the phase is O(1) per unit σ. Total phase swing over [3, 2√n] ~ O(√n) radians. For n = 10⁴, ~ 300 rad over the range — but the D-072 §5 says "phase-winding of arg(k_n·L′/L) ~ −300 rad over the peak region". So the integrand DOES oscillate with period ~2π/(phase derivative) — phase derivative ~ O(1)–O(3) rad/unit near the peak... With trapezoid at step h, we resolve oscillation if h·|Φ′| ≪ π. |Φ′| ≤ ~2–3? Then h = 0.05 gives 0.15 rad per step — 40 points per period. That's very fine. With h = 0.05 and range ~200 (n=10⁴: 3 to 200), that's 4000 points; each point needs Λ-sum up to K maybe 500–2000 at small σ — trivial. Cost is negligible. Actually let me reconsider: at σ = 3 the Λ sum needs K such that tail ~ ∫_K^∞ log x · x^{−3} dx ~ (log K)/(2K²) < 1e-42 → K ~ 1e20. NOT feasible!
Hmm. But wait — do we need the integrand at σ = 3 to 1e-42? No! We need the INTEGRAL to enough precision to render the verdict. The verdict compares Re(I_II) vs envelope ~1e4 (n=10⁴). Even 1e-6 relative on the envelope is overkill. The integrand near σ = 3 is O(1); a 1e-8 absolute error there contributes ≤ 1e-8 × (range) — nothing. So: accuracy budget: absolute error per point ≤ 1e-9 is plenty (integral error ≤ 2e-7 vs envelope 1e4). At σ = 3: Λ-sum tail (log K)/(2K²) < 1e-9 → K ~ 3e4: K = 50000, tail ~ (10.8)/(2·2.5e9) ~ 2e-9. Good enough. And mpmath cross-check at σ = 3 to validate.
Hmm wait, but dps ≥ 40 is prescribed. The point of dps 40 is to handle the CANCELLATION: the integrand values are ~e^{±6} ~ 400, and the integral may come out ~O(√n) = O(100) vs envelope 1e4 — cancellation of ~2 digits. With float64 we'd have ~13 digits left — actually fine. But there could be more cancellation. dps 40 gives huge headroom. Also k_n for n = 10⁵ (if we run it): values e^{20} ~ 5e8, integral maybe O(300) vs envelope 5.9e10 — cancellation ~ 8 digits; float64 leaves ~5 digits — borderline; dps 40 solves it. OK: mp.mp.dps = 50 for headroom. (The mpmath dps bug: use mp.mp.dps — noted in memory and E-031 does mp.mp.dps = 25... wait, E-031 uses `mp.mp.dps = 25`. Yes correct form.)
Now: what T exactly? "T = √n (zero-avoiding)". For the diagnostic at n = 10³: √n = 31.622...; zero ordinates near there: γ ≈ 32.935, 30.424, ... So T = 31.62 is between zeros at distance ~1.2 — fine, ε = 0 works for quadrature purposes as long as ζ′/ζ is evaluated by the exact Dirichlet series (no pole issues — poles are only at zeros, and we're evaluating |σ + iT − ρ| ≥ ... fine). But hold on — the ζ′/ζ via Dirichlet series is only valid for re w > 1! For σ ≤ 1 we can't use the Dirichlet series. But the right tail starts at σ = 3, so for the RIGHT part diagnostic we're entirely at σ ≥ 3 ✓.
Should E-32 cover the FULL horizontal [σ₀, σ₁] or just the right part [3, 2√n]? The mission (D1) says "compute the TRUE complex horizontal integral I_II at T = √n" and the verdict is about Re(I_II) ~ envelope vs ≪ envelope. The envelope in question (E-031) is the right-tail envelope ∫₃^{2√n}. The left/middle part [σ₀, 3] is charged separately (NI + 5.5(10.5 log+48)) and is NOT in dispute. So E-032 should compute the right part I_right = ∫₃^{2√n} Jlag dσ (complex, exact) and compare with the envelope ∫₃^{2√n}|Jlag| dσ.
I'll ALSO compute the middle part integral over [σ₀, 3] = [−5/2, 3] as a secondary check? That requires ζ′/ζ in the strip — mpmath only (no Dirichlet). mpmath zeta at dps 40, complex args, OK to ~1e-10 — fine. But is it needed for the verdict? The verdict is specifically about whether the per-side claim |I_II| = O(√n) survives via cancellation IN THE RIGHT TAIL (the broken part). The middle part is bounded by standard machinery. I think the primary deliverable is the right part. I'll include the middle part as an optional secondary computation if cheap — actually yes, let me include it: then we get the FULL I_II complex value, which directly answers "the per-side claim |I_II| = O(√n) — TRUE or FALSE at T = √n". The mpmath evaluation over [−2.5, 3] × {iT}: ζ′/ζ via mp.zeta(w, derivative=1)/mp.zeta(w) — careful: mp.zeta(s, derivative=1) gives ζ′(s). At dps 40 with complex s — known OK to ~1e-10 (per handoff). Kernel on [−2.5, 3] is ≤ e⁴+1 ~ 55.6, |ζ′/ζ| ≤ (log T)²-ish ~ 12 — integrand ~ 600 max, integral over length 5.5 ~ few thousand? Hmm, that's the same order as the claimed O(√n) = 100. The middle part honestly charged is ~NI + 5.5(10.5·log+48) ~ 5.5 × 85 ~ 470 + NI ~ maybe 300 → ~700. That's already > √n = 100... wait but that's an UPPER bound; the true middle integral could be ~50. The per-side claim |I_II| = O(√n) with an unstated constant — the verdict is really about the RIGHT part: does the true right-tail integral come out ~envelope (1e4, proving |I_II| ≫ √n and the claim FALSE) or ≪ envelope (hidden cancellation)?
OK here's the clean design:
**E-032 script** (`E-032-horizontal-true-integral.py`):
Parameters: n ∈ {1000, 10000} (and 100000 if cheap — I'll assess; likely include a coarse run), c = 1 (T = √n), ε chosen zero-avoiding: scan zero ordinates near √n (via mp.zetazero) and pick ε ∈ [0, 1) maximizing min clearance. Also compute for the repair heights c ∈ {1.5, 2} as a secondary validation (the repaired integrals should be tiny; that cross-validates the quadrature against the repair claim — actually that's E-033 territory; keep E-032 focused on T = √n; but a c=2 run is a nice sanity check that the same quadrature code gives small values where expected — cheap to add, adds confidence).
Computations:
1. **Setup**: T = √n + ε with ε zero-avoiding (report ε and clearance). Use mp.zetazero over a window around √n.
2. **ζ′/ζ evaluation** (primary: Dirichlet series for σ ≥ 3): D(w) = Σ_{k=2}^{K(σ)} Λ(k)/k^w with K(σ) minimal such that tail bound < tol·|...|. Tail bound: Σ_{k>K} Λ(k) k^{−σ} ≤ θ-tail via integral: ≤ (log K)·K^{1−σ}/(σ−1)·(1 + 1/log K + ...) — I'll use a simple certified bound: Σ_{k>K} Λ(k)/k^σ ≤ 2·Σ_{k>K} log(k)/k^σ ≤ 2·∫_{K−1}^∞ log x/x^σ dx = 2·[(log(K−1))/((σ−1)(K−1)^{σ−1}) + 1/((σ−1)²(K−1)^{σ−1})]. Choose K so this < 1e-11 (absolute; the integrand there is O(1)–O(400), so the ζ-factor error 1e-11 → integral error ~ 4e-8 — fine).
Cross-check (validation V-A): at a sparse grid of σ values (say 20 points across [3, 2√n]), compare D(w) vs mpmath −ζ′/ζ(w) (mp.zeta(w,1)/mp.zeta(w) — wait, mpmath: mp.zeta(w, derivative=1). Yes mp.zeta(w, derivative=1)). Require agreement ≤ 1e-8 relative-ish. Report max discrepancy.
3. **Kernel**: k_n(w−1) = (1+1/(w−1))ⁿ − 1. In mp precision direct: (w/(w−1))**n − 1. For n = 10⁵, w/(w−1) ≈ 1 + 1/(σ−1+iT), log ≈ ... direct power is fine in mp (mpmath handles complex power via exp/log; precision loss ~ n·ulp? At dps 50, fine).
4. **Quadrature**: composite trapezoid on σ ∈ [3, 2√n] at step h, with the integrand f(σ) = k_n(σ−1+iT)·(−ζ′/ζ(σ+iT)) — sign: −ζ′/ζ = D(w) as defined (D is −ζ′/ζ = Σ Λ/k^w ✓). Convergence check: run h and h/2, report |I_h − I_{h/2}| as the quadrature-error estimate. Choose h adaptively: the phase derivative |Φ′| ~ up to ~2–3 rad/unit near σ small... Let me just take h = 0.02 for n=10³ (range [3, 63] → 3000 pts) and h = 0.02 for n=10⁴ (range [3, 200] → 9850 pts). Each point: Λ-sum with K maybe up to 5e4 at σ=3 — that's the expensive end: 5e4 terms × 3000 pts(n=10³, but K large only at small σ)... hmm, total cost: for each σ, sum over k≤K(σ). At σ=3, K=5e4; at σ=4, K≈3e3; σ=5: K≈700; σ≥6: K≤300. So the σ ∈ [3, 4] strip has 50 points × ~3e4 terms = 1.5e6 term-evaluations (each a mpmath complex division k^w — k^w = exp(w log k) — mpmath mpc pow ~ microseconds at dps 50? More like 10–50 µs. 1.5e6 × 30µs = 45 s. Plus the rest negligible. For n=10⁴: same [3,4] cost + long tail cheap. OK ~1–2 min per n. Acceptable (may not need detached; but CLI kills Bash at ~2–10 min per memory — so run DETACHED with log file to be safe, or keep runtime < ~5 min. I'll optimize: use float64/log caching? No — keep it simple, mp everywhere; precompute log k once per k as mpf (K_max = 5e4 logs — fine), and k^{−w} = exp(−w·log k) with mpc exp... still per-(σ,k). Alternatively use mpmath's built-in? There's no built-in for truncated Λ sums. Fine, 1–2 min.
Actually — simpler speedup: for σ ∈ [3, 4] use mpmath's ζ directly as primary (validated against Dirichlet at sample points), and Dirichlet for σ ≥ 4 where K ≤ 3e3. mpmath zeta at dps 50 complex: ~1 ms per eval maybe. 50 points → trivial. Then total cost ~ 9850 × (K(σ) ~ 300 avg × 30µs) ~ 90 s. OK.
Hmm wait, but if mpmath is primary on [3,4] and Dirichlet on [4, 2√n], the validation V-A compares the two at sample points in both regions. Good.
5. **Outputs (checks)**:
- V-A (validation): max |D − (−ζ′/ζ)_mpmath| over the sample grid, and tail-bound certificate max K used.
- V1 (main): Re(I_right), Im(I_right), |I_right| at T = √n for n = 10³, 10⁴ — vs envelope E_env (recomputed by the same quadrature grid with |f|, and cross-checked against E-031's values 1.05e4 at n=10⁴).
- V2 (quadrature convergence): |I_h − I_{h/2}| / |I_h| small.
- V3 (optional but valuable): same at c = 1.5, 2 — expect |I_right| SMALL (repair verified by direct integration, not just product monotonicity).
- The verdict: ratio |I_right| / envelope.
Verdict interpretation (recorded, not auto-decided): if |I_right|/envelope ~ O(1) (say > 0.1) → per-side claim FALSE; if ≪ (say < 1e-2) → hidden cancellation. Also compare |I_right| vs C·√n.
Also worth computing: Re(I_right) specifically (D-073 verdict is on Re(I_II) since Im is constrained by the identity). Note: the mission says "Verdict: Re(I_II) ~ envelope ⟹ per-side claim FALSE; |I_II| ≪ envelope ⟹ hidden cancellation". I'll report Re, Im, |·| all three.
One more sanity consideration: T = √n vs T = √n + ε. Lagarias picks T = √n + ε_n, 0 ≤ ε ≤ 1, zero-avoiding. E-031 used T = √n exactly (ε = 0). For comparability, use ε from the zero-avoiding scan but also report ε; the difference is immaterial for the verdict (the envelope is a smooth envelope).
What about n = 10⁵? Range [3, 632], h = 0.02 → 31500 points, K(σ) cheap for σ > 4... ~ 3 min more. Values: kernel up to e^{20.98} ~ 1.3e9, integrand peak ~ 1.6e9 (product with ζ 1.8e-31·... wait no — the PRODUCT peak is 1.6e9? D-072 says peak product e^{20.98} ≈ 1.3e9 at σ = 120 (that's |k|·|ζsum| — yes the full product). Integral envelope 5.9e10. True integral could be ~O(√n) = 316 → cancellation of ~8.5 digits — at dps 50 fine. Include n=10⁵ if runtime allows (it's the decisive n for the finding). Actually — YES, include it: E-032's verdict at n=10⁵ is the most decisive (envelope 5.9e10 vs claimed O(√n) = O(316): if the true |I| comes out ~1e9+, the per-side claim is decisively false). Runtime maybe 3–5 min total. Run detached to be safe.
Wait, one concern on the quadrature at n=10⁵: phase |Φ′|. Let me estimate Φ(σ) = n·arg(1+1/(σ−1+iT)) ≈ −nT/((σ−1)²+T²). Φ′(σ) ≈ 2nT(σ−1)/((σ−1)²+T²)². At T² = n: Φ′ ≈ 2T³(σ−1)/((σ−1)²+T²)². Max over σ: let u = (σ−1)/T: Φ′ ≈ 2T³·uT/(T⁴(u²+1)²) = 2u/(1+u²)². Max of 2u/(1+u²)² at u = 1/√3: value = 2·(1/√3)/(4/3)² = (2/√3)·(9/16) ≈ 0.65. So |Φ′| ≤ ~0.65 rad/unit for the kernel. Plus the ζ′/ζ phase variation (slow, |d/dσ arg D| ≤ ~ |D′/D| ~ log-ish ~ O(1)). So total |Φ′| ≤ ~2 rad/unit; h = 0.02 gives 0.04 rad/step — 150 pts/period. Plenty. The h and h/2 check will confirm anyway.
Alright — also the zero-avoiding ε scan: mp.zetazero(k) for k around the index of √n. Number of zeros below T: N(T) ≈ (T/2π)log(T/2πe). For T = 31.6: ~ 48; for T = 100: ~ 191; for T = 316: ~ 770. So compute zeros in [√n − 2, √n + 3]: use mp.zetazero(j) for j in a small range around the index. Fine.
Also — the LEFT/middle part [−5/2, 3]: include? It would make E-032 the FULL I_II. Cost: mpmath ζ over 275 points (h=0.02) at dps 50 — each ζ + ζ′ eval ~ ms — trivial. Include it as a separate reported number (I_mid) so D-073 can report full I_II = I_mid + I_right as well. The verdict hinges on I_right, but the full-side number is the direct test of the per-side claim |I_II| = O(√n). Yes, include — labeled secondary.
Hmm, actually for I_mid I need ζ′/ζ in the strip where there could be nearby zeros? At im = T (zero-avoiding, clearance ≥ ~1/(16Ĉ₀) — actually the ε scan gives clearance maybe ~0.3), σ ∈ [−2.5, 3]: zeros ρ = β+iγ with |γ − T| < clearance would be a problem only if |σ − β| also small — mpmath handles ζ′/ζ near zeros fine (it's just a function eval; the value is large but accurate). No issue.
Kernel k_n(w−1) for σ ∈ [−2.5, 3]: |(w)/(w−1)|ⁿ — at σ = −2.5: |1 + 1/(w−1)| ≈ 1 — fine, ≤ e⁴+1 bounded.
OK also — V3 (repair heights c = 1.5, 2 direct integration): cheap to add (reuse machinery, T = c√n + ε, same n values, only right part). At c = 2, integrand ~e^{−43} at σ=100 — tiny; trapezoid fine. This directly verifies "the repaired right tail is genuinely small" by integration. Good.
Let me also think about whether the "hidden cancellation" STOP condition affects the plan: D-073 says if |I_II| comes out SMALL, STOP and report before pursuing 6-R-1. So after E-032, I report the verdict to the user before writing the repaired proof? Actually the thread prompt says D1 verdict settles whether anything remains to pursue at T = √n; the repair (D2) is needed REGARDLESS (the main line executes repair (R) with the recommended c). The STOP is only about pursuing the T=√n salvage further. So: land E-032 (6-R-0) as its own committed sub-stage, report the verdict to the user, and continue to 6-R-1 (the repaired proof) — the mission says land D1 first as its own committed sub-stage, and the D-073 success criteria include the repaired proof regardless. But per the mission "if |I_II| comes out SMALL, STOP and report to the user before going further" — so if small, I stop after 6-R-0 and consult. If large (per-side FALSE), proceed to 6-R-1 directly. I'll decide based on the numbers.
Now — the workflow: this is session 039. Let me check the journal for session 038 naming convention and the db.py registration. Also need to check the correspondence folder shouldn't be touched (freeze). New files: E-032 script + data sidecars, D-073 sections.
Let me also quickly check db.py usage and the E-031 JSON sidecar for the registration pattern. Actually the handoff notes say: db.py: init, log-experiment, add-result, add-derivation, add-graveyard, list. Let me check the exact CLI for log-experiment.
Plan of action:
1. Write E-032 script.
2. Test-run quickly at n=10³ with coarse settings in foreground (short), then full run detached with log.
3. Verify outputs, register in db, write D-073 §2, commit.
Actually before writing, let me look at the db.py CLI to get log-experiment's signature, and glance at journal-038 for session conventions. Let me be efficient: just check db.py help.
Let me now mark todo 1 complete and start building E-032.
One more design decision on the ε zero-avoiding scan: to keep determinism, scan ε ∈ {0, 0.05, ..., 0.95} and pick the one maximizing min |T − γ_j| over zeros within [√n−2, √n+3]. Report it. Deterministic across runs (zetazero deterministic at dps 50).
Precision: mp.mp.dps = 50 (note the mpmath bug: must use mp.mp.dps).
For the Λ(k) function: E-031's vonM only handles primes ≤ 47 — k up to 5e4 needs full factorization. Use sympy? Or simple trial division up to √k (≤224) — fine for 5e4 values (precompute a Λ table once per run via sieve: O(K log log K)). Use a sieve of Eratosthenes-style Λ computation: Λ(p^a) = log p. Simple: smallest-prime-factor sieve, then Λ(k) = log p if k is a prime power else 0. K_max = 5e4 → trivial.
Tail bound for choosing K(σ): Σ_{k>K} Λ(k)/k^σ ≤ 1.02·Σ_{k>K} log(k)/k^σ ≤ 1.02·∫_{K}^∞ (log x + 1/... hmm let me use a clean certified bound: for σ ≥ 3, Σ_{k>K} Λ(k) k^{−σ} ≤ Σ log(k) k^{−σ} ≤ ∫_{K−1}^∞ log x · x^{−σ} dx (since log x·x^{−σ} decreasing for x ≥ K−1 ≥ 2 when σ ≥ 3... derivative of log x·x^{−σ} = x^{−σ−1}(1 − σ log x) < 0 for log x > 1/σ ✓). Integral = [(log(K−1))/(σ−1) + 1/(σ−1)²]·(K−1)^{1−σ}. Choose K minimal with this < 1e-11. At σ=3: need [(log(K−1))/2 + 1/4]/(K−1)² < 1e-11 → (K−1)² > 1e11·(log(K−1)/2+0.25) → K−1 ~ 4e5?? Let me solve: (K−1)² > 1e11 · (ln(4e5)/2 ≈ 6.5) → K−1 > 2.5e6. Hmm, 2.5e6 terms × 50 points in [3,4]... 1.25e8 mpmath term evals × 30µs = ~1 hour. TOO SLOW.
Reconsider: use mpmath ζ as primary on [3, 5] (fast), Dirichlet for σ ≥ 5 where K(5): [(log(K−1))/4 + 1/16]/(K−1)⁴ < 1e-11 → (K−1)⁴ > 1e11·(log/4+1/16 ≈ 1.7) → K−1 > ~650. So K(5) ≈ 700, K(6) ≈ 130, K(7) ≈ 50, K ≥ 8: K ≤ 25. Great: for σ ≥ 5, Dirichlet is cheap and exact to 1e-11. For σ ∈ [3, 5]: mpmath primary, and VALIDATE mpmath against the Dirichlet series at the σ = 5 boundary (and a few interior points with a bigger-K spot check: at σ = 4, K(4): (K−1)³ > 1e11·(log/3+1/9 ≈ 2.4) → K ~ 6500 — a spot check at σ = 4 with K = 7000 is a one-off ~0.2 s ✓; at σ = 3.5: K ~ 5e4, one-off 1.5 s ✓; at σ = 3: K ~ 2.5e6 one-off ~ 75 s — acceptable as a ONE-point validation at n-independent (w = 3+iT differs per n... hmm, 3 validations × 75 s = 4 min extra. Reduce: validate mpmath at σ = 3 with tolerance 1e-8 instead of 1e-11 → K ~ 8e4, ~2.5 s ✓. Precision budget: we don't need 1e-11 at σ=3; 1e-8 is plenty.)
Actually — simpler unified approach: use mpmath −ζ′/ζ as PRIMARY everywhere on [3, 2√n] (it's just zeta evals; at large σ, ζ(σ+iT) = 1 + 2^{−w} + ... — does mpmath remain accurate at σ = 632, dps 50? Euler–Maclaurin with such large σ — mpmath should handle it (terms decay fast), but the handoff warns mpmath zeta untrustworthy beyond ~57 digits — we're at 50, borderline! And "mpmath complex-ζ OK to ~1e-10" — that was presumably at moderate args. At σ = 632, ζ ≈ 1 + 2^{−632+...} — the interesting part is ~2^{−632} ≈ 1e-190 below 1 — but we need ζ′/ζ ≈ log 2·2^{−w} + ... ~ 1e-190 magnitude?? NO WAIT — at σ = 632, |ζ′/ζ| ≈ 2^{−632}·log 2 ~ 1e-190 — but we don't need it: the integrand there is |k|·1e-190 ~ e^{√n/2}·1e-190 — utterly negligible. Where does the ENVELOPE peak? σ ≈ 0.36√n ≈ 114 (n=10⁵), where |ζ′/ζ| ~ 2^{−114} ~ 5e-35 — still tiny but relevant (product ~1.6e9). Can mpmath compute ζ(114+316i) accurately? ζ ≈ 1 + 2^{−s} + 3^{−s}..., the value is 1 + ~5e-35. In dps 50, mpmath represents 1 + 5e-35 fine (50 digits). The Euler–Maclaurin computation internally: should be OK, but the handoff's warning makes me NOT trust mpmath zeta at σ = 114+ at dps 50 without validation. The Dirichlet series at σ = 114 needs K: (K−1)^{113} > 1e11 → K−1 > 1e11^{1/113} ≈ 1.25 → K = 3!! Just k=2,3 terms. TRIVIAL.
So the clean design: **Dirichlet series primary everywhere on [3, 2√n]**, with per-σ adaptive K, EXCEPT on [3, 5) where K explodes — there use mpmath (moderate args, trustworthy, and validated against Dirichlet spot checks at σ = 3, 3.5, 4, 4.5 with the largest affordable K, tolerance 1e-8). mpmath on [3,5]: 100 points × (ζ + ζ′) — fast. Everywhere else: exact Dirichlet. Validation V-A: the four spot checks + continuity of the two at σ = 5 (compare mpmath vs Dirichlet at σ = 5 where Dirichlet K = 700 — exact to 1e-11).
This is clean and fast: total Dirichlet cost ~ 31500 points × avg K ~ 10 → trivial; mpmath cost ~ 100 × 2 zeta evals per n — trivial. Total runtime maybe 1–2 min for all three n values plus c-sweep.
Actually hold on, at σ slightly above 5 like 5.0–6.0, K ~ 130–700, points ~ 50, cost 50×400 = 2e4 terms — trivial.
And the h, h/2 convergence check: recompute everything at h/2 = 0.01 — still cheap (double). Good.
Precision subtlety for the kernel at n=10⁵, σ near 3: k = (w/(w−1))ⁿ − 1 where |w/(w−1)|ⁿ ~ e^{n·σ/((σ−1)²+T²)} ~ e^{~1} — fine.
Let me also double-check the trapezoid error. The integrand is smooth (analytic, |Φ′| ≤ ~2). Trapezoid error ~ O(h²·max|f″|·length). |f″| — f has curvature from phase ~ Φ′² ~ 4, magnitude ~400 (n=10⁴) → h²·400·200/12 ~ 0.0004·8000·... let me: h=0.02, h²=4e-4, error ~ (4e-4/12)·|f″|·L. |f″| ~ |Φ′|²·|f| ~ 4·400 = 1600 near peak, L ~ 200 → error ~ 4e-4/12 · 1600 · 200 ≈ 10.7. Hmm, that's vs envelope 1e4 and expected true value maybe ~100 — 10% error, marginal. The h vs h/2 check will measure the actual error; if too big, refine h to 0.005 (×4 cost — still trivial). Trapezoid for oscillatory analytic functions converges spectrally actually (Euler–Maclaurin: error ~ e^{−2π·dist to singularity/h} for periodic... not periodic here, but endpoints: the error is dominated by endpoint derivative corrections ~ h²(f′(b)−f′(a)) + higher. f′ near endpoints is small (f tiny at b=2√n; at a=3 f ~ O(1), f′ ~ O(1)) → h²·O(1) ~ 4e-4. The mid-range |f″| doesn't actually enter the Euler–Maclaurin endpoint expansion beyond... no wait, EM: error = Σ B_{2k}/(2k)! h^{2k}(f^{(2k−1)}(b) − f^{(2k−1)}(a)). f^{(2k−1)} at endpoints: at a=3, f′ ~ |f|·(|Φ′|+|growth|) ~ O(1); f‴ ~ |f|·(derivatives)³ ~ O(10). So h² term ~ 4e-4·O(1)/12 ~ 3e-5, h⁴ term ~ 1.6e-7·10 ~ 1.6e-6. EXCELLENT — trapezoid is near-spectral here because the function is tiny at both endpoints relative to its peak. So h = 0.02 with the h/2 check is more than adequate; even h = 0.05 would do. Good.
Now the mpmath ζ evaluation for the mid part [−2.5, 3]: 275 points × 2 evals — trivial. Wait, mpmath zeta at dps 50 in the critical strip at t ~ 316: Euler–Maclaurin cost grows with t — maybe 10–100 ms per eval at dps 50 — 275×2×3 n-values... n only changes T: 275 × 3 × 2 × 50 ms ≈ 80 s. Acceptable. Hmm, for n=10⁵, t=316: mpmath zeta at t=316 dps 50 — fine.
Actually, should I include I_mid at all? It dilutes focus but gives the full I_II. The verdict per the mission: "Re(I_II) ~ envelope ⟹ per-side claim FALSE; |I_II| ≪ envelope ⟹ hidden cancellation". Note the verdict's two prongs use Re(I_II) vs |I_II| — slightly inconsistent objects; I'll report everything and frame the verdict on I_right (the part whose envelope exploded). The middle part's envelope (~(e⁴+1)·[NI + 5.5·85] ~ 55.6 × ~800 ~ 4.4e4?? hmm wait that's bigger than the right envelope 1e4! Let me recompute: NI = Z2·2·log(16.5/c), Z2(317) = 0.6·log 319 + 0.886·log log 319 + 2.7 ≈ 0.6·5.77 + 0.886·1.75 + 2.7 ≈ 3.46+1.55+2.7 = 7.7; c = 1/(9·Ĉ₀(319)) ≈ 1/(9·(0.433·5.77+0.886·1.75+2.9)) = 1/(9·7.95) ≈ 0.014; log(16.5/0.014) = log 1180 ≈ 7.07; NI ≈ 7.7·2·7.07 ≈ 109. 5.5·(10.5·log 319 + 48) = 5.5·(60.6+48) = 597. Sum ≈ 706; ×(e⁴+1 = 55.6) ≈ 39250. So the MIDDLE part's honest bound is ~4e4 at n=10⁵ — vs the right-tail envelope 5.9e10. The middle bound is fine (it's charged in Bn as ≤ 7Ĥ+3.3 share ✓). The TRUE middle integral is probably ~O(100). OK.
So E-032 outputs: for each n and c ∈ {1, 1.5, 2}:
- ε chosen, clearance
- I_right (Re, Im, |·|), envelope_right (= ∫₃^{2√n}|f|), ratio
- quadrature convergence delta
- validation max discrepancy
For c = 1 only: also I_mid, I_full = I_mid + I_right, and the envelope_mid for context.
Actually for c ≠ 1 the endpoint is still 2√n (the rectangle's right edge stays σ₁ = 2√n in the repair; only T changes). Yes — repair (R) keeps σ₁ = 2√n, raises T only. ✓ (D-072 §6: I_I length 2T etc.)
Wait, one thing: for c = 2, n = 10⁵, T = 632: the Λ-sum at σ ∈ [3,5): mpmath zeta at t = 632, dps 50 — Euler–Maclaurin ~ √t terms... fine.
Also — for c = 1.5/2 do I need the ε zero-avoiding scan? The horizontal line at T = c√n: for the diagnostic, any T not within ~1e-6 of a γ works for quadrature; use the same scan. Cheap. OK.
Also record E-031 cross-check: envelope_right at c=1, n=10⁴ should ≈ E-031's 1.05e4 (E-031 used step 2 and K=300 Λ-sum; ours is finer/exacter). Add as check V0.
Runtime estimate total: Dirichlet part trivial; mpmath zeta: [3,5] strip 100 pts × 3 n × 3 c × 2 (h, h/2) = 1800 evals × ~50 ms = 90 s; mid part 275 × 3 × 2 × 2 × 50 ms = 165 s. Total ~4–5 min. Run detached with log, per the long-runs memory (CLI kills ~2–10 min; 5 min is borderline → detached).
Hmm — one more thing: the mpmath zeta dps-50 accuracy validation. V-A validates against Dirichlet at σ ∈ {3, 3.5, 4, 4.5, 5} for each T used. That's the key validation (mpmath at t = 316, σ = 3–5, moderate args — expect ~1e-45 accuracy actually; the known mpmath complex-ζ ~1e-10 issue was probably at higher t or specific paths. The spot check will tell us the truth and we report the discrepancy.)
And the Dirichlet series itself at σ ≥ 5 is EXACT (it's the definition of −ζ′/ζ for re > 1) with certified tail < 1e-11 — no validation needed beyond the tail certificate.
Edge case: k^w for k up to 700 at dps 50 — mpmath mp.power(k, -w) with mpf base and mpc exponent — fine.
Λ sieve: smallest prime factor sieve to K_max = 7000 (for spot checks) — trivial. Actually the spot check at σ=3 wants K ~ 8e4 for 1e-8. Sieve to 8e4 — fine.
Let me now also confirm the integrand sign/convention: Jlag n w = k_n(w−1)·(−ζ′/ζ w)? From rectInt'_Jlag: residue sum = ResW1 + Σ mult·(1−(ρ/(ρ−1))ⁿ). With integrand f(w) = k_n(w−1)·(−ζ′/ζ(w)): at w = ρ (zero, mult m): −ζ′/ζ has residue −m; k_n(ρ−1) = (ρ/(ρ−1))ⁿ − 1; residue of f = −m·((ρ/(ρ−1))ⁿ−1) = m·(1−(ρ/(ρ−1))ⁿ) ✓. At w = 1: −ζ′/ζ has residue +1 (ζ has residue 1 at pole → logarithmic derivative −ζ′/ζ ~ +1/(w−1)); k_n(0) = (0)ⁿ − 1 = −1 → residue −1... but ResW1 n = Σ C(n,j) lcoeff(j−1) — the residue at 1 of k_n(w−1)·(−ζ′/ζ) involves the full expansion of k_n(w−1) = (w/(w−1))ⁿ − 1 around w = 1: (w/(w−1))ⁿ = (1 + 1/(w−1))ⁿ·... hmm wait: w/(w−1) = 1 + 1/(w−1). So (w/(w−1))ⁿ = Σ_j C(n,j) (w−1)^{−j}. Residue of [(w/(w−1))ⁿ − 1]·(−ζ′/ζ(w)) at 1: from the principal parts: Σ_j C(n,j)(w−1)^{−j}·(−ζ′/ζ) — residue = Σ_j C(n,j)·[coeff of (w−1)^{j−1} in −ζ′/ζ] = Σ_j C(n,j)·lcoeff(j−1) where lcoeff(m) is the Taylor coeff of −ζ′/ζ(1+s) in s^m. ✓ matches ResW1. And −1·(−ζ′/ζ) contributes residue −1·(+1)·... the "−1" factor: residue = −(−1)?? The constant −1 times −ζ′/ζ(w): residue = (−1)·res(−ζ′/ζ) = (−1)(+1) = −1. Hmm, and ResW1 as defined includes... The ii′-1b statement: rectInt'_Jlag = ResW1 n + Σ zeros. So the "ResW1 n" in Lean must already be the FULL residue at 1 including that −1 — i.e. ResW1 n := Σ_{j=1}^{n} C(n,j)·lcoeff(j−1) (j starts at 1, and j=0 term is the −1 contribution −lcoeff(−1)... whatever — the Lean statement is proven, so the convention is consistent. For E-032 the integrand is unambiguous: **f(w) = k_n(w−1)·(−ζ′/ζ(w))**, and I_right = ∫_{3}^{2√n} f(σ+iT) dσ. The (II) segment in the residue theorem traverses LEFT-to-RIGHT or RIGHT-to-LEFT depending on orientation — the rectangle integral is (2πi)⁻¹∮ counterclockwise presumably; the top edge goes from right to left (σ decreasing). |I_II| unaffected by orientation; Re/Im signs flip. For the verdict, orientation/sign is immaterial (we report magnitudes and both parts). I'll integrate left-to-right (dσ from 3 to 2√n) and note the convention.
Good. Also for comparability with E-031: E-031's envelope used |k_n(w−1)| (NOT |k_n| = |(1+1/s)ⁿ − 1| — E-031 dropped the −1, fine since the −1 is negligible at the peak) and Λ-sum K=300. Our refined envelope will match to ~1%.
Now let me write the script. File: research/numerics/scripts/E-032-horizontal-true-integral.py.
Structure:
- dps = 50.
- Λ sieve to K_MAX = 100000 (covers spot checks).
- dirichlet_neg_logderiv(σ, T, tol=1e-11): Σ_{k=2}^{K} Λ(k)/k^{σ+iT} with K from the tail certificate.
- mp_neg_logderiv(w): -(mp.zeta(w, derivative=1)/mp.zeta(w)).
- kernel(n, σ, T): (1 + 1/(σ−1+iT))ⁿ − 1 — careful: k_n(w−1) = (1+1/(w−1))ⁿ − 1 = (w/(w−1))ⁿ − 1.
- integrand f(n, σ, T): kernel·D where D = mp or dirichlet depending on σ < 5.
- choose_eps(n, c): zeros near T0 = c√n via zetazero around index; scan ε grid; return ε, clearance.
- integrate(n, T, a, b, h, zeta_mode): trapezoid complex sum + envelope sum; returns I, Env.
- Main: for n in [10³, 10⁴, 10⁵], c in [1, 1.5, 2]: ε, then h=0.02 and h=0.05 convergence (use h=0.05 and 0.02; report delta; if delta/|I| > 1e-6 also compute 0.01... just compute h=0.05, 0.02 and extrapolate; report), right part [3, 2√n]; validation at the 5 spot σ's per (n, c=1) (and maybe all c). For c=1: mid part [−2.5, 3] via mpmath.
- Checks: V0 envelope matches E-031 (1.04–1.06e4 at n=10⁴); VA validation ≤ 1e-6 (expected ~1e-9); VC convergence delta/|I| ≤ 1e-4; V3 repair: |I_right(c=2)| ≤ 10·(some bound) — just report; the check: |I_right(c=2)| < |I_right(c=1)|/10³ or something — report ratios, mark check as "repaired values small" with a loose threshold like |I_right(2)| ≤ 50·√n·log n... Let me not over-constrain: the checks should be PASS/FAIL on things we're confident about: envelope reproducibility, validation agreement, quadrature convergence. The verdict numbers are reported, not checked (we don't know the answer in advance — that's the point of the diagnostic). For the repair: check monotone decrease of envelope? Envelope at c=2 is tiny by E-031 V3 — check Env(c=2)/Env(c=1) < 1e-6 at n=10⁵.
CSV rows: per (n, c): the full record. JSON sidecar: checks + verdict-relevant summary + notes.
db registration: db.py log-experiment — need to check its signature. Handoff: "db.py: init, log-experiment, add-result, add-derivation, add-graveyard, list. add-derivation signature: positional id, --title --task --status --file (NO --date flag)."
Let me check db.py log-experiment signature quickly.
Then run: quick foreground smoke test with small settings? The script caches (skip if JSON exists unless --force). For the smoke test I'll add a --smoke flag? No — keep the script deterministic per its cache convention; I'll just run it detached and poll. But a quick syntax check + a 10-second partial (e.g., python -c import) in foreground first.
Let me write the script now. One decision: to keep runtime low, do the h-convergence with h = 0.05 and h = 0.02 (two grids), both cheap since Dirichlet dominates and is trivial. mpmath part: [3,5] strip: 40 pts at h=0.05 + 100 pts at h=0.02 per (n,c) → 140×9 = 1260 evals ~ 60 s. Mid part (c=1 only): [−2.5, 3]: 110 + 275 = 385 × 3 = 1155 evals ~ 60–120 s. Total ~3 min. Detached it is.
Hmm, actually, let me reconsider including n=10⁵ for the mid part: mpmath zeta at t=316, σ∈[−2.5,3], 385 evals ~ maybe 100 ms each at dps 50 = 40 s. Fine.
Wait, also: at c=1, T=√n+ε, the mid-part integrand includes the near-zero regions |σ+iT − ρ| small — zeros with γ ≈ T? The ε-scan ensures clearance ≥ decent. And zeros with γ far from T are no issue. OK.
Also potential issue: mp.zeta(w, derivative=1) at w near the pole w=1? Only if T ≈ 0 — never (T ≥ 31).
Write it. Also make sure to use mp.mp.dps = 50 (the setter bug). And deterministic: yes.
For the JSON sidecar verdict field: leave a "verdict_inputs" block with Re/Im/|I_right|/envelope ratios per n — the D-073 §2 write-up interprets.
Let me also double check the trapezoid: I = h·[½f(a) + Σ_{i=1}^{N−1} f(a+ih) + ½f(b)]. b = 2√n might not land on grid: use N = ceil((b−a)/h), last partial step — simpler: adjust h_eff = (b−a)/N. Deterministic.
Envelope: same grid with |f|.
Now — mpmath zeta cross-check tolerance: at σ=3, Dirichlet K for 1e-8: (K−1)² > 1e8·(log/2+0.25) ~ 1e8·3.7 → K ~ 2e4 ✓ sieve to 1e5 covers. Spot checks at σ ∈ {3, 3.5, 4, 4.5, 5} with tol_dirichlet 1e-8, require |mp − dirichlet| ≤ 1e-6·max(1,|D|). Report max discrepancy.
K(σ) selection: K = min{k : tail_cert(σ, k) < tol}, computed by scanning k from 8 upward (geometric: try k = 8, 16, 32, ... then bisect? For determinism and simplicity: precompute Λ and log table; for each σ iterate k = K_prev... The values: σ=5: 700; σ=5.5: ~300; σ=6: 130; σ=7: 50; σ≥8: ≤ 30. Scan from 4 upward in steps until cert < tol — at σ=5 that's 700 iterations of trivial arithmetic — fine. Cache per unique σ-rounded? σ takes grid values 3.00, 3.02, ... — each unique, ~700 evaluations of a log formula each ~1µs — fine.
Alright, writing the script now.
One more consideration — the JSON sidecar format and CSV columns follow the E-031 pattern. And register via db.py log-experiment — check its args: probably `db.py log-experiment E-032 --title ... --session 039 --script ... --csv ... --json ...`? Let me check quickly.
All inputs absorbed. Marking reading complete and checking the db.py registration interface before building E-032.
tool: TodoWrite
input
{
"todos": [
{
"content": "Read all mission inputs (D-073 \u00a70, D-072, Lagarias pp. 27\u201329, D-071, E-031 script)",
"status": "completed",
"activeForm": "Reading mission inputs"
},
{
"content": "6-R-0: build + run E-032 diagnostic (true complex I_II at T = \u221an, n = 10\u00b3/10\u2074/10\u2075, dps \u2265 40) vs E-031 envelope; record verdict",
"status": "in_progress",
"activeForm": "Running E-032 diagnostic"
},
{
"content": "Register E-032 in research.db + write D-073 \u00a72 (verdict + numbers); commit sub-stage 6-R-0",
"status": "pending",
"activeForm": "Committing sub-stage 6-R-0"
},
{
"content": "6-R-1: D-073 \u00a7\u00a73\u20137 (dependency audit, corrected stepping lemma with explicit constants, choice of c, consequence audit, E-033 cross-validation)",
"status": "pending",
"activeForm": "Writing the repaired proof"
},
{
"content": "6-R-2: D-073 \u00a78 drafts (letter paragraph + per-side verdict paragraph); close thread; commit",
"status": "pending",
"activeForm": "Drafting letter/finding-note paragraphs"
}
]
}
tool: Bash
input
{
"command": "./.venv/Scripts/python.exe research/numerics/scripts/db.py log-experiment --help 2>&1 | head -30",
"description": "Show db.py log-experiment usage"
}
raw content_json (database row)
[{"type":"thinking","thinking":"All mission inputs read. Now I understand the full picture. Let me design E-032.\n\n**E-032 design (sub-stage 6-R-0, deliverable D1):**\n\nThe goal: compute the TRUE complex horizontal integral I_II at T = √n (zero-avoiding) by direct quadrature, and compare to the E-031 envelope.\n\nWhat exactly is I_II? In Lagarias's notation (Thm 6.1), the integrand on the horizontal segment (II) at height t = T, for ζ (π = Riemann zeta case):\n\nI_II = ∫ k_n(s)·(−ζ′/ζ(s+1)) ds\n\nWait — let me get the exact contour convention. From D-071 §4.1: the rectangle is z = −5/2 − iT, w = 2√n + iT; the integrand is the Lagarias-kernel integrand Jlag. From ii′-1b, `rectInt'_Jlag`: RectangleIntegral' (Jlag n) z w = ResW1 n + Σ ... where Jlag is the integrand of the (6.2) integral.\n\nIn Lagarias's paper, (6.2): I_2(n) = (1/2πi) ∫_C k_n(s)·(−L′/L(s+1,π)) ds? Actually from the proof passage: \"the integrand k_n(s)·(−L′/L(s,π))\" with k_n(s) = (1+1/s)ⁿ − 1, on segments where L′/L is evaluated at s+1... Let me look at the details:\n\n- D-072 says: \"The contour: integrand k_n(s)·(−L′/L(s+1)), k_n(s) = (1+1/s)ⁿ − 1, on the rectangle σ₀ ∈ (−3,−2), σ₁ = 2√n, im = ±T, T = √n + ε.\"\n\n- The stepping passage (6.12): |k_n(s+1)+1|/|k_n(s)+1| — the kernel stepping in s. And (6.10) gives |L′/L(σ+1+iT)| halving — so L′/L is evaluated at s+1. Wait, in (6.10) they write |L′/L(s,π)| ≤ 2^{−(σ−2)}|L′/L(2,π)| for σ > 2. And on (II), they step from σ = 3 with |L′/L| = O(1) \"since we are in the absolute convergence region\". Hmm — in the paper the integrand is k_n(s)·(−L′/L(s+1, π))? Let me check: (6.2) in the paper is\n\nI_2(n) = (1/2πi) ∫ k_n(s) ·(−L′/L(s+1, π)) ds? \n\nActually from D-072 and the E-031 script: `product(n, sig, c)` computes |k_n(w−1)|·|Σ_{k<300} Λ(k)/k^w| at w = σ+iT. So E-031 models the integrand as k_n(w−1)·ζ′/ζ(w) with w = s+1, i.e., integrand = k_n(s)·L′/L(s+1) where s ranges over σ ∈ [−3-ish, σ₁−1]... Hmm, but the variable substitution: if the integrand is k_n(s)·(−L′/L(s+1)) and we set w = s+1, then the integral is over w from σ₀+1 to σ₁+1. E-031 integrates the envelope over w ∈ [3, 2√n] roughly (actually sig from 3 to 2T). \n\nWait, actually there's a subtlety. Let me re-read. In Lagarias Thm 6.1, the integral I_2(n) is defined in (6.2). From the proof: \"We now consider the integral I_2(n) on the vertical segment (I) having Re(s) = σ₁ = 2√n\" and the horizontal segments (II), (IV) at im = ±T, and left vertical (III) at σ₀ ∈ (−3,−2). The integrand: k_n(s)·(−L′/L(s,π))... but then the zeta argument on (II) at the RIGHT end (σ near σ₁ = 2√n) is in the absolute convergence region, and at the LEFT end (σ = −3) it's at L′/L(−3+1)? No wait.\n\nFrom the stepping passage: \"we step across the interval (II) towards the right, in segments of length 1, starting from σ = 3. At the initial point we have |L′/L| = O(1) since we are in the absolute convergence region, and the estimate (6.10) gains a factor of 2 going one unit to the right.\"\n\n(6.10) is for Re(s) > 2: |L′/L(s)| ≤ 2^{−(σ−2)}|L′/L(2)|. So on (II), the L′/L argument at contour-point s is s+1 (so that at contour σ = 3−1 = 2... hmm no).\n\nActually the cleanest interpretation, consistent with E-031 and D-071: the integrand is k_n(s)·(−L′/L(s+1)) and stepping starts at contour σ = 2 with L′/L evaluated at 3? Hmm, but D-072 says \"starting from σ = 3\".\n\nLet me just use the convention from our own Lean work: `rectInt'_Jlag` has integrand Jlag n and the rectangle z = −5/2 − iT, w = 2√n + iT. From ii′-1b, Jlag n = the Lagarias kernel integrand. From D-071 §4.1, the residue sum is at 1 and at zeros ρ with term (1−(ρ/(ρ−1))ⁿ). The kernel k_n(s) = (1+1/s)ⁿ − 1 = ((s+1)/s)ⁿ − 1. The zero term (ρ/(ρ−1))ⁿ = (1 + 1/(ρ−1))ⁿ... So the integrand is Jlag n (w) = k_n(w−1)·(−ζ′/ζ(w))? Let's see: residue at w = ρ: k_n(ρ−1) = (ρ/(ρ−1))ⁿ − 1, times residue of −ζ′/ζ which is −mult. Product's residue: −mult·((ρ/(ρ−1))ⁿ − 1) = mult·(1 − (ρ/(ρ−1))ⁿ). ✓ matches. And at w = 1: k_n(0) = 0ⁿ − 1 = −1 (for n ≥ 1), residue of −ζ′/ζ at 1 is +1, so residue = −1·... hmm, but ResW1 n = Σ_j C(n,j)·lcoeff(j−1). Actually the (w−1)^{n+1} expansion gives more. OK whatever — the key point:\n\n**Integrand on horizontal (II): Jlag n (w) = k_n(w−1)·(−ζ′/ζ(w)), w = σ + iT, σ ∈ [σ₀, σ₁] = [−5/2, 2√n]** (in our variant-B rectangle; Lagarias uses σ₀ ∈ (−3,−2), and we adopted −5/2).\n\nSo I_II = ∫_{σ₀}^{σ₁} k_n(σ−1+iT)·(−ζ′/ζ(σ+iT)) dσ (with the (2πi)⁻¹ normalization for RectInt but the per-side bound |I_II| is the raw integral as charged in the paper convention).\n\nE-031 computed the envelope: |k_n(w−1)|·|ζ′/ζ(w)| integrated over σ ∈ [3, 2√n] (the \"right tail\"), with ζ′/ζ modeled by the Dirichlet series Σ_{k<300} Λ(k)/k^w (valid for Re w > 1, i.e., σ > 1... at σ = 3 it's fine).\n\n**E-032 must compute the TRUE complex integral** I_II (at least its right part [3, 2√n], or the full [σ₀, σ₁]) at T = √n zero-avoiding (T = √n + ε with ε chosen so the line stays away from zeros — for n = 10³, T ≈ 31.6; zeros near 31.6? We'd need to check the zero-avoiding choice. Actually for the diagnostic, we just need T = √n + ε with the horizontal line not hitting a zero; the quadrature is over σ at fixed im = T, and ζ′/ζ is evaluated by mpmath directly (ζ has no zeros on the line im = T as long as T is not exactly a γ). For diagnostic purposes, ε = 0.5 say, after checking no zero within some clearance. Actually simpler: pick ε to maximize clearance from the nearest zero ordinate.\n\nComputation plan:\n- For n ∈ {10³, 10⁴} (10⁵ if cheap — likely not: ζ′/ζ at σ up to 2√n = 632 for n=10⁵ with mpmath at dps 40... actually ζ(632+316i) is computable by mpmath but slow-ish; also k_n values involve e^{20} magnitudes; fine. But the quadrature over σ ∈ [3, 632] with an oscillatory integrand — the phase is O(1) rad/unit per D-073, so ~400–700 sample points might suffice with a fine grid. Cost: each ζ′/ζ evaluation at dps 40 via mpmath... mpmath zeta at σ=100+ is via Euler-Maclaurin, reasonably fast. Hmm, but at dps 40 and large σ, ζ(σ+iT) → 1 + 2^{−s} + ..., mpmath handles it. ζ′ similar. Could be maybe 10–100 ms per point → 700 points × 2 n values = fine.\n\nWait, actually — accuracy concern: mpmath's ζ at high σ is fine (absolutely convergent-ish region, Euler-Maclaurin). The handoff notes say \"mpmath complex-ζ OK to ~1e-10\" and \"mpmath zeta (integer+Hurwitz) UNTRUSTWORTHY beyond ~57 digits at any dps\". At dps 40, we're under 57 digits, and complex arguments are OK to ~1e-10 relative. The integrand magnitude ranges over e^{±20}; we need the integral's real part to maybe ~1e-6 relative of the envelope or better. Given values ~1e8–1e10 in the envelope, a 1e-10 relative error per point is fine.\n\nActually, more careful: mpmath zeta for complex s at dps 40 — the note says OK to ~1e-10 (probably absolute-ish at moderate args). The integrand peak is ~1.3e9 at n=10⁵... but we're not doing n=10⁵ necessarily (\"if cheap\"). For n=10⁴, peak ~430 (e^{6.05}); envelope integral ~1.05e4. An error of 1e-10 per point × 1000 points ~ 1e-7 — fine to detect whether Re(I) ~ 1e4 or ≪ 1e4.\n\nValidation: D-073 says \"validate ζ′/ζ against the Dirichlet series where re > 2\". So for σ ≥ 3 (re w ≥ 3... wait re > 2 for (6.10)), compute −ζ′/ζ(w) two ways: mpmath (zeta and zeta derivative, or logDeriv via diff) and the Dirichlet series Σ Λ(k)/k^w truncated with a tail bound. At σ ≥ 3, the tail beyond K is ≤ Σ_{k>K} Λ(k)/k^σ·... ~ small. Use K large enough (e.g., up to where K^{1−σ}·... < 1e-45). At σ = 3, need K ~ maybe 10⁷ for dps 40? Σ_{k>K} Λ(k) k^{-3} ~ (1/2)K^{-2} log K-ish... for 1e-45 need K ~ 1e22 — not feasible. Hmm. But we don't need dps-40 absolute accuracy in the ζ factor — we need the INTEGRAL accurately. \n\nRethink precision: the integrand magnitude on the right tail: at σ = 3, product ~ O(1) (e^{-0.03} at n=10⁵, similar smaller n). The peak ~ e^{0.066√n} is at σ ≈ 0.36√n: for n = 10³, √n ≈ 31.6, peak at σ ≈ 12, height e^{1.44} ≈ 4.2; for n = 10⁴, peak at σ ≈ 30, height ~430. So the dominant contribution is at σ ≥ 12 (n=10³) / σ ≥ 30 (n=10⁴) where the Dirichlet series converges FAST (2^{-σ} dominated). At σ = 12: Σ_{k>K} Λ(k)/k^{12} ~ tiny for K = 300. At σ = 30: K = 64 already gives 2^{-30}·... So the Dirichlet series with K = a few hundred IS the ζ′/ζ value to extreme precision in the peak region. \n\nSo the plan: compute −ζ′/ζ(w) via truncated Dirichlet series Σ_{k≤K} Λ(k)/k^w with K chosen per σ so the tail < 1e-42 (easy for σ ≥ 8; for σ ∈ [3, 8) use more terms or mpmath cross-check), and CROSS-VALIDATE against mpmath's −ζ′/ζ at a sample of points (mpmath diff of zeta or mpmath's `mp.zeta(w, derivative=1)`). The mission says \"validate ζ′/ζ against the Dirichlet series where re > 2\" — i.e., use mpmath as primary and Dirichlet as check, or vice versa. I'll use the Dirichlet series as primary for σ ≥ 3 (it's exact, fast, controlled tail) and mpmath zeta as the cross-check at sample points.\n\nQuadrature: trapezoidal with adaptive refinement. The phase: k_n(w−1) = ((w)/(w−1))ⁿ = exp(n·log(1+1/(w−1))). Phase ≈ n·Im log(1+1/(w−1)) ≈ −n·T/((σ−1)²+T²)... at T² = n, phase ≈ −nT/(σ²+n) ~ O(√n)?? Wait D-073 says \"phase O(1) rad/unit\" — the DERIVATIVE of the phase is O(1) per unit σ. Total phase swing over [3, 2√n] ~ O(√n) radians. For n = 10⁴, ~ 300 rad over the range — but the D-072 §5 says \"phase-winding of arg(k_n·L′/L) ~ −300 rad over the peak region\". So the integrand DOES oscillate with period ~2π/(phase derivative) — phase derivative ~ O(1)–O(3) rad/unit near the peak... With trapezoid at step h, we resolve oscillation if h·|Φ′| ≪ π. |Φ′| ≤ ~2–3? Then h = 0.05 gives 0.15 rad per step — 40 points per period. That's very fine. With h = 0.05 and range ~200 (n=10⁴: 3 to 200), that's 4000 points; each point needs Λ-sum up to K maybe 500–2000 at small σ — trivial. Cost is negligible. Actually let me reconsider: at σ = 3 the Λ sum needs K such that tail ~ ∫_K^∞ log x · x^{−3} dx ~ (log K)/(2K²) < 1e-42 → K ~ 1e20. NOT feasible!\n\nHmm. But wait — do we need the integrand at σ = 3 to 1e-42? No! We need the INTEGRAL to enough precision to render the verdict. The verdict compares Re(I_II) vs envelope ~1e4 (n=10⁴). Even 1e-6 relative on the envelope is overkill. The integrand near σ = 3 is O(1); a 1e-8 absolute error there contributes ≤ 1e-8 × (range) — nothing. So: accuracy budget: absolute error per point ≤ 1e-9 is plenty (integral error ≤ 2e-7 vs envelope 1e4). At σ = 3: Λ-sum tail (log K)/(2K²) < 1e-9 → K ~ 3e4: K = 50000, tail ~ (10.8)/(2·2.5e9) ~ 2e-9. Good enough. And mpmath cross-check at σ = 3 to validate.\n\nHmm wait, but dps ≥ 40 is prescribed. The point of dps 40 is to handle the CANCELLATION: the integrand values are ~e^{±6} ~ 400, and the integral may come out ~O(√n) = O(100) vs envelope 1e4 — cancellation of ~2 digits. With float64 we'd have ~13 digits left — actually fine. But there could be more cancellation. dps 40 gives huge headroom. Also k_n for n = 10⁵ (if we run it): values e^{20} ~ 5e8, integral maybe O(300) vs envelope 5.9e10 — cancellation ~ 8 digits; float64 leaves ~5 digits — borderline; dps 40 solves it. OK: mp.mp.dps = 50 for headroom. (The mpmath dps bug: use mp.mp.dps — noted in memory and E-031 does mp.mp.dps = 25... wait, E-031 uses `mp.mp.dps = 25`. Yes correct form.)\n\nNow: what T exactly? \"T = √n (zero-avoiding)\". For the diagnostic at n = 10³: √n = 31.622...; zero ordinates near there: γ ≈ 32.935, 30.424, ... So T = 31.62 is between zeros at distance ~1.2 — fine, ε = 0 works for quadrature purposes as long as ζ′/ζ is evaluated by the exact Dirichlet series (no pole issues — poles are only at zeros, and we're evaluating |σ + iT − ρ| ≥ ... fine). But hold on — the ζ′/ζ via Dirichlet series is only valid for re w > 1! For σ ≤ 1 we can't use the Dirichlet series. But the right tail starts at σ = 3, so for the RIGHT part diagnostic we're entirely at σ ≥ 3 ✓. \n\nShould E-32 cover the FULL horizontal [σ₀, σ₁] or just the right part [3, 2√n]? The mission (D1) says \"compute the TRUE complex horizontal integral I_II at T = √n\" and the verdict is about Re(I_II) ~ envelope vs ≪ envelope. The envelope in question (E-031) is the right-tail envelope ∫₃^{2√n}. The left/middle part [σ₀, 3] is charged separately (NI + 5.5(10.5 log+48)) and is NOT in dispute. So E-032 should compute the right part I_right = ∫₃^{2√n} Jlag dσ (complex, exact) and compare with the envelope ∫₃^{2√n}|Jlag| dσ. \n\nI'll ALSO compute the middle part integral over [σ₀, 3] = [−5/2, 3] as a secondary check? That requires ζ′/ζ in the strip — mpmath only (no Dirichlet). mpmath zeta at dps 40, complex args, OK to ~1e-10 — fine. But is it needed for the verdict? The verdict is specifically about whether the per-side claim |I_II| = O(√n) survives via cancellation IN THE RIGHT TAIL (the broken part). The middle part is bounded by standard machinery. I think the primary deliverable is the right part. I'll include the middle part as an optional secondary computation if cheap — actually yes, let me include it: then we get the FULL I_II complex value, which directly answers \"the per-side claim |I_II| = O(√n) — TRUE or FALSE at T = √n\". The mpmath evaluation over [−2.5, 3] × {iT}: ζ′/ζ via mp.zeta(w, derivative=1)/mp.zeta(w) — careful: mp.zeta(s, derivative=1) gives ζ′(s). At dps 40 with complex s — known OK to ~1e-10 (per handoff). Kernel on [−2.5, 3] is ≤ e⁴+1 ~ 55.6, |ζ′/ζ| ≤ (log T)²-ish ~ 12 — integrand ~ 600 max, integral over length 5.5 ~ few thousand? Hmm, that's the same order as the claimed O(√n) = 100. The middle part honestly charged is ~NI + 5.5(10.5·log+48) ~ 5.5 × 85 ~ 470 + NI ~ maybe 300 → ~700. That's already > √n = 100... wait but that's an UPPER bound; the true middle integral could be ~50. The per-side claim |I_II| = O(√n) with an unstated constant — the verdict is really about the RIGHT part: does the true right-tail integral come out ~envelope (1e4, proving |I_II| ≫ √n and the claim FALSE) or ≪ envelope (hidden cancellation)?\n\nOK here's the clean design:\n\n**E-032 script** (`E-032-horizontal-true-integral.py`):\n\nParameters: n ∈ {1000, 10000} (and 100000 if cheap — I'll assess; likely include a coarse run), c = 1 (T = √n), ε chosen zero-avoiding: scan zero ordinates near √n (via mp.zetazero) and pick ε ∈ [0, 1) maximizing min clearance. Also compute for the repair heights c ∈ {1.5, 2} as a secondary validation (the repaired integrals should be tiny; that cross-validates the quadrature against the repair claim — actually that's E-033 territory; keep E-032 focused on T = √n; but a c=2 run is a nice sanity check that the same quadrature code gives small values where expected — cheap to add, adds confidence).\n\nComputations:\n1. **Setup**: T = √n + ε with ε zero-avoiding (report ε and clearance). Use mp.zetazero over a window around √n.\n2. **ζ′/ζ evaluation** (primary: Dirichlet series for σ ≥ 3): D(w) = Σ_{k=2}^{K(σ)} Λ(k)/k^w with K(σ) minimal such that tail bound < tol·|...|. Tail bound: Σ_{k>K} Λ(k) k^{−σ} ≤ θ-tail via integral: ≤ (log K)·K^{1−σ}/(σ−1)·(1 + 1/log K + ...) — I'll use a simple certified bound: Σ_{k>K} Λ(k)/k^σ ≤ 2·Σ_{k>K} log(k)/k^σ ≤ 2·∫_{K−1}^∞ log x/x^σ dx = 2·[(log(K−1))/((σ−1)(K−1)^{σ−1}) + 1/((σ−1)²(K−1)^{σ−1})]. Choose K so this < 1e-11 (absolute; the integrand there is O(1)–O(400), so the ζ-factor error 1e-11 → integral error ~ 4e-8 — fine).\n Cross-check (validation V-A): at a sparse grid of σ values (say 20 points across [3, 2√n]), compare D(w) vs mpmath −ζ′/ζ(w) (mp.zeta(w,1)/mp.zeta(w) — wait, mpmath: mp.zeta(w, derivative=1). Yes mp.zeta(w, derivative=1)). Require agreement ≤ 1e-8 relative-ish. Report max discrepancy.\n3. **Kernel**: k_n(w−1) = (1+1/(w−1))ⁿ − 1. In mp precision direct: (w/(w−1))**n − 1. For n = 10⁵, w/(w−1) ≈ 1 + 1/(σ−1+iT), log ≈ ... direct power is fine in mp (mpmath handles complex power via exp/log; precision loss ~ n·ulp? At dps 50, fine).\n4. **Quadrature**: composite trapezoid on σ ∈ [3, 2√n] at step h, with the integrand f(σ) = k_n(σ−1+iT)·(−ζ′/ζ(σ+iT)) — sign: −ζ′/ζ = D(w) as defined (D is −ζ′/ζ = Σ Λ/k^w ✓). Convergence check: run h and h/2, report |I_h − I_{h/2}| as the quadrature-error estimate. Choose h adaptively: the phase derivative |Φ′| ~ up to ~2–3 rad/unit near σ small... Let me just take h = 0.02 for n=10³ (range [3, 63] → 3000 pts) and h = 0.02 for n=10⁴ (range [3, 200] → 9850 pts). Each point: Λ-sum with K maybe up to 5e4 at σ=3 — that's the expensive end: 5e4 terms × 3000 pts(n=10³, but K large only at small σ)... hmm, total cost: for each σ, sum over k≤K(σ). At σ=3, K=5e4; at σ=4, K≈3e3; σ=5: K≈700; σ≥6: K≤300. So the σ ∈ [3, 4] strip has 50 points × ~3e4 terms = 1.5e6 term-evaluations (each a mpmath complex division k^w — k^w = exp(w log k) — mpmath mpc pow ~ microseconds at dps 50? More like 10–50 µs. 1.5e6 × 30µs = 45 s. Plus the rest negligible. For n=10⁴: same [3,4] cost + long tail cheap. OK ~1–2 min per n. Acceptable (may not need detached; but CLI kills Bash at ~2–10 min per memory — so run DETACHED with log file to be safe, or keep runtime < ~5 min. I'll optimize: use float64/log caching? No — keep it simple, mp everywhere; precompute log k once per k as mpf (K_max = 5e4 logs — fine), and k^{−w} = exp(−w·log k) with mpc exp... still per-(σ,k). Alternatively use mpmath's built-in? There's no built-in for truncated Λ sums. Fine, 1–2 min.\n\nActually — simpler speedup: for σ ∈ [3, 4] use mpmath's ζ directly as primary (validated against Dirichlet at sample points), and Dirichlet for σ ≥ 4 where K ≤ 3e3. mpmath zeta at dps 50 complex: ~1 ms per eval maybe. 50 points → trivial. Then total cost ~ 9850 × (K(σ) ~ 300 avg × 30µs) ~ 90 s. OK.\n\nHmm wait, but if mpmath is primary on [3,4] and Dirichlet on [4, 2√n], the validation V-A compares the two at sample points in both regions. Good.\n\n5. **Outputs (checks)**:\n - V-A (validation): max |D − (−ζ′/ζ)_mpmath| over the sample grid, and tail-bound certificate max K used.\n - V1 (main): Re(I_right), Im(I_right), |I_right| at T = √n for n = 10³, 10⁴ — vs envelope E_env (recomputed by the same quadrature grid with |f|, and cross-checked against E-031's values 1.05e4 at n=10⁴).\n - V2 (quadrature convergence): |I_h − I_{h/2}| / |I_h| small.\n - V3 (optional but valuable): same at c = 1.5, 2 — expect |I_right| SMALL (repair verified by direct integration, not just product monotonicity).\n - The verdict: ratio |I_right| / envelope.\n\nVerdict interpretation (recorded, not auto-decided): if |I_right|/envelope ~ O(1) (say > 0.1) → per-side claim FALSE; if ≪ (say < 1e-2) → hidden cancellation. Also compare |I_right| vs C·√n.\n\nAlso worth computing: Re(I_right) specifically (D-073 verdict is on Re(I_II) since Im is constrained by the identity). Note: the mission says \"Verdict: Re(I_II) ~ envelope ⟹ per-side claim FALSE; |I_II| ≪ envelope ⟹ hidden cancellation\". I'll report Re, Im, |·| all three.\n\nOne more sanity consideration: T = √n vs T = √n + ε. Lagarias picks T = √n + ε_n, 0 ≤ ε ≤ 1, zero-avoiding. E-031 used T = √n exactly (ε = 0). For comparability, use ε from the zero-avoiding scan but also report ε; the difference is immaterial for the verdict (the envelope is a smooth envelope).\n\nWhat about n = 10⁵? Range [3, 632], h = 0.02 → 31500 points, K(σ) cheap for σ > 4... ~ 3 min more. Values: kernel up to e^{20.98} ~ 1.3e9, integrand peak ~ 1.6e9 (product with ζ 1.8e-31·... wait no — the PRODUCT peak is 1.6e9? D-072 says peak product e^{20.98} ≈ 1.3e9 at σ = 120 (that's |k|·|ζsum| — yes the full product). Integral envelope 5.9e10. True integral could be ~O(√n) = 316 → cancellation of ~8.5 digits — at dps 50 fine. Include n=10⁵ if runtime allows (it's the decisive n for the finding). Actually — YES, include it: E-032's verdict at n=10⁵ is the most decisive (envelope 5.9e10 vs claimed O(√n) = O(316): if the true |I| comes out ~1e9+, the per-side claim is decisively false). Runtime maybe 3–5 min total. Run detached to be safe.\n\nWait, one concern on the quadrature at n=10⁵: phase |Φ′|. Let me estimate Φ(σ) = n·arg(1+1/(σ−1+iT)) ≈ −nT/((σ−1)²+T²). Φ′(σ) ≈ 2nT(σ−1)/((σ−1)²+T²)². At T² = n: Φ′ ≈ 2T³(σ−1)/((σ−1)²+T²)². Max over σ: let u = (σ−1)/T: Φ′ ≈ 2T³·uT/(T⁴(u²+1)²) = 2u/(1+u²)². Max of 2u/(1+u²)² at u = 1/√3: value = 2·(1/√3)/(4/3)² = (2/√3)·(9/16) ≈ 0.65. So |Φ′| ≤ ~0.65 rad/unit for the kernel. Plus the ζ′/ζ phase variation (slow, |d/dσ arg D| ≤ ~ |D′/D| ~ log-ish ~ O(1)). So total |Φ′| ≤ ~2 rad/unit; h = 0.02 gives 0.04 rad/step — 150 pts/period. Plenty. The h and h/2 check will confirm anyway.\n\nAlright — also the zero-avoiding ε scan: mp.zetazero(k) for k around the index of √n. Number of zeros below T: N(T) ≈ (T/2π)log(T/2πe). For T = 31.6: ~ 48; for T = 100: ~ 191; for T = 316: ~ 770. So compute zeros in [√n − 2, √n + 3]: use mp.zetazero(j) for j in a small range around the index. Fine.\n\nAlso — the LEFT/middle part [−5/2, 3]: include? It would make E-032 the FULL I_II. Cost: mpmath ζ over 275 points (h=0.02) at dps 50 — each ζ + ζ′ eval ~ ms — trivial. Include it as a separate reported number (I_mid) so D-073 can report full I_II = I_mid + I_right as well. The verdict hinges on I_right, but the full-side number is the direct test of the per-side claim |I_II| = O(√n). Yes, include — labeled secondary.\n\nHmm, actually for I_mid I need ζ′/ζ in the strip where there could be nearby zeros? At im = T (zero-avoiding, clearance ≥ ~1/(16Ĉ₀) — actually the ε scan gives clearance maybe ~0.3), σ ∈ [−2.5, 3]: zeros ρ = β+iγ with |γ − T| < clearance would be a problem only if |σ − β| also small — mpmath handles ζ′/ζ near zeros fine (it's just a function eval; the value is large but accurate). No issue.\n\nKernel k_n(w−1) for σ ∈ [−2.5, 3]: |(w)/(w−1)|ⁿ — at σ = −2.5: |1 + 1/(w−1)| ≈ 1 — fine, ≤ e⁴+1 bounded.\n\nOK also — V3 (repair heights c = 1.5, 2 direct integration): cheap to add (reuse machinery, T = c√n + ε, same n values, only right part). At c = 2, integrand ~e^{−43} at σ=100 — tiny; trapezoid fine. This directly verifies \"the repaired right tail is genuinely small\" by integration. Good.\n\nLet me also think about whether the \"hidden cancellation\" STOP condition affects the plan: D-073 says if |I_II| comes out SMALL, STOP and report before pursuing 6-R-1. So after E-032, I report the verdict to the user before writing the repaired proof? Actually the thread prompt says D1 verdict settles whether anything remains to pursue at T = √n; the repair (D2) is needed REGARDLESS (the main line executes repair (R) with the recommended c). The STOP is only about pursuing the T=√n salvage further. So: land E-032 (6-R-0) as its own committed sub-stage, report the verdict to the user, and continue to 6-R-1 (the repaired proof) — the mission says land D1 first as its own committed sub-stage, and the D-073 success criteria include the repaired proof regardless. But per the mission \"if |I_II| comes out SMALL, STOP and report to the user before going further\" — so if small, I stop after 6-R-0 and consult. If large (per-side FALSE), proceed to 6-R-1 directly. I'll decide based on the numbers.\n\nNow — the workflow: this is session 039. Let me check the journal for session 038 naming convention and the db.py registration. Also need to check the correspondence folder shouldn't be touched (freeze). New files: E-032 script + data sidecars, D-073 sections.\n\nLet me also quickly check db.py usage and the E-031 JSON sidecar for the registration pattern. Actually the handoff notes say: db.py: init, log-experiment, add-result, add-derivation, add-graveyard, list. Let me check the exact CLI for log-experiment.\n\nPlan of action:\n1. Write E-032 script.\n2. Test-run quickly at n=10³ with coarse settings in foreground (short), then full run detached with log.\n3. Verify outputs, register in db, write D-073 §2, commit.\n\nActually before writing, let me look at the db.py CLI to get log-experiment's signature, and glance at journal-038 for session conventions. Let me be efficient: just check db.py help.\n\nLet me now mark todo 1 complete and start building E-032.\n\nOne more design decision on the ε zero-avoiding scan: to keep determinism, scan ε ∈ {0, 0.05, ..., 0.95} and pick the one maximizing min |T − γ_j| over zeros within [√n−2, √n+3]. Report it. Deterministic across runs (zetazero deterministic at dps 50).\n\nPrecision: mp.mp.dps = 50 (note the mpmath bug: must use mp.mp.dps).\n\nFor the Λ(k) function: E-031's vonM only handles primes ≤ 47 — k up to 5e4 needs full factorization. Use sympy? Or simple trial division up to √k (≤224) — fine for 5e4 values (precompute a Λ table once per run via sieve: O(K log log K)). Use a sieve of Eratosthenes-style Λ computation: Λ(p^a) = log p. Simple: smallest-prime-factor sieve, then Λ(k) = log p if k is a prime power else 0. K_max = 5e4 → trivial.\n\nTail bound for choosing K(σ): Σ_{k>K} Λ(k)/k^σ ≤ 1.02·Σ_{k>K} log(k)/k^σ ≤ 1.02·∫_{K}^∞ (log x + 1/... hmm let me use a clean certified bound: for σ ≥ 3, Σ_{k>K} Λ(k) k^{−σ} ≤ Σ log(k) k^{−σ} ≤ ∫_{K−1}^∞ log x · x^{−σ} dx (since log x·x^{−σ} decreasing for x ≥ K−1 ≥ 2 when σ ≥ 3... derivative of log x·x^{−σ} = x^{−σ−1}(1 − σ log x) < 0 for log x > 1/σ ✓). Integral = [(log(K−1))/(σ−1) + 1/(σ−1)²]·(K−1)^{1−σ}. Choose K minimal with this < 1e-11. At σ=3: need [(log(K−1))/2 + 1/4]/(K−1)² < 1e-11 → (K−1)² > 1e11·(log(K−1)/2+0.25) → K−1 ~ 4e5?? Let me solve: (K−1)² > 1e11 · (ln(4e5)/2 ≈ 6.5) → K−1 > 2.5e6. Hmm, 2.5e6 terms × 50 points in [3,4]... 1.25e8 mpmath term evals × 30µs = ~1 hour. TOO SLOW.\n\nReconsider: use mpmath ζ as primary on [3, 5] (fast), Dirichlet for σ ≥ 5 where K(5): [(log(K−1))/4 + 1/16]/(K−1)⁴ < 1e-11 → (K−1)⁴ > 1e11·(log/4+1/16 ≈ 1.7) → K−1 > ~650. So K(5) ≈ 700, K(6) ≈ 130, K(7) ≈ 50, K ≥ 8: K ≤ 25. Great: for σ ≥ 5, Dirichlet is cheap and exact to 1e-11. For σ ∈ [3, 5]: mpmath primary, and VALIDATE mpmath against the Dirichlet series at the σ = 5 boundary (and a few interior points with a bigger-K spot check: at σ = 4, K(4): (K−1)³ > 1e11·(log/3+1/9 ≈ 2.4) → K ~ 6500 — a spot check at σ = 4 with K = 7000 is a one-off ~0.2 s ✓; at σ = 3.5: K ~ 5e4, one-off 1.5 s ✓; at σ = 3: K ~ 2.5e6 one-off ~ 75 s — acceptable as a ONE-point validation at n-independent (w = 3+iT differs per n... hmm, 3 validations × 75 s = 4 min extra. Reduce: validate mpmath at σ = 3 with tolerance 1e-8 instead of 1e-11 → K ~ 8e4, ~2.5 s ✓. Precision budget: we don't need 1e-11 at σ=3; 1e-8 is plenty.)\n\nActually — simpler unified approach: use mpmath −ζ′/ζ as PRIMARY everywhere on [3, 2√n] (it's just zeta evals; at large σ, ζ(σ+iT) = 1 + 2^{−w} + ... — does mpmath remain accurate at σ = 632, dps 50? Euler–Maclaurin with such large σ — mpmath should handle it (terms decay fast), but the handoff warns mpmath zeta untrustworthy beyond ~57 digits — we're at 50, borderline! And \"mpmath complex-ζ OK to ~1e-10\" — that was presumably at moderate args. At σ = 632, ζ ≈ 1 + 2^{−632+...} — the interesting part is ~2^{−632} ≈ 1e-190 below 1 — but we need ζ′/ζ ≈ log 2·2^{−w} + ... ~ 1e-190 magnitude?? NO WAIT — at σ = 632, |ζ′/ζ| ≈ 2^{−632}·log 2 ~ 1e-190 — but we don't need it: the integrand there is |k|·1e-190 ~ e^{√n/2}·1e-190 — utterly negligible. Where does the ENVELOPE peak? σ ≈ 0.36√n ≈ 114 (n=10⁵), where |ζ′/ζ| ~ 2^{−114} ~ 5e-35 — still tiny but relevant (product ~1.6e9). Can mpmath compute ζ(114+316i) accurately? ζ ≈ 1 + 2^{−s} + 3^{−s}..., the value is 1 + ~5e-35. In dps 50, mpmath represents 1 + 5e-35 fine (50 digits). The Euler–Maclaurin computation internally: should be OK, but the handoff's warning makes me NOT trust mpmath zeta at σ = 114+ at dps 50 without validation. The Dirichlet series at σ = 114 needs K: (K−1)^{113} > 1e11 → K−1 > 1e11^{1/113} ≈ 1.25 → K = 3!! Just k=2,3 terms. TRIVIAL. \n\nSo the clean design: **Dirichlet series primary everywhere on [3, 2√n]**, with per-σ adaptive K, EXCEPT on [3, 5) where K explodes — there use mpmath (moderate args, trustworthy, and validated against Dirichlet spot checks at σ = 3, 3.5, 4, 4.5 with the largest affordable K, tolerance 1e-8). mpmath on [3,5]: 100 points × (ζ + ζ′) — fast. Everywhere else: exact Dirichlet. Validation V-A: the four spot checks + continuity of the two at σ = 5 (compare mpmath vs Dirichlet at σ = 5 where Dirichlet K = 700 — exact to 1e-11).\n\nThis is clean and fast: total Dirichlet cost ~ 31500 points × avg K ~ 10 → trivial; mpmath cost ~ 100 × 2 zeta evals per n — trivial. Total runtime maybe 1–2 min for all three n values plus c-sweep. \n\nActually hold on, at σ slightly above 5 like 5.0–6.0, K ~ 130–700, points ~ 50, cost 50×400 = 2e4 terms — trivial. \n\nAnd the h, h/2 convergence check: recompute everything at h/2 = 0.01 — still cheap (double). Good.\n\nPrecision subtlety for the kernel at n=10⁵, σ near 3: k = (w/(w−1))ⁿ − 1 where |w/(w−1)|ⁿ ~ e^{n·σ/((σ−1)²+T²)} ~ e^{~1} — fine.\n\nLet me also double-check the trapezoid error. The integrand is smooth (analytic, |Φ′| ≤ ~2). Trapezoid error ~ O(h²·max|f″|·length). |f″| — f has curvature from phase ~ Φ′² ~ 4, magnitude ~400 (n=10⁴) → h²·400·200/12 ~ 0.0004·8000·... let me: h=0.02, h²=4e-4, error ~ (4e-4/12)·|f″|·L. |f″| ~ |Φ′|²·|f| ~ 4·400 = 1600 near peak, L ~ 200 → error ~ 4e-4/12 · 1600 · 200 ≈ 10.7. Hmm, that's vs envelope 1e4 and expected true value maybe ~100 — 10% error, marginal. The h vs h/2 check will measure the actual error; if too big, refine h to 0.005 (×4 cost — still trivial). Trapezoid for oscillatory analytic functions converges spectrally actually (Euler–Maclaurin: error ~ e^{−2π·dist to singularity/h} for periodic... not periodic here, but endpoints: the error is dominated by endpoint derivative corrections ~ h²(f′(b)−f′(a)) + higher. f′ near endpoints is small (f tiny at b=2√n; at a=3 f ~ O(1), f′ ~ O(1)) → h²·O(1) ~ 4e-4. The mid-range |f″| doesn't actually enter the Euler–Maclaurin endpoint expansion beyond... no wait, EM: error = Σ B_{2k}/(2k)! h^{2k}(f^{(2k−1)}(b) − f^{(2k−1)}(a)). f^{(2k−1)} at endpoints: at a=3, f′ ~ |f|·(|Φ′|+|growth|) ~ O(1); f‴ ~ |f|·(derivatives)³ ~ O(10). So h² term ~ 4e-4·O(1)/12 ~ 3e-5, h⁴ term ~ 1.6e-7·10 ~ 1.6e-6. EXCELLENT — trapezoid is near-spectral here because the function is tiny at both endpoints relative to its peak. So h = 0.02 with the h/2 check is more than adequate; even h = 0.05 would do. Good.\n\nNow the mpmath ζ evaluation for the mid part [−2.5, 3]: 275 points × 2 evals — trivial. Wait, mpmath zeta at dps 50 in the critical strip at t ~ 316: Euler–Maclaurin cost grows with t — maybe 10–100 ms per eval at dps 50 — 275×2×3 n-values... n only changes T: 275 × 3 × 2 × 50 ms ≈ 80 s. Acceptable. Hmm, for n=10⁵, t=316: mpmath zeta at t=316 dps 50 — fine.\n\nActually, should I include I_mid at all? It dilutes focus but gives the full I_II. The verdict per the mission: \"Re(I_II) ~ envelope ⟹ per-side claim FALSE; |I_II| ≪ envelope ⟹ hidden cancellation\". Note the verdict's two prongs use Re(I_II) vs |I_II| — slightly inconsistent objects; I'll report everything and frame the verdict on I_right (the part whose envelope exploded). The middle part's envelope (~(e⁴+1)·[NI + 5.5·85] ~ 55.6 × ~800 ~ 4.4e4?? hmm wait that's bigger than the right envelope 1e4! Let me recompute: NI = Z2·2·log(16.5/c), Z2(317) = 0.6·log 319 + 0.886·log log 319 + 2.7 ≈ 0.6·5.77 + 0.886·1.75 + 2.7 ≈ 3.46+1.55+2.7 = 7.7; c = 1/(9·Ĉ₀(319)) ≈ 1/(9·(0.433·5.77+0.886·1.75+2.9)) = 1/(9·7.95) ≈ 0.014; log(16.5/0.014) = log 1180 ≈ 7.07; NI ≈ 7.7·2·7.07 ≈ 109. 5.5·(10.5·log 319 + 48) = 5.5·(60.6+48) = 597. Sum ≈ 706; ×(e⁴+1 = 55.6) ≈ 39250. So the MIDDLE part's honest bound is ~4e4 at n=10⁵ — vs the right-tail envelope 5.9e10. The middle bound is fine (it's charged in Bn as ≤ 7Ĥ+3.3 share ✓). The TRUE middle integral is probably ~O(100). OK.\n\nSo E-032 outputs: for each n and c ∈ {1, 1.5, 2}:\n- ε chosen, clearance\n- I_right (Re, Im, |·|), envelope_right (= ∫₃^{2√n}|f|), ratio\n- quadrature convergence delta\n- validation max discrepancy\nFor c = 1 only: also I_mid, I_full = I_mid + I_right, and the envelope_mid for context.\n\nActually for c ≠ 1 the endpoint is still 2√n (the rectangle's right edge stays σ₁ = 2√n in the repair; only T changes). Yes — repair (R) keeps σ₁ = 2√n, raises T only. ✓ (D-072 §6: I_I length 2T etc.)\n\nWait, one thing: for c = 2, n = 10⁵, T = 632: the Λ-sum at σ ∈ [3,5): mpmath zeta at t = 632, dps 50 — Euler–Maclaurin ~ √t terms... fine.\n\nAlso — for c = 1.5/2 do I need the ε zero-avoiding scan? The horizontal line at T = c√n: for the diagnostic, any T not within ~1e-6 of a γ works for quadrature; use the same scan. Cheap. OK.\n\nAlso record E-031 cross-check: envelope_right at c=1, n=10⁴ should ≈ E-031's 1.05e4 (E-031 used step 2 and K=300 Λ-sum; ours is finer/exacter). Add as check V0.\n\nRuntime estimate total: Dirichlet part trivial; mpmath zeta: [3,5] strip 100 pts × 3 n × 3 c × 2 (h, h/2) = 1800 evals × ~50 ms = 90 s; mid part 275 × 3 × 2 × 2 × 50 ms = 165 s. Total ~4–5 min. Run detached with log, per the long-runs memory (CLI kills ~2–10 min; 5 min is borderline → detached).\n\nHmm — one more thing: the mpmath zeta dps-50 accuracy validation. V-A validates against Dirichlet at σ ∈ {3, 3.5, 4, 4.5, 5} for each T used. That's the key validation (mpmath at t = 316, σ = 3–5, moderate args — expect ~1e-45 accuracy actually; the known mpmath complex-ζ ~1e-10 issue was probably at higher t or specific paths. The spot check will tell us the truth and we report the discrepancy.)\n\nAnd the Dirichlet series itself at σ ≥ 5 is EXACT (it's the definition of −ζ′/ζ for re > 1) with certified tail < 1e-11 — no validation needed beyond the tail certificate.\n\nEdge case: k^w for k up to 700 at dps 50 — mpmath mp.power(k, -w) with mpf base and mpc exponent — fine.\n\nΛ sieve: smallest prime factor sieve to K_max = 7000 (for spot checks) — trivial. Actually the spot check at σ=3 wants K ~ 8e4 for 1e-8. Sieve to 8e4 — fine.\n\nLet me now also confirm the integrand sign/convention: Jlag n w = k_n(w−1)·(−ζ′/ζ w)? From rectInt'_Jlag: residue sum = ResW1 + Σ mult·(1−(ρ/(ρ−1))ⁿ). With integrand f(w) = k_n(w−1)·(−ζ′/ζ(w)): at w = ρ (zero, mult m): −ζ′/ζ has residue −m; k_n(ρ−1) = (ρ/(ρ−1))ⁿ − 1; residue of f = −m·((ρ/(ρ−1))ⁿ−1) = m·(1−(ρ/(ρ−1))ⁿ) ✓. At w = 1: −ζ′/ζ has residue +1 (ζ has residue 1 at pole → logarithmic derivative −ζ′/ζ ~ +1/(w−1)); k_n(0) = (0)ⁿ − 1 = −1 → residue −1... but ResW1 n = Σ C(n,j) lcoeff(j−1) — the residue at 1 of k_n(w−1)·(−ζ′/ζ) involves the full expansion of k_n(w−1) = (w/(w−1))ⁿ − 1 around w = 1: (w/(w−1))ⁿ = (1 + 1/(w−1))ⁿ·... hmm wait: w/(w−1) = 1 + 1/(w−1). So (w/(w−1))ⁿ = Σ_j C(n,j) (w−1)^{−j}. Residue of [(w/(w−1))ⁿ − 1]·(−ζ′/ζ(w)) at 1: from the principal parts: Σ_j C(n,j)(w−1)^{−j}·(−ζ′/ζ) — residue = Σ_j C(n,j)·[coeff of (w−1)^{j−1} in −ζ′/ζ] = Σ_j C(n,j)·lcoeff(j−1) where lcoeff(m) is the Taylor coeff of −ζ′/ζ(1+s) in s^m. ✓ matches ResW1. And −1·(−ζ′/ζ) contributes residue −1·(+1)·... the \"−1\" factor: residue = −(−1)?? The constant −1 times −ζ′/ζ(w): residue = (−1)·res(−ζ′/ζ) = (−1)(+1) = −1. Hmm, and ResW1 as defined includes... The ii′-1b statement: rectInt'_Jlag = ResW1 n + Σ zeros. So the \"ResW1 n\" in Lean must already be the FULL residue at 1 including that −1 — i.e. ResW1 n := Σ_{j=1}^{n} C(n,j)·lcoeff(j−1) (j starts at 1, and j=0 term is the −1 contribution −lcoeff(−1)... whatever — the Lean statement is proven, so the convention is consistent. For E-032 the integrand is unambiguous: **f(w) = k_n(w−1)·(−ζ′/ζ(w))**, and I_right = ∫_{3}^{2√n} f(σ+iT) dσ. The (II) segment in the residue theorem traverses LEFT-to-RIGHT or RIGHT-to-LEFT depending on orientation — the rectangle integral is (2πi)⁻¹∮ counterclockwise presumably; the top edge goes from right to left (σ decreasing). |I_II| unaffected by orientation; Re/Im signs flip. For the verdict, orientation/sign is immaterial (we report magnitudes and both parts). I'll integrate left-to-right (dσ from 3 to 2√n) and note the convention.\n\nGood. Also for comparability with E-031: E-031's envelope used |k_n(w−1)| (NOT |k_n| = |(1+1/s)ⁿ − 1| — E-031 dropped the −1, fine since the −1 is negligible at the peak) and Λ-sum K=300. Our refined envelope will match to ~1%.\n\nNow let me write the script. File: research/numerics/scripts/E-032-horizontal-true-integral.py.\n\nStructure:\n- dps = 50.\n- Λ sieve to K_MAX = 100000 (covers spot checks).\n- dirichlet_neg_logderiv(σ, T, tol=1e-11): Σ_{k=2}^{K} Λ(k)/k^{σ+iT} with K from the tail certificate.\n- mp_neg_logderiv(w): -(mp.zeta(w, derivative=1)/mp.zeta(w)).\n- kernel(n, σ, T): (1 + 1/(σ−1+iT))ⁿ − 1 — careful: k_n(w−1) = (1+1/(w−1))ⁿ − 1 = (w/(w−1))ⁿ − 1.\n- integrand f(n, σ, T): kernel·D where D = mp or dirichlet depending on σ < 5.\n- choose_eps(n, c): zeros near T0 = c√n via zetazero around index; scan ε grid; return ε, clearance.\n- integrate(n, T, a, b, h, zeta_mode): trapezoid complex sum + envelope sum; returns I, Env.\n- Main: for n in [10³, 10⁴, 10⁵], c in [1, 1.5, 2]: ε, then h=0.02 and h=0.05 convergence (use h=0.05 and 0.02; report delta; if delta/|I| > 1e-6 also compute 0.01... just compute h=0.05, 0.02 and extrapolate; report), right part [3, 2√n]; validation at the 5 spot σ's per (n, c=1) (and maybe all c). For c=1: mid part [−2.5, 3] via mpmath.\n- Checks: V0 envelope matches E-031 (1.04–1.06e4 at n=10⁴); VA validation ≤ 1e-6 (expected ~1e-9); VC convergence delta/|I| ≤ 1e-4; V3 repair: |I_right(c=2)| ≤ 10·(some bound) — just report; the check: |I_right(c=2)| < |I_right(c=1)|/10³ or something — report ratios, mark check as \"repaired values small\" with a loose threshold like |I_right(2)| ≤ 50·√n·log n... Let me not over-constrain: the checks should be PASS/FAIL on things we're confident about: envelope reproducibility, validation agreement, quadrature convergence. The verdict numbers are reported, not checked (we don't know the answer in advance — that's the point of the diagnostic). For the repair: check monotone decrease of envelope? Envelope at c=2 is tiny by E-031 V3 — check Env(c=2)/Env(c=1) < 1e-6 at n=10⁵.\n\nCSV rows: per (n, c): the full record. JSON sidecar: checks + verdict-relevant summary + notes.\n\ndb registration: db.py log-experiment — need to check its signature. Handoff: \"db.py: init, log-experiment, add-result, add-derivation, add-graveyard, list. add-derivation signature: positional id, --title --task --status --file (NO --date flag).\"\n\nLet me check db.py log-experiment signature quickly.\n\nThen run: quick foreground smoke test with small settings? The script caches (skip if JSON exists unless --force). For the smoke test I'll add a --smoke flag? No — keep the script deterministic per its cache convention; I'll just run it detached and poll. But a quick syntax check + a 10-second partial (e.g., python -c import) in foreground first.\n\nLet me write the script now. One decision: to keep runtime low, do the h-convergence with h = 0.05 and h = 0.02 (two grids), both cheap since Dirichlet dominates and is trivial. mpmath part: [3,5] strip: 40 pts at h=0.05 + 100 pts at h=0.02 per (n,c) → 140×9 = 1260 evals ~ 60 s. Mid part (c=1 only): [−2.5, 3]: 110 + 275 = 385 × 3 = 1155 evals ~ 60–120 s. Total ~3 min. Detached it is.\n\nHmm, actually, let me reconsider including n=10⁵ for the mid part: mpmath zeta at t=316, σ∈[−2.5,3], 385 evals ~ maybe 100 ms each at dps 50 = 40 s. Fine.\n\nWait, also: at c=1, T=√n+ε, the mid-part integrand includes the near-zero regions |σ+iT − ρ| small — zeros with γ ≈ T? The ε-scan ensures clearance ≥ decent. And zeros with γ far from T are no issue. OK.\n\nAlso potential issue: mp.zeta(w, derivative=1) at w near the pole w=1? Only if T ≈ 0 — never (T ≥ 31).\n\nWrite it. Also make sure to use mp.mp.dps = 50 (the setter bug). And deterministic: yes.\n\nFor the JSON sidecar verdict field: leave a \"verdict_inputs\" block with Re/Im/|I_right|/envelope ratios per n — the D-073 §2 write-up interprets.\n\nLet me also double check the trapezoid: I = h·[½f(a) + Σ_{i=1}^{N−1} f(a+ih) + ½f(b)]. b = 2√n might not land on grid: use N = ceil((b−a)/h), last partial step — simpler: adjust h_eff = (b−a)/N. Deterministic.\n\nEnvelope: same grid with |f|.\n\nNow — mpmath zeta cross-check tolerance: at σ=3, Dirichlet K for 1e-8: (K−1)² > 1e8·(log/2+0.25) ~ 1e8·3.7 → K ~ 2e4 ✓ sieve to 1e5 covers. Spot checks at σ ∈ {3, 3.5, 4, 4.5, 5} with tol_dirichlet 1e-8, require |mp − dirichlet| ≤ 1e-6·max(1,|D|). Report max discrepancy.\n\nK(σ) selection: K = min{k : tail_cert(σ, k) < tol}, computed by scanning k from 8 upward (geometric: try k = 8, 16, 32, ... then bisect? For determinism and simplicity: precompute Λ and log table; for each σ iterate k = K_prev... The values: σ=5: 700; σ=5.5: ~300; σ=6: 130; σ=7: 50; σ≥8: ≤ 30. Scan from 4 upward in steps until cert < tol — at σ=5 that's 700 iterations of trivial arithmetic — fine. Cache per unique σ-rounded? σ takes grid values 3.00, 3.02, ... — each unique, ~700 evaluations of a log formula each ~1µs — fine.\n\nAlright, writing the script now.\n\nOne more consideration — the JSON sidecar format and CSV columns follow the E-031 pattern. And register via db.py log-experiment — check its args: probably `db.py log-experiment E-032 --title ... --session 039 --script ... --csv ... --json ...`? Let me check quickly.","signature":""},{"type":"text","text":"All inputs absorbed. Marking reading complete and checking the db.py registration interface before building E-032."},{"type":"tool_use","id":"TodoWrite_10","name":"TodoWrite","input":{"todos":[{"content":"Read all mission inputs (D-073 §0, D-072, Lagarias pp. 27–29, D-071, E-031 script)","status":"completed","activeForm":"Reading mission inputs"},{"content":"6-R-0: build + run E-032 diagnostic (true complex I_II at T = √n, n = 10³/10⁴/10⁵, dps ≥ 40) vs E-031 envelope; record verdict","status":"in_progress","activeForm":"Running E-032 diagnostic"},{"content":"Register E-032 in research.db + write D-073 §2 (verdict + numbers); commit sub-stage 6-R-0","status":"pending","activeForm":"Committing sub-stage 6-R-0"},{"content":"6-R-1: D-073 §§3–7 (dependency audit, corrected stepping lemma with explicit constants, choice of c, consequence audit, E-033 cross-validation)","status":"pending","activeForm":"Writing the repaired proof"},{"content":"6-R-2: D-073 §8 drafts (letter paragraph + per-side verdict paragraph); close thread; commit","status":"pending","activeForm":"Drafting letter/finding-note paragraphs"}]},"extra_content":null},{"type":"tool_use","id":"Bash_11","name":"Bash","input":{"command":"./.venv/Scripts/python.exe research/numerics/scripts/db.py log-experiment --help 2>&1 | head -30","description":"Show db.py log-experiment usage"},"extra_content":null}]