Updates:
Labels: EasyToFix NeedsReview asmeurer
Comment #4 on issue 2065 by asmeurer: Wrong result with expressions like
limit(x**0.5, x, oo)
http://code.google.com/p/sympy/issues/detail?id=2065
This is really easy to fix. Here is the code from limit.py (comments
added):
if e.is_Pow:
if e.args[0] == z:
if e.args[1].is_Rational:
if e.args[1] > 0:
##############
# BRANCH 1
##############
return z0**e.args[1]
else:
if z0 == 0:
if dir == "+":
return S.Infinity
else:
return -S.Infinity
else:
return z0**e.args[1]
if e.args[1].is_number:
if e.args[1].evalf() > 0:
##############
# BRANCH 2
##############
return S.Zero
else:
if dir == "+":
return S.Infinity
else:
return -S.Infinity
sqrt(x) (or x**Rational(1, 2)) takes branch 1, because Rational(1,
2).is_Rational is True. This returns oo**Rational(1, 2), which correctly
gives oo. x**0.5, however, takes branch 2, which returns just 0. But,
oo**0.5 also works correctly:
In [7]: oo**0.5
Out[7]: ∞
Actually, that code means that there are also these bugs too:
In [5]: limit(x**0.5, x, 1)
Out[5]: 0
In [6]: limit(x**0.5, x, 20)
Out[6]: 0
So I have a fix at http://github.com/asmeurer/sympy/tree/2065, and a pull
request for it at http://github.com/sympy/sympy/pull/6. Please review.
Basically, I removed the second branch (is_number), and made the first one
run for is_number instead of is_Rational.
And to answer your question, based on the code above, it should be clear
that this bug is isolated to the limit algorithm, specifically limit(x**b,
x, n), where b is a number that isn't an instance of Rational.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-iss...@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.