In Sage Math, how do you implement a symbolic product? specifically I want the qPochhammer

1.1k Views Asked by At

Note : on math.stackexchange I searched for the following keyword combinations: sage math prod sage math prod product and found nothing so I think this is a new question.

I want to implement a symbolic product, namely the qPochhammer symbol.

I tried

prod( 1 - x*q**i for i in (0 .. (n-1) ) )

but it says TypeError: unable to simplify to float approximation

If n is an integer greater than 1, prod( 1 - x*q^i for i in (0..2) ) it does what's expected -(q^2*x - 1)*(q*x - 1)*(x - 1)

But I'd like a symbolic version or at least the best way to make it a function. Thanks! - #ernestyalumni @ernestyalumni

1

There are 1 best solutions below

1
On

Perhaps this might be a solution for you. (Implement as a function: [Sage Cell Server])

x = var("x")
q = polygen(ZZ, "q")
qPochhammer = lambda n: prod([ 1 - x*q^i for i in range(n + 1) ])
print qPochhammer(2) # for example