generate.py

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

2612 bytes, as of the version from 2026-10-26 04:16 (current). Recorded here, not run.

"""Jacobi theta₄ constants at singular nomes -- numberdb.org/T505.

Run with SageMath (or a compatible passagemath installation):

    sage -pip install numberdb
    sage -python generate.py              # verify every stored entry
    sage -python checks.py                # independent checks before filling
    sage -python checks.py --stored       # check the values read from T505

A draft requires its author's NUMBERDB_API_KEY for authenticated reads.
With NUMBERDB_KEY_FROM_STDIN=1, read that key from standard input instead.
The script performs no writes. The initial selection is every integer r=1..12,
with tau=i*sqrt(r) and q=exp(-pi*sqrt(r)); square factors of r are retained.

Arb evaluates both the argument and the full fourth theta constant as balls.
The 96-bit working guard gives 429 working bits at 100 significant digits.
The accompanying checks measure the actual accuracy of every result and
ensure its entire ball lies inside the serialized 100-digit interval.
"""
import os
import sys
import numberdb.sage as numberdb
from sage.rings.complex_arb import ComplexBallField

WORKING_GUARD = 96


class ThetaFourSingular(numberdb.Generator):
    table = 'T505'
    parameters = ('r',)
    type = 'R'
    digits = 100
    rigour = 'proven'
    files = ('generate.py', 'checks.py', 'check.py')

    def enumerate(self, maximum=12):
        for r in range(1, maximum + 1):
            yield {'r': str(r)}

    def value(self, params, digits):
        r = int(params['r'])
        if r <= 0:
            raise ValueError('r must be a positive integer')
        C = ComplexBallField(numberdb.bits(digits, losing=WORKING_GUARD))
        tau = C.gen(0) * C(r).sqrt()
        value = C(0).jacobi_theta(tau)[3]
        if not (value.real().is_finite() and value.imag().is_finite()
                and value.imag().contains_zero() and value.real() > 0):
            raise ArithmeticError('theta4 did not give a positive finite real ball')
        real = value.real()
        if int(real.accuracy()) < numberdb.bits(digits, losing=16):
            raise ArithmeticError('insufficient retained accuracy')
        if r == 1:
            return {'number': real, 'comment':
                    r'The square lattice point $\tau_1=i$. Here $\theta_4(0,e^{-\pi})=\theta_2(0,e^{-\pi})$; its Gamma expression is CITE{formula-square}.'}
        return real


if __name__ == '__main__':
    if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
        numberdb.configure(api_key=sys.stdin.read().strip())
    report = ThetaFourSingular().verify(sample=None)
    print(report)
    sys.exit(0 if report.ok else 1)