Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'u/rws/replace_maxima_with_pynac_singular_in_expression_…
Browse files Browse the repository at this point in the history
…factor__' of git://trac.sagemath.org/sage into u/tscrim/expression_factor-23835
  • Loading branch information
tscrim committed Aug 24, 2018
2 parents 23a2b10 + e9484ce commit 19cff3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/sage/coding/code_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def entropy(x, q=2):
sage: codes.bounds.entropy(0, 2)
0
sage: codes.bounds.entropy(1/5,4).factor()
1/10*(log(5) + log(3) - 4*log(4/5))/log(2)
1/10*(log(3) - 4*log(4/5) - log(1/5))/log(2)
sage: codes.bounds.entropy(1, 3)
log(2)/log(3)
Expand Down
22 changes: 12 additions & 10 deletions src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4116,7 +4116,7 @@ cdef class Expression(CommutativeRingElement):
sage: g = derivative(f, x); g # this is a complex expression
-1/2*((x^2 + 1)*x/(x^2 - 1)^2 - x/(x^2 - 1))/((x^2 + 1)/(x^2 - 1))^(3/4)
sage: g.factor()
-x/((x + 1)^2*(x - 1)^2*((x^2 + 1)/(x^2 - 1))^(3/4))
-x/((x + 1)^2*(x - 1)^2*((x^2 + 1)/((x + 1)*(x - 1)))^(3/4))
::
Expand Down Expand Up @@ -11141,22 +11141,24 @@ cdef class Expression(CommutativeRingElement):
sage: (f(x).diff(x)^2-1).factor()
(diff(f(x), x) + 1)*(diff(f(x), x) - 1)
"""
from sage.calculus.calculus import symbolic_expression_from_maxima_string, symbolic_expression_from_string
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:
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())
return self

def factor_list(self, dontfactor=[]):
"""
Expand Down

0 comments on commit 19cff3a

Please sign in to comment.