When I evaluate the following function
def f(k,varvz,D,z): return np.exp(-(k*(np.sqrt(z**2 + D**2)-D)+(0.041-0.0094*k)*z**2)/varvz) def g(k,varvz,D): return integrate.quad(f,-np.inf,np.inf,args=(k,varvz,D)) a,err= g(1.24,9.61,1.8) print a I get infand the following error message
inf c:\users\user1\appdata\local\temp\tmp5iuiuo.py:11: RuntimeWarning: overflow encountered in exp return np.exp(-(k*(np.sqrt(z**2 + D**2)-D)+(0.041-0.0094*k)*z**2)/varvz) But if I change the order of arguments in the definition of f
def f(z,k,varvz,D): return np.exp(-(k*(np.sqrt(z**2 + D**2)-D)+(0.041-0.0094*k)*z**2)/varvz) def g(k,varvz,D): return integrate.quad(f,-np.inf,np.inf,args=(k,varvz,D)) a,err= g(1.24,9.61,1.8) print a I get the desired result 14.5716742277
Why is this so?
Thanks
args=(k,varvz,D)?