{{ message }}
/ sympy Public

[GSoC] Series: Correcting incorrect limit evaluations based on different assumptions of the limit variable#19292

Merged
merged 4 commits into from May 12, 2020
Merged

[GSoC] Series: Correcting incorrect limit evaluations based on different assumptions of the limit variable #19292

merged 4 commits into from May 12, 2020

Conversation

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

sachin-4099 commented May 11, 2020 • edited

Fixes: #8481
Fixes: #9041
Fixes: #14556
Fixes: #16722
Fixes: #17792
Fixes: #18992

Brief description of what is fixed or changed

Incorrect limit evaluation takes place based on different assumptions of the variable in the limit expression.

The assumption `integer = True` is causing these issues.

As we know, Gruntz algorithm changes a variable to a dummy with `positive=True` if the variable does not possess that property. We can make it define a dummy, if the limit variable has `integer=True` property.
So, Gruntz algorithm would not need to work with variables having `integer=True` property and thus this issue won’t occur.
The rewrite line can come later, after the dummy variable has been substituted.

Now the limit evaluations take place correctly:

``````In [6]: b = Symbol('b', positive=True, integer=True)
In [7]: limit(factorial(b+1)**(1/(b+1)) - factorial(b)**(1/b), b, oo)
Out[7]:
-1
e

In [8]: n = Symbol('n',positive=True,integer=True)

In [9]: limit(factorial(n)/sqrt(n)*(E/n)**n,n,oo)
Out[9]:
___   ____
\/ 2 *\/ pi

In [10]: z = symbols('z', positive=True)

In [11]: limit(binomial(n + z, n)*n**-z, n, oo)
Out[11]: 1/gamma(z + 1)

In [12]: z = symbols('z', positive=True, integer=True)

In [13]: limit(binomial(n + z, n)*n**-z, n, oo)
Out[13]: 1/gamma(z + 1)
``````

Release Notes

• series
• Adds a condition to `limitinf() function of gruntz.py` resolving incorrect limit evaluations

``` Correcting incorrect limit evaluation based on different assumptions ```
``` 8c3d74e ```
`of the limit variable`

sympy-bot commented May 11, 2020 • edited

 ✅ Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like: series Adds a condition to `limitinf() function of gruntz.py` resolving incorrect limit evaluations (#19292 by @sachin-4099) This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed. ``````Fixes: #14556 Fixes: #16722 Fixes: #17792 #### Brief description of what is fixed or changed **Incorrect limit evaluation** takes place based on **different assumptions** of the variable in the limit expression. The assumption `integer = True` is causing these issues. As we know, Gruntz algorithm changes a variable to a dummy with `positive=True` if the variable does not possess that property. We can make it define a dummy, if the limit variable has `integer=True` property. So, Gruntz algorithm would not need to work with variables having `integer=True` property and thus this issue won’t occur. The rewrite line can come later, after the dummy variable has been substituted. Now the limit evaluations take place correctly: ``` In [6]: b = Symbol('b', positive=True, integer=True) In [7]: limit(factorial(b+1)**(1/(b+1)) - factorial(b)**(1/b), b, oo) Out[7]: -1 e In [8]: n = Symbol('n',positive=True,integer=True) In [9]: limit(factorial(n)/sqrt(n)*(E/n)**n,n,oo) Out[9]: ___ ____ \/ 2 *\/ pi In [10]: z = symbols('z', positive=True) In [11]: limit(binomial(n + z, n)*n**-z, n, oo) Out[11]: 1/gamma(z + 1) In [12]: z = symbols('z', positive=True, integer=True) In [13]: limit(binomial(n + z, n)*n**-z, n, oo) Out[13]: 1/gamma(z + 1) ``` #### Other Comments Regression Tests have been added. #### Release Notes * series * Adds a condition to `limitinf() function of gruntz.py` resolving incorrect limit evaluations `````` Update The release notes on the wiki have been updated.

changed the title Series: Correcting incorrect limit evaluations based on different assumptions of the limit variable [GSoC] Series: Correcting incorrect limit evaluations based on different assumptions of the limit variable May 11, 2020
requested a review from jksuom May 11, 2020
requested a review from leosartaj May 11, 2020
added 2 commits May 11, 2020
``` Made minor changes ```
``` f344484 ```
``` Removing unused variable ```
``` d9ec1c0 ```

sachin-4099 commented May 11, 2020

 Please let me know if this is a similar issue: #9252

Codecov Report

Merging #19292 into master will decrease coverage by `0.020%`.
The diff coverage is `100.000%`.

```@@              Coverage Diff              @@
##            master    #19292       +/-   ##
=============================================
- Coverage   75.593%   75.573%   -0.021%
=============================================
Files          651       651
Lines       169545    169545
Branches     40016     40016
=============================================
- Hits        128165    128131       -34
- Misses       35762     35795       +33
- Partials      5618      5619        +1     ```

reviewed
sympy/series/gruntz.py Outdated Show resolved Hide resolved

jksuom commented May 11, 2020

 This looks good. Gruntz's algorithm deals with functions of a continuous variable.

reviewed
sympy/series/gruntz.py Outdated Show resolved Hide resolved

sachin-4099 commented May 11, 2020

``` Made minor changes ```
``` eef26bb ```

jksuom commented May 11, 2020

 That looks like a bug. The result should depend on `c`.

sachin-4099 commented May 11, 2020

 That looks like a bug. The result should depend on `c`. Alright.

merged commit `7a3e064` into sympy:master May 12, 2020
3 checks passed
This was referenced May 23, 2020