prepare_check.py

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

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

"""Exact generic-q coefficients for independent Kashaev checks.
SageMath 10.9: sage -python prepare_check.py > coefficient-data.json
Implements NRZ arXiv:1209.1409v2 equation (22), itself Masbaum's rational
skein-eigenvalue formula (33) combined with (49)/Remark 5.2. Unlike the
root-field nested generator this uses generic-q rational cancellation.
For k and l the common denominator is (q;q)_(2k+1). Its quotient by
(q;q)_(k+l+1)(q;q)_(k-l) is an exact polynomial. Every division is checked
by an exact zero remainder. Only after cancellation may q be a root.
"""
import json,sys,hashlib
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
from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing
from sage.env import SAGE_VERSION
P=PolynomialRing(ZZ,'q');q=P.gen();L=LaurentPolynomialRing(ZZ,'q');z=L.gen()
@lru_cache(maxsize=None)
def factorial(n):
    return P.one() if n==0 else factorial(n-1)*(1-q**n)
@lru_cache(maxsize=None)
def denominator_ratio(k,l):
    value,rem=factorial(2*k+1).quo_rem(factorial(k+l+1)*factorial(k-l))
    assert rem==0
    return value

def coefficient(p,k):
    terms=[]
    for l in range(k+1):
        exponent=k+p*l*(l+1)+l*(l-1)//2
        terms.append((exponent,ZZ(-1)**l*(1-q**(2*l+1))*denominator_ratio(k,l)))
    shift=min(e for e,v in terms)
    numerator=factorial(k)*sum((q**(e-shift)*v for e,v in terms),P.zero())
    quotient,remainder=numerator.quo_rem(factorial(2*k+1))
    assert remainder==0,(p,k,'non-Laurent rational coefficient')
    assert all(type(c).__module__.startswith('sage.rings.integer') for c in quotient.list())
    return z**shift*L(quotient)

rows={}
for p in [1,-1,2,-2,3,-3,4,-4]:
    rows[str(p)]=[]
    for k in range(32):
        c=coefficient(p,k)
        rows[str(p)].append({'k':k,'coefficients':{str(e):str(v) for e,v in c.dict().items()}})
    print('completed p='+str(p),file=sys.stderr,flush=True)
assert all(L({int(e):ZZ(v) for e,v in row['coefficients'].items()})==z**row['k'] for row in rows['1'])
assert all(L({int(e):ZZ(v) for e,v in row['coefficients'].items()})==ZZ(-1)**row['k']*z**(-(row['k']*(row['k']+1)//2)) for row in rows['-1'])
print(json.dumps({'method':'generic rational q-sum NRZ (22), exact cancellation before evaluation','sage':SAGE_VERSION,'coefficients':rows},separators=(',',':')))