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
Requesting implementing "Integrate" method #1597
Comments
Thanks for the feedback @amcostant. We have done some work on the Rubi integration, see, e.g., #1497. I would like to see it finished and be able to do integrations in SymEngine. I don't have time to drive the main effort, but if anybody is interested to take a shot at that, I would be happy to help. Update: See the comment below for the exact step by step plan how to help. |
@certik I didn't see Integrate talked about in that issue, where would I even begin to look to where I can help? |
@Cazadorro thanks for the interest. There are two avenues. One is to do what SymPy does, and implement the algorithms into SymEngine. You can start by looking at SymPy's integrate() and then try to implement some of the algorithms into SymEngine. The other avenue is to work on the Rubi integration (which SymPy doesn't have either yet), as that will provide good integration support. |
@certik I've noticed a bunch of bugs in complicated integration with the current integration scheme in Sympy (it fails with sqrts and abs on many functions), I would prefer not to go that route if rubi integration is where everything is heading anyway. How would I help on that front? I've followed a bunch of threads and haven't really found where the "list of things we still need to do" is for rubi integration, which it looks like you are involved in some what. |
@Cazadorro I need to get up to speed on that also. @Upabjojr, do you think you could please write (or point me to if you've already done this) a simple write up with a list of steps what needs to be done to get Rubi integration into SymEngine? |
First you have to test whether the current code generator works eighth SymPy. That's probably pretty easy. After that, you need to translate the utility functions into SymEngine. After this is done, try to point the code generator to target C++. I expect some bugs to arise as it's not thoroughly tested. Anyway, it's definitely faster than implementing the algorithm from scratch. Hopefully we'll get some students for GSoC 2020. |
@Upabjojr thanks! To clarify: by "current code generator", are you talking about this file: It seems that already generates C++. Can you point us to the SymPy utilities functions that need to be translated to SymEngine? |
Rubi has utility functions. The current python translations are in a subfolder of rubi in SymPy. |
Ok, is this the code generator that we need to get working again with SymPy: https://github.com/sympy/sympy/blob/d7a854fb789591114d7d51c3f23bba2fd4d520cc/sympy/integrals/rubi/parsetools/generate_rules.py |
Here are the utility functions that need to be translated to SymEngine: https://github.com/sympy/sympy/blob/d7a854fb789591114d7d51c3f23bba2fd4d520cc/sympy/integrals/rubi/utility_function.py |
Ok, so to start, let's start with the simplest rule file, which is this one: And see if we can port it to SymEngine. It seems that one only requires a few utility functions. So that will get us started. Then we'll go from there. |
Well, that's the code translator. It translates the rules from Mathematica to Python. After that step, the rules haven't been loaded into MatchPy yet. You need to load them into MatchPy and then call the code generator for the decision tree (which is not the rule generator). |
I see. the |
It's inside MatchPy. Some edits are necessary to use the code generator. There's an open PR somewhere. For C++, the code generator is in symengine. |
The main problem is the usage of lambdas. When you generate the decision tree you can't find the definitions, IIRC. |
On SymPy. By the way, the rules will probably need support for C++20 if ported to C++. |
@Upabjojr is this the code generator for the decision tree in matchpy: https://github.com/HPAC/matchpy/blob/a90cc4684c85f6afea0a6386d2338374eda7e1d9/matchpy/matching/code_generation.py, and here is how to use it? |
Yes, it takes a It's not thoroughly tested, I fixed a bug earlier this year. |
Ok, thanks. Let's summarize the exact steps to do.
@Upabjojr, is this your understanding? Are the links I provided correct? Assuming this is correct, then I would suggest to take some simple subset of Rubi rules from SymPy, say the piecewise_linear.py that I mentioned above (or even something simpler at first), then do the step 1. with it, and verify that it works. Then port only the utility functions required in |
The links are correct. Currently SymPy defines a |
The code generator works with |
Thanks, I updated the above comment with step 0. |
I updated with a link for initial implementation of step 1. |
For your information: |
To whom it may concern,
I was wondering if there were any plans to develop an Integrate method in SymEngine. I understand that there are some workarounds for polynomial integration, but unfortunately, there is no shortcut for non-posynomials. Currently, I am having to convert to SymPy and back which is very slow, but overall faster than performing everything in SymPy.
The text was updated successfully, but these errors were encountered: