I am trying to take a relatively simple limit using sympy:
from sympy import *
f,k,b = symbols('f k b')
test = f**b - k**b
limit(test,k,f)
I am expecting 0, but I am getting:
>>> limit(test,k,f)
f**b - exp(b*log(f))
Mathematically this is correct (and zero), but why doesn't it evaluate to zero?
Note if I define:
from sympy import *
f,k,b = symbols('f k b')
test = exp(b*log(f)) - exp(b*log(k))
limit(test,k,f)
then I do get zero.
It would be incorrect to assert the limit is zero in general. Consider the following computation in Python console:
>>> (-1)**(1/2)
(6.123233995736766e-17+1j)
>>> (-1 - 1e-15j)**(1/2)
(5.053215498074303e-16-1j)
Because of the branch cut of complex square root along the negative real axis, the two extremely close values of the base produce quite different results (the difference is about 2j).
The limit is indeed zero if we stick to positive base and real exponents
from sympy import *
k = symbols('k')
f = symbols('f', positive=True)
b = symbols('b', real=True)
test = f**b - k**b
limit(test,k,f) # returns 0