Skip to content
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

Made changes for better user-interpretation of series which are demonstrably divergent #22809

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

faze-geek
Copy link
Contributor

@faze-geek faze-geek commented Jan 6, 2022

References to other Issues or PRs

Closes #14191

Brief description of what is fixed or changed

Modified : concrete/summations.py
Modified : concrete/tests/test_sums_products.py
Added code for required series which are known to be divergent but on master it returns self .So a converge check is added once the summation fails ,which is useful information for the user.
Secondly anything constant should be treated as convergent .I observed that on master -

>>> Sum(cos(n), (n, x, x + 1)).doit()
cos(x) + cos(x + 1)
>>> Sum(cos(n), (n, x, x + 1)).is_convergent()
False

Here if 'x' was a number then on master the output is 'True'. The basic observation here was that cos(n) anyways will always stay bounded and hence cos(x) + cos(x+1) should be convergent.
After my commits -

>>> Sum(cos(x), (x, n, n + 10)).doit()
cos(n) + cos(n + 1) + cos(n + 2) + cos(n + 3) + cos(n + 4) + cos(n + 5) + cos(n + 6) + cos(n + 7) + cos(n + 8) + cos(n + 9) + cos(n + 10)
>>> Sum(cos(x), (x, n, n + 10)).is_convergent()
True 

This gives 'True' unless n is substituted S.Infinity/oo

Other comments

I will be adding appropriate tests and look into the failed checks soon !

Release Notes

NO ENTRY

@sympy-bot
Copy link

sympy-bot commented Jan 6, 2022

Hi, I am the SymPy bot (v162). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

  • No release notes entry will be added for this pull request.
Click here to see the pull request description that was parsed.
<!-- 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. -->
Closes #14191

#### Brief description of what is fixed or changed
Modified : ` concrete/summations.py `
Modified : ` concrete/tests/test_sums_products.py `
Added code for required series which are known to be divergent but on master it returns `self` .So a converge check is added once the summation fails ,which is useful information for the user.
Secondly anything constant should be treated as convergent .I observed that on master -
```
>>> Sum(cos(n), (n, x, x + 1)).doit()
cos(x) + cos(x + 1)
>>> Sum(cos(n), (n, x, x + 1)).is_convergent()
False
```
Here if  'x' was a number then on master the output is 'True'. The basic observation here was that cos(n) anyways will always stay bounded and hence cos(x) + cos(x+1) should be convergent.
After my commits -
```
>>> Sum(cos(x), (x, n, n + 10)).doit()
cos(n) + cos(n + 1) + cos(n + 2) + cos(n + 3) + cos(n + 4) + cos(n + 5) + cos(n + 6) + cos(n + 7) + cos(n + 8) + cos(n + 9) + cos(n + 10)
>>> Sum(cos(x), (x, n, n + 10)).is_convergent()
True 
```
This gives 'True' unless n is substituted `S.Infinity/oo`
#### Other comments
I will be adding appropriate tests and look into the failed checks soon !

#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers.

or if no release note(s) should be included use:

NO ENTRY

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

@anutosh491
Copy link
Member

anutosh491 commented Jan 7, 2022

@faze-geek The tests are failing because of the another issue which has been fixed here #22200 by me . It's done from my side and needs review to merge , maybe @oscargus or @smichr can help us out with that ! I don't see your code is responsible for the error but yeah the changes you made would involve this to be done .

On master we have

>>> Sum(Piecewise((1/4*2**d, d>=-1), (0, True)), (d, -oo, -1)).is_convergent()
TypeError: Invalid NaN comparison

On my pr

>>> Sum(Piecewise((1/4*2**d, d>=-1), (0, True)), (d, -oo, -1)).is_convergent()
True

@faze-geek
Copy link
Contributor Author

@faze-geek The tests are failing because of the another issue which has been fixed here #22200 by me . I don't see your code is responsible for the error but yeah the changes you made would involve this to be done .

Thanks for informing me about this . I looked into it and feel if it is a SymPy issue ,once #22200 is merged my failing checks will get resolved .

@faze-geek faze-geek changed the title Added code for better user-interpretation of series which are demonstrably divergent Made changes for better user-interpretation of series which are demonstrably divergent Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sum doit for series which are demonstrably divergent
4 participants