-
Notifications
You must be signed in to change notification settings - Fork 154
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
Gruntz Demo #2688
base: main
Are you sure you want to change the base?
Gruntz Demo #2688
Conversation
cc @certik |
We can demonstrate the sample case that sympy use in their documentation which is
So i) ii) We then use sign on the generated exponent and the input variable
Now based on the value returned through sign, we return the output
|
Internally
This gives us |
A slightly more involved example would be this
|
Perfect. Yes, let's do the sin(x)/x, and you can take the running example in sympy and just simplify it to the bare minimum. Then we'll port the simplified code to LPython. |
The latest commit fixes some import errors and any issues with the code and now we can get results for our simplified gruntz algorithm through sympy. I've added a test for the same saying
I could maybe add another file that is relevant only for the |
The recent commits simplifies the previous version of gruntz by quite a bit. For our use case i.e.
|
Also talking about the So the
All of these have |
For the
I've raised a PR to symengine to add functionality for |
The
And technically the |
…nto gruntz_demo
Add more tests
Add more tests, fix a few bugs
Listing all blockers below. |
return list1 | ||
if e.func == Mul or e.func == Add: | ||
a: S = e.args[0] | ||
b: S = e.args[1] |
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.
Minor Blocker:
So technically if we have e.func == Add
or e.func == Mul
, we would like to use the as_two_terms
function for splitting the expression into two sub expressions. For simple expressions we can just use args
to split the expression.
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.
Okay this is a blocker for the case mrv(2*sin(x)/x, x)
or any case involving more than 1 *
or +
operator. In that case the .args
can't cover for the as_two_terms
function.
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've opened an issue for the same here.
symengine/symengine#2018
elif e.is_Integer: | ||
return {} | ||
elif e.is_Mul or e.is_Add: | ||
a, b = e.as_two_terms() |
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.
as_two_terms
is required here.
This is a draft PR trying to replicate the gruntz algorithm and a few test cases for the same.