This program should find the difference between the integral of a specific function and the number obtained with the trapezoid formula.
I expect to get some values within a range so I can graph them, but instead this is what I am getting:
generator object <genexpr> at 0x000001A1B1A66F48
I expect to get some values within a range so I can graph them, but instead this is what I am getting:
generator object <genexpr> at 0x000001A1B1A66F48
a=0 b=1 n=500 h=(b-a)/(n) def f(x): return x**2 def trapezoidal(f,a,b,n): return (h/2)*(f(a)+f(b))+h*( sum(f(a+h*i) for i in range(1, (n-1))) ) print(trapezoidal(f,a,b,n)) lambda x: f(x) c= integrate.quad(f,0,1) print(c) error=(abs(trapezoidal-c) for n in range (300,900)) print(error)