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

Limit erroneously reported as infinity #11270

Open
krey opened this Issue Jun 21, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@krey
Copy link

krey commented Jun 21, 2016

> limit(log(   1/2  *exp(u*x)+   1/2  *exp(-u*x))/(x**2), x, 0)
oo
> limit(log(S("1/2")*exp(u*x)+S("1/2")*exp(-u*x))/(x**2), x, 0)
u**2/2

The latter of the two is the correct answer. I understand that the discrepancy is due to the fact that python converts 1/2 into a floating point number before sympy is able to treat it as a fraction.

But I think it is buggy behaviour to return infinity instead throwing an "UnknownLimitError" or something.

I'm using the latest version (1.0 apparently?) from pip under Python 3.5.1 on ArchLinux.

@jksuom

This comment has been minimized.

Copy link
Member

jksuom commented Jun 22, 2016

python converts 1/2 into a floating point number

Also this is possible:

>>> 1/2
0

Python converts the argument of log to 0.

@krey

This comment has been minimized.

Copy link

krey commented Jun 22, 2016

Not in Python 3 ;-)

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