generate-numerical-run.py

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

4103 bytes, as of the version from 2026-11-20 05:53 (current). Recorded here, not run.

"""T772: primitive positive real periods of rank-zero elliptic curves over Q.

Install: sage -pip install numberdb
Run offline: sage -python generate.py (preview; no writes)
Verify stored data: sage -python generate.py --verify (key for a private draft)
Explicit additive upload: sage -python generate.py --publish

Keep roster.py, allgens.00000-09999 and alllabels.00000-09999 beside this
file. roster.py verifies the frozen Cremona source bytes before enumerating
all individual source rank-zero curves of conductor at most 100. N,c4,c6
identify the integral minimal model, not its class representative.

The invariant differential is dx/(2*y+a1*x+a3). If f=4*x^3+b2*x^2+2*b4*x+b6,
its roots are algebraic and certified by Sage AA/QQbar. For positive
minimal discriminant, write e1>e2>e3 for the real roots; w1 is
pi/AGM(sqrt(e1-e3),sqrt(e1-e2)). For negative discriminant, let e be the
real root and a+i*b a nonreal root with b>0. Set h=sqrt((e-a)^2+b^2),
r=sqrt(h), and x=sqrt((h+e-a)/2); w1=pi/AGM(r,x).
All square roots are positive real ones. These are the real-period formulas
of Sage's period_lattice.py, evaluated in Arb RealBallField with propagated
algebraic input enclosures, never an interval around a floating point result.
640 working bits gave at least 624 accurate relative bits on the full roster;
100 significant decimal digits are serialized. No BSD relation is an input.
The finite cutoff is a practical arithmetic reference selection, not a
restriction of the natural rank-zero family. See argument-selection.md.
"""
import argparse
import os
from functools import lru_cache
from pathlib import Path
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.qqbar import AA, QQbar
import sage.rings.qqbar as _qqbar
# Modular Sage does not run sage.all initialization.
if not hasattr(_qqbar, "QQbar_I"):
    _qqbar._init_qqbar()
from sage.rings.real_arb import RealBallField
from roster import make_roster

BASE=Path(__file__).resolve().parent
ROSTER=make_roster()
ROWS={(r['N'],r['c4'],r['c6']):r for r in ROSTER['curves']}
R=PolynomialRing(QQ,'x'); X=R.gen()

@lru_cache(maxsize=None)
def root_data(key):
    row=ROWS[key]
    a1,a2,a3,a4,a6=map(ZZ,row['ainvs'])
    b2=a1*a1+4*a2; b4=a1*a3+2*a4; b6=a3*a3+4*a6
    f=4*X**3+b2*X**2+2*b4*X+b6
    if row['discriminant']>0:
        roots=sorted(f.roots(AA,multiplicities=False),reverse=True)
        assert len(roots)==3 and roots[0]>roots[1]>roots[2]
        return 1,roots
    roots=f.roots(QQbar,multiplicities=False)
    real=[AA(z.real()) for z in roots if z.imag()==0]
    nonreal=[z for z in roots if z.imag()>0]
    assert len(real)==len(nonreal)==1
    return -1,(real[0],AA(nonreal[0].real()),AA(nonreal[0].imag()))

def period(key,precision=640):
    B=RealBallField(precision)
    sign,roots=root_data(key)
    if sign>0:
        e1,e2,e3=map(B,roots)
        a=(e1-e3).sqrt(); b=(e1-e2).sqrt()
    else:
        e,a0,b0=map(B,roots)
        h=((e-a0)**2+b0**2).sqrt()
        a=h.sqrt();b=((h+e-a0)/2).sqrt()
    assert a>0 and b>0
    value=B.pi()/a.agm(b)
    assert value.is_finite() and value>0 and value.rad()>0
    return value

class RealPeriods(numberdb.Generator):
    table='T772'
    parameters=['N','c4','c6']
    type='R'
    digits=100
    rigour='proven'
    def enumerate(self):
        for r in ROSTER['curves']:
            yield {k:r[k] for k in self.parameters}
    def value(self,params,digits):
        key=tuple(int(params[k]) for k in self.parameters)
        return period(key,max(640,numberdb.bits(digits,losing=256)))

if __name__=='__main__':
    parser=argparse.ArgumentParser(description=__doc__)
    options=parser.add_mutually_exclusive_group()
    options.add_argument('--publish',action='store_true')
    options.add_argument('--verify',action='store_true')
    args=parser.parse_args();g=RealPeriods()
    if args.publish: print(g.publish(overwrite=False))
    elif args.verify:print(g.verify(sample=None))
    else:print(g.preview())