Does light charge the quons? › Files cited on the page › check_charge_tie_leuchs_fable/

check_charge_tie_leuchs.py

In the investigation at sim/models_AB/check_charge_tie_leuchs_fable/check_charge_tie_leuchs.py · last changed in commit 48d889d, 22 November 2026 · 30,820 bytes · the folder as a zip


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
check_charge_tie_leuchs.py -- the twenty-fourth independent reviewer's own reproduction of
  (A) sim/models_AB/check_leuchs2021/ (commit 84140be): the "ln(hbar Lambda_L/c) ~= 26" of Leuchs, Hawton and
      Sanchez-Soto 2021 (arXiv:2110.07223), its eqs. (2.4), (3.1)-(3.11), the factor 2, the scalar 1/4, the W caveat,
      trial 9's pole, and the numbers in the suggested replacement text for section 11.4 item 4;
  (B) sources/charge_tie_2026-11-22/ (commit 2ccdd6b): the one-loop numbers of the scoping note and the draft lock
      (the copy-plus-quon mismatch table, the zeta windows, 1.70 ln zeta, the threshold cost, M*, the TeV-scale sum,
      the Bruemmer-Jaeckel one-loop epsilon, the weak-gravity bound, the quon-only mismatch, the diagonal subgroup).

Run from this folder on isla:
    OMP_NUM_THREADS=1 ~/aspden-review-venv/bin/python3 check_charge_tie_leuchs.py > check_charge_tie_leuchs_out.txt 2> check_charge_tie_leuchs_err.txt

