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

TypeError: '>' not supported between instances of 'Poly' and 'int' calling integrate in sympy 1.12 #26501

Open
nasser1 opened this issue Apr 15, 2024 · 1 comment

Comments

@nasser1
Copy link

nasser1 commented Apr 15, 2024

This integral has no antiderivative. But why sympy gives exception? It should just return the input as is

from sympy import *
x=symbols('x')
integrate( exp( x/ln(x) ),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 1829, in risch_integrate
    ans, i, b = integrate_hyperexponential(fa, fd, DE, conds=conds)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/risch.py", line 1562, in integrate_hyperexponential
    qa, qd, b = integrate_hyperexponential_polynomial(pp, DE, z)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/risch.py", line 1514, in integrate_hyperexponential_polynomial
    va, vd = rischDE(iDta, iDtd, Poly(aa, DE.t), Poly(ad, DE.t), DE)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/rde.py", line 786, in rischDE
    n = bound_degree(A, B, C, DE)
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/integrals/rde.py", line 330, in bound_degree
    n = max(n, m[0])
        ^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'Poly' and 'int'


Version info

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

>python --version
Python 3.11.8
>


@oscarbenjamin
Copy link
Contributor

Looks like m[0] is Poly(0). Probably it should be converted somewhere:

try:
(za, zd), m = limited_integrate(alphaa, alphad, [(etaa, etad)],
DE)
except NonElementaryIntegralException:
pass
else:
if len(m) != 1:
raise ValueError("Length of m should be 1")
n = max(n, m[0])

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