import scipy as sp
import numpy as np
from sympy import *
import matplotlib.pyplot as plt
def fun(x):
return [np.sin(el)/el for el in x]
end = 100
trap = 10000
x = np.linspace(0.001, end, trap)
y = fun(x)
#分割近似求积分
print sum(y)*end/trap*2
print scipy.integrate.quad(lambda x:np.sin(x)/x, 0.001,np.inf)
print scipy.integrate.quad(lambda x:np.exp(-x), 0,np.inf)
z = symbols('z')
print sympy.integrate(sin(z)/z, (z, 0, oo))
plt.plot(x,y)
plt.show()
scipy算积分有bug
原文作者:14142135623731
原文地址: https://www.jianshu.com/p/47eac18f08bf
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
原文地址: https://www.jianshu.com/p/47eac18f08bf
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。