check_stored.py

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

2808 bytes, as of the version from 2026-10-29 04:58 (current). Recorded here, not run.

"""Verify the actual T600 decimal intervals and identities after reading the API.
Run with Sage: sage -python check_stored.py
Requires stored-document.json, numerical-evidence.json and generate.py.
"""
import json
from pathlib import Path
from decimal import Decimal
from fractions import Fraction
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.env import SAGE_VERSION
import generate as gen

P=Path(__file__).resolve().parent
stored=json.loads((P/'stored-document.json').read_text())
evidence=json.loads((P/'numerical-evidence.json').read_text())
R=RealBallField(numberdb.bits(220))

def exact(q):return QQ(q.numerator)/q.denominator

def bounds(text):
    if isinstance(text,dict):text=text['number']
    center=Fraction(text)
    ulp=Fraction(10)**Decimal(text).as_tuple().exponent
    return exact(center-ulp),exact(center+ulp),len(Decimal(text).as_tuple().digits)

readback={}
for d,forms in stored['Numbers'].items():
    for form,text in forms.items():
        lo,hi,digits=bounds(text)
        assert digits==100,(d,form,digits)
        L=gen.logdet(int(d),200); answer=L.exp() if form=='det' else L
        assert answer.is_finite() and answer.accuracy()>600
        assert answer>R(lo) and answer<R(hi),(d,form)
        # Independent continuation values, already compared to 160 places.
        expected=R(exact(Fraction(evidence['rows'][int(d)-1][form])))
        assert expected>R(lo) and expected<R(hi)
        readback[(int(d),form)]=(lo,hi)
assert list(readback)==[(d,c) for d in range(1,21) for c in ('det','logdet')]
for d in range(1,21):
    dl,du=readback[d,'det'];ll,lu=readback[d,'logdet']
    assert dl>0
    assert R(ll).exp()<R(du) and R(lu).exp()>R(dl)
# The known circle identities lie within the stored intervals.
for form,answer in [('det',R.pi()**2),('logdet',2*R.pi().log())]:
    lo,hi=readback[1,form]
    assert answer>R(lo) and answer<R(hi)
# All displayed spectral formulas use exactly the same polynomial multiplicities
# checked at 1000 integer pairs in checks.py; Z1(s)=2*4^(-s)*zeta(2s)
# also follows directly by factoring its k^2 eigenvalues term by term.
print(json.dumps({'table':'T600','entries':40,'significant_digits_each':100,
 'arb_enclosures_contained_in_stored_intervals':40,
 'independent_continuation_values_in_stored_intervals':40,
 'det_logdet_interval_identities':20,'circle_identities':2,
 'enumeration_and_parameter_order':'passed','sage_version':SAGE_VERSION,
 'minimum_stored_value_characters':min(len(str(x['number'] if isinstance(x,dict) else x)) for f in stored['Numbers'].values() for x in f.values()),
 'maximum_stored_value_characters':max(len(str(x['number'] if isinstance(x,dict) else x)) for f in stored['Numbers'].values() for x in f.values())},indent=2))