back to table · edit · history · where entries came from · files · download
7252 bytes, as of the version from 2026-11-15 23:53. Recorded here, not run.
"""Independent builder checks for T720, not a scientific-review verdict.
sage -python checks.py entries.json [quadrature-checkpoints.json]
Uses mpmath's own Bessel implementations and tanh-sinh quadrature in the
original r variable, rather than Arb integration in log(r). All 19 raw
integrals are checked at 70 working decimal digits against a 1e-55 relative
scale; this numerical check is heuristic and does not certify 100 digits.
The stored-digit certificates come from the generator's full enclosures.
Closed forms are independently evaluated at 170 digits and tested against
the complete stored last-place intervals. These cover both exact rational
rows and four transcendental raw cases, including a modular L-value.
The eta product and its Fricke transformation supply a Bessel-independent
Mellin check for B_5(1): B_5(1)=pi^2 L(f,2)/2, f=(eta_1 eta_2 eta_3 eta_6)^2.
Zhou, arXiv:1706.08308v4, Theorem 4.2.5 / (4.2.25) proves the identity.
Exact Fourier coefficients are generated by a polynomial product and checked
against LMFDB 6.4.a.a; 240/300-term split Mellin sums must agree. No sibling
table is an oracle. Inputs with reversed sign and a missing normalization
factor deliberately test that the comparisons can fail.
"""
import json
import sys
import time
from functools import lru_cache
from pathlib import Path
from decimal import Decimal, localcontext
import mpmath as mp
def interval(text):
if '/' in str(text):
a,b = str(text).split('/')
y = mp.mpf(a)/mp.mpf(b)
return y,y
x = Decimal(str(text))
if x == x.to_integral() and '.' not in str(text) and 'e' not in str(text).lower():
y=mp.mpf(str(text));return y,y
unit = Decimal(1).scaleb(x.as_tuple().exponent)
with localcontext() as context:
context.prec=250
return mp.mpf(str(x-unit)),mp.mpf(str(x+unit))
def contains(text, reference):
lo,hi=interval(text)
return bool(mp.isfinite(lo) and mp.isfinite(hi) and
hi-lo <= mp.mpf('2e-98')*max(1,abs(reference)) and lo<=reference<=hi)
def eta_coefficients(M):
# f=q*product_{m>=1} (1-q^m)^(2*(1+[2|m]+[3|m]+[6|m])).
a=[0]*M;a[0]=1
for d in (1,2,3,6):
for m in range(d,M,d):
for repeat in range(2):
for k in range(M-1,m-1,-1):a[k]-=a[k-m]
return [0]+a
def modular_banana(M):
a=eta_coefficients(M)
control=[1,-2,-3,4,6,6,-16,-8,9,-12,12,-12,38,32,-18,16,-126,-18,20]
assert a[1:20]==control
T=1/mp.sqrt(6)
# Fricke sign +1, weight 4; at s=2 both split Mellin pieces are equal.
s=mp.fsum(a[m]*mp.exp(-2*mp.pi*m*T)*(T/(2*mp.pi*m)+1/(2*mp.pi*m)**2)
for m in range(1,M+1))
return 4*mp.pi**4*s
def main(entries_path, checkpoint_path=None):
entries=json.loads(Path(entries_path).read_text())
result={'table':'T720','checked_entries':0,'total_entries':len(entries),
'failures':[],'known_answer_control':False,'negative_control_rejected':False,
'method':'mpmath 70 dps, direct-r tanh-sinh; independent 170-dps closed forms and eta Mellin sum',
'independence':'No generator imports or Arb calls. Shared defining integral and conventions. Scalar normalizations are checked separately.',
'limitations':'All-row quadrature comparison checks 55 decimal places, heuristically. Rigorous 100-digit enclosures are provided by generate.py, not by this cross-check.',
'mpmath_version':mp.__version__,'comparisons':[]}
start=time.time()
with mp.workdps(170):
modular1=modular_banana(240);modular2=modular_banana(300)
assert abs(modular1-modular2)<mp.mpf('1e-165')
closed={(2,0):mp.mpf(1)/2,
(3,0):(mp.polygamma(1,mp.mpf(1)/3)-mp.polygamma(1,mp.mpf(2)/3))/12,
(3,1):mp.pi**2/16,(4,0):7*mp.zeta(3)/8,
(5,1):modular2}
result['modular_precision_discrepancy']=mp.nstr(abs(modular1-modular2),12)
controls=[]
for record in entries:
params=record['params'];n=int(params['n']);t=int(params['t']);norm=params['normalization']
if (n,t) not in closed:continue
ref=closed[n,t]*(1 if norm=='bessel' else 2**(n-1))
ok=contains(record['number'],ref)
controls.append({'params':params,'interval_contains_closed_form':ok})
if not ok:result['failures'].append({'kind':'closed form','params':params})
result['closed_form_checks']=controls
result['known_answer_control']=bool(controls) and all(x['interval_contains_closed_form'] for x in controls)
# A sign error, missing scale, NaN and vacuous comparisons must fail.
case=next(x for x in entries if x['params']=={'n':3,'t':1,'normalization':'feynman'})
wrong=[-mp.pi**2/4,mp.pi**2/16,mp.nan]
result['negative_control_rejected']=all(not contains(case['number'],x) for x in wrong)
checkpoints={}
if checkpoint_path and Path(checkpoint_path).exists():
checkpoints=json.loads(Path(checkpoint_path).read_text())
with mp.workdps(70):
@lru_cache(maxsize=200000)
def k0(r):return mp.besselk(0,r)
@lru_cache(maxsize=200000)
def i0(q,r):return mp.besseli(0,q*r)
for n,t in [(n,t) for n in range(2,9) for t in sorted({0}|{(n-2*j)**2 for j in range(1,(n-1)//2+1)})]:
key=str(n)+','+str(t)
if key in checkpoints:
ref=mp.mpf(checkpoints[key]['reference'])
else:
q=mp.sqrt(t)
def f(r):return r*(i0(q,r) if t else 1)*k0(r)**n if r else mp.mpf(0)
ref=mp.quad(f,[0,1,4,16,64,160],method='tanh-sinh')
checkpoints[key]={'reference':mp.nstr(ref,70),'elapsed_seconds':time.time()-start}
if checkpoint_path:Path(checkpoint_path).write_text(json.dumps(checkpoints,indent=2))
for norm in ['bessel','feynman']:
record=next(x for x in entries if x['params']=={'n':n,'t':t,'normalization':norm})
with mp.workdps(170):
expected=ref*(1 if norm=='bessel' else 2**(n-1))
text=record['number'];lo,hi=interval(text)
middle=(lo+hi)/2
delta=abs(middle-expected)/max(1,abs(expected))
ok=bool(mp.isfinite(expected) and delta<mp.mpf('1e-55'))
result['comparisons'].append({'params':record['params'],'relative_scale_error':mp.nstr(delta,12),'pass':ok})
if not ok:result['failures'].append({'kind':'quadrature','params':record['params']})
result['checked_entries']+=1
print('QUADRATURE_CHECKPOINT '+json.dumps({'key':key,'reference':mp.nstr(ref,70),'elapsed_seconds':time.time()-start}),flush=True)
result['elapsed_seconds']=time.time()-start
return result
if __name__=='__main__':
inp=sys.argv[1] if len(sys.argv)>1 else 'entries.json'
chk=sys.argv[2] if len(sys.argv)>2 else 'quadrature-checkpoints.json'
answer=main(inp,chk)
Path('check-results.json').write_text(json.dumps(answer,indent=2))
print(json.dumps(answer,indent=2))
if answer['failures'] or not answer['known_answer_control'] or not answer['negative_control_rejected']:sys.exit(1)