from pylab import *
from scipy import *
from numpy import *
from scipy.io import read_array
from scipy import integrate
def Jotn(f,a):
I=integrate.quad(lambda t: exp(-f*(1+a*sin(t))),0.,2*pi) / (2*pi*exp(-f))
return(float(I[0]))
print (Jotn(10,0.1))
f,a = meshgrid(arange(1, 10, 0.1),arange(0, 0.2, 0.1))
Z=Jotn(f,a)
figure()
cmap = cm.get_cmap('jet', 100) # 100 discrete colors
im = plt.imshow(Z, interpolation='nearest', origin='lower',cmap=cm.gray, extent=(1,10,0,1))
show()
выдаёт
./maxwell.py
1.26606587775
Traceback (most recent call last):
File "./maxwell.py", line 48, in <module>
Z=Jotn(f,a)
File "./maxwell.py", line 44, in Jotn
I=integrate.quad(lambda t: exp(-f*(1+a*sin(t))),0.,2*pi) / (2*pi*exp(-f))
File "/usr/lib/python2.6/dist-packages/scipy/integrate/quadpack.py", line 185, in quad
retval = _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points)
File "/usr/lib/python2.6/dist-packages/scipy/integrate/quadpack.py", line 249, in _quad
return _quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit)
quadpack.error: Supplied function does not return a valid float.