back to table · edit · history · where entries came from · files · download
2638 bytes, as of the version from 2026-11-09 14:49 (current). Recorded here, not run.
"""Validate T690's stored numbers against the independent build evidence.
Run: sage -python readback_checks.py (key required for private draft).
Requires numerical-evidence.json beside this script. This reads the live table
and compares all 162 written intervals with the archived independent Dokchitser
computations; it also tests functional equations and the Petersson identity on
the stored values. It does not recompute the independent values. checks.py does.
"""
import numberdb.sage as numberdb
from sage.rings.real_mpfr import RealField
from decimal import Decimal
import json,math,pathlib,os,sys
if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':numberdb.configure(api_key=sys.stdin.read().strip())
R=RealField(900)
p=pathlib.Path(__file__).parent
e=json.loads((p/'numerical-evidence.json').read_text())
rows=numberdb.table('T690')['Numbers']
if isinstance(rows,dict):
flat=[]
for k,byi in rows.items():
for i,bys in byi.items():
for s,value in bys.items():flat.append({'params':{'k':k,'i':i,'s':s},'number':value['number'] if isinstance(value,dict) else value})
rows=flat
stored={tuple(int(row['params'][x]) for x in ('k','i','s')):str(row['number']) for row in rows}
ind={tuple(row[x] for x in ('k','i','s')):row for row in e['independent_checks'] if row['kind']=='entry'}
assert len(stored)==162 and set(stored)==set(ind)
def ulp(text):return R(10)**Decimal(text).as_tuple().exponent
def gamma(k,s):
z=R(s)
return 2*(2*R.pi())**(-z)*z.gamma()*R.pi()**(-(z-k+2)/2)*((z-k+2)/2).gamma()
errors=[];ferrors=[]
for key,text in stored.items():
k,i,s=key;x=R(text);y=R(ind[key]['dok700'])
error=abs(x-y)/ulp(text);assert error<=1,(key,'independent ulp',str(error));errors.append(error)
t=2*k-1-s;other=stored[k,i,t]
err=abs(gamma(k,s)*x-gamma(k,t)*R(other))
bound=abs(gamma(k,s))*ulp(text)+abs(gamma(k,t))*ulp(other)
assert err<=bound,(key,'functional equation');ferrors.append(err/bound)
norm_errors=[]
for record in e['independent_checks']:
if record['kind']!='norm':continue
k,i=record['k'],record['i'];text=stored[k,i,k]
factor=R(math.factorial(k-1))/(R(2)**(2*k-1)*R.pi()**(k+1))
err=abs(factor*R(text)-R(record['petersson']))/(factor*ulp(text))
assert err<=1,(k,i,'Petersson stored ulp');norm_errors.append(err)
print(json.dumps({'table':'T690','stored_entries':len(stored),'independent_interval_comparisons':len(errors),
'functional_equations_on_stored_values':len(ferrors),'petersson_relations_on_stored_values':len(norm_errors),
'max_independent_ulp_error':str(max(errors)), 'max_feq_fraction_of_combined_radius':str(max(ferrors)),
'max_petersson_fraction_of_radius':str(max(norm_errors))},indent=2))