back to table · edit · history · where entries came from · files · download
2211 bytes, as of the version from 2026-11-02 01:06 (current). Recorded here, not run.
"""Read-back generator and independent-interval checks for numberdb.org/T664.
Use NUMBERDB_API_KEY for a private draft, or pipe a key with
NUMBERDB_KEY_FROM_STDIN=1. Requires numerical-values.json and
independent-comparison.json beside this script.
"""
import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
from generate import BertinQ,SELECTED
from pathlib import Path
from decimal import Decimal,localcontext
import os,sys,json
if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':numberdb.configure(api_key=sys.stdin.read().strip())
p=Path(__file__).parent
report=BertinQ().verify(sample=None);print(report,flush=True);assert report.ok
d=numberdb.table('T664');rows=d['Numbers']
assert list(rows)==[str(k) for k in SELECTED]
vals=json.loads((p/'numerical-values.json').read_text());ind=json.loads((p/'independent-comparison.json').read_text())
def number(value):return value['number'] if isinstance(value,dict) else value
def interval(v):
x=Decimal(number(v));r=Decimal(1).scaleb(x.as_tuple().exponent);return x,r
with localcontext() as context:
context.prec=240
max_fraction=Decimal(0)
for k,v in rows.items():
x,r=interval(v)
for s in [vals[k]['value210'],ind[k]['value']]:
error=abs(x-Decimal(s));assert error<r
max_fraction=max(max_fraction,error/r)
x,dx=interval(rows['12']);y,dy=interval(rows['0']);assert abs(x-4*y)<=dx+4*dy
t283=numberdb.table('T283')['Numbers']
for k,n,f in [('-4','4',Decimal(2)),('-3','3',Decimal(8)/5)]:
x,dx=interval(rows[k]);y,dy=interval(t283[n]);assert abs(x-f*y)<=dx+abs(f)*dy
p0=numberdb.table('T663')['Numbers']['0'];x,dx=interval(rows['-3']);y,dy=interval(p0)
assert abs(x-Decimal(8)*y/5)<=dx+Decimal(8)*dy/5
R=RealBallField(650);watson=9*(R(1)/3).gamma()**6/(R(2)**(R(14)/3)*R.pi()**4)
s=numberdb.table('T393')['Numbers']['A']['3'];x,r=interval(s)
assert abs(watson-R(str(x)))<R(str(r))
print('STORED '+json.dumps({'table':'T664','entries':len(rows),'generator_verified':True,'enumeration_matches':True,'independent_intervals_checked':len(rows),'maximum_error_in_stored_ulps':str(max_fraction),'factor_four_relation':True,'smyth_companions':True,'P_companion_dirichlet_relation':True,'watson_companion':True}),flush=True)