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
series: support Piecewise expressions in mrv() #1214
Conversation
422f0b6
to
09c8583
Compare
@anutosh491 do you still think, that sympy/sympy#18492 is solved in the SymPy? ;-) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Thanks, I did. But I don't know how much I can help you: my knowledge of the current state of the SymPy's series module (and related things) is very limited. In my opinion, the limit() function and series() helpers tend to be more and more complex in the SymPy. (BTW, as a first point, I would suggest you to change pictures to the code snippets, if it possible. In this way I can better understand which example really poses a problem for the Diofant.) But maybe I'm wrong. For instance, you can try to compare tests for limit() for the SymPy vs the Diofant. It's not too hard to extract them with the ast module, here I can help you. That you can compare with the code complexity. E.g.:
vs
I can guess, that your chances to be accepted will slightly increase if you find the SymPy - more successful.
Feel free to open a bug if you have found any issue. There are definitely a lot of things to be improved (and a related project). |
Thanks @skirpichev , whenever I see any bug in Btw, I have a pr trying to implement the leading term method for Piecewise functions, which addresses all these cases perfectly and hence there's no real need to do it through The tests are quite extensive so that it caters to any form of piecewise expression that can be formed . Maybe you could have a look at it and let me know if I can improve something . Could be added to diofant too if you like , currently I find no failing piecewise limit through the code as I ended up trying multiple cases !! |
A good example why the implementation of the limit() in SymPy tends to be more and more complex...
As I said before, I don't know how limit() capabilities are implemented in the SymPy now. Your code seems to be too complex. Does it handle more Piecewise limits than the Diofant?
Yeah, I should implement support for arbitrary boolean expressions in limit(), i.e. And(x > 0, x < 1). Also, the implementation of limits for relational expressions is wrong in the Diofant. E.g. limit(x > 0, x, 0) should be True. |
Correct correct , I've tried to explain a bit regarding why it ended up becoming complex .
I assume yes , cause I see that code answering any sort of Piecewise expression , the test go as follows(shown below) - and it took me good amount of time to answer all sort of limits for all these functions. Like i've shown below there are about 6 ways to represent the same Piecewise function(or rather the meaning behind it) in sympy currently , hence to address all these limits, it took some careful observation from my side and eventually the code became complex. Hence either we standardize how we declare peicewise functions ( maybe moving from -oo to oo, like first the left most piece and moving to the right most piece) or end with complicated code.
|
I'll look then. But I would appreciate, if you point to a specific example (except for above notes about BooleanFunction's and #1217). |
BTW, now I've an implementation for Boolean/Relational limits (#1218), which supports all mentioned above your tests. Few lines less. |
That's nice to hear, I'll give it a look sometime soon . Would like to know better ways to tackle these sort of limits ! |
@skirpichev I had written to you on gitter few days back , continuing our discussion on the performance of the series module in diofant and sympy . I tried to reach out to you there so that I do not to disturb the purpose of the pr which our discussion would end up doing eventually . |
Thank you for the report, I've deleted my gitter account. Feel free to reach me in any public space of the Diofant project. If you see an issue - report, please. |
Thanks @skirpichev for the reply , I had some doubts regarding implementation of order based on multivariate expressions in sympy and diofant . There were some comments pointed on a pr of mine by jksoum (didn't use @ to prevent unnecessary reference)
That makes no sense, 3)
would mean that |x + 2y| < M|x + y| for some constant M, at least when x and y are close to 0, but that is obviously not true: x + 2*y need not be 0 when x + y is 0 (except when both variables are 0). This type of definition might be meaningful but probably impossible to implement in general. I think that the only feasible definition in multivariable case is the one where leading terms are taken in a definite order. First, the leading term of f(x, y) wrt. x would be something like The points raised here are quite legit and would I be great if I could look into these and address these during Gsoc . But I am not clear regarding what should be the probable answers then
Hence I would like to know your views on this and how could we maybe incorporate what he says ,cause the things being pointed out are quite valid and I feel should be addressed ! |
I see here
What else do you expect?
All this seems to be wrong, indeed. See also sympy/sympy#6822
Well, there is a reference (wikipedia article). f(x)=O(g(x)) as x->p iff there exists M: |f(x)|<=M |g(x)| in a some neighbourhood of x=p. Most code for multivariate O probably doesn't use this definition. For most expressions, I doubt there are too much possible correct (and simple!) transformations for the O constructor: you can drop a constant for the Mul expression, or take a leading term if one factor is an univariate expression... Probably, it's fine to use original expressions in all examples above. BTW, I'm not sure, that the multivariate O notation is useful at all. |
FYI: #1228 |
Thanks @skirpichev , I feel maybe we could go with the sequential leading term protocol that we have been following . |
Another issue I had but can't comprehend of a solution is something which
Now I would be glad if I you could guide me tackle this as there is no clear way for me to go here . This also seems to be a very interesting problem to me as this makes me question both the standard p-series test and also the result from |
Any meaningful definition of the multivariate Order should a restriction of the quoted above. Is this happens in your case? Second, in which case your definition could be useful practically? Currently, the univariate order is used only for series (i.e. to get a form
This branch seems to be wrong.
That's a correct simplification. |
Okay , I guess I need to give more thought about these things . I haven't taken into account the usage and other thing it could affect as of now .I'll give more thought on this and get back to you . Till then I would like to hear your views on the same . Did you stumble upon any approach or idea since when I told you about the issue here ?? If you think there's a somewhat correct direction to proceed here , I would like to build upon that.
Could you maybe tell me how though ? I mean p_series test is standard right ! whenever the power is greater than or equal to -1 the series is divergent ! |
Your above sum with the term |
Another issue I have been trying to solve is based on a log rewrite for series expansion at a complex branch cut . Diofant is close but fails due to different reasons , sympy maybe needs more work here .
The results aren't too different as wolfram shows The case of |
First result is odd. Second is correct, isn't? -oo case seems incorrect too (by -1 factor?). |
Yupp the first result needs improvements, |
Another issue I had seen in diofant and thought of letting you know was the following . Series for the inverse error functions fails at two prominent points which are +1 and -1
|
Thanks, PoleError is a wrong error here. See #1233. I would appreciate a bugreport next time, however. |
No description provided.