I have defined a function in Python 2.7.15 which takes two inputs (b,v)
, but I have noticed that f(50,0.1)
produces very different results to those of f(50.0,0.1)
. This is the function:
def f(b,v):
h=b*v/math.sqrt(1-v**2)
def dJ_dp(J,p):
return [J[1],-J[0]+3.0/2*J[0]**2+1/(2*h**2)]
J0 = [0.0000001,1/b]
ps = np.linspace(0,15,50)
Js = odeint(dJ_dp, J0, ps)
us = Js[:,0]
return (ps,1/us)
I've needed to define dJ_dp
inside f(b,v)
because it needs the value h
. Why are the outputs so different? Why are they different at all?
My hypotheses was that something went wrong when defining h
but that doesn't seem to be the case.