back to table · edit · history · where entries came from · files · download
2157 bytes, as of the version from 2026-11-16 02:39. Recorded here, not run.
"""Check the conditional T665 factorization, propagating stored uncertainties.
Run: sage -python check_companions.py; inputs are stored.json and curve-inputs.json.
This checks a companion identity, not independent correctness of either table.
"""
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from check_periods import C,R,I,beta,stored_parts,endpoints,records_from
import json,sys
from fractions import Fraction
from pathlib import Path
def field_part(bounds):
lo,hi=bounds
return R(I(QQ(lo.numerator)/lo.denominator,QQ(hi.numerator)/hi.denominator))
def field_value(text):return C(*[field_part(x) for x in stored_parts(text)])
path=Path(__file__).parent
curve=json.loads((path/'curve-inputs.json').read_text())
periods=records_from(json.loads((path/'stored.json').read_text()))
lookup={(int(x['params']['N']),int(x['params']['a']),int(x['params']['b'])):x['number'] for x in curve['entries']}
failures=[];checked=[]
for row in periods:
p=row['params'];n=int(p['n']);d=int(p['d']);a=list(map(int,str(p['a']).split('.')))
if a[0]+a[1]>=d:continue
v=field_value(lookup[(d,a[0],a[1])])/d**n;partial=a[0]+a[1]
for k in a[2:]:
theta=2*R.pi()*R(QQ(k)/d)
v*= (1-C(theta.cos(),theta.sin()))*beta(QQ(partial)/d,QQ(k)/d)
partial+=k
stored=field_value(row['number']);delta=v-stored
ok=True
for residual,component in zip((delta.real(),delta.imag()),(stored.real(),stored.imag())):
lo,hi=endpoints(residual);sl,sh=endpoints(component)
if not lo<=0<=hi:ok=False
if (hi-lo)*10**95>max(abs(sl),abs(sh),Fraction(1)):ok=False
if not ok:failures.append([p,str(delta)])
checked.append({'params':p,'residual':str(delta),'passes':bool(ok)})
print(json.dumps({'checked_entries':len(checked),'total_entries':len(periods),'failures':failures,
'method':'Conditional curve factorization, using actual T665 stored intervals with propagated uncertainty; zero residual containment and absolute width below 1e-95 times max(1,component magnitude)',
'source':{k:v for k,v in curve.items() if k!='entries'},'comparisons':checked},indent=2))
if failures:sys.exit(1)