Reputation: 57
I want to calculate the limit of the exp((a-b)*x)
function to x
tending to infinity, where symbols a and b were defined as real and positive:
a = Symbol('a', real=True, positive=True)
b = Symbol('b', real=True, positive=True)
However, the limit depends on the difference a-b
. If a<b
, the limit is zero. If a=b
, the limit is 1. If a>b
, the limit is infinity. How to set these conditions?
Upvotes: 4
Views: 328
Reputation: 19029
Let d = a - b
then define a Piecewise with the limits for different conditions:
>>> oolim = lambda A: limit(exp(A*x),x,oo)
>>> f = Piecewise((oolim(d), a>b), (oolim(0), Eq(a,b)), (oolim(-d),True)); f
Piecewise((oo, a > b), (1, Eq(a, b)), (0, True))
You could substitute a value for a
and/or b
into f
and the expression will evaluate/update:
>>> f.subs({a:3, b:5})
0
Upvotes: 1