program.py

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

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

import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
L = LaurentPolynomialRing(ZZ, 'q')
q = L.gen()
F = L.fraction_field()

def poch(e, k):
    result = L.one()
    for j in range(k):
        result *= 1 - q**(e+j)
    return result

def colored_jones(p, hand, N):
    total = F.zero()
    for k in range(N):
        for ell in range(k+1):
            total += (q**k * poch(1-N,k) * poch(1+N,k)
                      * ZZ(-1)**ell * q**(p*ell*(ell+1)+ell*(ell-1)//2)
                      * (1-q**(2*ell+1)) * poch(1,k)
                      / (poch(1,k+ell+1)*poch(1,k-ell)))
    J = L(total)
    if hand == 'mirror':
        J = J(q**(-1))
    elif hand != 'source':
        raise ValueError('hand must be source or mirror')
    m = int(J.valuation())
    return PolynomialRing(ZZ, 'q')(q**(-m)*J), m

colored_jones(-4, 'source', 5)  # (stored polynomial, Laurent shift m)