Updates:
Status: Started
Comment #8 on issue 1793 by asmeurer: Integration failure
http://code.google.com/p/sympy/issues/detail?id=1793
Another example, which fails in master, polys9, my branch with the
above "patch", and 1766, but passes in
sympy-0.6.7:
In [1]: integrate((sin(y)*x**3 + 2*cos(y)*x**2 + 12)/(x**2 + 2), x)
---------------------------------------------------------------------------
CoercionFailed Traceback (most recent call last)
/Users/aaronmeurer/Documents/python/sympy/sympy/<ipython console> in
<module>()
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/utilities/decorator.pyc
in
threaded_decorator(expr, *args, **kwargs)
54 return Add(*[ func(f, *args, **kwargs) for f in
expr.args ])
55 else:
---> 56 return func(expr, *args, **kwargs)
57
58 threaded_decorator.__doc__ = func.__doc__
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/integrals/integrals.py
in
integrate(*args,
**kwargs)
537
538 if isinstance(integral, Integral):
--> 539 return integral.doit(deep = False)
540 else:
541 return integral
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/integrals/integrals.py
in
doit(self, **hints)
150
151 for x,ab in self.limits:
--> 152 antideriv = self._eval_integral(function, x)
153
154 if antideriv is None:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/integrals/integrals.py
in
_eval_integral(self, f,
x)
327 # poly(x)
328 if g.is_rational_function(x):
--> 329 parts.append(coeff * ratint(g, x))
330 continue
331
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/integrals/rationaltools.py
in
ratint(f, x,
**flags)
61 t = symbol
62
---> 63 L = ratint_logpart(r, Q, x, t)
64
65 real = flags.get('real')
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/integrals/rationaltools.py
in
ratint_logpart(f,
g, x, t)
184
185 for a, j in h_lc_sqf:
--> 186 h = h.exquo(Poly(a.gcd(q)**j, x))
187
188 inv, coeffs = h_lc.invert(q), [S(1)]
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polytools.py in
gcd(f, g)
1922 Poly(x - 1, x, domain='ZZ')
1923 """
-> 1924 _, per, F, G = f.unify(g)
1925
1926 try:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polytools.py in
unify(f, g)
558 F = DMP(dict(zip(f_monoms, f_coeffs)), dom, lev)
559 else:
--> 560 F = f.rep.convert(dom)
561
562 if g.gens != gens:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/polyclasses.py
in convert(f, dom)
1293 return f
1294 else:
-> 1295 return DMP(dmp_convert(f.rep, f.lev, f.dom, dom), dom,
f.lev)
1296
1297 def coeffs(f, order=None):
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/densebasic.py
in dmp_convert(f, u, K0,
K1)
416 """
417 if not u:
--> 418 return dup_convert(f, K0, K1)
419 if K0 is not None and K0 == K1:
420 return f
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/densebasic.py
in dup_convert(f, K0, K1)
397 return f
398 else:
--> 399 return dup_strip([ K1.convert(c, K0) for c in f ])
400
401 @cythonized("u,v")
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/polys/algebratools.py
in convert(K1, a, K0)
126 return result
127
--> 128 raise CoercionFailed("can't convert %s of type %s
to %s" % (a, K0, K1))
129 else:
130 try:
CoercionFailed: can't convert DMF(([-2], [1]), ZZ) of type ZZ(sin(y)) to
ZZ(cos(y),sin(y))
Poly is so intent on making things like Poly(sin(y)*x, x) have the domain
ZZ[sin(y)] or ZZ(sin(y)), when we really
don't care about the coefficients as algebraic entities, and just want EX.
The solution is to make an option for
Poly, composite, which when set to False will not try to make polynomial
rings or fraction fields out of
symbolic coefficients, but just make the domain EX.
In [3]: Poly(x*sin(y), x)
Out[3]: Poly(sin(y)*x, x, domain='ZZ[sin(y)]')
In [4]: Poly(x*sin(y), x, composite=False)
Out[4]: Poly(sin(y)*x, x, domain='EX')
Selectively using this in rationaltools.py causes both integrals from this
issue and issue 1576 (sorry about
that) to pass, as well as all existing tests. See my integration branch.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-iss...@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.