generate.py

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

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

"""Generate T817, Classical q-Lommel polynomials, exactly in Z[x,c,q].

Install SageMath (or modular passagemath with the polynomial rings) and numberdb:
    sage -pip install numberdb
    sage -python generate.py                   # exact offline computation
    sage -python generate.py --verify          # read and reproduce all stored rows
    sage -python generate.py --publish         # fill this existing draft only

For private reads/writes configure your own NUMBERDB_API_KEY and the required
session engine/model/run attribution. Credentials and attribution are not part
of this reusable source. NUMBERDB_KEY_FROM_STDIN=1 reads a piped key instead.

The only table parameter is n >= 0; the default selection is n=0,...,5.
The indeterminates are x,c,q in that order, with x=2/z in the q-Bessel connection
and c the independent order marker corresponding to q^nu, not nu. All variables
remain symbolic. H_n=(c;q)_n h_n uses a fixed denominator-clearing scale.
Kim and Stanton, arXiv:2105.10096v2, Definition 2.2 and Proposition 3.5 give the
recurrence; Theorem 4.9 gives the independently implemented finite-sum check.
No rounding or numerical precision is involved. The recurrence supplies the
polynomial continuation at (c;q)_n=0; the singular monic quotient is not used.
"""
import argparse
import json
import os
import sys
from functools import lru_cache
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

R = PolynomialRing(ZZ, names=('x', 'c', 'q'))
x, c, q = R.gens()
MAX_N = 5

@lru_cache(maxsize=None)
def polynomial(n):
    n = ZZ(n)
    if n < 0:
        raise ValueError('The degree must be nonnegative.')
    if n == 0:
        return R(1)
    if n == 1:
        return (1-c)*x
    return (1-c*q**(n-1))*x*polynomial(n-1)-c*q**(n-2)*polynomial(n-2)

class ClassicalQLommel(numberdb.Generator):
    table = 'T817'
    parameters = ('n',)
    type = 'Z[]'
    rigour = 'exact'
    digits = 100  # ignored for exact polynomials
    files = ('generate.py',)

    def enumerate(self, max_n=MAX_N):
        for n in range(int(max_n)+1):
            yield {'n': n}

    def value(self, params, digits):
        return polynomial(params['n'])

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--publish', action='store_true')
    parser.add_argument('--verify', action='store_true')
    parser.add_argument('--max-n', type=int, default=MAX_N)
    args = parser.parse_args()
    if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
        numberdb.configure(api_key=sys.stdin.read().strip())
    generator = ClassicalQLommel()
    if args.publish or os.environ.get('NUMBERDB_PUBLISH') == '1':
        print(generator.publish(max_n=args.max_n))
    elif args.verify:
        print(generator.verify(sample=None))
    else:
        values = [generator.value(params, 100) for params in generator.enumerate(max_n=args.max_n)]
        assert all(value.parent() is R for value in values)
        assert all(type(a).__name__ == 'Integer' for value in values for a in value.coefficients())
        print(json.dumps({'entries': len(values), 'largest_value_characters': max(len(str(v)) for v in values), 'rigour': 'exact'}))