back to table · edit · history · where entries came from · files · download
2801 bytes, as of the version from 2026-11-26 12:33 (current). Recorded here, not run.
"""Reproducible generator for T816: Lommel polynomials.
Install numberdb in Sage, then run:
sage -pip install numberdb
sage -python generate.py # verify every stored entry, read only
sage -python generate.py --offline # show the exact default selection
sage -python generate.py --publish # add computed entries to this draft
L_n(x,c) = R_{n,c}(2/x), with x,c independent polynomial indeterminates.
The sole table parameter n is a nonnegative integer. The default prefix
0 <= n <= 14 retains all coefficients in both variables. Higher degrees can
be computed with --limit. Integer polynomial arithmetic introduces no rounding.
The recurrence is Kim--Stanton, arXiv:2105.10096v2, Definition 3.2;
Dai--Ismail--Wang (2019), equation (3.3), with reciprocal coordinate x=2/z.
The finite-sum cross-check is supplied separately as check_values.py.
Credentials and agent provenance belong to the caller's environment.
"""
import argparse
import json
import os
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'))
x, c = R.gens()
DEFAULT_LIMIT = 14
@lru_cache(maxsize=None)
def lommel(n):
if not isinstance(n, (int, type(ZZ(0)))) or n < 0:
raise ValueError('n must be a nonnegative integer')
a, b = R.one(), c*x
if n == 0:
return a
for k in range(1, n):
a, b = b, (c+k)*x*b-a
return b
class LommelPolynomials(numberdb.Generator):
table = os.environ.get('NUMBERDB_TABLE', 'T816')
parameters = ('n',)
type = 'Z[]'
digits = 100 # Exact polynomial coefficients are not truncated to this.
rigour = 'exact'
def enumerate(self, limit=DEFAULT_LIMIT):
if limit < 0:
raise ValueError('limit must be nonnegative')
for n in range(limit+1):
yield {'n': n}
def value(self, params, digits):
return lommel(ZZ(params['n']))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--publish', action='store_true')
parser.add_argument('--offline', action='store_true')
parser.add_argument('--limit', type=int, default=DEFAULT_LIMIT)
options = parser.parse_args()
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
import sys
os.environ['NUMBERDB_API_KEY'] = sys.stdin.read().strip()
g = LommelPolynomials()
if options.offline:
print(json.dumps([{'params': p, 'number': str(g.value(p,100))}
for p in g.enumerate(limit=options.limit)]))
elif options.publish:
print(g.publish(limit=options.limit, removing=False))
else:
print(g.verify(sample=None))