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' in combination with 'positive=True' gives wrong result #22893
Comments
True , this is a somewhat distantly known error in sympy and has been reported various at multiple locations . Check this one out which I did catch myself #22334 .It's not that difficult to find sympy returning different results for limits evaluated for different forms of the expressions(using This seems to be due to the
|
@jksuom @0sidharth Currently there are more than a couple of issues based on such backgrounds(I remember 3 atleast at this moment) . These problems basically boil down to calculating symbolic limits (in different forms after simplifying, using I see that many of these boil down the core of the gruntz algorithm which is the
If we don't have any particular assumption on
It's either '>' or '<' and this is one of the prominent reasons why we encounter these cases . Hence whenever a user declared the variable
Hence whenever we tackle |
I have encountered a problem with the 'limit' function in combination with the 'positive=True' assumption on symbols. Here is a minimal example that reproduces the problem:
a, b = symbols("a b", positive=True)
my_expr = (a * exp(-a*x) + b * exp(-b * x)) * exp(b * x)
limit(my_expr,x,oo)
which returns
oo
while the result should be
b
,a+b
oroo
, depending on the sign of (b-a).When the 'positive=True' assumption is removed, as in
a, b = symbols("a b")
my_expr = (a * exp(-a*x) + b * exp(-b * x)) * exp(b * x)
limit(my_expr,x,oo)
the result is
NotImplementedError: Result depends on the sign of -sign(a)
which is OK, but actually the result depends on the sign of b-a only, not on the sign of a.
If the expression is expanded before evaluation, as in
a, b = symbols("a b", positive = True)
my_expr = (a * exp(-a*x) + b * exp(-b * x)) * exp(b * x)
limit(my_expr.expand(),x,oo)
the result is
NotImplementedError: Result depends on the sign of sign(-a + b)
which is the correct behavior from my point of view.
The text was updated successfully, but these errors were encountered: