generate.py

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

4152 bytes, as of the version from 2026-11-01 13:10. Recorded here, not run.

"""Quadratic CM determinants of Hessian Mahler measures -- numberdb.org/T651.

Run with SageMath, downloading catalogue.py and analytic.py alongside:
    sage -pip install numberdb mpmath
    sage -python generate.py             # recompute and verify every entry
    sage -python generate.py --fill      # fill the existing draft

--fill needs NUMBERDB_API_KEY; publish() here writes entries only. This
program never offers, reviews or publishes a draft. The sole parameter t
selects an oriented quadratic CM argument with fixed coefficients a,b.

Analytic periods are evaluated at digits+40 and digits+90 working decimal
places. Their determinant must agree to at least digits+15 relative digits.
The output retains 100 digits, with heuristic (agreement-checked) rigour.
Neither precision agreement nor quadrature estimates certify error bounds.
The signed expression is a*nu(t)^2+b*nu(conjugate(t))^2, without absolute value.
See argument-selection.md and numerical-evidence.json for scope and checks.
"""
import sys,os
from functools import lru_cache
import numberdb.sage as numberdb
import mpmath as mp
from catalogue import items,label
from analytic import nu
ITEMS=items()
BY_KEY={i['key']:i for i in ITEMS}
LOW_EXTRA_DIGITS=40
HIGH_EXTRA_DIGITS=90

@lru_cache(maxsize=None)
def evaluated(key,digits):
    item=BY_KEY[key]; results=[]; periods=[]
    for working in (digits+LOW_EXTRA_DIGITS,digits+HIGH_EXTRA_DIGITS):
        v=nu(key,working);w=nu(item['conjugate'],working)
        with mp.workdps(working):
            value=item['a']*mp.mpf(v)**2+item['b']*mp.mpf(w)**2
            assert mp.isfinite(value) and value!=0
            results.append(mp.nstr(value,working-8)); periods.append([v,w])
    with mp.workdps(digits+110):
        low,high=map(mp.mpf,results)
        difference=abs((low-high)/high)
        agreement=-mp.log10(difference) if difference else mp.inf
        assert agreement>digits+15,(key,agreement)
        v,w=map(mp.mpf,periods[1])
        cancellation=(abs(item['a']*v*v)+abs(item['b']*w*w))/abs(high)
        return dict(number=mp.nstr(high,digits,strip_zeros=False),
                    low=results[0],high=results[1],periods=periods,
                    agreement_digits=str(agreement),cancellation_factor=str(cancellation))

class HessianDeterminants(numberdb.Generator):
    table='T651'
    parameters=('t',)
    type='R'
    digits=100
    rigour='heuristic (agreement-checked)'
    files=('generate.py','catalogue.py','analytic.py','argument-selection.md',
           'compute.py','dry_run.py',
           'integral_checks.py','cm_checks.py','lvalue_check.py','readback_checks.py',
           'numerical-evidence.json','computed.jsonl','integral-checks.jsonl','cm-checks.json',
           'source-evidence.json','source-table1.json',
           'lvalue-check.json','skill-evidence.json','skill-manifest.json','check.py')

    def environment(self):
        return dict(super().environment(),mpmath=mp.__version__)

    def enumerate(self):
        for item in ITEMS:yield {'t':item['key']}

    def value(self,params,digits):
        item=BY_KEY[str(params['t'])]
        def period_link(key):
            from catalogue import exact
            inside=bool(-1<exact(item,key==item['conjugate'])<27)
            tid='T650' if inside else 'T649'
            return 'HREF{'+tid+'#'+key+'}['+(r'$\widetilde N$' if inside else '$N$')+']'
        return {'number':evaluated(item['key'],digits)['number'],
                'param-latex':label(item),
                'comment':r'The coefficients are $a='+str(item['a'])+r'$ and $b='+str(item['b'])+r'$ (CITE{ST}, Table 1, row '+str(item['row'])+'). The period at $t$ is '+period_link(item['key'])+' and the period at $t^\\sigma$ is '+period_link(item['conjugate'])+'.'}

if __name__=='__main__':
    if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':numberdb.configure(api_key=sys.stdin.read().strip())
    g=HessianDeterminants()
    if '--fill' in sys.argv:
        print(g.publish(message='Fill fifteen quadratic CM determinants with independent numerical checks.'))
    else:
        report=g.verify(sample=None);print(report);sys.exit(0 if report.ok else 1)