from sympy import *
def f(t):
f = 2000*log(140000/(140000-2100*t))-9.8*t
return f
a = 8
b = 30
x = symbols('x')
truth = integrate(f(x),(x,a,b)).evalf()
print(truth) #真值
n = 2 #步长,就是将(a,b)区间分为多少个块
h = (b-a)/n
result = h* f(h*(-1/sqrt(3))+(b+a)/n) + h* f(h*(1/sqrt(3))+(b+a)/n)
print(result.evalf())
结果:
11061.3355350810
11058.4407811414