q-Pochhammer expression

Hello all - I am looking for a way to express the q-Pochhammer symbol (a; q)_n which is explained on wikipedia as follow:

Screenshot 2024-08-19 164225

What I am not looking for is a way to evaluate to q-Pochhammer symbol (a; q)_n for given numerical values a, q, n as the function q_poch in q_analogues.py < sage/src/sage/combinat/q_analogues.py at develop · sagemath/sage · GitHub> or the function qp in mpmath.py https://mpmath.org/doc/current/functions/qfunctions.html does.

My aim by expressing the q-Pochhammer symbol (a; q)_n and using it symbolically is to simplify a complex expressions like f = q**(n*k) * q_pochhammer(q**(-n-1), q**(-1), k) * q_pochhammer(q**(-n+1), q, k) by using simplify(f) and fractionise it then by numerator / denumerator = fraction(f). in order to yield the numerator and denumerator

Overall it is about transforming a complex expression containing one or more q-Pochhammer expressions into a rational expression f = numerator/denumerator.

Any ideas?

You could use sympy.concrete.products.product

>>> a, q = symbols('a q', real=True)
>>> k, n = symbols('a q', integer=True)
>>> product(1-a*q**k, (k, 0, n-1))
Product(-a*q**a + 1, (a, 0, q - 1))

Thanks for the hint! I tried to implement product(f, (i, a, b)) in the way suitable. But something still goes wrong.

In my main.py-file I have:

import sympy as sp
from sympy import *
import second

n, k, q = sp.symbols('n,k,q')


def fun_rational(fun, variables=[]):
    fun = fun.simplify()
    num, denum = fraction(fun)
    print(num)
    print(denum)
    print(type(num))
    print(type(denum))


fun_rational(binomial(n+1,k)/binomial(n,k))

fun_rational(factorial(n)/factorial(n - 3))

fun_rational(q**(n*k) * q_pochhammer(q**(-n-1), q**(-1), k) * q_pochhammer(q**(-n+1), q, k))

And in a second.py-file I have:

import sympy as sp
from sympy import *


a, q, k, n = sp.symbols('a q k n', real=True)
#k, n = symbols('a q', integer=True)

def q_pochhammer(a, q, n, k):
    fun = product(1-a*q**k, (k, 0, n - 1))

q_pochhammer(a, q, n, k)

print(fun)

When running the second.py-file on its own I get the error "NameError: name ‘fun’ is not defined
". I don’t know how to fix it.

In

def q_pochhammer(a, q, n, k):
    fun = product(1-a*q**k, (k, 0, n - 1))

q_pochhammer(a, q, n, k)

print(fun)

the fun in fun = product(1-a*q**k, (k, 0, n - 1)) is inside the function q_pochhammer and for that reason local to the scope that is the body of that function. The statement print(fun) is outside of the function and cannot see it.

Maybe you wanted to do

def q_pochhammer(a, q, n, k):
    return product(1-a*q**k, (k, 0, n - 1))

fun = q_pochhammer(a, q, n, k)

print(fun)

I see. Thanks for the explanation and improvement.