Opened 2 months ago
Last modified 13 days ago
#27304 new defect
Bug in factorization of simple symbolic expressions
Reported by: | egourgoulhon | Owned by: | |
---|---|---|---|
Priority: | blocker | Milestone: | sage-8.8 |
Component: | symbolics | Keywords: | factor, exponential, pynac |
Cc: | rws, bpage | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
As reported in this ask.sagemath question, we have currently (Sage 8.7.beta3):
sage: factor(2*exp(x) + exp(-x)) 3*e^x
as well as
sage: factor(x*exp(-x) + exp(-x)) (x + 1)*e^x
This bug is there since at least Sage 8.4.beta4. It is not in Sage 8.3, hence it must have been introduced between 8.4.beta0 and 8.4.beta4. It seems to have been introduced in #23835 (see comment:5).
Change History (10)
comment:1 Changed 2 months ago by
- Description modified (diff)
comment:2 Changed 2 months ago by
- Priority changed from major to critical
comment:3 follow-up: ↓ 5 Changed 2 months ago by
A difference between Sage 8.3 (where the factorization works) and Sage 8.4.beta4 is that in Sage 8.3 the factorization is performed by Maxima: cf. these lines of src/sage/symbolic/expression.pyx
def factor(self, dontfactor=[]): from sage.calculus.calculus import symbolic_expression_from_maxima_string, symbolic_expression_from_string if len(dontfactor) > 0: m = self._maxima_() name = m.name() varstr = ','.join(['_SAGE_VAR_'+str(v) for v in dontfactor]) cmd = 'block([dontfactor:[%s]],factor(%s))'%(varstr, name) return symbolic_expression_from_maxima_string(cmd) else: try: from sage.rings.all import QQ f = self.polynomial(QQ) w = repr(f.factor()) return symbolic_expression_from_string(w) except (TypeError, NotImplementedError): pass return self.parent()(self._maxima_().factor())
while in Sage 8.4.beta4 and later, it is performed by pynac (via the function g_factor
):
def factor(self, dontfactor=[]): from sage.calculus.calculus import symbolic_expression_from_maxima_string cdef GEx x cdef bint b if dontfactor: m = self._maxima_() name = m.name() varstr = ','.join(['_SAGE_VAR_' + str(v) for v in dontfactor]) cmd = 'block([dontfactor:[%s]],factor(%s))' % (varstr, name) return symbolic_expression_from_maxima_string(cmd) sig_on() try: b = g_factor(self._gobj, x) finally: sig_off() if b: return new_Expression_from_GEx(self._parent, x) else: return self
Maxima is correct there: in Sage 8.7.beta3, we have
./sage -maxima (%i1) factor(2*exp(x) + exp(-x)); - x 2 x (%o1) %e (2 %e + 1)
So I would say it is a pynac bug.
comment:4 Changed 2 months ago by
- Keywords pynac added
comment:5 in reply to: ↑ 3 Changed 2 months ago by
The change from Maxima factorization to Pynac one, which triggered the bug, was introduced in #23835, which has been merged in Sage 8.4.beta3.
comment:6 Changed 2 months ago by
- Description modified (diff)
comment:7 Changed 2 months ago by
This sage-support post might be related...
comment:8 Changed 4 weeks ago by
- Milestone changed from sage-8.7 to sage-8.8
Moving all blocker/critical issues from 8.7 to 8.8.
comment:9 Changed 2 weeks ago by
- Priority changed from critical to blocker
comment:10 Changed 13 days ago by
- Cc bpage added
in the same vein :
which is true, but largely not what we seek...
which is false. But :
Deserves to be
critical
, if notblocker
.