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

Different result of limit after simplify #11526

Open
jbrea opened this Issue Aug 17, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@jbrea
Copy link

jbrea commented Aug 17, 2016

Hi

I just stumbled over the surprising result that the limit function
returns a different result if I apply simplify to the argument.
The full example is here:

$ python
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.

import sympy
print(sympy.version)
1.0
from sympy import *
tau, J, v0, theta = symbols('tau J v0 theta')
df = diff(1/(tau_log((J-v0)/(J-theta))), J)
limit(df, J, oo)
-1/(tau_v0)
limit(simplify(df), J, oo)
-1/(-tau_theta + tau_v0)

The second result (after applying the simplification) is correct.
The first one isn't.

@jksuom jksuom added the series label Aug 18, 2016

@jksuom

This comment has been minimized.

Copy link
Member

jksuom commented Aug 18, 2016

The same phenomenon is visible in this part of the computation (where 1/J is written for J in order to have the limit J -> 0 instead of J -> oo):

>>> e = log((1/J - v0)/(1/J - theta))
>>> e.as_leading_term(J)
-J*v0
>>> e.series(J, n=2)
J*(theta - v0) + O(J**2)

The reason for the difference in the leading terms is this line

    expr = expr.func(*[t.as_leading_term(x) for t in expr.args]).removeO()

If some of the leading terms in a sum cancel each other, it is necessary to consider higher order terms.

skirpichev added a commit to skirpichev/diofant that referenced this issue Aug 20, 2016

Add regression test for sympy/sympy#11526
This also partially fix issues with
Add._eval_as_leading_term, mentioned by @jksuom.
Anyway, this expand_mul() call looks like a hack,
so I'll remove one.

Closes sympy/sympy#11526

skirpichev added a commit to skirpichev/diofant that referenced this issue Aug 21, 2016

Add regression test for sympy/sympy#11526
This also partially fix issues with
Add._eval_as_leading_term, mentioned by @jksuom.
Anyway, this expand_mul() call looks like a hack,
so I'll remove one.

Closes sympy/sympy#11526

skirpichev added a commit to diofant/diofant that referenced this issue Aug 22, 2016

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