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

RecursionError: maximum recursion depth exceeded in comparison calling integrate in sympy 1.12 #26506

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 number of exceptions RecursionError: maximum recursion depth exceeded in comparison in sympy 1.12. Here is just one example out of many

from sympy import *
x=symbols('x')
integrand="ln(x**2+x-1)**2/x**3"
integrate( sympify(integrand), x)

gives very long output the end of which is

File "/usr/lib/python3.11/site-packages/sympy/core/power.py", line 1440, in _is_one
    return (expr - 1).is_zero
            ~~~~~^~~
  File "/usr/lib/python3.11/site-packages/sympy/core/decorators.py", line 236, in _func
    return func(self, other)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/core/decorators.py", line 106, in binary_op_wrapper
    return func(self, other)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/core/expr.py", line 208, in __sub__
    return Add(self, -other)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/core/cache.py", line 72, in wrapper
    retval = cfunc(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/core/operations.py", line 98, in __new__
    c_part, nc_part, order_symbols = cls.flatten(args)
                                     ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/sympy/core/add.py", line 265, in flatten
    elif isinstance(o, TensExpr):
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen abc>", line 119, in __instancecheck__
RecursionError: maximum recursion depth exceeded in comparison


Version info

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

>python --version
Python 3.11.8
>

For reference the anti derivative should be

<< Rubi`
integrand = Log[x^2 + x - 1]^2/x^3
Integrate[integrand, x]

Log[x]-1/2 (1+Sqrt[5]) Log[1-Sqrt[5]+2 x]+3 Log[1/2 (-1+Sqrt[5])] Log[1-Sqrt[5]+2 x]-1/4 (3+Sqrt[5]) Log[1-Sqrt[5]+2 x]^2-1/2 (1-Sqrt[5]) Log[1+Sqrt[5]+2 x]-1/2 (3-Sqrt[5]) Log[-((1-Sqrt[5]+2 x)/(2 Sqrt[5]))] Log[1+Sqrt[5]+2 x]-1/4 (3-Sqrt[5]) Log[1+Sqrt[5]+2 x]^2-1/2 (3+Sqrt[5]) Log[1-Sqrt[5]+2 x] Log[(1+Sqrt[5]+2 x)/(2 Sqrt[5])]+3 Log[x] Log[1+(2 x)/(1+Sqrt[5])]+Log[-1+x+x^2]/x-3 Log[x] Log[-1+x+x^2]+1/2 (3+Sqrt[5]) Log[1-Sqrt[5]+2 x] Log[-1+x+x^2]+1/2 (3-Sqrt[5]) Log[1+Sqrt[5]+2 x] Log[-1+x+x^2]-Log[-1+x+x^2]^2/(2 x^2)+3 PolyLog[2,-((2 x)/(1+Sqrt[5]))]-1/2 (3+Sqrt[5]) PolyLog[2,-((1-Sqrt[5]+2 x)/(2 Sqrt[5]))]-1/2 (3-Sqrt[5]) PolyLog[2,(1+Sqrt[5]+2 x)/(2 Sqrt[5])]-3 PolyLog[2,1+(2 x)/(1-Sqrt[5])]

skirpichev added a commit to skirpichev/diofant that referenced this issue Apr 16, 2024
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