# Limits: limit of order term should raise error #2991

Closed
wants to merge 1 commit into
from

None yet

### 2 participants

Contributor
 See #2865 A few doubts:- I'm not sure what type of error should be given. Now I give a ValueError. Tell me if some other error is to be given and if error message is to be changed. Output for limit(Order(2)*x, x, S.NaN) was S.NaN, now it gives error. Is that correct?
 avichaldayal Limits: limit of order term should raise error 57d1eb3
Contributor
 But you introduce new bug instead: In [1]: gruntz(O(x), x, 0) ... ValueError: Cannot find limit of O(1/x, (x, oo)) 
Contributor
 Output for limit(Order(2)*x, x, S.NaN) was S.NaN, now it gives error. Is that correct? O(2)*nan is nan why limit should be different?
Contributor
 I'm not clear with limits of order term. -> I'm thinking that limit of order term is not defined so an error should be thrown. So gruntz(O(x), x, 0) should raise an error. -> limit(O(2)*x, x, S.NaN) is an interesting case. Gruntz returns the correct answer i.e. nan but limit thinks it's an error by gruntz hence raises an error. Other cases unrelated to this PR like limit(exp(x)/x**2, x, S.NaN) also raise an error while gruntz gives the correct nan answer -> Maybe the following should be removed: r = gruntz(e, z, z0, dir) if r is S.NaN: raise PoleError() 
Contributor
 I'm not clear with limits of order term. Then try to make it clear first, please educate yourself. All calculus textbooks have (ε, δ) limit definition, most of them introduce O(f(x)) notation as well. -> I'm thinking that limit of order term is not defined so an error should be thrown. So gruntz(O(x), x, 0) should raise an error. I don't see reason why this limit can't be computed (to be 0). In fact, just by definition - O(x) is a set of functions f(x), for which \lim_{x->0}\sup|f(x)/x| < \infty. -> limit(O(2)*x, x, S.NaN) is an interesting case. Gruntz returns the correct answer i.e. nan but limit thinks it's an error by gruntz hence raises an error. Then you should fix this. -> Maybe the following should be removed: You can try...
Contributor
 An off moment, misunderstood the issue, sorry for that. Will submit the correct patch as soon as I'm done with my application.
commented on the diff Mar 28, 2014
sympy/series/tests/test_gruntz.py
 @@ -464,3 +465,7 @@ def test_issue_3583(): def test_issue_3997(): from sympy.functions import sign assert gruntz(x**-pi, x, 0, dir='-') == oo*sign((-1)**(-pi)) + + +def test_gh_issue_2865():
 skirpichev Contributor just test_issue_2865 (we don't use google code bug tracker anymore)
commented on the diff Mar 28, 2014
sympy/series/tests/test_limits.py
 @@ -417,3 +416,7 @@ def test_issue_3265(): a = Symbol('a') e = z/(1 - sqrt(1 + z)*sin(a)**2 - sqrt(1 - z)*cos(a)**2) assert limit(e, z, 0).simplify() == 2/cos(2*a) + + +def test_gh_issue_2865():
 skirpichev Contributor as well, test_issue_2865
Contributor
 Closing this for now, see this.
closed this Apr 22, 2014
self-assigned this Apr 22, 2014