-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[GSoC] Functions: Fixes errors in assumptions when rewriting RisingFactorial / FallingFactorial as gamma or factorial #18696
Conversation
✅ Hi, I am the SymPy bot (v160). 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.
Update The release notes on the wiki have been updated. |
I suggest that you use as a starting point my |
Extremely sorry I read late |
No problem...and I just got a better Piecewise, I think. See how it goes as you have time. |
A diff to update this with changes I had in progress is here |
Doctests as well as tests in concrete module are failing with this diff |
The
|
This is the critical line in hypersimp: sympy/sympy/simplify/simplify.py Line 305 in 3dff1b9
It creates a Piecewise function that the following lines cannot currently simplify. It would suffice to consider the rightmost interval in piecewise. In some cases, this can be enforced by adding assumptions to arguments.
|
There is a problem with this: The input expression has no Piecewise. It only appears in the process, in |
this is the simplest fix but these functions have meaning for non-integer cases so I think we need a more robust solution. Or, for the sake of this PR, should we just do that and deal with how to handle Piecewise in another PR? |
I will do as you say, IMHO, we can currently do this and then it is better to handle the remaining work in another PR. |
gitter is not working for me. Regarding how to proceed, I would like to hear from @jksuom and/or @oscarbenjamin . If we commit this without the improved handling in place then anyone relying on the current behavior will have a broken system. |
I think that there are two possibilities.
Alternatively,
|
If I understand correctly, this is what I was doing in my |
I mean something like this:
|
The problem with this is that if it is not known then then else-form will be returned but then it will evaluate incorrectly when given a negative argument. That is what the Piecewise was trying to circumvent. |
I think that using a Piecewise is the right approach in general. I don't understand what problem it is causing though... (probably too tired) |
It fails |
Should that pass though?
That Piecewise not a hypergeometric function because it can not be represented using any hypergeometric power series. What is the example function for which this fails and why is it important to know if it is actually hypergeometric? |
>>> rf(x,y).is_hypergeometric(x)
True
>>> rf(x,y).is_hypergeometric(y)
True
>>> (x+y).is_hypergeometric(x)
True
>>> (gamma(x + y)/gamma(x)).is_hypergeometric(x)
True
>>> Piecewise((gamma(x + y)/gamma(x),x>=0),(x+y,True)).is_hypergeometric(x)
False (That's just a toy representation of the idea; and if I am repeating something that doesn't make sense in light of what @jksuom has already told me it is a reflection of my almost total ignorance about hypergeometricity) |
There are two operations, rewriting and giving an argument. Would it be possible to give the argument before rewriting? |
If I don't think that a Piecewise is hypergeometric just because each of its cases would be. |
In the failing doctests an assertion that Perhaps rewrite should simply fail if the assumption is not present (thus forcing the user to give the argument before rewriting). But a So |
Any news on this? @sachin-4099 @smichr |
Thanks for reminding, I will look into this and finish this. |
Can a piecewise be hypergeometric in certain cases?? @oscarbenjamin @smichr |
I don't see why not. Note that the Piecewise can have conditions that don't depend on the variable of interest e.g.: In [8]: expr = x * Piecewise((1, y<0), (2, True))
In [9]: expr
Out[9]:
⎛⎧1 for y < 0⎞
x⋅⎜⎨ ⎟
⎝⎩2 otherwise⎠
In [10]: expr.is_hypergeometric(x)
Out[10]: True
In [11]: expr.is_hypergeometric(y)
Out[11]: False In general a piecewise function of x can be at least piecewise-hypergeometric (if each piece is hypergeometric). |
So, in your opinion, this is not correct:
|
None is always a valid answer in fuzzy logic. |
Since,
Can you elaborate on this? |
You're returning a Piecewise function while rewriting as gamma. maybe I'm the only one who feels this way. Why use Piecewise when there are alternatives. I guess if @oscarbenjamin @jksuom @smichr are okay with the approach then it's cool. |
What are the alternatives, can you elaborate keeping in mind the issue #13446? |
c6222e9
to
2025dda
Compare
Thanks, this is ready to be merged. |
Fixes: #6878
Fixes: #13446
Fixes: #14871
Fixes: #18686
Brief description of what is fixed or changed
Previously:
Now:
Other Comments
Regression Tests have been added
Release Notes
RisingFactorial
/FallingFactorial
asgamma
orfactorial