# sympy/sympy

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.

# Calculate limit error #5383

Open
opened this Issue Apr 18, 2011 · 8 comments

Projects
None yet
6 participants

### satels commented Apr 18, 2011

 ``````In [63]: import sympy In [64]: x = sympy.symbols('x') In [65]: x0=0 In [66]: func = ( 1.0*1+ 1.0*x)**( 1.0*1/x) In [67]: print sympy.limit(func, x, x0) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/satels/ in () /usr/local/lib/python2.6/dist-packages/sympy/series/limits.pyc in limit(e, z, z0, dir) 89 90 try: ---> 91 r = gruntz(e, z, z0, dir) 92 except PoleError: 93 r = heuristics(e, z, z0, dir) /usr/local/lib/python2.6/dist-packages/sympy/series/gruntz.pyc in gruntz(e, z, z0, dir) 505 elif dir == "+": 506 e0 = e.subs(z,z0+1/x) 507 else: 508 raise NotImplementedError("dir must be '+' or '-'") --> 509 return limitinf(e0, x) /usr/local/lib/python2.6/dist-packages/sympy/series/gruntz.pyc in limitinf(e, x) 337 if e.has(log): 338 e = e.normal() --> 339 c0, e0 = mrv_leadterm(e,x) 340 sig=sign(e0,x) 341 if sig==1: return S.Zero # e0>0: lim f = 0 /usr/local/lib/python2.6/dist-packages/sympy/series/gruntz.pyc in mrv_leadterm(e, x, Omega) 395 e_up = moveup([e],x)[0] 396 #calculate the lead term --> 397 mrv_leadterm_up = mrv_leadterm(e_up, x, Omega_up) 398 #move the result (c0, e0) down 399 return tuple(movedown(mrv_leadterm_up, x)) /usr/local/lib/python2.6/dist-packages/sympy/series/gruntz.pyc in mrv_leadterm(e, x, Omega) 406 series = calculate_series(f, wsym) 407 series=series.subs(log(wsym), logw) --> 408 return series.leadterm(wsym) 409 410 /usr/local/lib/python2.6/dist-packages/sympy/core/basic.pyc in leadterm(self, x) 2342 if not c.has(x): 2343 return c,e -> 2344 raise ValueError("cannot compute leadterm(%s, %s), got c=%s" % (self, x, c)) 2345 2346 ValueError: cannot compute leadterm(exp(log(1.0 + _w)/_w), _w), got c=exp(log(1.0)/_w) sympy 0.6.7 `````` Original issue for #5383: http://code.google.com/p/sympy/issues/detail?id=2284 Original author: https://code.google.com/u/112786146078013975159/
Contributor

### jorgeecardona commented Mar 7, 2012

 ``````In '0.7.1-git': In [47]: import sympy In [48]: x = sympy.symbols('x') In [49]: x0=0 In [50]: func = ( 1.0*1+ 1.0*x)**( 1.0*1/x) In [51]: print sympy.limit(func, x, x0) oo Which is a wrong result, must be 'e' `````` Original comment: http://code.google.com/p/sympy/issues/detail?id=2284#c1 Original author: https://code.google.com/u/110744338503062407082/
Contributor

### skirpichev commented Aug 3, 2013

 ``````**Labels:** Series `````` Original comment: http://code.google.com/p/sympy/issues/detail?id=2284#c2 Original author: https://code.google.com/u/113518207426301808764/

### sympy-issue-migrator commented Dec 6, 2013

 ``````Hi, I'm Pramod. I'm currently working on this bug. I will post a pull request in 3-4 days. `````` Original comment: http://code.google.com/p/sympy/issues/detail?id=2284#c3 Original author: https://code.google.com/u/107326118649629739894/
Contributor

### pramodch commented Jan 19, 2014

 ``````Please review this pull request https://github.com/sympy/sympy/pull/2801 `````` Original comment: http://code.google.com/p/sympy/issues/detail?id=2284#c6 Original author: https://code.google.com/u/113405803415599232942/
Contributor

### skirpichev commented Jan 19, 2014

 ``````**Labels:** NeedsReview `````` Original comment: http://code.google.com/p/sympy/issues/detail?id=2284#c7 Original author: https://code.google.com/u/113518207426301808764/
Contributor

### skirpichev commented Feb 26, 2014

 ``````**Labels:** -NeedsReview `````` Original comment: http://code.google.com/p/sympy/issues/detail?id=2284#c8 Original author: https://code.google.com/u/113518207426301808764/

Closed

### satels commented Oct 12, 2014

 In [9]: import sympy In [10]: x = sympy.symbols('x') In [11]: x0=0 In [12]: func = ( 1.0_1+ 1.0_x)*_( 1.0_1/x) In [13]: print sympy.limit(func, x, x0) 2.71828182845905

Contributor

### skirpichev commented Oct 13, 2014

 At least, we don't have a regression test.

### skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 23, 2016

``` Replace Float's with Rational's early in the limit code ```
```Limit algorithms (i.e. Gruntz) doesn't work well with
non-exact numbers.

TODO: Perhaps, it's a user task to convert them to
Rationals/whatever and it's better to raise an exception
instead of this conversion.

Fixes diofant#296
Fixes sympy/sympy#11270

Few outdated comments in test_compute_leading_term are removed.

This also closes sympy/sympy#5383 (regression test added).```
``` 76e0913 ```

### skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 25, 2016

``` Replace Float's with Rational's early in the limit code ```
```Limit algorithms (i.e. Gruntz) doesn't work well with
non-exact numbers.

TODO: Perhaps, it's a user task to convert them to
Rationals/whatever and it's better to raise an exception
instead of this conversion.

Fixes diofant#296
Fixes sympy/sympy#11270

Few outdated comments in test_compute_leading_term are removed.

This also closes sympy/sympy#5383 (regression test added).```
``` ebca09e ```
to join this conversation on GitHub. Already have an account? Sign in to comment