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
Simplify before testing convergence #16739
Simplify before testing convergence #16739
Conversation
Added simplification of function, before testing for convergence and added tests. Fixed sympy#16699.
✅ Hi, I am the SymPy bot (v147). 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:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5. 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.
|
Is there a way to just return None if you know that simplification? Or if this is a high-level routine then maybe using simplify makes sense. |
I do not think this resolves the issue. This patch works in the specific example and probably is better than nothing.
the result given by SymPy is A possible alternative is to evaluate
|
@smichr I did not fully understand what you said. Do you mean that if the call to simplify fails? When exactly should I return None. >>> print(O(factorial(n), (n, oo)))
O(factorial(n), (n, oo))
>>> print(O(factorial(n)/factorial(n-2), (n, oo)))
O(1, (n, oo))
>>> print(O(factorial(n)/factorial(n+2), (n, oo)))
O(1, (n, oo)) We would want that the |
So again, this function call is the problem here, right? >>> n = Symbol('n')
>>> O(1-cos(n), (n, 0))
O(1) The result should have been Also calling |
Exactly. This is the main problem. |
I see that I had an incomplete thought in my suggestion. What it was intended to suggest is that maybe obtaining a meaningless O expression of something like that would allow you to know that you should return none of else use a limit or simplification. |
This reverts commit c46395e.
Update the master to the current state and restart on the issue.
What's the status of this? @AnimeshSinha1309 @smichr |
Sorry, I did not follow up on this. My Attempts did not work out, I would appriciate any help I can get. I am available to work again, trying now. |
Honestly I am out of ideas, simple fixes to the For now, this is my plan for fixing the limit comparison test in summations.py ### ------ limit-comparison with p-series ------ ###
if limit(sequence_term * sym, sym, oo) > 0:
return False
if limit(sequence_term * (sym ** 1.0001), sym, oo) < oo:
return True |
Changed the is_convergent() method to test limit comparison against 1/n and 1/n**1.0001, fixing the convergence test problem, though not the sharp order problem.
sympy/sympy/concrete/products.py Lines 359 to 360 in 12d8f53
Is this example not incorrect, since Product(n/(n + 1), (n, 1, oo)) = (1/2) * (2/3) * ... * (n-1/n) = 1/n = 1/oo = 0 . So the answer should be True, it's convergent, should it not?
|
Some tests fixed, some code. Changed some tests that seem most certainly wrong, esp. an example.
An infinite product with limit 0 is considered divergent. |
Handling the negative constant, fixing what I thought was an erroneous test and changed.
Codecov Report
@@ Coverage Diff @@
## master #16739 +/- ##
=============================================
+ Coverage 73.922% 74.482% +0.559%
=============================================
Files 620 623 +3
Lines 160243 161391 +1148
Branches 37600 37878 +278
=============================================
+ Hits 118456 120208 +1752
+ Misses 36305 35858 -447
+ Partials 5482 5325 -157 |
Thanks for that, I fixed my mistake, undid the example that I had changed. I am just confused about one more thing, I changed a few lines in Summation, and added 3 tests for it, why is my Codecov score still falling, should I just keep adding mode examples? |
Issue sympy#14488 is no longer raising a NotImplementedError due to the limit being evaluated correctly.
### ------------- alternating series test ----------- ### | ||
dict_val = sequence_term.match((-1)**(sym + p)*q) | ||
if not dict_val[p].has(sym) and is_decreasing(dict_val[q], interval): | ||
return S.true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this and everything below is untested. Are these tests (alternating series etc) not already implemented somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand, there are already tests for Alternating Series and for everything else that follows. I believe that the issue might be that my p-series limit comparison is just returning a solution, blocking access to some of the functions later in the code. But now the codecov score looks pretty decent, right? And if not, what is it that I fix, I have no clue about codecov?
Closing as the associated issue is outdated. |
Added simplification of function, before testing for convergence and added tests.
References to other Issues or PRs
Fixes #16699
Brief description of what is fixed or changed
Fixing issues with Sum of the factorial series, just added simplification of the expression before the tests for convergence start.
Release Notes