repair-checks-20261026T171740Z.py

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

3148 bytes, as of the version from 2026-10-27 02:01 (current). Recorded here, not run.

"""Closed-form spot checks for unchanged Bessel moments -- numberdb.org/T521.
Run: sage -python repair-numerical-checks.py [stored-document.json]
Default: document-before.json beside this script. No website writes.
Instruction manifest: agents/runs/20261026T171740Z-repair-skills/manifest.json
Manifest SHA-256: d03b756eaa1cd22ce39c8cee78fb3a44b052146786d6371925ac7bc9dec564f3
Skill SHA-256: b4d51ded0d52cfe3dcc0859de0845c3879b0c2363273ba7e06ded40b18
These checks evaluate eleven pre-existing closed forms in 700-bit Arb balls,
independently of the quadrature generator. Rational arguments enter exactly
and their ball uncertainty propagates. They do not certify the other 29 rows.
"""
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.complex_arb import ComplexBallField
from sage.env import SAGE_VERSION
from pathlib import Path
from math import factorial,comb
import json,sys
B=RealBallField(700);C=ComplexBallField(700)
p=Path(__file__).parent;doc=json.loads(Path(sys.argv[1] if len(sys.argv)>1 else p/'document-before.json').read_text())
control=B(2).zeta()-B.pi()**2/6
assert control.is_finite() and control.contains_zero() and B(control.rad())<B(10)**(-200)

def decimal(text):
 text=text.lower();mantissa,*exponent=text.split('e');e=int(exponent[0]) if exponent else 0
 places=len(mantissa.split('.')[1]) if '.' in mantissa else 0
 unit=QQ(10)**(e-places);center=QQ(int(mantissa.replace('.','')))*unit
 return center,unit

# Independent binomial convolution gives the squared multinomial counts.
def counts(r,parts):
 if parts==1:return 1
 return sum(comb(r,j)**2*counts(r-j,parts-1) for j in range(r+1))
assert [counts(r,3) for r in range(4)]==[1,3,15,93]
assert [counts(r,4) for r in range(4)]==[1,4,28,256]
checks=[]
def check(a,b,k,value):
 s=doc['Numbers'][str(a)+','+str(b)][str(k)]
 center,unit=decimal(s);error=abs(value-B(center))/B(unit)
 assert value.is_finite() and value>0 and B(value.rad())<abs(value)*B(10)**(-180)
 assert error<1,(a,b,k,str(error))
 # Negative control: ten last-place units must fail containment.
 shifted=abs(value-B(center+10*unit))/B(unit);assert shifted>1
 checks.append({'params':{'a':a,'b':b,'k':k},'error_in_last_place_units':str(error),'enclosure_inside_stored_interval':True,'perturbation_detected':True})
for r in range(4):
 check(1,2,2*r+1,B.pi()/(3*B(3).sqrt())*(B(QQ(2)**r*factorial(r)/QQ(3)**r))**2*counts(r,3))
 check(1,3,2*r+1,B.pi()**2/16*(B(QQ(factorial(r))/QQ(4)**r))**2*counts(r,4))
l2=(C(2).zeta(C(QQ(1)/3))-C(2).zeta(C(QQ(2)/3)))/9
assert l2.imag().contains_zero()
check(0,3,1,3*l2.real()/4)
check(0,4,1,7*B(3).zeta()/8)
check(0,4,3,7*B(3).zeta()/32-B(QQ(3)/16))
print(json.dumps({'table':'T521','sage_version':SAGE_VERSION,'working_bits':700,'instruction_manifest':'agents/runs/20261026T171740Z-repair-skills/manifest.json','instruction_manifest_sha256':'d03b756eaa1cd22ce39c8cee78fb3a44b052146786d6371925ac7bc9dec564f3','control':'zeta(2)=pi^2/6','checks':checks,'checked_rows':len(checks),'numerical_values_changed':False,'scope':'Eleven closed forms only; no full quadrature rerun.'},indent=2))