generate.py

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

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

"""Reproduce Sierpinski's full square-lattice Epstein finite part (T877).

Requires numberdb and SageMath (or passagemath with real Arb balls).
    sage -pip install numberdb
    sage -python generate.py                 # offline calculation, no writes
    sage -python generate.py --verify        # compare every stored entry
    sage -python generate.py --publish       # fill the authorized target only

There are no parameters. The sum includes all ordered signed nonzero
integer vectors and has squared-norm exponent s. Its Laurent coefficient at
s=1 is pi*(2*log(2)+3*log(pi)+2*EulerGamma-4*logGamma(1/4)).
Benedetto et al., arXiv:2008.01462v2, (D.7), and DLMF 23.17.3 give this
expression. The quarter is an exact rational; real logGamma uses the positive
Gamma value. Arb encloses constants, inputs and operations. At 100 digits,
512 working bits retain over 490 accuracy bits. The separate eta_check.py
checks this by a bounded logarithmic eta product rather than Gamma.
Credentials and session/model declarations belong in the environment.
"""
import argparse
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from numberdb._write import to_text

class SierpinskiConstant(numberdb.Generator):
    table = 'T877'
    parameters = ()
    type = 'R'
    digits = 100
    rigour = 'proven'

    def enumerate(self):
        yield {}

    def value(self, params, digits):
        if params != {}:
            raise ValueError('This constant has no parameters.')
        field = RealBallField(max(512, numberdb.bits(digits, losing=160)))
        pi = field.pi()
        result = pi * (2*field(2).log() + 3*pi.log()
                       + 2*field.euler_constant()
                       - 4*field(QQ(1)/4).log_gamma())
        if not result.is_finite() or result.accuracy() < numberdb.bits(digits, losing=16):
            raise ArithmeticError('The enclosure does not support the requested digits')
        return result

if __name__ == '__main__':
    parser=argparse.ArgumentParser(description=__doc__)
    actions=parser.add_mutually_exclusive_group()
    actions.add_argument('--verify',action='store_true')
    actions.add_argument('--publish',action='store_true')
    parser.add_argument('--digits',type=int,default=100)
    options=parser.parse_args()
    generator=SierpinskiConstant(); generator.digits=options.digits
    if options.verify:
        print(generator.verify(sample=None))
    elif options.publish:
        print(generator.publish(removing=False))
    else:
        for params in generator.enumerate():
            print(params,to_text(generator.value(params,options.digits),digits=options.digits))