Comment #2 on issue 2315 by sapta.ii...@gmail.com: integrate(1/(x**2 +
n**2, x) failure, where n is an integer
http://code.google.com/p/sympy/issues/detail?id=2315
The problem is with poly division. Currently in master
from sympy import *
from sympy.abc import x
a = Poly(x)
b = Poly(2,x)
a.div(b)
(Poly(0, x, domain='ZZ'), Poly(x, x, domain='ZZ'))
b = Poly(sqrt(2),x)
a.div(b)
(Poly(2**(1/2)/2*x, x, domain='EX'), Poly(0, x, domain='EX'))
With my diff
a.div(b)
(Poly(1/2*x, x, domain='QQ'), Poly(0, x, domain='ZZ'))
diff --git a/sympy/polys/polytools.py b/sympy/polys/polytools.py
index 0a6b38e..b5d9b81 100644
--- a/sympy/polys/polytools.py
+++ b/sympy/polys/polytools.py
@@ -56,6 +56,10 @@
register_context,
)
+from sympy.polys.domains import (
+ ZZ,
+)
+
from sympy.mpmath import (
polyroots as npolyroots,
)
@@ -1383,6 +1387,11 @@ def div(f, g, auto=False):
(Poly(1/2*x + 1, x, domain='QQ'), Poly(5, x, domain='QQ'))
"""
+ if g.degree() == 0 and g.domain == ZZ:
+ p = f.as_expr()/g.as_expr()
+ r = 0
+ return Poly(p, f.gens), Poly(r, f.gens)
+
dom, per, F, G = f._unify(g)
if auto and dom.has_Ring:
The logic should probably go somewhere else as it seems to destroy the
symmetric beauty of the code. This is all I could think of here.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.