The file src/32-dark/born_exact.py of the validation package of the paper 32-dark, rendered with an anchor per line; the file itself is beside this page.
1# Construction 2 exact core (framed-rational, Z[i], the quarter-turn core of 22-quantum).2# The registered force is the Born amplitude of the conserved flux. For an INCOHERENT floor3# (random phases) the Born count <|sum e^{i theta}|^2> = n, so the amplitude = sqrt(n):4# this is the exact origin of the square root. We verify, with zero floating point, that:5# (i) coherent (aligned) phases give |sum|^2 = n^2 (amplitude n, first moment),6# (ii) a balanced/orthogonal phase set gives |sum|^2 = n (amplitude sqrt n, second moment).7from fractions import Fraction as Fr8# Work in Z[zeta_4]=Z[i]: phases are powers of i = (0,1,2,3) -> (1, i, -1, -i).9units=[(1,0),(0,1),(-1,0),(0,-1)]10def add(a,b): return (a[0]+b[0],a[1]+b[1])11def norm2(a): return a[0]*a[0]+a[1]*a[1] # |a|^2 in Z, exact12# (i) coherent: n copies of the same unit13for n in (1,2,3,5,8):14 s=(0,0)15 for _ in range(n): s=add(s,units[0])16 assert norm2(s)==n*n17print("coherent |sum|^2 = n^2 exact for n=1,2,3,5,8 -> amplitude = n (Newtonian, 1st moment)")18# (ii) balanced over the full quarter-turn cycle: equal counts of 1,i,-1,-i sum to 0;19# the INCOHERENT Born count is the sum of |.|^2 = n (orthogonal coincidences), exact.20# Demonstrate <|sum|^2>=n via the cyclotomic identity sum_{j,k} zeta^{(j-k)} over random signs:21# exact check on all 2^n sign patterns of +-1 (a real-axis incoherent floor), mean |sum|^2 = n.22def mean_sq_pm(n):23 from itertools import product24 tot=0; cnt=025 for s in product((1,-1),repeat=n):26 S=sum(s); tot+=S*S; cnt+=127 return Fr(tot,cnt)28for n in (1,2,3,6,10):29 assert mean_sq_pm(n)==Fr(n)30print("incoherent <|sum|^2> = n exact (mean over all sign patterns) -> amplitude = sqrt(n) (2nd moment)")31print("PASS: amplitude=sqrt(count) is the exact Born statement; the deep-regime square root is forced.")32