back to table · edit · history · where entries came from · files · download
2975 bytes, as of the version from 2026-10-30 19:31 (current). Recorded here, not run.
"""T628 repair checks; run beside generate.py, before.json, inertia.json.
sage -python repair-20261030T192745Z-checks.py
Exact integration verifies the inertia normalization independently of the
energy generator. Existing energy decimals are checked against propagated
root enclosures at 500 and 700 bits; this is a regression check, not a new
independent critique of their computation. No network or credentials needed.
"""
import json, platform
from pathlib import Path
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.real_arb import RealBallField
from sage.env import SAGE_VERSION
from generate import enclose, MaclaurinEnergyRatios
out=Path(__file__).parent
p=PolynomialRing(QQ,'u'); u=p.gen()
def integral_minus_one_one(poly):
antiderivative=poly.integral()
return antiderivative(1)-antiderivative(-1)
assert integral_minus_one_one(p(1))==2
mass_factor=integral_minus_one_one(1-u*u)
inertia_factor=integral_minus_one_one((1-u*u)**2)/2
ratio=inertia_factor/mass_factor
assert mass_factor==QQ(4)/3 and inertia_factor==QQ(8)/15 and ratio==QQ(2)/5
# Cylindrical slices at z=c*u have radius a*sqrt(1-u^2).
# M=rho*pi*a^2*c*mass_factor; I=rho*pi*a^4*c*inertia_factor.
# At c=a=R the same exact ratio is I/(M*R^2).
inertia=json.loads((out/'inertia.json').read_text())
assert QQ(inertia['Numbers']['0']['number'])==ratio
assert 'I/(MR^2)' in inertia['Definition']
doc=json.loads((out/'before.json').read_text())
assert [str(p['k']) for p in MaclaurinEnergyRatios().enumerate()]==list(doc['Numbers'])
assert MaclaurinEnergyRatios.digits==100
F=RealBallField(700)
evidence={'table':'T628','skill_manifest':'agents/runs/20261030T192745Z-repair-skills/manifest.json',
'skill_sha256':{'local':'dedecbdca15a728b6e594bfa79f0d149896fca336080ac27b53f513e0b16cd2e','live':'dedecbdca15a728b6e594bfa79f0d149896fca336080ac27b53f513e0b16cd2e'},
'sage_version':SAGE_VERSION,'python_version':platform.python_version(),
'inertia_derivation':{'method':'exact polynomial integrals over cylindrical slices z=c*u','mass_factor':str(mass_factor),'inertia_factor':str(inertia_factor),'I_over_Ma2':str(ratio),'spherical_limit':'a=c=R','linked_n_zero_matches':True},
'unchanged_energy_regression':[]}
for key,text in doc['Numbers'].items():
assert len(text.split('.')[1])==100
center=QQ(int(text.replace('.','')))/10**100; ulp=QQ(1)/10**100
b,lo,hi=enclose(int(key),working_bits=500)
b2,lo2,hi2=enclose(int(key),working_bits=700)
assert (lo,hi)==(lo2,hi2)
for ball in (b,b2):
assert ball.is_finite() and ball>F(center-ulp) and ball<F(center+ulp)
assert b.overlaps(b2)
evidence['unchanged_energy_regression'].append({'k':int(key),'full_enclosures_inside_stored_interval':True,'same_root_bracket':True,'radius_500_bits':str(b.rad()),'radius_700_bits':str(b2.rad())})
print('EVIDENCE_JSON='+json.dumps(evidence,sort_keys=True))