First time here? Check out the FAQ!

Ask Your Question
0

Sagemath 9.2 Product function Bug

asked 4 years ago

updated 4 years ago

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)
Preview: (hide)

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 ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

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.

Preview: (hide)
link

Comments

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

Dima gravatar imageDima ( 4 years ago )

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: 4 years ago

Seen: 387 times

Last updated: Feb 17 '21