The file src/32-dark/firstpassage_finite.py of the validation package of the paper 32-dark, rendered with an anchor per line; the file itself is beside this page.
1#!/usr/bin/env python32# =====================================================================3# firstpassage_finite.py -- the finite-cycle first-passage law and the4# controlled reduction to e^{-sqrt(x)} (Proposition `prop:passage').5#6# Referee point #2: the manuscript used the Brownian transform7# E[e^{-s T_a}] = e^{-a sqrt(2s)} without a finite-shell error bound.8# Here we (A) verify the EXACT discrete-line transform9# E[e^{-s T_a}] = e^{-a arccosh(e^s)},10# (B) bound its deviation from the Brownian sqrt-form, which is O(s) and11# hence O(Omega^{-1/2}) at the substrate step rate, and (C) solve the12# killed walk on the FINITE cycle Z_{N} and show the wrap correction is13# exponentially negligible for a barrier below the coherence horizon.14# No floats where an identity is claimed (mpmath at 60 digits).15# =====================================================================16import mpmath as mp17mp.mp.dps = 601819def hr(t): print("\n"+"="*70+"\n"+t+"\n"+"="*70)2021# ---------------------------------------------------------------------22# A. exact single-step factor and the arccosh transform (an identity)23# f(z) = (1 - sqrt(1-z^2))/z solves (z/2) f^2 - f + (z/2) = 0;24# at z=e^{-s}, f = e^{-arccosh(e^s)} exactly.25# ---------------------------------------------------------------------26hr("A. f(e^{-s}) = e^{-arccosh(e^s)} (exact single-step identity)")27for s in [mp.mpf('1.0'), mp.mpf('0.1'), mp.mpf('1e-3'), mp.mpf('1e-6')]:28 z = mp.e**(-s)29 f = (1 - mp.sqrt(1 - z**2))/z30 g = mp.e**(-mp.acosh(mp.e**s))31 quad = (z/2)*f**2 - f + (z/2) # should be 032 print(f" s={mp.nstr(s,3):>8}: f={mp.nstr(f,12)} e^-arccosh={mp.nstr(g,12)} "33 f"|f-g|={mp.nstr(abs(f-g),3)} quad={mp.nstr(abs(quad),3)}")3435# ---------------------------------------------------------------------36# B. exact exponent gamma(s)=arccosh(e^s) vs Brownian sqrt(2s):37# gamma(s) = sqrt(2s) (1 + s/12 + ...), so the RELATIVE error is O(s).38# ---------------------------------------------------------------------39hr("B. arccosh(e^s) = sqrt(2s)(1 + s/6 + s^2/120 + ...); relative error = O(s)")40print(f" {'s':>10} {'arccosh(e^s)':>16} {'sqrt(2s)':>16} {'rel.err':>12} {'rel.err/s':>10}")41for s in [mp.mpf('1e-1'), mp.mpf('1e-2'), mp.mpf('1e-3'), mp.mpf('1e-4')]:42 gamma = mp.acosh(mp.e**s)43 brown = mp.sqrt(2*s)44 rel = (gamma-brown)/brown45 print(f" {mp.nstr(s,2):>10} {mp.nstr(gamma,10):>16} {mp.nstr(brown,10):>16} "46 f"{mp.nstr(rel,4):>12} {mp.nstr(rel/s,4):>10}")47print(" -> rel.err/s -> 1/6: the reduction is controlled, error linear in the step rate s.")4849# substrate step rate: chronon/Hubble ~ 1/sqrt(Omega), Omega ~ 1e122.50# (rel.err = s/6 + O(s^2); evaluate the leading series term to avoid the51# catastrophic cancellation of arccosh(e^s)-sqrt(2s) at s~1e-61.)52Omega = mp.mpf('1e122')53s_sub = 1/mp.sqrt(Omega)54rel_sub = s_sub/655print(f"\n substrate: s ~ Omega^-1/2 = {mp.nstr(s_sub,3)}; relative exponent error "56 f"~ s/6 = {mp.nstr(rel_sub,3)}")57print(f" => the resolvable-window reading e^{{-sqrt x}} is carrier-exact to ~{mp.nstr(rel_sub,1)}.")5859# ---------------------------------------------------------------------60# C. killed walk on the FINITE cycle Z_N: exact escape vs the line.61# Barrier (absorbing) at a, source at 0, per-step survival z=e^{-s};62# solve the linear recurrence for the escape (first-passage) generating63# value exactly, compare to the infinite-line f(z)^a.64# ---------------------------------------------------------------------65hr("C. finite cycle Z_N: escape vs infinite line (wrap correction)")66def escape_cycle(N, a, z):67 # states 0..N-1 on a cycle; absorbing barrier at site a; start at 0.68 # E[z^{T_a}] = sum over paths weighted z^steps until first hit of a.69 # Solve h_i = E[z^{T_a} | start i]; h_a = 1; for i != a:70 # h_i = (z/2)(h_{i-1} + h_{i+1}) (indices mod N), killed by z<1.71 n = N72 A = mp.zeros(n, n); b = mp.zeros(n, 1)73 for i in range(n):74 if i == a:75 A[i, i] = 1; b[i] = 176 else:77 A[i, i] = 178 A[i, (i-1) % n] += -z/279 A[i, (i+1) % n] += -z/280 h = mp.lu_solve(A, b)81 return h[0]82def escape_line(a, z):83 f = (1 - mp.sqrt(1 - z**2))/z84 return f**a85for (N, a, s) in [(40, 5, mp.mpf('0.05')), (80, 5, mp.mpf('0.05')), (200, 8, mp.mpf('0.02'))]:86 z = mp.e**(-s)87 ec = escape_cycle(N, a, z); el = escape_line(a, z)88 print(f" N={N:>4} a={a} s={mp.nstr(s,2)}: cycle={mp.nstr(ec,12)} line={mp.nstr(el,12)} "89 f"|diff|={mp.nstr(abs(ec-el),3)} (~e^-(N-a)arccosh(e^s)={mp.nstr(mp.e**(-(N-a)*mp.acosh(mp.e**s)),2)})")90print(" -> wrap correction vanishes ~ e^{-(N-a)}; for a << sqrt(Omega) it is carrier-negligible.")9192hr("VERDICT")93print(""" * the exact carrier transform is e^{-a arccosh(e^s)} (A), an identity;94 * its reduction to the Brownian e^{-a sqrt(2s)} = e^{-sqrt x} has relative95 error O(s) = O(Omega^{-1/2}) ~ 1e-61 at the substrate step (B);96 * on the finite cycle the wrap correction is O(e^{-(N-a) arccosh(e^s)}), negligible for a97 barrier below the coherence horizon sqrt(Omega) (C).98 => e^{-sqrt x} is the resolvable-window reading of an exact finite-cycle99 law, carrier-exact to O(Omega^{-1/2}); independently it is the amplitude100 identity of Proposition prop:born (exact in Z[i]).""")101