Ask Your Question
0

Sagemath 9.2 Product function Bug

asked 2021-02-17 02:00:44 +0200

updated 2021-02-17 02:10:17 +0200

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 flag offensive close merge delete

Comments

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.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-02-17 10:32:40 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-02-17 11:23:04 +0200

Emmanuel Charpentier gravatar image

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.

edit flag offensive delete link more

Comments

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-02-17 02:00:44 +0200

Seen: 81 times

Last updated: Feb 17