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

Calculate limit error #5383

Open
satels opened this Issue Apr 18, 2011 · 8 comments

Comments

Projects
None yet
6 participants
@satels
Copy link

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/<ipython console> in <module>()

/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/

@jorgeecardona

This comment has been minimized.

Copy link
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/

@skirpichev

This comment has been minimized.

Copy link
Contributor

skirpichev commented Aug 3, 2013

@sympy-issue-migrator

This comment has been minimized.

Copy link

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/

@pramodch

This comment has been minimized.

Copy link
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/

@skirpichev

This comment has been minimized.

Copy link
Contributor

skirpichev commented Jan 19, 2014

@skirpichev

This comment has been minimized.

Copy link
Contributor

skirpichev commented Feb 26, 2014

@satels satels added imported labels Mar 7, 2014

@asmeurer asmeurer referenced this issue Mar 29, 2014

Closed

2284_series #7316

@satels

This comment has been minimized.

Copy link

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

@satels satels closed this Oct 12, 2014

@skirpichev

This comment has been minimized.

Copy link
Contributor

skirpichev commented Oct 13, 2014

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

@skirpichev skirpichev reopened this Oct 13, 2014

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).

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment