sagemath/sage

Actually fix: "Do not use pynac's poly_mul_expand function until it has been debugged"

mkoeppe opened this issue · 8 comments

#31479 with this title was merged in 9.3.rc3 but its branch contained something else.

CC: @DaveWitteMorris

Component: symbolics

Author: Dave Morris

Branch/Commit: 2b88eb5

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/31679

Author: Dave Morris

Reviewer: Matthias Koeppe

comment:4

On 32-bit:

**********************************************************************
File "src/sage/symbolic/expression.pyx", line 4882, in sage.symbolic.expression.Expression.expand
Failed example:
    ((a + b + c)^30 * (3*b + d - 5/d)^3).expand().subs(a=0,b=2,c=-1)
Expected:
    d^3 + 18*d^2 + 93*d - 465/d + 450/d^2 - 125/d^3 + 36  
Got:
    d^3 + 18*d^2 + 1739461754973*d - 8697308774865/d + 450/d^2 - 125/d^3 + 36
**********************************************************************
1 item had failures:
   1 of  43 in sage.symbolic.expression.Expression.expand
    [2941 tests, 1 failure, 44.35 s]
----------------------------------------------------------------------
sage -t --long --random-seed=0 src/sage/symbolic/expression.pyx  # 1 doctest failed
----------------------------------------------------------------------
comment:5

I don't have time to push a branch until tomorrow, but I think that (for 9.3) we can solve the problem by weakening the doctest so that it works for both 64-bit and 32-bit. Maybe:

sage: a,b,c,d = var("a b c d")
sage: f = ((a + b + c)^30 * (3*b + d - 5/d)^3).expand().subs(a=0,b=2,c=-1)
sage: sum(sign(s) * (abs(ZZ(s)) % ZZ(2^20)) * d^i for s,i in f.coefficients())
d^3 + 18*d^2 + 93*d - 465/d + 450/d^2 - 125/d^3 + 36

Branch pushed to git repo; I updated commit sha1. New commits:

ef84adfMerge branch 'public/31554' of git://trac.sagemath.org/sage into #31679polymulexpand
2b88eb5fix doctest for 32-bit

Changed commit from 296d4c7 to 2b88eb5

comment:8

This doctest looks a bit strange, but overall this is good enough as a hotfix for 9.3 for this severe bug.

Changed branch from public/31554 to 2b88eb5