# Sagemath 9.2 Product function Bug

In sagemath 9.2 the product function have a bug in multiplication.

var('q')
var('jt')
((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 31) * q**(1 /24 ))).expand()


returned a result with leading series to be (Both wrong in the powers and the coefficients )

...+ 2*q^(121/24) - 2*q^(49/24) - 2*q^(25/24) + 2*q^(1/24)


while

((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 31) * q**(1 /24 )).expand()).expand()


returned a result with leading series to be

...+ q^(653/120) - q^(65/24) - q^(293/120) - q^(41/24) - q^(173/120) + q^(17/24) + q^(53/120)


Notice that both

((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 30) * q**(1 /24 ))).expand()
((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 30) * q**(1 /24 )).expand()).expand()


returned a result with leading series to be

...+ q^(653/120) - q^(65/24) - q^(293/120) - q^(41/24) - q^(173/120) + q^(17/24) + q^(53/120)

edit retag close merge delete

1

Note that :

sage: foo=((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 31) * q**(1 /24 ))).expand()
sage: bar=((q^(2/3)+q**(2/5))*(prod([1-q^u for u in (1..31)]) * q**(1 /24 ))).expand()
sage: bool(foo==bar)
True


In other words, the use of the Python prod on the explicit extension of your factors gives the same result as the (evaluated) symbolic product. The problem may be somewhere else.

( 2021-02-17 10:32:40 +0200 )edit

Sort by ยป oldest newest most voted

The problem is with (repeated) expand :

sage: var("q, jt")
(q, jt)
sage: A=q^(2/3)+q**(2/5)
sage: B=product(1 -q**jt, jt, 1 , 31)*q**(1 /24 )
sage: bool((A*B).expand()==(A*B.expand()).expand())
False
sage: (((A*B).expand())/(A*B.expand()).expand()).factor()
2*q^(1/24)/(q^(17/24) + q^(53/120))


However :

sage: bool(A*B==A*B.expand()) # Damn slow...
True
sage: ((A*B)/(A*B.expand())).factor()
1


This is anexpand bug, now Trac#31411.

more

this is an oldish bug, same happens with almost 3 years old https://github.com/pynac/pynac/releas...

( 2021-02-17 13:36:15 +0200 )edit