generate.py

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

2828 bytes, as of the version from 2026-12-02 04:36 (current). Recorded here, not run.

"""Reproduce the square-lattice Weierstrass sigma values for T911.

Install numberdb in Sage, then run:
    sage -pip install numberdb
    sage -python generate.py             # verify all stored entries
    sage -python generate.py --publish   # authorized entries upload only

The canonical sigma function has full periods 1,i, not half-periods 1,i.
FLINT elliptic_sigma uses lattice Z+tau*Z and rigorously enclosing theta
algorithms; here tau=i. Inputs (a+i*b)/N are enclosed exact rationals.
Default enumeration retains every lift of exact order 2<=N<=8 in the
half-open unit square. 512 bits supply guarded 100-digit values, and the
serializer refuses insufficient precision. The zero component on either
coordinate axis is exact by conjugation and square-rotation symmetry.
The companion check_values.py uses a separately implemented Laurent
recurrence with an analytic tail bound, not the production theta formula.
Credentials and model provenance belong to the invoking environment.
"""
import argparse
from math import gcd
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.complex_arb import ComplexBallField


class SquareLatticeSigma(numberdb.Generator):
    table = 'T911'
    parameters = ('N', 'a', 'b')
    type = 'C'
    digits = 100
    rigour = 'proven'

    def enumerate(self):
        for N in range(2, 9):
            for a in range(N):
                for b in range(N):
                    if gcd(gcd(a, b), N) == 1:
                        yield dict(N=N, a=a, b=b)

    def value(self, params, digits):
        N, a, b = (ZZ(params[k]) for k in self.parameters)
        if N < 2 or not (0 <= a < N and 0 <= b < N) or gcd(gcd(a, b), N) != 1:
            raise ValueError('Expected an exact-order lift in the half-open unit square.')
        C = ComplexBallField(max(512, numberdb.bits(digits, losing=128)))
        result = C(QQ(a)/N, QQ(b)/N).elliptic_sigma(C(0, 1))
        if not all(t.is_finite() for t in (result.real(), result.imag())):
            raise ArithmeticError('Nonfinite sigma enclosure.')
        # Reflection z -> 1+i-z and square symmetry give additional
        # exact zero components at (1+3i)/4 and (3+i)/4.
        if a == 0 or (4*a == N and 4*b == 3*N):
            result = C(0, result.imag())
        if b == 0 or (4*a == 3*N and 4*b == N):
            result = C(result.real(), 0)
        if (N, a, b) == (2, 1, 0):
            return {'number': result, 'equals': 'HREF{T910}'}
        return result


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--publish', action='store_true')
    args = parser.parse_args()
    generator = SquareLatticeSigma()
    print(generator.publish() if args.publish else generator.verify(sample=None))