postfill.py

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

2459 bytes, as of the version from 2026-11-02 20:37 (current). Recorded here, not run.

"""Readback checks for Petersson norms -- numberdb.org/T684.

Run: sage -python postfill.py, with the generator attachments beside it.
Set NUMBERDB_API_KEY when reading the private draft. The default also runs
Generator.verify on all entries; main(recompute=False) runs the stored-value
identities only. It never offers, reviews or publishes a draft.
"""
import json
from pathlib import Path
from decimal import Decimal,localcontext
import numberdb.sage as numberdb
from numberdb._generate import _stored_entries
from generate import PeterssonNorms,ROSTER,index
from forms import algebra


def main(client=None,recompute=True):
    report=None
    if recompute:
        report=PeterssonNorms().verify(sample=None,client=client)
        assert report.ok
    d=numberdb.table('T684',client=client);flat=_stored_entries(d)
    assert len(flat)==276
    evidence=json.loads(Path(__file__).with_name('numerical-evidence.json').read_text())
    with localcontext() as ctx:
        ctx.prec=260;parsed={}
        for key,text in flat.items():
            v=Decimal(text);u=Decimal(1).scaleb(v.as_tuple().exponent)
            assert v>0;parsed[key]=(v,u)
        for row in ROSTER:
            mu=Decimal(int(index(row['level'])));roots=algebra(row['label'])[2]
            for name,(root,real) in roots.items():
                a,ua=parsed[name+',integral'];b,ub=parsed[name+',index-normalized']
                assert abs(a-mu*b)<=ua+mu*ub
                conjugate=next(n for n,(z,r) in roots.items() if z==root.conjugate())
                for convention in ('integral','index-normalized'):
                    a,ua=parsed[name+','+convention];b,ub=parsed[conjugate+','+convention]
                    assert abs(a-b)<=ua+ub
        for q in evidence['independent_eta_checks']:
            a,u=parsed[q['form']+',integral'];assert abs(a-Decimal(q['integral']))<=u
        errors=[]
        for q in evidence['independent_prime_checks']:
            a,u=parsed[q['form']+',integral'];error=abs(a-Decimal(q['integral']))/a
            assert error<Decimal('1e-50');errors.append(error)
    return {'table':'T684','generator_verify':str(report) if report is not None else 'not repeated in this readback-only call','entries':276,'normalization_pairs':138,'conjugation_entries':276,'independent_eta_comparisons':6,'independent_prime_comparisons':8,'max_prime_readback_relative_difference':str(max(errors))}

if __name__=='__main__':print(json.dumps(main(),indent=2))