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
limit(1/x, x, 0) == oo ?? #11667
Comments
I want to work on this. Can someone give me a hint on where to start..? |
I don't know to much about Sympy, but the logic say to me, when you don't send a direction you should calc the limit in both sides, then compare it, if are equals return the value, if not return nan. |
There are some older issues about this, if you search. It would be nice to make limit bidirectional by default. |
bidirectional by default meaning the same logic that is described in the previous comment by latot? |
I think it would make more sense to raise an exception when the different sided limits differ. |
Hi, sadly i'm not agree, conceptually the limit of an discontinuous functions is simply not defined, i think that is nan, or the expression you like, but an exception i think its too heavy, you can check the limit basically for tree reasons, get the right limit, get the left limit and get the limit of a point, in this last case its the same to check if the limit exist, actually Sympy works with discontinuous functions, at least to me don't have to much sense send the exception with this in mind. Thx.Cya. |
The nice thing about an exception is that it could contain a message indicating to the user why the limit failed. |
mmm, if i'm right.. so, can be only in a practical case, i start working with discontinuos function, think in piecewise or |
I don't see why you wouldn't need to check for |
mm, i think an example will be better, lets imagine we have a n count of functions, f1, f2, f3..... Thx. Cya. |
Note that |
Hi, i try calc the limit with this but instead have a raise of the limit don't exist i get a
for now i think conceptually its fine send an exception if the limit can't be calculated, that is because sympy can continue be improved, but an undefined value i think have other meaning. |
Yes, i also think raising exception will be more appropriate. I will try to implement it. |
Hi, I submitted a pull request for a patch to this a few hours ago #11694 . Currently, if the bidirectional limit doesn't exist, the function returns None, since there is no limit at that point. |
This is not a bug. If you want to calculate the result from both sides, set the
|
mm, i think is very very not intuituve, from the "default" concept of limit, when you eval it, should be from both directions, usually asking a limit means compare the limits from all directions to get it, and if all are the same return that value. Sympy have a default value for dir when is not given, but that default value is different from what usually i think we expect from getting in the limit function. |
The docstring says:
So will have to work as the docstring says. |
Hi, i don't think is a good idea, at least, is not following the limit concept, why not change the doc? I think this can follow the actual definition of limit (in math), (in general when we talk about limit). |
See also: #8341, #14387, #8320.
|
My understanding is that complex limits aren't implemented at all, and it would require some work to implement them. I would also like to see the default move to bi-directional. The main concern is how robust the bi-directional code is.
The proper thing to return would be The advantage of an exception is that it can indicate in the message why the limit didn't work, e.g., for a bidirectional limit that the two-sided limits exist but were not equal. |
For example, the code that deals with bidirectional limits just does a simple Lines 263 to 269 in 5899a5c
Meaning if the limits are equal but don't come out exactly symbolically identical, it will think the limit doesn't exist. I'm also interested to know if limit algorithm itself could work bi-directionally, rather than computing the whole limit twice. That would be more efficient and potentially more robust, depending on how the algorithm works. My guess is that if we made Finally, it should be noted that changing the default for |
I guess what bothers me is that to me it feels a bit as if |
Except if execution doesn't end up in
Whether or not differing left and right limits entail an exception or |
In the |
Maybe there can be a special kind of In [2]: p = Piecewise((x*cos(y), y<0), (1-y, y>=0))
In [3]: p
Out[3]:
⎧x⋅cos(y) for y < 0
⎨
⎩ 1 - y otherwise
In [4]: p.limit(y, 0, '+')
Out[4]: 1
In [5]: p.limit(y, 0, '-')
Out[5]: x
In [6]: p.limit(y, 0, '+-')
---------------------------------------------------------------------------
ValueError This could perhaps return: In [6]: L = p.limit(y, 0, '+-')
In [6]: L
Out[6]: BidirectionalLimit(x, 1)
In [6]: L.subs(x, 1)
Out[6]: 1
In [6]: L.exists
Out[6]: x = 1
In [6]: L.lhs
Out[6]: x
In [6]: L.subs(x, 2)
Out[6]: UnequalBidirectionalLimit(2, 1) |
I guess |
Hi, just as a complement, the direction concept depdends in the numbers of vars we are working, so in the actual case of the issue, there is one var, so the only directions are (+) and (-), but if we have 2 var then we will have (var1, var2)... (+,+), (+,-), (-+), (-,-), so the number of directions would be 2^number of vars..., so when we have a lot of variables we will need check a lot of directions. When we want the limit is just compare all the values i write above and if they are the same we can know there is a limit, this is just to consider not only the 1 var case. |
There are other ways a limit might not exist other than the bidirectional limit case, and I think it's reasonable to assume SymPy could show it in some of those cases. We already have AccumBounds which is close to this for periodic limits. By the way, I noticed that
Multidimensional limits aren't really supported. There are more than 4 directions for 2 variables. There are an infinite number of directions. For a limit to exist you want it to be path independent. I don't think it's worth discussing multidimensional or complex limits too much until we can actually implement something useful for them.
As for zoo, I think if a limit gives oo in one direction and -oo in another then zoo is a reasonable answer. Or at least it is for 1/z, where zoo is the complex limit. Maybe it would be more problematic in cases where the complex limit isn't always zoo. |
Closes sympy/sympy#19442 Closes sympy/sympy#11667
Closes sympy/sympy#19442 Closes sympy/sympy#11667
Hi, well, what definition of limit are you using? or this is a bug.
I search if this issue exist and i can't found it, if i search bad close it please.
Thx. Cya.
The text was updated successfully, but these errors were encountered: