generate.py

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

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

"""Even-odd q-Lommel polynomials, NumberDB table T819.

Install numberdb in SageMath 10.9 (the checked runtime):
    sage -pip install numberdb
    sage -python generate.py             # verify the stored table, no writes
    sage -python generate.py --publish   # explicitly fill the existing draft

E_n(x,c,q)=(c;q)_n p_n(x;c,q), with ordered formal variables x,c,q.
The fixed denominator-clearing normalization follows Kim and Stanton,
Three families of q-Lommel polynomials, arXiv:2105.10096v2, Definition 2.3.
Exact integer-polynomial arithmetic needs no numerical precision claim.
The default complete prefix n=0,...,6 limits expanded row length; limit=N
in enumerate extends it. No values of c or q are sampled.
Proposition 4.16 supplies the separately implemented coefficient checker.
No credential or agent/model attribution is stored in this reusable source.
"""

import argparse
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()
DEFAULT_LIMIT = 6


def degree_index(value):
    if isinstance(value, (float, bool)):
        raise TypeError('n must be an exact nonnegative integer')
    n = ZZ(value)
    if n < 0 or (not isinstance(value, str) and n != value):
        raise ValueError('n must be a nonnegative integer')
    return int(n)


@lru_cache(maxsize=None)
def polynomial(n):
    n = degree_index(n)
    if n == 0:
        return R.one()
    previous, current = R.one(), (1-c)*x
    for j in range(1, n):
        m = j//2
        a = c*q**(3*m-1) if j % 2 == 0 else q**m
        previous, current = current, (1-c*q**j)*x*current-a*previous
    return current


class EvenOddQLommel(numberdb.Generator):
    table = 'T819'
    parameters = ('n',)
    type = 'Z[]'
    rigour = 'exact'
    digits = 100

    def enumerate(self, limit=DEFAULT_LIMIT):
        for n in range(degree_index(limit)+1):
            yield {'n': n}

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


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