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
Added floor implementation in solvers #18596
base: master
Are you sure you want to change the base?
Conversation
In Installation procedure, details about installing SymPy using PyPI was added and a minor sentence was fixed.
sudo python setup.py install part was removed from README as it was bit of an overkill when explaining the basic installation procedure
…r/sympy into 12296_floor_implementation Revived the floor implementation PR
✅ 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: 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.
|
I still have to write proper docstrings for |
Sorry, accidentally closed the branch. |
sympy/solvers/solvers.py
Outdated
@@ -1699,7 +1700,7 @@ def _expand(p): | |||
else: | |||
soln = list(soln.keys()) | |||
|
|||
if soln is not None: | |||
if soln is not None and not type(gens[0]) == floor: |
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.
This seems like a fragile method for handling this case. Why in particular should the type not be floor?
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.
@oscarbenjamin On speculation, we can solve the polynomial when the generator is a floor
but then we would have to check if the floor(x)
is an integer or not. If it is not, then an empty solution will have to be returned. Your thoughts?
Updated the floor implementation function in such a way that now it returns solutions as a set of Intervals.
@ethankward @oscarbenjamin I have updated the floor implementation function to return answers in terms of Intervals which seems to be appropriate when dealing with |
You need to add a lot more tests for this. As a starting point:
If the function cannot solve certain classes of equations it should raise Also wouldn't it make more sense for this to go in |
@ethankward ok I will add more test cases to see how well the function works with different expressions along with making it work with nested |
@ethankward since the answers are in sets, then probably it makes sense to add this in solveset but I would see how solveset works to add it there eventually. |
I don't think that solve should return intervals. |
@oscarbenjamin @ethankward I will move the this functionality to solveset as it seems that it should be there instead in solve. But where should I move this function in |
@ethankward I moved the |
Moved the floor implementation from solvers to solveset.
@oscarbenjamin @ethankward I tried solving
and answer for
and I don't know how to combine them as of now. Should I add a |
@oscarbenjamin @ethankward When I was going through some limits of this implementation, I found out that a case like: |
There are many other examples of periodic functions other than |
@ethankward @oscarbenjamin I have added a recursive check for checking for the expressions which shouldn't be evaluated. For now, it doesn't evaluate the Trigonometric and Hyperbolic terms. I will extend this by trying more things out. |
That approach is not going to work. There are an infinite number of types of equations that you cannot handle other than |
@ethankward so instead of blacklist, I would just check if the expression has only floor type or not. If it does, then the solution will be computed. |
Updated the recursive check to not handle expressions when any other subclass of Function other than floor is in the expression
@ethankward I have updated the implementation. Also, to address
|
@mijo2 This has merge conflicts. Please resolve them. |
Sure thing. Sorry for the late reply. |
Codecov Report
@@ Coverage Diff @@
## master #18596 +/- ##
=============================================
+ Coverage 75.583% 75.617% +0.034%
=============================================
Files 651 651
Lines 169535 169591 +56
Branches 40014 40028 +14
=============================================
+ Hits 128140 128241 +101
+ Misses 35784 35740 -44
+ Partials 5611 5610 -1 |
Changed an equality expression to ```is_instance``` call. Co-authored-by: Gagandeep Singh <gdp.1807@gmail.com>
References to other Issues or PRs
Revives #12296
Closes #12296
Brief description of what is fixed or changed
--> Added a function that can solve expressions when floor is used in them.
Other comments
Example:
Release Notes