back to table · edit · history · where entries came from · files · download
1563 bytes, as of the version from 2026-11-26 02:34 (current). Recorded here, not run.
import numberdb.sage as numberdb
import sage.all
from sage.version import version as sage_version
from sage.rings.rational_field import QQ
from generate import Dimensions,records
from numberdb._write import to_text
from dry_run import main as dry_run
import json,sys,platform,hashlib
from pathlib import Path
assert dry_run([str(Path(__file__).resolve().parent/'generate.py')])==0
certs=records();g=Dimensions();texts=[]
for params,cert in zip(g.enumerate(),certs):
result=g.value(params,100);ball=result['number'];text=to_text(ball,100)
assert type(ball).__name__=='RealBall' and ball.is_finite() and ball.rad()>0
# The returned enclosure includes both exact endpoints, and text's ulp interval
# must contain the complete certified bracket with exact rational arithmetic.
assert ball.lower().exact_rational()<=QQ(cert['lo']) and QQ(cert['hi'])<=ball.upper().exact_rational()
from decimal import Decimal
z=Decimal(text);numer,denom=z.as_integer_ratio();mid=QQ(numer)/QQ(denom)
step=QQ(1)/10**(-z.as_tuple().exponent)
assert mid-step<=QQ(cert['lo'])<QQ(cert['hi'])<=mid+step
texts.append({'params':params,'number':text,'param-latex':result['param-latex']})
print('SERIALIZED_JSON '+json.dumps(texts),flush=True)
print('OFFLINE_JSON '+json.dumps({'entries':len(texts),'all_native_real_balls':True,'all_finite_nonzero_radius':True,'all_brackets_contained_in_returned_balls':True,'all_brackets_contained_in_serialized_intervals':True,'dry_run_passed':True,'python':platform.python_version(),'sage':sage_version,'numberdb':numberdb.__version__}),flush=True)