# Limit erroneously reported as infinity #11270

Open
opened this Issue Jun 21, 2016 · 2 comments

Projects
None yet
2 participants

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

Fixes diofant#296
Fixes sympy/sympy#11270

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
``` ebca09e ```