Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoercionFailed: Cannot convert type <class 'sympy.core.add.Add'> to QQ_I calling integrate in sympy 1.12 #26509

Open
nasser1 opened this issue Apr 15, 2024 · 0 comments

Comments

@nasser1
Copy link

nasser1 commented Apr 15, 2024

I do not know if this is known or reported before. Feel free to close if so.

I see few of exceptions CoercionFailed. Here is just one example out of many

from sympy import *
x,c,b,a=symbols('x c b a')
integrand="x**2*atan(c+(1+I*c)*tan(b*x+a))"
integrate( sympify(integrand), x)

gives

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.11/site-packages/sympy/integrals/integrals.py", line 1567, in integrate
    return integral.doit(**doit_flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/integrals.py", line 612, in doit
    antideriv = self._eval_integral(
                ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/integrals.py", line 955, in _eval_integral
    result, i = risch_integrate(f, x, separate_integral=True,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/risch.py", line 1831, in risch_integrate
    ans, i, b = integrate_primitive(fa, fd, DE)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/risch.py", line 1460, in integrate_primitive
    q, i, b = integrate_primitive_polynomial(p, DE)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/risch.py", line 1409, in integrate_primitive_polynomial
    rv = limited_integrate(aa, ad, [(Dta, Dtb)], DE)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/prde.py", line 838, in limited_integrate
    h, A = param_rischDE(Fa, Fd, G, DE)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/prde.py", line 729, in param_rischDE
    h, B = param_poly_rischDE(a, b, r, n, DE)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/prde.py", line 535, in param_poly_rischDE
    b, q = b.quo_ground(a), [qi.quo_ground(a) for qi in q]
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/polys/polytools.py", line 1348, in quo_ground
    result = f.rep.quo_ground(coeff)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/polys/polyclasses.py", line 430, in quo_ground
    return f.per(dmp_quo_ground(f.rep, f.dom.convert(c), f.lev, f.dom))
                                       ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/polys/domains/domain.py", line 463, in convert
    raise CoercionFailed("Cannot convert %s of type %s to %s" % (element, type(element), self))
sympy.polys.polyerrors.CoercionFailed: Cannot convert _t0**2*exp(2*I*a) + 1 of type <class 'sympy.core.add.Add'> to QQ_I[x,b,_t0,exp(I*a)]


Version info

>>> import sympy
>>> sympy.__version__
'1.12'

>python --version
Python 3.11.8
>

For reference the anti derivative should be

In[1]:= <<Rubi`
In[9]:= integrand=x^2*ArcTan[c+(1+I*c)*Tan[b*x+a]]
In[10]:= Int[integrand,x]

Out[10]= -((b x^4)/12)+1/3 x^3 ArcTan[c+(1+I c) Tan[a+b x]]-1/6 I x^3 Log[1-I c E^(2 I a+2 I b x)]-(x^2 PolyLog[2,I c E^(2 I a+2 I b x)])/(4 b)-(I x PolyLog[3,I c E^(2 I a+2 I b x)])/(4 b^2)+PolyLog[4,I c E^(2 I a+2 I b x)]/(8 b^3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants