-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
sympy.limit yields incorrect result #9075
Comments
Interestingly, if you make n positive
|
Consider the function `g=(6**(n+1)+n+1)/(6**n+n)` where x is real and
n is an integer
Some heuristics seem to fail here.
Use the superior Gruntz algorithm:
```
In [9]: g
Out[9]: (6**(n + 1) + n + 1)/(6**n + n)
In [10]: gruntz(g, n, oo)
Out[10]: 6
```
|
According to the documentation, limit uses some heuristics to solve the "easy" cases for speed, and uses the Gruntz algorithm for all other cases. So something is failing in the heuristics. Interestingly, gruntz also fails for the case that smichr pointed out:
|
Bug traces back to atleast 0.7.2. Also in a reduced version...
Looks like the heuristic is equating |
On some debugging,
This ultimately boils down to |
This patch introduces a performance regression (very non-trivial to fix), but given the number of bugs fixed and that old heuristics was completely wrong - I believe this is a fair trade. Closes sympy/sympy#10610 Closes sympy/sympy#9075 (I don't think this is all, but who cares.)
This patch introduces a performance regression (very non-trivial to fix), but given the number of bugs fixed and that old heuristics was completely wrong - I believe this is a fair trade. Closes sympy#10610 Closes sympy#9075 (I don't think this is all, but who cares.)
Python 2.7.9; SymPy 0.7.6
Consider the function
g=(6**(n+1)+n+1)/(6**n+n)
where x is real and n is an integerIt is easy to show that the limit of g as n->oo is 6
Yet, look at the output of the following code:
out[4]: 1
The text was updated successfully, but these errors were encountered: