crosscheck.py

back to table · edit · history · where entries came from · files · download

1675 bytes, as of the version from 2026-11-20 10:08 (current). Recorded here, not run.

"""Compare ten stored coefficient claims with existing modular tables.

Needs SageMath, numberdb, generate.py, check_evidence.py, and the saved selected
T634/T657 rows. This dependent consistency check is additional to theta/AGM.
"""
import sys,pathlib,json
p=pathlib.Path(__file__).parent;sys.path.insert(0,str(p))
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.libs.pari import pari
from check_evidence import stored_bounds,bracket_ball,compare,narrow
from generate import coefficient,eta_quotient
S=PolynomialRing(QQ,'x');x=S.gen()
a=json.loads((p/'T634-selected.json').read_text());b=json.loads((p/'T657-selected.json').read_text())
rows=[]
for ea,eb in zip(a,b):
 r=int(ea['params']['r']);assert ea['params']==eb['params']
 t=coefficient(r);R=eta_quotient(r,600)[0];mod=R+24+4096/R
 text=ea['number']
 if '.' in text or 'e' in text.lower():
  lo,hi=stored_bounds(text); v=bracket_ball(lo,hi,t.parent())
 else:
  lo=hi=QQ(text);v=t.parent()(lo)
 assert narrow(mod) and narrow(v,280) and mod.overlaps(v), ('T634',r)
 assert narrow(256*t**4-104) and (256*t**4-104).overlaps(v), ('fourth-power',r)
 P=S(eb['number']);assert P(mod).contains_zero()
 assert P(256*x**4-104)(t).contains_zero()
 rows.append({'r':r,'T634_interval':text,'T657_polynomial':str(P),'matched':True})
# Confirm the canonical modular equation with an independent PARI component.
phi=pari.ellmodulareqn(2)
assert phi[1]==0 and phi[0]==pari('(x+16)^3-x*y')
print('CROSSCHECK_JSON='+json.dumps({'checked_entries':10,'rows':rows,'pari_ellmodulareqn_2_canonical':str(phi),'all_matched':True}))