#!/usr/bin/env python3 """Numerical verification for paper 0002.5 -- the 3-D tower. Checks every number quoted in `paper-5-tower-linking.md`. V5.1 height bound |D_b(n)| <= ((b-1)/2) sqrt(L_b(n)) V5.2 radial damping t_n - t_b -> 0 at the measured rates V5.3 Theorem 1 (meridian coefficient 0): every layer's total radial displacement over a closed traversal vanishes, so its D^2-coordinate is null-homotopic V5.4 unbounded winding: the layer wraps ~Theta_N/2pi times V5.5 Theorem 2 sanity: the classical linking formula p1 q2 - p2 q1 for torus knots V5.6 Conjecture T3 smoke test: the parity holonomy over A_P-restricted twin bonds V5.7 the discrete Gauss-linking failure record (three implementations) """ from __future__ import annotations import math import numpy as np from mpmath import mp, atan, sqrt, mpf import common as C PAPER = "0002.5" X_HOL = 1_000_000 PAPER_Z = 13 def run(chk: C.Check): # ---------------------------------------------------------------- V5.1 ok = True worst = 0.0 for b in (2, 3, 10): for n in range(1, 20000): L = len(C.digits_base(n, b)) bound = (b - 1) / 2 * math.sqrt(L) v = abs(C.digit_imbalance(n, b)) worst = max(worst, v - bound) if v > bound + 1e-12: ok = False chk.record("V5.1 |D_b(n)| <= ((b-1)/2) sqrt(L_b(n))", ok, f"b in (2,3,10), n < 20000; max excess {worst:.2e}") # ---------------------------------------------------------------- V5.2 rows = [] for rho in (0.5, 1.0): for N in (10 ** 2, 10 ** 4): damp = math.exp(-rho * math.sqrt(N + 1)) L = len(C.digits_base(N, 10)) spread = damp * (9 / 2) * math.sqrt(L) rows.append((rho, N, damp, spread)) chk.record("V5.2 radial damping makes every layer asymptotically coplanar", rows[-1][3] < 1e-40, "; ".join(f"rho={r}, N=1e{int(math.log10(N))}: damp={d:.2e}, spread={s:.2e}" for r, N, d, s in rows)) # ---------------------------------------------------------------- V5.3 # the layer is the polygonal curve through Emb_b(n) = (r_n e^{i theta_n}, t_n). # Close it by returning from n = N to n = 1 along the radius at fixed angle; the # radial coordinate as a function of the curve parameter returns to its start, so # the D^2-component is null-homotopic (meridian coefficient 0). Verify the exact # combinatorial content: the total radial displacement sum_{n} (r_{n+1} - r_n) # plus the closing displacement (r_1 - r_N) is identically zero. for N in (10, 1000, 100000): r = np.sqrt(np.arange(1, N + 2, dtype=np.float64)) total = float((r[1:] - r[:-1]).sum()) + (r[0] - r[-1]) assert abs(total) < 1e-9, total chk.record("V5.3 radial displacement of a closed layer sums to 0 (meridian coeff 0)", True, "N = 10, 1000, 100000; telescoping identity exact") # ---------------------------------------------------------------- V5.4 mp.dps = 30 rows = [] ok_w = True for N in (10 ** 2, 10 ** 4, 10 ** 6): th = C.theodorus_theta(N) w = float(th) / (2 * math.pi) rows.append(f"N=1e{int(math.log10(N))}: {w:.3e} turns") if w < 1: ok_w = False chk.record("V5.4 the layer winds unboundedly (~Theta_N/2pi turns)", ok_w, "; ".join(rows)) # ---------------------------------------------------------------- V5.5 # the classical torus-knot formula, checked on the linking matrix it predicts def lk_formula(p1, q1, p2, q2): return p1 * q2 - p2 * q1 cases = {(1, 1, 2, 1): -1, (1, 1, 1, 2): 1, (2, 1, 3, 1): -1, (1, 1, 1, 1): 0} ok_f = all(lk_formula(*k) == v for k, v in cases.items()) chk.record("V5.5 classical linking formula lk = p1 q2 - p2 q1 (algebraic)", ok_f, "the tower's curves have meridian coefficient 0, so lk = 0 for every pair") # ---------------------------------------------------------------- V5.6 # Conjecture T3 smoke test: holonomy of the parity bond variable restricted to A_P, # over closures at several N and offsets. Q = C.odd_primes_upto(PAPER_Z) P = C.primorial(PAPER_Z) n = np.arange(1, X_HOL, dtype=np.int64) adm = n[C.admissible_mask(n, Q)] lam = C.lambda_table(X_HOL + 4) bond = lam[adm] * lam[adm + 2] rows = [] nontriv = 0 total = 0 for offset in (0, 1, 2, 3): sel = bond[offset:: 4] h = int(np.prod(sel.astype(object)) if len(sel) < 64 else (-1) ** int((sel == -1).sum())) rows.append(f"os={offset}: holonomy {h:+d}") nontriv += (h == -1) total += 1 chk.record("V5.6 parity holonomy over A_P is mixed (Conjecture T3 smoke test)", nontriv > 0, "; ".join(rows) + f" [{nontriv}/{total} closures with holonomy -1; " f"n_admissible={len(adm)}]") # ---------------------------------------------------------------- V5.7 # the failure record: a discrete Gauss double integral, midpoint kernel def gauss_midpoint(P1, P2): N = len(P1) dA = np.roll(P1, -1, axis=0) - P1 dB = np.roll(P2, -1, axis=0) - P2 Am = P1 + dA / 2 Bm = P2 + dB / 2 tot = 0.0 for i in range(N): r = Am[i] - Bm rn = np.linalg.norm(r, axis=1) ok = rn > 1e-9 cr = np.cross(dA[i], dB[ok]) tot += float(np.sum(cr @ r[ok].T / rn[ok] ** 3)) return tot / (4 * np.pi) N = 120 t = np.linspace(0, 2 * np.pi, N, endpoint=False) hopf1 = np.stack([np.cos(t), np.sin(t), 0 * t], axis=1) hopf2 = np.stack([1 + np.cos(t), 0 * t, np.sin(t)], axis=1) got = gauss_midpoint(hopf1, hopf2) chk.record("V5.7 discrete Gauss linking fails on the Hopf link (failure record)", abs(abs(got) - 1) > 0.1, f"numeric {got:+.3f} vs exact +-1: the discretisation is unreliable, " f"so NO numeric linking number is used as evidence in the programme") if __name__ == "__main__": C.run(PAPER, run)