Repository: sympy/sympy
Pull request: Added tests for issue 16735
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->
Fixes #16735

#### Brief description of what is fixed or changed
Adds tests to `concrete/tests/test_sums_products.py` and `series/tests/test_limitseq.py`

#### Other comments


#### Release Notes
<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
NO ENTRY
<!-- END RELEASE NOTES -->

Problem statement:
Sum.is_convergent uses the incorrect results from limit_seq
`limit_seq` gives the following wrong results:
```
In [1]: limit_seq(5**n/factorial(n),n)                                                                                                                                                  
Out[1]: ∞
```
```
In [2]: limit_seq(5**n/gamma(n+1),n)                                                                                                                                                    
Out[2]: ∞
```
Remarkably, this ends up being correct:
```
In [3]: limit_seq(5**n/gamma(n-1),n)                                                                                                                                                    
Out[3]: 0
```
Even though `gruntz` can compute both these limits, `Sum.is_convergent` uses the incorrect results from `limit_seq` to wrongly conclude that 
```
In [4]: Sum(5**n/gamma(n+1), (n, 1, oo)).is_convergent()                                                                                                                               
Out[4]: False
```

Hints from issue discussion:
On current master:
```
In [1]: limit_seq(5**n/factorial(n),n)
Out[1]: 0

In [2]: limit_seq(5**n/gamma(n+1),n)
Out[2]: 0

In [3]: Sum(5**n/gamma(n+1), (n, 1, oo)).is_convergent()
Out[3]: True
```
This issue seems fixed. Only requires a test in order to be closed.

Will adding the lines
```python
def test_issue_16735():
    assert limit_seq(5**n/factorial(n),n) == 0
    assert limit_seq(5**n/gamma(n+1),n) == 0
    assert Sum(5**n/gamma(n+1), (n, 1, oo)).is_convergent() is True
```
to `concrete/test_sums_products.py` close the issue?
Should I go for it?
> assert limit_seq(5**n/factorial(n),n) == 0

Should be added to `series/test_limitseq.py`. No need to add the `gamma` testcase, both are essentially the same.

> assert Sum(5**n/gamma(n+1), (n, 1, oo)).is_convergent() is True

Add this one to `concrete/test_sums_products.py`.

Commit message: Added tests for issue 16735

Patch to review:
diff --git a/sympy/concrete/tests/test_sums_products.py b/sympy/concrete/tests/test_sums_products.py
index 18a9f850d573..7c8aa5e92258 100644
--- a/sympy/concrete/tests/test_sums_products.py
+++ b/sympy/concrete/tests/test_sums_products.py
@@ -1317,6 +1317,11 @@ def test_issue_14313():
     assert Sum(S.Half**floor(n/2), (n, 1, oo)).is_convergent()
 
 
+@XFAIL
+def test_issue_16735():
+    assert Sum(5**n/gamma(n+1), (n, 1, oo)).is_convergent() is True
+
+
 @XFAIL
 def test_issue_14871():
     assert Sum((Rational(1, 10))**x*RisingFactorial(0, x)/factorial(x), (x, 0, oo)).rewrite(factorial).doit() == 1
diff --git a/sympy/series/tests/test_limitseq.py b/sympy/series/tests/test_limitseq.py
index 870c6c5d8da0..1300b4b98f31 100644
--- a/sympy/series/tests/test_limitseq.py
+++ b/sympy/series/tests/test_limitseq.py
@@ -125,6 +125,10 @@ def test_issue_10382():
     assert limit_seq(fibonacci(n+1)/fibonacci(n), n) == S.GoldenRatio
 
 
+def test_issue_16735():
+    assert limit_seq(5**n/factorial(n),n) == 0
+
+
 @XFAIL
 def test_limit_seq_fail():
     # improve Summation algorithm or add ad-hoc criteria


Code review comments:
diff_hunk: @@ -1317,6 +1317,11 @@ def test_issue_14313():
     assert Sum(S.Half**floor(n/2), (n, 1, oo)).is_convergent()
 
 
+@XFAIL
path: sympy/concrete/tests/test_sums_products.py
text: @user1:
This should be removed. This is not a test which fails.

diff_hunk: @@ -1317,6 +1317,11 @@ def test_issue_14313():
     assert Sum(S.Half**floor(n/2), (n, 1, oo)).is_convergent()
 
 
+@XFAIL
+def test_issue_16735():
+    assert Sum(5**n/gamma(n+1), (n, 1, oo)).is_convergent() is True
path: sympy/concrete/tests/test_sums_products.py
text: @user1:
This can be `S.true` rather than `True`.

@author:
I see that S.true issue. When it is True, the test fails and hence I added `@user2`

@author:
Please review the changes now.