Does light charge the quons? › Files cited on the page › the trials
slow_light_zero_pressure.py
#!/usr/bin/env python3
"""Trial 24: how much light slows as matter thins to nothing, and whether it slows in empty space.
Lock: papers/Lock_slow_light_zero_pressure_2026-11-23.md. Author seat. Run once, after the lock is committed."""
import csv
import math
import os
import subprocess
import warnings
import numpy as np
from scipy.integrate import quad
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(os.path.dirname(HERE))
NIST = os.path.join(ROOT, "sources/slow_light_2026-11-23/nist_npT/unzipped")
C = 299792458.0
E, ME, EPS0 = 1.602176634e-19, 9.1093837015e-31, 8.8541878128e-12
checks = [0, 0]
def check(ok, text):
checks[1] += 1
checks[0] += bool(ok)
print(f" {'pass' if ok else 'FAIL'}: {text}")
def load(gas):
out = []
with open(os.path.join(NIST, gas, f"data-{gas}-2062.csv")) as f:
for r in csv.reader(f):
if len(r) == 3 and r[0][:1].isdigit():
out.append([float(x) for x in r])
a = np.array(out)
return a[:, 0] + 273.15, a[:, 1], a[:, 2] * 1e-8, np.round(a[:, 0]).astype(int)
def fit(T, p, r, Tj, form):
"""form: 'full' (A,B,C,eps), 'quad' (A,B,eps), 'line' (A,eps). Returns parameters, covariance, residuals over sigma."""
y = p * Tj / T
s = np.sqrt(0.05**2 + (1e-6 * p) ** 2)
npow = {"line": 1, "quad": 2, "full": 3}[form]
X = np.column_stack([r**k for k in range(1, npow + 1)] + [np.ones_like(r)])
scale = np.abs(X).max(axis=0)
Xs = X / scale / s[:, None]
coef, *_ = np.linalg.lstsq(Xs, y / s, rcond=None)
cov = np.linalg.inv(Xs.T @ Xs)
res = y / s - Xs @ coef
chi2 = float(res @ res) / (len(y) - len(coef))
coef, cov = coef / scale, cov / np.outer(scale, scale)
return coef, cov * chi2, chi2
def intercept(T, p, r, Tj, form):
c, cov, chi2 = fit(T, p, r, Tj, form)
A, eps = c[0], c[-1]
return -eps / A, math.sqrt(cov[-1, -1]) / A, eps, A, chi2
def combine(x, s):
x, s = np.array(x), np.array(s)
w = 1 / s**2
m = (w * x).sum() / w.sum()
chi = ((x - m) ** 2 * w).sum() / (len(x) - 1)
return m, math.sqrt(1 / w.sum()) * max(1, math.sqrt(chi)), math.sqrt(chi)
PRIMARY = {"nitrogen": "full", "argon": "full", "helium": "quad"}
GASES = ("nitrogen", "argon", "helium")
def part_a(shift=0.0, boot=400, quiet=False, form=None):
rng = np.random.default_rng(24)
out = {}
for gas in GASES:
T, p, r, iso = load(gas)
r = r + shift
rows = []
for t in sorted(set(iso)):
m = iso == t
Tj = t + 273.15
f = form or PRIMARY[gas]
i0, s, eps, A, chi2 = intercept(T[m], p[m], r[m], Tj, f)
bs = np.nan
if boot:
idx = np.where(m)[0]
b = []
for _ in range(boot):
k = rng.choice(idx, len(idx))
b.append(intercept(T[k], p[k], r[k], Tj, f)[0])
pt = float(np.std(b))
# whole pressure settings resampled: the readings at one setting share its weights and its errors
order = np.argsort(p[idx])
lab = np.zeros(len(idx), int)
lab[order] = np.concatenate([[0], np.cumsum(np.diff(p[idx][order]) > 1e-3 * p[idx][order][:-1])])
ns = lab.max() + 1
npar = {"line": 2, "quad": 3, "full": 4}[f]
b = []
while len(b) < boot:
pick = rng.integers(0, ns, ns)
if len(set(pick)) < npar + 1:
continue
k = np.concatenate([idx[lab == q] for q in pick])
b.append(intercept(T[k], p[k], r[k], Tj, f)[0])
bs = max(pt, float(np.std(b)))
else:
pt = np.nan
rows.append((t, i0, s, bs, eps, A, chi2, pt))
out[gas] = rows
if not quiet:
print(f" {gas} ({f}): t (C), intercept i0, errors (covariance; points; used = larger of points and settings), eps_p (Pa), chi2/dof")
for q in rows:
print(f" {q[0]:4d} {q[1]:+.3e} {q[2]:.1e} {q[7]:.1e} {q[3]:.1e} {q[4]:+8.4f} {q[6]:.2f}")
return out
def summary(out, use=3):
res = {}
for gas, rows in out.items():
e = [q[use] if not math.isnan(q[use]) else q[2] for q in rows]
m, s, birge = combine([q[1] for q in rows], e)
em, es, eb = combine([q[4] for q in rows], [x * q[5] for x, q in zip(e, rows)])
res[gas] = (m, s, birge, em, es, eb, np.mean([q[5] for q in rows]), rows[0][5])
return res
# ---------------------------------------------------------------- Part C data: Xu and Ma 2016, Table 1, as printed
XM = [("080916C(1)", 4.35, 12.4, 1.974, 4.46, 1), ("080916C(2)", 4.35, 27.4, 6.453, 9.86, 0), ("090510", 0.903, 29.9, 0.452, 7.21, 0),
("090902B", 1.822, 39.9, 25.506, 12.9, 1), ("090902Bs a", 1.822, 11.9, 0.674, 3.84, 1), ("090902Bs b", 1.822, 14.2, 1.559, 4.58, 1),
("090902Bs c", 1.822, 18.1, 5.812, 5.84, 1), ("090902Bs d", 1.822, 12.7, 11.554, 4.10, 0), ("090902Bs e", 1.822, 15.4, 12.700, 4.97, 0),
("090926A", 2.1071, 19.5, 6.603, 6.53, 1), ("100414A", 1.368, 29.7, 13.968, 8.70, 1), ("130427A", 0.3399, 72.6, 13.509, 9.02, 1),
("140619B", 2.67, 22.7, 0.141, 7.96, 0)]
def ols(x, y):
n = len(x)
X = np.column_stack([x, np.ones(n)])
c, *_ = np.linalg.lstsq(X, y, rcond=None)
r = y - X @ c
s2 = r @ r / (n - 2)
cov = s2 * np.linalg.inv(X.T @ X)
return c[0], math.sqrt(cov[0, 0]), c[1], math.sqrt(cov[1, 1]), r
def best_line(x, y, tol):
best = 0
n = len(x)
for i in range(n):
for j in range(i + 1, n):
if x[i] == x[j]:
continue
m = (y[j] - y[i]) / (x[j] - x[i])
if m <= 0:
continue
c = y[i] - m * x[i]
best = max(best, int((np.abs(y - m * x - c) <= tol + 1e-12).sum()))
return best
def tof(z, n=1):
H0, Om = 67.4e3 / 3.0856775814913673e22, 0.3153
return quad(lambda u: (1 + u) ** n / (H0 * math.sqrt(Om * (1 + u) ** 3 + 1 - Om)), 0, z)[0]
def ciddor(lam_um, p, tC, ng=False):
"""Ciddor 1996 dry standard air (15 C, 101325 Pa), scaled by ideal-gas density [M]; group index if ng."""
def std(l):
s2 = 1 / l**2
return (5792105 / (238.0185 - s2) + 167917 / (57.362 - s2)) * 1e-8
v = std(lam_um)
if ng:
h = 1e-4
v -= lam_um * (std(lam_um + h) - std(lam_um - h)) / (2 * h)
return v * (p / 101325.0) * (288.15 / (tC + 273.15))
def main():
warnings.simplefilter("ignore")
print("git HEAD at run:", subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, cwd=HERE).stdout.strip())
print("Trial 24. Lock: papers/Lock_slow_light_zero_pressure_2026-11-23.md")
print("\n=== Part A. The intercept at zero pressure ===")
out = part_a()
S = summary(out)
inst = {g: 0.1 / S[g][7] for g in GASES}
print(" combined (bootstrap errors, Birge-inflated): gas, mean i0, error, Birge, mean eps_p (Pa), error, instrument's stated 0.1 Pa as refractivity")
lim = {}
for g in GASES:
m, s, b, em, es, eb, Am, A0 = S[g]
lim[g] = abs(m) + 2 * s
null = abs(m) < 2 * s or abs(m) < inst[g]
print(f" {g:9s} {m:+.3e} +- {s:.1e} Birge {b:.2f} {em:+.4f} +- {es:.4f} Pa (Birge {eb:.2f}) {inst[g]:.2e}")
print(f" VA1: {'nothing left at zero pressure' if null else 'NOT within 2 sigma or the stated offset'}; limit |i0| + 2 sigma = {lim[g]:.2e} ({lim[g]*C:.2e} m/s)")
ms, ss = [S[g][0] for g in GASES], [S[g][1] for g in GASES]
es_, ss_ = [S[g][3] for g in GASES], [S[g][4] for g in GASES]
mi, si, bi = combine(ms, ss)
me, se, be = combine(es_, ss_)
print(f" VA2: one i0 in refractivity for all three gases: {mi:+.2e} +- {si:.1e}, chi2/dof {bi**2:.2f}; one eps_p in pascals: {me:+.4f} +- {se:.4f}, chi2/dof {be**2:.2f}")
cand = bi**2 < 2 and be**2 > 4 and abs(mi) > 3 * si
print(f" candidate for E2 by the lock's rule: {'YES' if cand else 'no'}")
A20 = out["nitrogen"][0][5]
g_a, g_s = 0.108, 0.006
print(f" VA3: GAMOR a = {g_a}({int(g_s*1000)}) Pa = {g_a/A20:.2e} +- {g_s/A20:.1e} in refractivity, {g_a/g_s:.0f} sigma by its own error; "
f"NIST 2016 pressure-independent 2.0 mPa (k = 2) = {0.002/A20:.2e}; ratio {g_a/0.002:.0f}; "
f"{'not reproduced at lower pressure by another instrument (cause not explained)' if g_a > 3*0.002 else 'consistent'}")
print(" VA4: injections")
ok = True
for sh in (1e-9, -1e-9):
o2 = part_a(shift=sh, boot=0, quiet=True)
base = part_a(shift=0.0, boot=0, quiet=True)
for g in GASES:
d = np.mean([a[1] - b[1] for a, b in zip(o2[g], base[g])])
ok &= abs(d / sh - 1) < 0.01
print(f" add {sh:+.0e}: {g:9s} i0 moves {d:+.4e}")
check(ok, "K5: a step of either sign is recovered within 1%")
T, p, r, iso = load("nitrogen")
from mpmath import mp, mpf
mp.dps = 40
nv = 1 + mpf("1e-6")
worst = max(abs((nv * (1 + mpf(x))) / (nv * 1) - (1 + mpf(x))) for x in r[:200])
print(f" multiply gas and vacuum index by 1 + 1e-6: the measured n_gas/n_vac changes by at most {float(worst):.1e}")
check(worst < 1e-15, "K5: a slowing of the vacuum itself leaves a refractometer's reading unchanged (E3 cannot be seen here)")
print(" VA5: other forms, mean intercept per gas (weighted, no bootstrap)")
for f in ("line", "quad", "full"):
o3 = part_a(boot=0, quiet=True, form=f)
print(f" {f:5s}: " + "; ".join(f"{g} {combine([q[1] for q in o3[g]], [q[2] for q in o3[g]])[0]:+.2e} (chi2/dof {np.mean([q[6] for q in o3[g]]):.3g})" for g in GASES))
r1 = 101325.0 / A20
check(abs(r1 / 2.79e-4 - 1) < 0.01, f"K1: nitrogen n - 1 at 101325 Pa, 20 C (leading term) = {r1:.4e} against 2.79e-4")
rat = [q[7] / q[2] for g in GASES for q in out[g]]
check(all(0.5 < x < 2 for x in rat), f"K2: point-bootstrap over covariance error between {min(rat):.2f} and {max(rat):.2f}")
print("\n=== Part B. The absolute check ===")
V = {"Froome 1958 (air, corrected)": (299792.50, 0.10), "Michelson, Pease, Pearson 1935 (0.5-5.5 mm Hg)": (299774.0, 11.0)}
v0, e0 = 299792.4562, 0.0011
for k, (v, e) in V.items():
print(f" {k}: {v} +- {e}; minus Evenson 1972 (vacuum) {v0}: {v-v0:+.3f} km/s = {(v-v0)/v0:+.2e}, {(v-v0)/math.hypot(e, e0):+.1f} sigma")
for mm in (0.5, 3.0, 5.5):
n1 = 0.000293 * mm * 1333.2 / (1 + 0.00367 * 20) / 1.0136e6
print(f" residual air at {mm} mm Hg, 20 C (their formula): n - 1 = {n1:.2e}, {n1*C/1000:.3f} km/s")
n55 = 0.000293 * 5.5 * 1333.2 / (1 + 0.00367 * 20) / 1.0136e6 * C / 1000
print(f" rule: the 1935 shortfall is {abs(299774.0-v0)/n55:.0f} times what all the air at 5.5 mm could make, and the air was already corrected for: not air")
print(" B2. light against what is not light, delta = (other's speed or limit - light's)/c:")
yr = 365.25 * 86400
B2 = [("SLAC 11 GeV electrons and visible light (Brown 1973), 2 sigma", 1.3e-6 + 2 * 2.7e-6), ("SLAC 15-20.5 GeV electrons and gamma rays (Guiragossian 1974)", 2e-7),
("SN 1987A neutrinos 3 h ahead over 168,000 light-years", 3 * 3600 / (168000 * yr)), ("gravity, GW170817 (larger side)", 3e-15),
("cosmic rays, no vacuum Cherenkov light (trial 22)", 4e-24)]
for k, d in B2:
print(f" {k}: {d:.1e} = {d*C:.1e} m/s")
print(" none bounds a slowing that matter's own limit shares (R-ii)")
print("\n=== Part C. The energy claim re-analysed (Xu and Ma 2016, 13 events) ===")
K = np.array([e[4] for e in XM]); Y = np.array([e[3] for e in XM]); main_ = np.array([e[5] for e in XM]) == 1
a, sa, b, sb, _ = ols(K, Y)
print(f" C1 all 13: slope {a:.2f} +- {sa:.2f} (1e-18/GeV), {a/sa:.1f} sigma; intercept {b:.1f} +- {sb:.1f} s")
a8, sa8, b8, sb8, r8 = ols(K[main_], Y[main_])
print(f" C2 their 8: slope {a8:.2f} +- {sa8:.2f}, {a8/sa8:.0f} sigma; intercept {b8:.1f} +- {sb8:.1f} s")
check(abs(a - 1.7) < 1.4 and abs(sa - 1.4) < 0.5 and abs(a8 - 2.78) < 0.2 and abs(b8 + 10.7) < 1.5, "K3: C1 and C2 reproduce the paper's fits within its errors")
tol = float(np.max(np.abs(r8)))
rng = np.random.default_rng(24)
real = best_line(K, Y, tol)
N = 20000
cnt = [best_line(K, rng.permutation(Y), tol) for _ in range(N)]
frac = np.mean(np.array(cnt) >= 8)
verdict = "a line through 8 of 13 is easy to find by chance" if frac > 0.05 else ("not chance" if frac < 0.003 else "weak")
print(f" C3 tolerance {tol:.2f} s; real data: a line of positive slope catches {real} of 13; shuffled delays: >= 8 in {frac:.4f} of {N} "
f"(>= 7 in {np.mean(np.array(cnt) >= 7):.4f}, >= 6 in {np.mean(np.array(cnt) >= 6):.4f}); verdict by the rule: {verdict}")
invE = 2.78e-18
d221 = invE * 1000 * tof(0.151)
d090 = invE * 28 * tof(0.903)
print(f" C4 predicted delay: 1 TeV from GRB 221009A {d221:.0f} s; LHAASO's limit allows {1/1.0e20*1000*tof(0.151):.2f} s (ratio {invE*1.0e20:.0f}); "
f"28 GeV from GRB 090510 {d090:.1f} s against 0.859 s (a) and 0.010 s (e): ratios {d090/0.859:.0f} and {d090/0.010:.0f}")
Tm = tof(0.034)
m, sm = 0.030 / Tm, 0.012 / Tm
print(f" C5 MAGIC Mrk 501: 1/E_LV = {m:.2e} +- {sm:.1e} per GeV; minus Xu-Ma 2.78e-18: {(m-2.78e-18)/math.hypot(sm, 0.20e-18):+.1f} sigma; LHAASO's limit 1.0e-20: {m/1e-20:.0f} times smaller")
print("\n=== Part E. How much light slows (air, 20 C, 633 nm) ===")
pa = 1.0
ph, gr = ciddor(0.633, pa, 20), ciddor(0.633, pa, 20, True)
print(f" per pascal: phase n - 1 = {ph:.3e}, group {gr:.3e}; a light signal slows by {gr*C:.4f} m/s per pascal")
for P in (101325.0, 1e5, 1.0, 1e-7, 1e-10):
print(f" {P:9.3g} Pa: {ciddor(0.633, P, 20, True)*C:.3e} m/s")
v1 = ciddor(0.633, 101325, 20, True) * C / 1000
check(80 < v1 < 85, f"K4: at 101325 Pa, 20 C the signal slows by {v1:.1f} km/s")
w = 2 * math.pi * C / 633e-9
pe = E**2 / (2 * EPS0 * ME * w**2) # group: +pe per electron (phase: -pe)
pH = 4.5 * 4 * math.pi * (5.29177210903e-11) ** 3 / 2 # hydrogen atom, static
SP = [("interplanetary", 0.0, 5e6), ("interstellar", 1e6, 3e4), ("intergalactic", 0.0, 0.25)]
print(" space, 633 nm, signal (group) slowing; atoms + free electrons per m^3 (densities from trials 22-23 and memory):")
sp = []
for k, nH, ne in SP:
v = (nH * pH + ne * pe) * C
sp.append((k, (nH + ne), v))
print(f" {k:14s} {nH:.2g} + {ne:.2g}: {v:.2e} m/s ({v/C:.1e} of c)")
w14 = 2 * math.pi * 1.4e9
print(f" radio, 1.4 GHz, interstellar electrons 3e4 per m^3: {3e4*E**2/(2*EPS0*ME*w14**2)*C:.2e} m/s")
figure(out, S, lim, g_a / A20, g_s / A20, 0.002 / A20, B2, sp)
print(f"\nCode checks: {checks[0]} of {checks[1]} pass.")
def figure(out, S, lim, gam, gams, nist16, B2, sp):
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
COL = {"nitrogen": "#2a78d6", "argon": "#1baf7a", "helium": "#eda100"}
MK = {"nitrogen": "o", "argon": "s", "helium": "^"}
INK, MUT, GRID = "#1d1d1f", "#5f6368", "#e4e4e8"
plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 10, "axes.edgecolor": MUT, "axes.labelcolor": INK, "xtick.color": MUT, "ytick.color": MUT})
fig = plt.figure(figsize=(12, 15))
gs = fig.add_gridspec(3, 1, height_ratios=[1.0, 1.1, 1.3], hspace=0.36)
ax = [fig.add_subplot(gs[i]) for i in range(3)]
for a in ax:
a.grid(True, color=GRID, lw=0.8); a.set_axisbelow(True)
for sp_ in ("top", "right"):
a.spines[sp_].set_visible(False)
a = ax[0]
for g in GASES:
T, p, r, iso = load(g)
m = iso == 20
c, _, _ = fit(T[m], p[m], r[m], 293.15, PRIMARY[g])
rr = np.linspace(0, r[m].max(), 200)
co = list(c[:-1]) + [0] * (3 - len(c[:-1]))
a.plot((co[0] * rr + co[1] * rr**2 + co[2] * rr**3 + c[-1]) / 1e3, rr * 1e4, color=COL[g], lw=2)
a.plot(p[m] / 1e3, r[m] * 1e4, MK[g], ms=5, color=COL[g], mec="white", mew=0.5, label=f"{g}, {m.sum()} measured points")
a.annotate(g, (p[m].max() / 1e3, r[m].max() * 1e4), xytext=(6, 0), textcoords="offset points", va="center", color=INK)
a.plot([0], [0], "D", color=INK, ms=7, zorder=5); a.annotate("vacuum: the reference, zero by construction", (4, -0.05), xytext=(330, 0.55), color=INK, va="center", arrowprops=dict(arrowstyle="-", color=MUT))
a.set_xlim(-8, 560); a.set_ylim(-0.4, None)
a.set_xlabel("pressure (kPa)"); a.set_ylabel("slowing n − 1 (parts in 10,000)")
a.set_title("1. Measured slowing in three gases (NIST, 20 °C), and the fits carried to zero pressure", loc="left", fontsize=12, color=INK)
a.legend(frameon=False, loc="upper left")
a = ax[1]
y, yt = 0, []
for g in GASES:
for q in out[g]:
a.errorbar(q[1] * 1e10, y, xerr=2 * q[3] * 1e10, fmt=MK[g], ms=5, color=COL[g], ecolor=COL[g], elinewidth=1.5)
y += 1
y += 1.0
a.errorbar(S[g][0] * 1e10, y, xerr=2 * S[g][1] * 1e10, fmt="D", ms=8, color=COL[g], mec=INK, elinewidth=3)
yt.append((y, f"{g}: all nine")); yt.append((y - 6, f"{g}, 20 to 160 °C")); y += 2.5
a.errorbar(gam * 1e10, y, xerr=2 * gams * 1e10, fmt="v", ms=8, color="#e34948", elinewidth=2); yt.append((y, "GAMOR 2019 (cause unknown)")); y += 3
a.errorbar(0, y, xerr=nist16 * 1e10, fmt="none", ecolor=INK, elinewidth=4); yt.append((y, "NIST 2016, 100 Pa and up (limit)"))
a.axvline(0, color=INK, lw=1.2)
a.set_yticks([t[0] for t in yt]); a.set_yticklabels([t[1] for t in yt]); a.invert_yaxis()
a.set_xlabel("slowing left over at zero pressure (parts in 10¹⁰); bars are 2σ")
a.set_title("2. What is left when the fits reach zero pressure", loc="left", fontsize=12, color=INK)
a = ax[2]
P = np.logspace(5, -12, 200)
a.loglog(P, [ciddor(0.633, x, 20, True) * C for x in P], color=COL["nitrogen"], lw=2.5)
for x, t in ((1e5, "1 atm"), (1.0, "1 Pa"), (1e-7, "10⁻⁷ Pa"), (1e-10, "10⁻¹⁰ Pa")):
v = ciddor(0.633, x, 20, True) * C
a.plot([x], [v], "o", color=COL["nitrogen"], ms=7); a.annotate(f"{t}: {v:.2g} m/s", (x, v), xytext=(10, -14 if x == 1e-7 else 6), textcoords="offset points", ha="left", color=INK)
kT = 1.380649e-23 * 293.15
for i, (k, N, v) in enumerate(sp):
pe_ = N * kT
a.plot([max(pe_, 1.2e-21)], [v], "s", color="#4a3aa7", ms=8)
a.annotate(f"{k} space", (max(pe_, 1.2e-21), v), xytext=(-10 if i == 2 else 10, 4), textcoords="offset points", ha="right" if i == 2 else "left", color=INK)
for k, d in B2:
a.axhline(d * C, color="#e34948", lw=1.2, ls="--")
left = "cosmic" in k
a.annotate(k + f": below {d*C:.0e} m/s", (2.5e5 if left else 2e-21, d * C), xytext=(0, 3), textcoords="offset points", ha="left" if left else "right", fontsize=8.5, color=MUT)
a.set_xlim(4e5, 1e-21); a.set_ylim(1e-21, 1e6)
a.set_xlabel("pressure (Pa), falling to the right; space at its density as a gas at 20 °C")
a.set_ylabel("how much a light signal slows (m/s)")
a.set_title("3. The prediction: slowing falls in step with pressure. Dashed: limits on any slowing of the vacuum itself\n (light against particles, gravity, neutrinos; none covers a slowing that matter shares)", loc="left", fontsize=12, color=INK)
fn = os.path.join(ROOT, "papers/figures/fig-slow-light.png")
fig.savefig(fn, dpi=150, bbox_inches="tight", facecolor="white")
print(" figure:", os.path.relpath(fn, ROOT))
if __name__ == "__main__":
main()