"""ebound.py -- (E): Lambda_s's error below, explicit at every depth, and the takeover depth's upper bound C r^(3/2) it gives. QUESTION. certclosed.py's Lambda_s(J) = log m_s - log 2 - log(pi tau + 1) - 2 log I_r(J) is d log J - log K_s^2 + eps_s(J) (kfactor.py). Is there an explicit delta_s(J), falling in J, with eps_s(J) >= -delta_s(J) at every r >= 3, s <= r - 2, J >= r - 1, small at J >= C r^(3/2)? Then J^B <= C r^(3/2) wherever d log(C r^(3/2)) - log K_s^2 > delta_s(C r^(3/2)) at every s, no step inequality needed: the bound rises in J. BY HAND, PREDICTIONS, KILL and CONTROLS: frozen before this file's code, copied here. d = r - 1 - s, e = d//2, u = d - e, n = s + u = r - 1 - e, x = (J + 1)/2, dl = J' - J. Exactly eps = a1 + a2 - a3 - a4 + a5: a1 = log C(2J, J) - J log 4 + (1/2) log(pi J) >= -1/(4J) (Wendel); a2 = log (J + 1/2)_u - u log J >= u^2/(2J) - u(4u^2 - 1)/(24J^2); a3 = log (J + 1)_n - n log J <= n(n + 1)/(2J) - n(n + 1)(2n + 1)/(12J^2) + n^2(n + 1)^2/(12J^3) (log(1 + y) <= y - y^2/2 + y^3/3); a4 = log(pi tau + 1) - log(pi t0), t0 = sqrt(J) rho/2, tau^2 = t0^2 + Q: a4 <= 2Q+/(J rho^2) + 2/(pi rho sqrt J); a5 = 2 log Gamma(x + r/2) - 2 log Gamma(x) - r log(J/2) >= (r^2 - 2r - 1)/(2(J + 1)) - r(r - 1)(r - 2)/(6J^2) + r/J - r/(2J^2): a5 is 2[log Gamma(x + r/2) - log Gamma(x) - (r/2) log x] + r log(1 + 1/J), the last >= r/J - r/(2J^2). Even r: the bracket is 2 sum over k < r/2 of log(1 + 2k/(J + 1)) >= (r(r - 2)/2)/(J + 1) - r(r - 1)(r - 2)/(6(J + 1)^2), by log(1 + y) >= y - y^2/2. Odd r = 2m + 1: Wendel's Gamma(x + 1/2)/Gamma(x) >= x/sqrt(x + 1/2) gives 2 log(Gamma(x + 1/2)/Gamma(x)) - log x >= -1/(J + 1), and 2 sum over k < m of log(1 + (2k + 1)/(J + 1)) >= ((r - 1)^2/2)/(J + 1) - r(r - 1)(r - 2)/(6(J + 1)^2). The 1/J terms: N1/2 - 1/4 - 2Q+/rho^2 (a5's 1/(J + 1) >= 1/J - 1/J^2), N1 = (2e + 1)r - e(e + 1) + u^2 - 1 = (2e + 1)s + 4e^2 + 3e + (4e + 2)dl. As Q = (dl/4)rho^2 + P_e/(16D) + (2s + 1)/(16(2J' - 1)), D = (2s - 1)(2s + 3), N1 rho^2 >= 4Q+ holds where (N1 - dl)rho^2 >= R = P_e/(4D) + (2s + 1)/(4(2J' - 1)), and it does at every s, by cases. s = 0 (e >= 1, rho^2 = (8e + 3)/6, P_e(0)/(4D) = (4e + 1)(4e + 3)/12, 2J' - 1 >= 3): the left is at least e(4e + 3)(8e + 3)/6, R at most ((4e + 1)(4e + 3) + 1)/12, and 2e(8e + 3) >= 4e + 2. e = 0, s >= 1 (d = dl = 1, rho^2 = (4s - 1)/(4s - 2), P_0 = (2s + 3)(8s^2 - 1), 2J' - 1 >= 2s + 3): 4D times the left less R is at least 8s^2 + 16s - 2 > 0. e >= 1, s >= 1 (rho^2 >= 2e + 1, D >= 5s and 5, 2J' - 1 >= 2s + 1): P_e/(16D) = (2e + 1)s/4 + (2e + 1)^2/8 + ((8e + 2)s + 8e^2 + 8e + 3)/(16D) leaves the left less R at least 2e(2e + 1)s + (2e + 1)(4e^2 + 2e - 1/2) - (8e^2 + 16e + 5)/20 - 1/4 > 0. So the 1/J terms are >= -1/(4J). The 1/J^2 terms: T2 = n(n + 1)(2n + 1)/12 - r(r - 1)(r - 2)/6 - u(4u^2 - 1)/24 - (r^2 - r - 1)/2, whose r^3 parts cancel to O(e r^2) (d = 2: T2 >= -3r^2/4). LEMMA E: eps_s(J) >= -delta_s(J), delta_s = 1/(4J) + 2/(pi rho sqrt J) + max(-T2, 0)/J^2 + n^2(n + 1)^2/(12J^3), each term falling in J. COROLLARY. With LEMMA K (kfactor.py), at J >= C r^(3/2): Lambda_s >= d log(C/4) - log(c rho/e!) + (d/2 - e) log r - delta_s(C r^(3/2)), c = 2^(3/2) sqrt(pi). d >= 3: > 0.7 at C = 12, every r >= 3. d = 1: > 0 from r = 5. d = 2 binds: 2 log(C/4) - log(c rho_2) > delta, both sides monotone in r; at C = 12 the margin tends to 0.0358 and delta ~ 0.106 r^(-3/4): r0 about 9 by hand. Any C > 4 (c sqrt 3)^(1/2) = 11.787 has a finite r0: limsup J^B/r^(3/2) <= 2^(11/4)(3 pi)^(1/4). PREDICTIONS. (1) LEMMA E's bound holds at every cell read. (2) The slack eps + delta at J = 12 r^(3/2), d = 2 falls with r. (3) At C = 12 the closed condition holds at every r >= r0, r0 in 8..12. (4) J^B(r) <= 12 r^(3/2) at every r = 3..r0 - 1, both parities. (5) N1 rho^2 >= 4Q+ at every (r, s), r <= 300, J = r - 1 (the hand step's record). KILL. "KILL E: least eps + delta over the cells: x (r, s, J)": KILLED iff x < 0; cells: every s of r = 3..60 and of r = 101, 201, 401, 1001, at J = r - 1, r, 2r, 3r, then J = ceil(m r^(3/2)), m = 1, 2, 4, 8, 12, 16, 64, and 10^7. "KILL C: largest J^B(r)/r^(3/2) over r = 3..r0 - 1: q (r)": KILLED iff q > 12. CONTROLS. POSITIVE: eps at (21, 18), (41, 37), J = 10^4, 10^6, 10^8 reprints kfactor's gaps (the instrument); eps + delta at d = 2, J = 10^8 within 1e-3. PLANTS: delta without the cubic gain (T2 with its n(n + 1)(2n + 1)/12 dropped) read in the direction it pushes (delta up: KILL E silent, its least larger); delta less 1/(4J) and 2/(pi rho sqrt J), the two O(1/sqrt J) terms dropped, fires KILL E somewhere. FINDINGS. "KILL E: least eps + delta over the cells: +1.177e-07 (3, 1, 10000000): HOLDS". "KILL C: largest J^B(r)/r^(3/2) over r = 3..8: 7.8666 (8): HOLDS". CONTROLS: eps reprints kfactor's six gaps (-1.541e-03 .. -3.628e-05); eps + delta at J = 1e8 is 2.149e-07 at (21, 18), 4.299e-07 at (41, 37). The root-terms plant fires KILL E (-6.848e-02 at (4, 2, 32)). The cubic plant on the cells reads nothing: the least sits at J = 10^7, where the cubic term is nil (+1.177e-07 both). The cubic plant on the corollary carries: at C = 11.79, r = 10^6, d = 2 the closed condition reads +5.19e-04, and -6.80e-04 without the cubic gain. (1) held. (2) held: eps + delta at J = 12 r^(3/2), d = 2 falls 4.13e-02, 2.65e-02, 1.88e-02, 1.33e-02, 8.37e-03, 4.18e-03, 2.64e-03 at r = 5, 11, 21, 41, 101, 401, 1001. (3) held: the closed condition at C = 12 fails at r = 3..7 alone over r <= 2000 (d <= 4 also read at r = 2001..10^6, step 997, none fail); r0 = 8, d = 2's margin +0.0004 at 8, +0.0048 at 9, +0.0358 at 10^6. At r <= 600 it fails at 598 r at C = 11.79 (the last 600), 203 at 11.8 (the last 205), 5 at 12, 1 at 13, none at 16. (4) held: J^B 37, 56, 76, 98, 136, 178 at r = 3..8, J^B/r^(3/2) at most 7.8666 (r = 8). (5) held: N1 rho^2 >= 4Q+ at every s of r = 3..300. Changed from the freeze: KILL C reads r = 3..8, not 3..r0 - 1 = 3..7, since the hand proof below starts at 9; at the fold a5's and N1's sketches above were written out, s = 0 among N1's cases, so (5) is a record. THE PROOF PAST r = 9, by hand. At J >= 12 r^(3/2) each majorant below falls in r term by term (delta's own quartic term need not). d = 2 (n = r - 2, T2 = -3r^2/4 + 5r/4 - 1/8): 2 log 3 - log c - (1/2) log rho_2^2 >= 0.02632 at s >= 6, rising; delta <= 1/(48 r^(3/2)) + 2/(pi sqrt 3 sqrt 12 r^(3/4)) + 3/(576 r) + 1/(20736 sqrt r), under 0.02179 at r = 9, falling ("HAND" line). d = 1 (T2 = (-6r^2 + 6r + 9)/24, rho_1^2 <= 1.1 at s >= 3): margin 0.2435 against delta 0.0571 at r = 5, the margin rising, delta falling. d >= 3, every r >= 3 (rho >= 1, rho^2 <= 1.2d + 1.5): d log 3 - log c - (1/2) log(1.2d + 1.5) >= 0.869 at d = 3, rising in d, and delta <= 0.0872 at r = 3 (its majorant), falling. Lambda_s > 0 at every real J >= 12 r^(3/2), so J^B(r) <= ceil(12 r^(3/2)) at every r >= 9, a theorem (tau^2's (b) is summed by hand in certclosed.py; LEMMA E's a5 and N1 steps are written out above, case by case, at the fold), and at r = 3..8 by the closed certificate's crossings: J_ch(r) <= ceil(12 r^(3/2)) at every r >= 3, a rule at r = 3..8. For any C > 11.787, d = 2's delta at C r^(3/2) tends to 0 (the cubic gain cancels r^3/J^2) and d = 2's margin to 2 log(C/4) - log(c sqrt 3) > 0, while d = 1's grows as (1/2) log r and d >= 3's stays above 0.8 against a delta under 0.1 (each majorant term scales as 1/C, C^(-1/2) or C^(-2)): limsup J_ch/r^(3/2) <= limsup J^B/r^(3/2) <= 2^(11/4)(3 pi)^(1/4) = 11.787, beside the proved liminf >= 2 sqrt(2 exp 1) = 4.66328 over every r (losses.py). Wall 11.8 s, peak 65.6 MB, 8/8 checks (the HAND check added after the first run; the cubic plant on the cells made a record, being forced, and jb's flags at r = 3..8 checked, at the audit; KILL E reads 41615 cells). A break forcing one flag at (5, 2) fails it, 7/8. RUN: python ebound.py (one process). """ import os import sys import time from fractions import Fraction from math import ceil, lgamma, log, pi, sqrt os.environ.setdefault("OPENBLAS_NUM_THREADS", "1") import mpmath as mp # noqa: E402 from certclosed import jb, lam_mp, tau2 # noqa: E402 mp.mp.dps = 40 CHECKS = [] C0 = 12 LIM = 2 ** 2.75 * (3 * pi) ** 0.25 # 4 (c sqrt 3)^(1/2) = 11.787 def check(name, ok, detail=""): CHECKS.append(bool(ok)) tail = f" ({detail})" if detail else "" print(f" {'PASS' if ok else 'FAIL'} {name}{tail}", flush=True) def parts(r, s): d = r - 1 - s e = d // 2 u = d - e n = s + u rho2 = 2 * e + 1 + Fraction(2 * s + 4 * e + 3, (4 * s - 2) * (2 * s + 3)) return d, e, u, n, rho2 def logK2_mp(r, s): """log K_s^2 = (3r - 2) log 2 + 2 log Gamma(r/2) + log rho - log gamma - (1/2) log pi, gamma = 2^s (2s - 1)!! e!/(s + 3/2)_e.""" d, e, u, n, rho2 = parts(r, s) lg = mp.loggamma h = mp.mpf(3) / 2 lgam = s * mp.log(2) + (lg(2 * s) - lg(s) - (s - 1) * mp.log(2) if s else 0) lgam += lg(e + 1) - (lg(s + h + e) - lg(s + h)) return ((3 * r - 2) * mp.log(2) + 2 * lg(mp.mpf(r) / 2) + mp.log(mp.mpf(rho2.numerator) / rho2.denominator) / 2 - lgam - mp.log(mp.pi) / 2) def eps_mp(r, s, J): d = r - 1 - s return lam_mp(r, s, J) - (d * mp.log(J) - logK2_mp(r, s)) def T2x24(r, s, cubic=True): """24 T2, an integer.""" d = r - 1 - s u = d - d // 2 n = s + u t = (- 4 * r * (r - 1) * (r - 2) - u * (4 * u * u - 1) - 12 * (r * r - r - 1)) if cubic: t += 2 * n * (n + 1) * (2 * n + 1) return t def rho2f(r, s): e = (r - 1 - s) // 2 return 2 * e + 1 + (2 * s + 4 * e + 3) / ((4 * s - 2) * (2 * s + 3)) def delta(r, s, J, cubic=True, root=True): """LEMMA E's delta_s(J), J real >= r - 1.""" d = r - 1 - s n = s + d - d // 2 rho = sqrt(rho2f(r, s)) t2 = T2x24(r, s, cubic) / 24 out = max(-t2, 0.0) / J ** 2 + (n * (n + 1)) ** 2 / (12 * J ** 3) if root: out += 1 / (4 * J) + 2 / (pi * rho * sqrt(J)) return out def n1_ok(r, s): """The 1/J step: N1 rho^2 >= 4 Q+ at J = r - 1 (Q falls in J).""" d, e, u, n, rho2 = parts(r, s) J = r - 1 Q = tau2(r, s, J) - Fraction(J, 4) * rho2 N1 = (2 * e + 1) * r - e * (e + 1) + u * u - 1 return N1 * rho2 >= 4 * max(Q, 0) def closed(r, s, C, cubic=True): """LEMMA K's form: d log(C/4) - log(c rho/e!) + (d/2 - e) log r - delta_s(C r^(3/2)).""" d = r - 1 - s e = d // 2 c = 2 ** 1.5 * sqrt(pi) return (d * log(C / 4) - log(c) - 0.5 * log(rho2f(r, s)) + lgamma(e + 1) + (d / 2 - e) * log(r) - delta(r, s, C * r ** 1.5, cubic)) def main(): t0 = time.time() print("CONTROLS", flush=True) want = {(21, 18): (-1.541e-03, -3.454e-04, -3.645e-05), (41, 37): (6.014e-04, -3.244e-04, -3.628e-05)} off = [] for (r, s), w in want.items(): got = [float(eps_mp(r, s, J)) for J in (10 ** 4, 10 ** 6, 10 ** 8)] print(f" eps at ({r}, {s}), J = 1e4, 1e6, 1e8: " + ", ".join(f"{g:+.3e}" for g in got), flush=True) off += [(r, s) for g, x in zip(got, w) if abs(g - x) > 1e-3 * abs(x)] slack = got[2] + delta(r, s, 10 ** 8) check(f"POSITIVE: eps + delta at ({r}, {s}), J = 1e8, in [0, 1e-3]", 0 <= slack <= 1e-3, f"{slack:.3e}") check("POSITIVE: eps reprints kfactor's gaps to 4 digits", not off, f"off {off}") ranks = list(range(3, 61)) + [101, 201, 401, 1001] cells = [] for r in ranks: Js = {r - 1, r, 2 * r, 3 * r, 10 ** 7} Js |= {ceil(m * r ** 1.5) for m in (1, 2, 4, 8, 12, 16, 64)} cells += [(r, s, J) for s in range(r - 1) for J in sorted(Js)] least = least_pl = least_cu = None for r, s, J in cells: ep = float(eps_mp(r, s, J)) for key, dl in (("e", delta(r, s, J)), ("p", delta(r, s, J, root=False)), ("c", delta(r, s, J, cubic=False))): v = (ep + dl, r, s, J) if key == "e": least = v if least is None or v < least else least elif key == "p": least_pl = v if least_pl is None or v < least_pl else least_pl else: least_cu = v if least_cu is None or v < least_cu else least_cu check("PLANT: delta less its two O(1/sqrt J) terms fires KILL E", least_pl[0] < 0, f"least {least_pl[0]:+.3e} at {least_pl[1:]}") print(f" PLANT, a record (forced: delta can only rise): without the " f"cubic gain the least reads {least_cu[0]:+.3e} against " f"{least[0]:+.3e}", flush=True) ok11 = closed(10 ** 6, 10 ** 6 - 3, 11.79) pl11 = closed(10 ** 6, 10 ** 6 - 3, 11.79, cubic=False) check("PLANT: at C = 11.79, r = 10^6, d = 2 the closed condition holds, " "and fails without the cubic gain", ok11 > 0 > pl11, f"{ok11:+.2e}, {pl11:+.2e}") if not all(CHECKS): print("CONTROL FAILED: nothing below is read.") sys.exit(1) print("THE READ", flush=True) bad5 = [(r, s) for r in range(3, 301) for s in range(r - 1) if not n1_ok(r, s)] check("(5) N1 rho^2 >= 4 Q+ at J = r - 1, every s, r = 3..300", not bad5, f"off at {bad5[:5]}") print(" (2) eps + delta at J = 12 r^(3/2), d = 2: " + ", ".join( f"r={r}: {float(eps_mp(r, r - 3, ceil(12 * r ** 1.5))) + delta(r, r - 3, ceil(12 * r ** 1.5)):.2e}" for r in (5, 11, 21, 41, 101, 401, 1001)), flush=True) fails = [r for r in range(3, 2001) if min(closed(r, s, C0) for s in range(r - 1)) <= 0] r0 = max(fails) + 1 if fails else 3 far = [r for r in range(2001, 10 ** 6 + 1, 997) if min(closed(r, r - 1 - d, C0) for d in (1, 2, 3, 4)) <= 0] print(f" (3) closed condition at C = 12 fails at r = {fails}; " f"r0 = {r0}; d <= 4 at r = 2001..10^6 step 997 fails at {far[:5]}", flush=True) d2 = [(closed(r, r - 3, C0), r) for r in (r0, r0 + 1, 100, 10 ** 4, 10 ** 6)] print(" d = 2's margin at C = 12: " + ", ".join( f"r={r}: {m:+.4f}" for m, r in d2), flush=True) for C in (11.79, 11.8, 12, 13, 16): bad = [r for r in range(3, 601) if min(closed(r, s, C) for s in range(r - 1)) <= 0] print(f" C = {C}: closed condition fails at {len(bad)} r <= 600, " f"the last {max(bad) if bad else None}", flush=True) q, flags = [], [] for r in range(3, max(r0, 9)): # 3..8: the hand proof starts at 9 rows = [jb((r, s, 1)) for s in range(r - 1)] flags += [(r, x[1]) for x in rows if not (x[4] and x[5])] J = max(x[2] for x in rows) q.append((J / r ** 1.5, r, J)) print(f" r = {r:2d}: J^B {J}, J^B/r^1.5 {J / r ** 1.5:.4f}", flush=True) check("jb's step inequalities, float/mpmath agreement and Lambda <= 0 " "one below, every order of r = 3..8", not flags, f"off {flags[:5]}") print(f" KILL E read {len(cells)} cells", flush=True) c = log(2 ** 1.5 * sqrt(pi)) m2 = 2 * log(3) - c - 0.5 * log(rho2f(9, 6)) dl2 = (1 / (48 * 9 ** 1.5) + 2 / (pi * sqrt(3) * sqrt(12) * 9 ** 0.75) + 3 / (576 * 9) + 1 / (20736 * 3)) m1 = log(3) - c - 0.5 * log(1.1) + 0.5 * log(5) J5 = 12 * 5 ** 1.5 dl1 = (1 / (4 * J5) + 2 / (pi * sqrt(J5)) + (6 * 25 - 30 - 9) / 24 / J5 ** 2 + 400 / (12 * J5 ** 3)) m3 = 3 * log(3) - c - 0.5 * log(5.1) J3 = 12 * 3 ** 1.5 dl3 = (1 / (4 * J3) + 2 / (pi * sqrt(J3)) + (27 / 6 + 27 / 48 + 4.5) / J3 ** 2 + 81 / (12 * J3 ** 3)) print(f" HAND: d = 2 at r = 9 margin floor {m2:.6f}, delta majorant " f"{dl2:.6f}; d = 1 at r = 5 {m1:.4f}, {dl1:.4f}; d = 3 at r = 3 " f"{m3:.4f}, {dl3:.4f}", flush=True) check("HAND: each margin above its delta majorant at its start", m2 > dl2 and m1 > dl1 and m3 > dl3) x = least print(f"KILL E: least eps + delta over the cells: {x[0]:+.3e} " f"{x[1:]}: {'KILLED' if x[0] < 0 else 'HOLDS'}") if q: qm = max(q) print(f"KILL C: largest J^B(r)/r^(3/2) over r = 3..{max(r0, 9) - 1}: " f"{qm[0]:.4f} ({qm[1]}): {'KILLED' if qm[0] > 12 else 'HOLDS'}") print(f"{sum(CHECKS)}/{len(CHECKS)} checks, {time.time() - t0:.1f} s") sys.exit(0 if all(CHECKS) else 1) if __name__ == "__main__": main()