@@ -4116,7 +4116,7 @@ cdef class Expression(CommutativeRingElement):
41164116 sage: g = derivative(f, x); g # this is a complex expression
41174117 -1/2*((x^2 + 1)*x/(x^2 - 1)^2 - x/(x^2 - 1))/((x^2 + 1)/(x^2 - 1))^(3/4)
41184118 sage: g.factor()
4119- -x/((x + 1)^2*(x - 1)^2*((x^2 + 1)/(x^2 - 1))^(3/4))
4119+ -x/((x + 1)^2*(x - 1)^2*((x^2 + 1)/((x + 1)*(x - 1) ))^(3/4))
41204120
41214121 ::
41224122
@@ -11141,22 +11141,24 @@ cdef class Expression(CommutativeRingElement):
1114111141 sage: (f(x).diff(x)^2-1).factor()
1114211142 (diff(f(x), x) + 1)*(diff(f(x), x) - 1)
1114311143 """
11144- from sage.calculus.calculus import symbolic_expression_from_maxima_string, symbolic_expression_from_string
11144+ from sage.calculus.calculus import symbolic_expression_from_maxima_string
11145+ cdef GEx x
11146+ cdef bint b
1114511147 if dontfactor:
1114611148 m = self ._maxima_()
1114711149 name = m.name()
1114811150 varstr = ' ,' .join([' _SAGE_VAR_' + str (v) for v in dontfactor])
1114911151 cmd = ' block([dontfactor:[%s ]],factor(%s ))' % (varstr, name)
1115011152 return symbolic_expression_from_maxima_string(cmd)
11153+ sig_on()
11154+ try :
11155+ b = g_factor(self ._gobj, x)
11156+ finally :
11157+ sig_off()
11158+ if b:
11159+ return new_Expression_from_GEx(self ._parent, x)
1115111160 else :
11152- try :
11153- from sage.rings.all import QQ
11154- f = self .polynomial(QQ)
11155- w = repr (f.factor())
11156- return symbolic_expression_from_string(w)
11157- except (TypeError , NotImplementedError ):
11158- pass
11159- return self .parent()(self ._maxima_().factor())
11161+ return self
1116011162
1116111163 def factor_list (self , dontfactor = []):
1116211164 """
0 commit comments