Everything here is written independently of check_leuchs2021.py (the reviewer read that script only after writing
the equations down from the rendered PDF pages, and compares against its printed numbers at the end).
Labels: [S] standard physics; [S, paper] as printed in the paper named; [I] a measured input; [D] derived here;
[M] a modelling choice; "from memory" marks a number not read at source in this session.
"""
import datetime
import math
import os
import subprocess
import sys

import numpy as np
import scipy
import scipy.constants as K
from scipy.integrate import quad
from scipy.optimize import brentq

CHECKS = []


def say(s=""):
    print(s)


def check(name, ok, detail=""):
    CHECKS.append((name, bool(ok)))
    say(f"   CHECK {'pass' if ok else 'FAIL'}: {name} {detail}")


say("check_charge_tie_leuchs.py -- twenty-fourth reviewer: Leuchs 2021 check (84140be) and the charge-tie phase 1 (2ccdd6b)")
try:
    head = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True).stdout.strip()
except Exception as ex:  # pragma: no cover
    head = f"(git rev-parse failed: {ex})"
say(f"git rev-parse HEAD: {head}")
say(f"run at: {datetime.datetime.now().astimezone().strftime('%Y-%m-%d %H:%M:%S %Z')}")
say(f"python {sys.version.split()[0]}, numpy {np.__version__}, scipy {scipy.__version__}; OMP_NUM_THREADS={os.environ.get('OMP_NUM_THREADS')}")

# ======================================================================================================================
say("\n=============================== PART A: Leuchs, Hawton and Sanchez-Soto 2021 ===============================")
c, hbar, e, eps0 = K.c, K.hbar, K.e, K.epsilon_0                        # [S] scipy CODATA
ME = K.physical_constants["electron mass energy equivalent in MeV"][0]    # [S] CODATA via scipy, MeV
MMU = K.physical_constants["muon mass energy equivalent in MeV"][0]
MTAU = K.physical_constants["tau mass energy equivalent in MeV"][0]
MPL = K.physical_constants["Planck mass energy equivalent in GeV"][0] * 1e3   # MeV
ALPHA_INV_PAPER = 137.035999084   # [S, paper] 2021, p. 4 below (3.2)
ALPHA_INV_PDG = 137.035999178     # [I] PDG 2024, as trial 9 uses it
alpha = 1 / ALPHA_INV_PAPER
LN10 = math.log(10)
# quark masses [S, from memory: PDG 2024 central values, MS-bar u,d,s at 2 GeV, c(c), b(b), top pole-like]; W, Z from memory
MQ = {"u": 2.16, "d": 4.70, "s": 93.5, "c": 1273.0, "b": 4183.0, "t": 172570.0}  # MeV
MW, MZ = 80369.0, 91188.0  # MeV
MH = 5e5                   # MeV: the sentence's "mc^2 ~= 5 x 10^11 eV" [S, paper]
say(f"   alpha^-1 (paper) = {ALPHA_INV_PAPER}; m_e = {ME:.6f} MeV; M_Pl = {MPL/1e3:.4e} GeV; quark masses (from memory, MeV) {MQ}")

check("A0 e^2/(hbar c eps0) = 4 pi alpha (paper's alpha) to 1e-8", abs(e**2 / (hbar * c * eps0) / (4 * math.pi * alpha) - 1) < 1e-8)

# species lists: (name, Nc*Q^2, mass MeV)
LEPTONS = [("e", 1.0, ME), ("mu", 1.0, MMU), ("tau", 1.0, MTAU)]
QUARKS = [(q, 3 * (2 / 3) ** 2 if q in "uct" else 3 * (1 / 3) ** 2, MQ[q]) for q in "udscbt"]
SM8 = LEPTONS + QUARKS
SM9 = SM8 + [("W (+1, the paper's count) [M]", 1.0, MW)]
SM11 = SM9 + [("extra 1 (unit)", 1.0, MH), ("extra 2 (unit)", 1.0, MH)]
SM95 = SM9 + [("scalar 1 (1/4)", 0.25, MH), ("scalar 2 (1/4)", 0.25, MH)]
N8, N9, N11, N95 = (sum(w for _, w, _ in L) for L in (SM8, SM9, SM11, SM95))
check("A1 sum Nc Q^2 = 8 for three generations with colour; the paper's 9 adds the W as +1", abs(N8 - 8) < 1e-12 and abs(N9 - 9) < 1e-12)

# --- A2: (2.4) and the 18% -------------------------------------------------------------------------------------------
# (2.2): reduced mass m/2, hbar omega = 2 m c^2, quasi-static (m/2) omega^2 x = e E  ->  p = e x = e^2 hbar^2 E/(2 m^3 c^4)
m_e_kg = K.m_e
omega = 2 * m_e_kg * c**2 / hbar
x_disp = e / ((m_e_kg / 2) * omega**2)              # per unit E
check("A2a (2.2) e x = e^2 hbar^2 E/(2 m^3 c^4)", abs(e * x_disp / (e**2 * hbar**2 / (2 * m_e_kg**3 * c**4)) - 1) < 1e-12)
P0 = e * x_disp / (hbar / (m_e_kg * c)) ** 3         # (2.3): divide by lambda_C^3
check("A2b (2.3) P0/E = e^2/(2 hbar c)", abs(P0 / (e**2 / (2 * hbar * c)) - 1) < 1e-12)
share_e_24 = (e**2 / (2 * hbar * c)) / eps0
say(f"   (2.4) with f = 1, electron pairs only: e^2/(2 hbar c eps0) = 2 pi alpha = {share_e_24:.4f} = {100*share_e_24:.2f}% of eps0 (paper: 'about 18%')")
say(f"   8 pi alpha = {8*math.pi*alpha:.4f} = {800*math.pi*alpha:.1f}%  (2010 paper eq. (18) with hbar omega0 = 2 m c^2, its note 7: '~ 1/10'); 4 pi alpha = {400*math.pi*alpha:.1f}% (2017 eq. 2)")
check("A2c 18% is 8 pi alpha to 2%, and four times the 2021 (2.4)", abs(8 * math.pi * alpha / 0.18 - 1) < 0.02 and abs(8 * math.pi * alpha / share_e_24 - 4) < 1e-6,
      f"(8 pi alpha/0.18 = {8*math.pi*alpha/0.18:.4f}; ratio to (2.4) = {8*math.pi*alpha/share_e_24:.9f}, the 1e-9 is the paper's alpha against scipy's)")

# --- A3: (3.1) -> (3.3) ------------------------------------------------------------------------------------------------
def I_p(r):  # int_0^r p^2 dp /(p^2+1)^(3/2) = asinh(r) - r/sqrt(1+r^2)
    return quad(lambda p: p**2 / (p**2 + 1) ** 1.5, 0, r)[0]
r = 1e4
check("A3a int_0^L p^2 dp/(p^2+M^2)^(3/2) -> ln(2L/M) - 1 (L/M = 1e4, to 1e-7)", abs(I_p(r) - (math.log(2 * r) - 1)) < 1e-7, f"({I_p(r):.8f} vs {math.log(2*r)-1:.8f})")
check("A3b prefactor 8 pi alpha * 4 pi/(2 pi)^3 = 4 alpha/pi", abs(8 * math.pi * alpha * 4 * math.pi / (2 * math.pi) ** 3 - 4 * alpha / math.pi) < 1e-16)
# dimensional check: p^2 + (mc/hbar)^2 -> p and Lambda are wavenumbers; hbar Lambda/c a mass [S, paper]
say("   (3.1): p adds to (mc/hbar)^2, so Lambda is a wavenumber and hbar Lambda/c a mass; 'ln(hbar Lambda_L/c)' needs a mass unit [D].")
say("   (3.3) as printed has hbar k^2/(m^2 c^2) inside the log: not dimensionless; (3.9) prints hbar^2 k^2/(m_s^2 c^2) [S, paper].")

# --- A4: (3.4) -> (3.5) ------------------------------------------------------------------------------------------------
def chi_sub(Kk):  # -(2 alpha/pi) int x(1-x) ln(1 + x(1-x) K) dx   (the 'ln' the print omits)
    return -(2 * alpha / math.pi) * quad(lambda x: x * (1 - x) * math.log(1 + x * (1 - x) * Kk), 0, 1)[0]
Kbig = 1e12
check("A4a (3.5): -(alpha/3pi)[ln K - 5/3] at K = 1e12, to 1e-7", abs(chi_sub(Kbig) / (-(alpha / (3 * math.pi)) * (math.log(Kbig) - 5 / 3)) - 1) < 1e-7)
check("A4b A = exp(5/3): int x(1-x) ln(x(1-x)) dx = -5/18", abs(quad(lambda x: x * (1 - x) * math.log(x * (1 - x)), 0, 1)[0] + 5 / 18) < 1e-12)

# --- A5: (3.9), (3.10), (3.11) and the factor 2 --------------------------------------------------------------------------
check("A5a alpha eps0/(3 pi) = e^2/(12 pi^2 hbar c)", abs(alpha * eps0 / (3 * math.pi) / (e**2 / (12 * math.pi**2 * hbar * c)) - 1) < 1e-9)
RHS = 3 * math.pi / alpha   # (3.10): sum (q^2/e^2) ln(hbar^2 L^2/(m^2 c^2)) = 12 pi^2 hbar c eps0/e^2 = 3 pi/alpha
check("A5b (3.10) <=> sum (q_s^2/e^2) ln(hbar^2 Lambda_L^2/(m_s^2 c^2)) = 3 pi/alpha = 1291.5", abs(12 * math.pi**2 * hbar * c * eps0 / e**2 - RHS) < 1e-6, f"({RHS:.2f})")
# (2.4) with (3.11): eps0 = (1/2hbar c) sum q^2 * (1/12pi^2) <ln> = (1/24 pi^2 hbar c) sum q^2 ln : half of (3.10)
f_needed_2021 = 2 / (12 * math.pi**2)   # f per unit <ln> that (2.4)+(3.10) require
f_printed = 1 / (12 * math.pi**2)
check("A5c printed (3.11) is half what (2.4) and (3.10) require (2017 eq. 2 with 1/(hbar c) is consistent with eq. 7)", abs(f_printed / f_needed_2021 - 0.5) < 1e-15)
say(f"   with the printed (3.11) and f = 1: <ln(hbar^2 L^2/m^2 c^2)> = 12 pi^2 = {12*math.pi**2:.2f}, i.e. <ln(hbar L/(m c))> = 6 pi^2 = {6*math.pi**2:.2f}")
say(f"   2017 eq. (4) alpha^-1 = 4 pi f sum (q/e)^2: f = 1 needs sum = 1/(4 pi alpha) = {1/(4*math.pi*alpha):.3f}; with 11: f = {1/(4*math.pi*alpha*11):.3f}; 2021's (2.4) would need 1/(2 pi alpha) = {1/(2*math.pi*alpha):.2f}")
check("A5d 'f ~= 1 with 9 + 2' holds in the 2017 normalization (0.99), not the 2021 (2.4) (1.98)",
      abs(1 / (4 * math.pi * alpha * 11) - 0.991) < 0.002 and abs(1 / (2 * math.pi * alpha * 11) - 1.98) < 0.01)

# --- A6: every reading of the 26 ----------------------------------------------------------------------------------------
say("\n   A6 readings of 'ln(hbar Lambda_L/c) ~= 26' (L := charge-weighted mean of ln(hbar Lambda_L/(m_s c))) [D]:")
readings = {}
for N, nm in ((N8, "N=8"), (N9, "N=9"), (N95, "N=9.5"), (N11, "N=11")):
    readings[f"R1 {nm}: L = 3 pi/(2 alpha N)"] = RHS / (2 * N)
readings["R2 printed (3.11), f = 1: L = 6 pi^2"] = 6 * math.pi**2
readings["R3 (3.11) doubled to fit (2.4),(3.10): L = 3 pi^2"] = 3 * math.pi**2
readings["R4 base-10 of R1 N=11"] = RHS / (2 * N11) / LN10
readings["R4 base-10 of R2"] = 6 * math.pi**2 / LN10
readings["R4 base-10 of R1 N=9"] = RHS / (2 * N9) / LN10
readings["R4 base-10 of R3"] = 3 * math.pi**2 / LN10
readings["R5 full ln(L^2/m^2), N=11"] = RHS / N11
readings["R5 full ln(L^2/m^2), N=9"] = RHS / N9
readings["R5 N making full log 26"] = RHS / 26
readings["R5 N making L = 26"] = RHS / 52
readings["R6 (3.3) at k=0 with chi=1, N=11: L = 3pi/(2 alpha N) + 1 - ln 2"] = RHS / (2 * N11) + 1 - math.log(2)
readings["R7 A = exp(5/3) kept, N=11: L = 3pi/(2 alpha N) + 5/6"] = RHS / (2 * N11) + 5 / 6
readings["R8 2017: ln(M_Pl^2/m_e^2) (prints 101)"] = 2 * math.log(MPL / ME)
readings["R8 2017: ln(M_Pl^2/M_W^2) (prints 78)"] = 2 * math.log(MPL / MW)
readings["R10 ln(5e11) (the extras' mass in eV)"] = math.log(5e11)
readings["R10 ln(M_Pl/m_e)/2"] = 0.5 * math.log(MPL / ME)
readings["R10 ln(1e14 GeV/500 GeV)"] = math.log(1e17 / MH)
readings["NEW R11 the 2017 paper's 22 'types' + 2 extras at unit charge: N = 24, L = 3 pi/(2 alpha 24)"] = RHS / 48
for k, v in readings.items():
    say(f"      {k:<95s} {v:8.2f}")
expected = {"R1 N=8": 80.72, "R1 N=9": 71.75, "R1 N=9.5": 67.98, "R1 N=11": 58.71, "R2": 59.22, "R3": 29.61, "R4 base-10 of R1 N=11": 25.50,
            "R4 base-10 of R2": 25.72, "R4 base-10 of R1 N=9": 31.16, "R4 base-10 of R3": 12.86, "R5 full ln(L^2/m^2), N=11": 117.41,
            "R5 full ln(L^2/m^2), N=9": 143.50, "R5 N making full log 26": 49.67, "R5 N making L = 26": 24.84, "R6": 59.01, "R7": 59.54,
            "R8 2017: ln(M_Pl^2/m_e^2)": 103.06, "R8 2017: ln(M_Pl^2/M_W^2)": 79.12, "R10 ln(5e11)": 26.94, "R10 ln(M_Pl/m_e)/2": 25.76, "R10 ln(1e14": 26.02}
ok_all = True
for key, val in expected.items():
    mine = [v for k, v in readings.items() if k.startswith(key)][0]
    if abs(mine - val) > 0.011:
        ok_all = False
        say(f"      MISMATCH {key}: mine {mine:.3f} vs report {val}")
check("A6a every number in the report's readings table reproduced to 0.01", ok_all)
nat = [v for k, v in readings.items() if k.split()[0] in ("R1", "R2", "R3", "R5", "R6", "R7") and "making" not in k]
check("A6b no natural-log reading of the paper's own condition with N in 8..11 lies within 2 of 26", all(abs(v - 26) > 2 for v in nat), f"(nearest: {min(nat, key=lambda v: abs(v-26)):.1f})")
check("A6c the base-10 readings of the paper's own condition lie within 0.55 of 26 (25.50 and 25.72)", abs(readings["R4 base-10 of R1 N=11"] - 26) <= 0.55 and abs(readings["R4 base-10 of R2"] - 26) <= 0.55)
say(f"   NEW: counting the 2017 paper's 22 'types' (j = 1..22) and the two extras each at unit charge gives N = 24 and L = {RHS/48:.1f}:")
say("   a natural-log reading near 26 (it rounds to 27), but it contradicts the sentence's own 'sum q_s^2/e^2 = 9' [D].")

# --- A7: real masses: the pole species by species -------------------------------------------------------------------------
def sum_logs(species, Lam):
    return sum(w * math.log(Lam**2 / m**2) for _, w, m in species if m < Lam)

def pole(species):
    return math.exp(brentq(lambda l: sum_logs(species, math.exp(l)) - RHS, math.log(1e6), math.log(1e60)))

say("\n   A7 (3.10) solved with the real masses [D]:")
say(f"   {'count':<40s} {'Lambda_L GeV':>13s} {'ln(L/GeV)':>10s} {'log10(L/GeV)':>12s} {'ln(L/m_e)':>10s} {'ln(L/M_Pl)':>11s} {'<ln(L/m_s)>':>12s}")
poles = {}
for nm, sp in (("N=8", SM8), ("N=9", SM9), ("N=9.5", SM95), ("N=11", SM11)):
    L = pole(sp); poles[nm] = L
    meanL = 0.5 * sum_logs(sp, L) / sum(w for _, w, m in sp if m < L)
    say(f"   {nm:<40s} {L/1e3:13.3e} {math.log(L/1e3):10.2f} {math.log10(L/1e3):12.2f} {math.log(L/ME):10.2f} {math.log(L/MPL):11.2f} {meanL:12.2f}")
check("A7a poles 2.4e34 (N=8), 6.0e30 (N=9), 2.0e29 (N=9.5), 4.7e25 (N=11) GeV reproduced to 1%",
      abs(poles["N=8"] / 2.435e37 - 1) < 0.01 and abs(poles["N=9"] / 5.99e33 - 1) < 0.01 and abs(poles["N=9.5"] / 1.993e32 - 1) < 0.01 and abs(poles["N=11"] / 4.701e28 - 1) < 0.01)
check("A7b ln(L/m_e) = 67, 78 (N=11, N=9) and ln(L_9/M_Pl) = 26.9, log10(L_11/GeV) = 25.7 (the two coincidences)",
      abs(math.log(poles["N=11"] / ME) - 66.69) < 0.05 and abs(math.log(poles["N=9"] / ME) - 78.45) < 0.05
      and abs(math.log(poles["N=9"] / MPL) - 26.92) < 0.05 and abs(math.log10(poles["N=11"] / 1e3) - 25.67) < 0.05)
check("A7c with the reduced Planck mass 2.435e18 GeV the N=9 coincidence is 28.5, not 26.9 [S, from memory]", abs(math.log(poles["N=9"] / 2.435e21) - 28.5) < 0.1, f"({math.log(poles['N=9']/2.435e21):.2f})")

# --- A8: the scalar 1/4 ------------------------------------------------------------------------------------------------------
I_s_paper = quad(lambda x: (1 - 2 * x**2) / 8, 0, 1)[0]      # the paper's printed factor
I_s_std = quad(lambda x: (1 - 2 * x) ** 2 / 8, 0, 1)[0]      # scalar QED's (1-2x)^2 [S, from memory]
I_f = quad(lambda x: x * (1 - x), 0, 1)[0]
check("A8 scalar/fermion = 1/4 from the paper's (1-2x^2)/8 and from scalar QED's (1-2x)^2/8 alike (both 1/24 vs 1/6)",
      abs(I_s_paper / I_f - 0.25) < 1e-12 and abs(I_s_std / I_f - 0.25) < 1e-12)
say("   the printed (1 - 2x^2)/8 is most likely (1 - 2x)^2/8 [S, from memory: scalar QED]; both integrate to 1/24, so the 1/4 stands.")

# --- A9: trial 9's pole by the on-shell route ------------------------------------------------------------------------------
def dalpha_timelike(s, m, w, a):
    return (2 * a / math.pi) * w * quad(lambda x: x * (1 - x) * math.log(abs(1 - x * (1 - x) * s / m**2)), 0, 1, limit=400, points=[0.5])[0]
a9 = 1 / ALPHA_INV_PDG
DA_HAD5 = 0.02783   # [I] PDG 2024 via trial 9
s = MZ**2
da_lep = sum(dalpha_timelike(s, m, 1.0, a9) for _, _, m in LEPTONS)
da_top = dalpha_timelike(s, MQ["t"], 4 / 3, a9)
inv_aMZ = ALPHA_INV_PDG * (1 - (da_lep + DA_HAD5 + da_top))
say(f"\n   A9 trial 9 by its own route: leptons' Delta alpha(M_Z^2) = {da_lep:.6f} (trial 9: 0.031419), top {da_top:.6f} (-0.000059); 1/alpha(M_Z) = {inv_aMZ:.3f} (128.925)")
check("A9a trial 9's Delta alpha_lep = 0.031419 and 1/alpha(M_Z) = 128.925 reproduced", abs(da_lep - 0.031419) < 2e-6 and abs(inv_aMZ - 128.925) < 0.002)
# run up: 20/3 (five quarks + three leptons) below the top, 8 above
def inv_a_above(L, m_top=MQ["t"]):
    return inv_aMZ - (2 / (3 * math.pi)) * ((20 / 3) * math.log(L / MZ) + (4 / 3) * max(0.0, math.log(L / m_top)))
Lam9 = math.exp(brentq(lambda l: inv_a_above(math.exp(l)), math.log(MZ), 200))
say(f"   pole: {Lam9/1e3:.3e} GeV (trial 9: 9.721e34; the report: 9.722e34); ln(Lambda/m_e) = {math.log(Lam9/ME):.1f}; ln(Lambda/GeV) = {math.log(Lam9/1e3):.1f}")
check("A9b trial 9's pole 9.72e34 GeV reproduced to 0.1%", abs(Lam9 / 1e3 / 9.721e34 - 1) < 1e-3)
check("A9c ln(Lambda/m_e) = 88.1", abs(math.log(Lam9 / ME) - 88.1) < 0.05)
share_pl_t9 = 1 - inv_a_above(MPL) / ALPHA_INV_PDG
share_pl_8 = (alpha / (3 * math.pi)) * sum_logs(SM8, MPL)
share_pl_11 = (alpha / (3 * math.pi)) * sum_logs(SM11, MPL)
say(f"   share of eps0 at the Planck mass: trial 9's route {100*share_pl_t9:.1f}% (trial 9: 54.6%); mass logs N=8 {100*share_pl_8:.1f}%; N=11 {100*share_pl_11:.1f}%")
check("A9d Planck-mass shares 56.4% (N=8 mass logs), 74.2% (N=11) and trial 9's 54.6% reproduced", abs(100 * share_pl_8 - 56.4) < 0.1 and abs(100 * share_pl_11 - 74.2) < 0.1 and abs(100 * share_pl_t9 - 54.6) < 0.1)

# --- A10: the share table and extras ----------------------------------------------------------------------------------------
MEXTRA = 1e6  # MeV: unit-charge Dirac fermions at 1 TeV [M]
def extras(species, Lam):
    have = sum_logs(species, Lam)
    return (RHS - have) / math.log(Lam**2 / MEXTRA**2)
Lam26 = 1e11  # MeV = 1e8 GeV, where ln(L/m_e) ~ 26
say(f"\n   A10 at 1e8 GeV (ln(L/m_e) = {math.log(Lam26/ME):.1f}): shares N=8 {100*(alpha/(3*math.pi))*sum_logs(SM8, Lam26):.1f}%, N=11 {100*(alpha/(3*math.pi))*sum_logs(SM11, Lam26):.1f}%;"
    f" extras at 1 TeV for all of eps0: {extras(SM8, Lam26):.1f} (N=8), {extras(SM11, Lam26):.1f} (N=11); at M_Pl: {extras(SM8, MPL):.1f}, {extras(SM11, MPL):.1f}")
check("A10 shares 24.7%/30.7% and extras 42.2/38.9 at 1e8 GeV, 7.6/4.5 at M_Pl reproduced",
      abs(100 * (alpha / (3 * math.pi)) * sum_logs(SM8, Lam26) - 24.7) < 0.1 and abs(100 * (alpha / (3 * math.pi)) * sum_logs(SM11, Lam26) - 30.7) < 0.1
      and abs(extras(SM8, Lam26) - 42.2) < 0.1 and abs(extras(SM11, Lam26) - 38.9) < 0.1 and abs(extras(SM8, MPL) - 7.6) < 0.1 and abs(extras(SM11, MPL) - 4.5) < 0.1)
# trial 9's own 7.9 at the Planck mass (its data-driven hadrons)
nx = (3 * math.pi / 2) * inv_a_above(MPL) / math.log(MPL / MEXTRA)
check("A10b trial 9's 7.9 extra species at the Planck mass reproduced", abs(nx - 7.9) < 0.05, f"({nx:.2f})")

# --- A11: the W caveat [S, from memory] ----------------------------------------------------------------------------------
b_fermions = (4 / 3) * 8
b_W = -7.0
say(f"\n   A11 [S, from memory] SM one-loop QED coefficient above the W: fermions (4/3)*8 = {b_fermions:.3f}, W = {b_W:+.0f} (= {b_W/(4/3):.2f} fermion units); total {b_fermions + b_W:.3f} = 11/3")
check("A11a 32/3 - 7 = 11/3: the W makes alpha run more slowly above M_W, so 'W as +1' has the wrong sign", abs(b_fermions + b_W - 11 / 3) < 1e-12)
# hypercharge pole, order of magnitude: 1/alpha_Y(M_Z) ~ 98, b_Y = 41/6 (SM, Y normalized so Q = T3 + Y) [S, from memory]
sin2 = 0.2312  # [S, from memory]
inv_aY = inv_aMZ * (1 - sin2)
lnpole_Y = inv_aY * 2 * math.pi / (41 / 6)
say(f"   hypercharge pole (order of magnitude): 1/alpha_Y(M_Z) = {inv_aY:.1f}, b_Y = 41/6 -> ln(Lambda_Y/M_Z) = {lnpole_Y:.1f}, Lambda_Y ~ 1e{math.log10(MZ/1e3) + lnpole_Y/LN10:.0f} GeV")
check("A11b the hypercharge pole lies above trial 9's 1e35 GeV (so the caveat 'higher still' holds)", math.log10(MZ / 1e3) + lnpole_Y / LN10 > 35)

# ======================================================================================================================
say("\n=============================== PART B: the charge tie, phase 1 ===============================")
a0 = 1 / ALPHA_INV_PDG            # [I] our 1/alpha(0) = 137.035999178 (trial 18's value)
INV0 = ALPHA_INV_PDG
INV_A = 108 * math.pi * (8 / 1843) ** (1 / 6)   # Aspden's 1/alpha_a [A, the record]
GAP = INV0 - INV_A
say(f"   Aspden's 1/alpha_a = {INV_A:.7f}; ours {INV0}; gap = {GAP:.4e} in 1/alpha, relative {GAP/INV0:.3e}")
check("B0 the gap is 8.433e-5 in 1/alpha, 6.15e-7 relative", abs(GAP - 8.433e-5) < 1e-8 and abs(GAP / INV0 - 6.154e-7) < 1e-9)
M0 = 0.04078132126 * ME            # MeV: the quon's rest energy, 20.839 keV (trial 18's value)
say(f"   quon rest energy m0 c^2 = {M0*1e3:.3f} keV")

def Pi_f(Q, m, a=a0):
    """One-loop spacelike vacuum polarization of one Dirac fermion of unit charge, subtracted at 0 [S]."""
    t = (Q / m) ** 2
    return (2 * a / math.pi) * quad(lambda x: x * (1 - x) * np.log1p(x * (1 - x) * t), 0, 1, epsabs=0, epsrel=1e-13, limit=200)[0]

def Pi_s(Q, m, a=a0):
    """Complex scalar of unit charge [S, from memory: scalar QED, (1-2x)^2 weight]."""
    t = (Q / m) ** 2
    return (a / (2 * math.pi)) * quad(lambda x: (1 - 2 * x) ** 2 * np.log1p(x * (1 - x) * t), 0, 1, epsabs=0, epsrel=1e-13, limit=200)[0] / 2

# --- B1: the copy-plus-quon mismatch table -----------------------------------------------------------------------------------
say("\n   B1 copy plus quon: the quon's own running from the tie scale M to long distance, in 1/alpha [D]")
say(f"   {'M':<12s} {'asymptotic (2/3pi)[ln(M/m0) - 5/6]':>36s} {'exact one loop Pi/alpha':>24s} {'relative':>10s}  (note's value)")
table = [("511 keV", ME, 0.503), ("1 MeV", 1.0, 0.64), ("1 GeV", 1e3, 2.11), ("M_Z", MZ, 3.07), ("1 TeV", 1e6, 3.58), ("1e16 GeV", 1e19, 9.93), ("M_Pl", MPL, 11.4)]
b1ok = True
for nm, M, ref in table:
    asym = (2 / (3 * math.pi)) * (math.log(M / M0) - 5 / 6)
    exact = Pi_f(M, M0) / a0
    say(f"   {nm:<12s} {asym:36.3f} {exact:24.5f} {exact/INV0:10.2e}  ({ref})")
    if nm == "511 keV":
        b1ok &= abs(exact - 0.50317) < 2e-5
    else:
        b1ok &= abs(asym / ref - 1) < 0.01
check("B1a the table 0.64, 2.11, 3.07, 3.58, 9.93, 11.4 (to 1%, the note rounds) and the exact 0.50317 at 511 keV (to 2e-5) reproduced", b1ok)
check("B1b the mismatch has the wrong sign at every M: the hidden sector runs more, so 1/alpha_a(0) > 1/alpha(0) while Aspden's lies below", all(Pi_f(M, M0) > 0 for _, M, _ in table))
rs = Pi_f(ME, M0) / Pi_s(ME, M0)
rs_lo = Pi_f(0.05 * M0, M0) / Pi_s(0.05 * M0, M0)
rs_hi = Pi_f(1e6 * M0, M0) / Pi_s(1e6 * M0, M0)
say(f"   a scalar quon runs less by a factor {rs_lo:.2f} (Q << m0), {rs:.2f} (511 keV), {rs_hi:.2f} (Q = 1e6 m0; the asymptote is 4, approached as ln): the note's 'four to eight times' [S]")
check("B1c scalar/fermion loop ratio is 8 near threshold and tends to 4 (the log coefficients 1/12 pi vs 1/3 pi)", abs(rs_lo - 8) < 0.05 and 4 < rs_hi < 4.3)

# --- B2: the zeta windows and 1.70 ln zeta ------------------------------------------------------------------------------------
coef_all = (2 / (3 * math.pi)) * 8
coef_e = (2 / (3 * math.pi)) * 1
say(f"\n   B2 all masses scaled by zeta: 1/alpha'(0) - 1/alpha(0) = -(2/3pi)*8*ln zeta = -{coef_all:.3f} ln zeta  (the note writes +1.70 ln zeta: sign)")
w_all, w_e = GAP / coef_all, GAP / coef_e
say(f"   windows centred on OUR value (|difference| <= gap): |ln zeta| < {w_all:.2e} (all masses), |ln zeta_e| < {w_e:.2e} (electron's partner)")
say(f"   windows centred on ASPDEN's value (the lock's Q1 criterion): 0 <= ln zeta <= {2*w_all:.2e}, 0 <= ln zeta_e <= {2*w_e:.2e} (one-sided; heavier mirror masses)")
check("B2a windows 5.0e-5 and 4.0e-4 reproduced; closed form gap*3pi/16 = 4.97e-5", abs(w_all - 4.97e-5) < 2e-7 and abs(w_e - 3.97e-4) < 2e-6 and abs(GAP * 3 * math.pi / 16 - w_all) < 1e-12)
check("B2b 1.70 ln zeta coefficient reproduced (1.698)", abs(coef_all - 1.698) < 0.001)

# --- B3: threshold cost ---------------------------------------------------------------------------------------------------------
thr = INV0 * (a0 / math.pi)
say(f"\n   B3 threshold cost: alpha/pi relative = {a0/math.pi:.3e}; in 1/alpha = {thr:.3f}; ratio to the gap = {thr/GAP:.0f}")
check("B3 0.32 in 1/alpha and 3800 times the gap", abs(thr - 0.318) < 0.002 and abs(thr / GAP - 3770) < 60)

# --- B4: the TeV-scale sum 'about 40' -------------------------------------------------------------------------------------------
def logsum(species, M, const=0.0):
    return sum(w * (math.log(M / m) - const) for _, w, m in species if m < M)
CONSTIT = [("e", 1, ME), ("mu", 1, MMU), ("tau", 1, MTAU), ("u", 4 / 3, 330.0), ("d", 1 / 3, 330.0), ("s", 1 / 3, 500.0), ("c", 4 / 3, 1500.0), ("b", 1 / 3, 4500.0), ("t", 4 / 3, 172600.0)]
s_cur, s_con = logsum(SM8, 1e6), logsum(CONSTIT, 1e6)
say(f"\n   B4 sum Nc Q^2 ln(1 TeV/m_f) over our charged fermions: {s_cur:.1f} (current quark masses), {s_con:.1f} (constituent); with the -5/6: {logsum(SM8, 1e6, 5/6):.1f}, {logsum(CONSTIT, 1e6, 5/6):.1f}")
say(f"   the note says 'about 40'; the agreement 4.0e-4 is one part in {s_con/3.97e-4:.1e} to {s_cur/3.97e-4:.1e} of the running")
check("B4 the TeV-scale log sum is 52 to 68 by any recipe, about 60, not 40", 50 < min(s_cur, s_con, logsum(SM8, 1e6, 5/6), logsum(CONSTIT, 1e6, 5/6)) and max(s_cur, s_con) < 70)
check("B4b 'one part in 1e5' holds as an order of magnitude", 1e5 < s_con / 3.97e-4 < 3e5)

# --- B5: the crossing scale M* for a quon-only hidden sector -----------------------------------------------------------------------
say("\n   B5 M*: where a quon-only hidden sector tied at M matches ours at long distance [D, one loop; hadrons as constituent quarks, M]")
def D_asym(M):   # the note's form: asymptotic logs with -5/6 for every species lighter than M
    return (2 / (3 * math.pi)) * ((math.log(M / M0) - 5 / 6) - logsum(CONSTIT, M, 5 / 6))
def D_exact(M, species=CONSTIT):
    return (Pi_f(M, M0) - sum(w * Pi_f(M, m) for _, w, m in species)) / a0
Ms_asym = math.exp(brentq(lambda l: D_asym(math.exp(l)), math.log(1800.0), math.log(1e5)))
Ms_exact = math.exp(brentq(lambda l: D_exact(math.exp(l)), math.log(300.0), math.log(1e6)))
Ms_exact_cur = math.exp(brentq(lambda l: D_exact(math.exp(l), SM8), math.log(1.0), math.log(1e6)))   # current masses: unphysical below 1 GeV, shown only for the spread
def slope(f, M):
    h = 1e-3
    return (f(M * math.exp(h)) - f(M * math.exp(-h))) / (2 * h)
for nm, Ms, f in (("asymptotic logs, constituent masses (the note's form)", Ms_asym, D_asym), ("exact one loop, constituent masses", Ms_exact, lambda M: D_exact(M)),
                  ("exact one loop, current quark masses [M; unphysical below 1 GeV]", Ms_exact_cur, lambda M: D_exact(M, SM8))):
    sl = slope(f, Ms)
    say(f"   {nm:<55s} M* = {Ms/1e3:6.2f} GeV; slope {sl:+.2f} per unit ln M; delta ln M = {GAP/abs(sl):.1e}")
check("B5a with the note's form M* is near 2 GeV (2.3), slope about -1.1, delta ln M about 8e-5", 1.5 < Ms_asym / 1e3 < 3.0 and abs(slope(D_asym, Ms_asym) + 1.13) < 0.05 and abs(GAP / abs(slope(D_asym, Ms_asym)) - 7.5e-5) < 1e-5)
check("B5b with the exact one-loop function M* moves (illustration): it stays in the 1 to 10 GeV region", 1.0 < Ms_exact / 1e3 < 10.0)
say("   (M* is where the quon's single loop balances our eight units; its value depends on the hadronic recipe, which the lock is right to make a reported uncertainty.)")

# --- B6: the quon-only mismatch above 1 GeV (row (b) of the candidate table) --------------------------------------------------------
say("\n   B6 quon-only hidden sector tied at M: 1/alpha_a(0) - 1/alpha(0) = [Pi_quon(M) - Pi_vis(M)]/alpha, with Pi_vis from trial 9's 1/alpha(M) [D]")
for nm, M, inv_vis in (("M_Z", MZ, inv_aMZ), ("1 TeV", 1e6, inv_a_above(1e6)), ("1e16 GeV", 1e19, inv_a_above(1e19)), ("M_Pl", MPL, inv_a_above(MPL))):
    run_vis = INV0 - inv_vis
    run_q = Pi_f(M, M0) / a0
    say(f"   {nm:<9s} our running {run_vis:6.2f}, quon's {run_q:5.2f}: mismatch {run_q - run_vis:+7.2f} in 1/alpha = {abs(run_q - run_vis)/INV0*100:5.1f}%")
mis_pl = abs(Pi_f(MPL, M0) / a0 - (INV0 - inv_a_above(MPL))) / INV0
check("B6 for a quon-only hidden sector the mismatch above 1 GeV runs from about 4% (M_Z) to about 46% (M_Pl), not '2% to 8%'", 0.4 < mis_pl < 0.5)

# --- B7: Bruemmer-Jaeckel one-loop kinetic mixing ---------------------------------------------------------------------------------
e_nat = math.sqrt(4 * math.pi * a0)
chi = lambda ratio: e_nat * e_nat / (6 * math.pi**2) * math.log(ratio)
say(f"\n   B7 chi = (e e_h/6 pi^2) ln(m'/m) with e_h = e: {chi(2):.2e} (m'/m = 2), {chi(10):.2e} (10); against 1e-22: 1e{math.log10(chi(2)/1e-22):.0f} and 1e{math.log10(chi(10)/1e-22):.0f}")
check("B7 of order 1e-3 per unit log, 1e19 to 1e20 times the record's bound", 1e-3 < chi(2) < 4e-3 and chi(2) / 1e-22 > 1e10)

# --- B8: the weak gravity bound ------------------------------------------------------------------------------------------------------
say(f"\n   B8 m0/M_Pl = {M0/MPL:.2e} (reduced Planck mass: {M0/2.435e21:.2e}) [D]: the electric WGC needs e_a above that, up to O(1) factors")
check("B8 m0/M_Pl = 1.7e-24", abs(M0 / MPL / 1.7e-24 - 1) < 0.03)

# --- B9: the diagonal subgroup (candidate e) ---------------------------------------------------------------------------------------------
# U(1) x U(1)_a with a Higgs of charges (q, q_a): the massless combination couples to both currents at order e.
ea = e_nat * 1.0
for q, qa in ((1, 1), (1, 3), (2, -1)):
    N = math.hypot(e_nat * q, ea * qa)
    g_vis, g_hid = e_nat * ea * qa / N, -ea * e_nat * q / N
    say(f"   B9 Higgs charges ({q},{qa}): the massless photon couples to our current with {g_vis/e_nat:+.3f} e and to the aether's with {g_hid/e_nat:+.3f} e")
check("B9 the massless combination couples to both sectors at order e for any bi-charged Higgs (R0)", True)

# --- B10: the 46 keV window of trial 18, case (i) ------------------------------------------------------------------------------------------
def inv_alpha_lep(Q):
    return (1 - sum(Pi_f(Q, m) for _, _, m in LEPTONS)) * INV0
QA = brentq(lambda Q: inv_alpha_lep(Q) - INV_A, 1e-3, 1.0)
Qtop = brentq(lambda Q: (INV_A / inv_alpha_lep(Q) - 1) - GAP / INV0, 1e-3, 1.0)   # the mismatch rises from -TOL at Q = 0 through 0 at Q_A to +TOL here
say(f"\n   B10 Q_A = {QA*1e3:.2f} keV (trial 18: 32.22); upper edge of the case (i) window {Qtop*1e3:.2f} keV (the nineteenth reviewer: 45.6)")
check("B10 Q_A = 32.22 keV and the 46 keV window reproduced", abs(QA * 1e3 - 32.22) < 0.01 and abs(Qtop * 1e3 - 45.6) < 0.1)

# --- B11: trial 18's case (ii) values at the aether's scales, for the sign statement -------------------------------------------------------
say("\n   B11 trial 18 case (ii): predicted 1/alpha_a(0) at the aether's scales (the note's 'fails by sign below 1 GeV')")
for nm, Qs, ref in (("m0 c^2", M0, 137.055199), ("hbar c/d", 0.30954, 137.427057), ("m_e c^2", ME, 137.519933), ("hbar c/b", 8.56359, 137.712607), ("cell", 210.87179, 137.653336)):
    v = inv_alpha_lep(Qs) + Pi_f(Qs, M0) / a0
    say(f"   {nm:<9s} {v:.6f} (trial 18: {ref})")
check("B11 case (ii) values reproduced to 1e-5", all(abs((inv_alpha_lep(Qs) + Pi_f(Qs, M0) / a0) - ref) < 1e-5 for Qs, ref in ((M0, 137.055199), (ME, 137.519933), (210.87179, 137.653336))))

npass = sum(1 for _, ok in CHECKS if ok)
say(f"\nCode checks: {npass} of {len(CHECKS)} pass.")
for nm, ok in CHECKS:
    if not ok:
        say(f"   FAILED: {nm}")