1Single interval¶
The trapezoidal rule approximates the integral as the area below the
straight line approximation
∫abf(x)dx≈(b−a)2f(a)+f(b) Another
approximation to the area is to use the function value at the mid-point
∫abf(x)dx≈(b−a)f(2a+b) Let c=(a+b)/2. Using Taylor formula
f(x)=f(c)+(x−c)f′(c)+21(x−c)2f′′(ξx),ξx between x and c Integrating both sides
∫abf(x)dx−(b−a)f(2a+b)=21∫ab(x−c)2f′′(ξx)dx Using integral mean value theorem, the error is
∫abf(x)dx−(b−a)f(2a+b)=21f′′(η)∫ab(x−c)2dx=24(b−a)3f′′(η),η∈[a,b] 2Composite rule¶
Let us partition [a,b] into n intervals each of width h=(b−a)/n. The mid-points of these intervals are
xj=a+(j−21)h,j=0,1,…,n−1 The integral is given by
∫abf(x)dx=j=1∑n−1∫xj−1xjf(x)dx=j=1∑n−1hf(xj)+24h3j=1∑nf′′(ηj),ηj∈[xj−1,xj]=In(f)+En(f) where
In(x)=h[f0+f1+…+fn−1] and the error is
En(f)=24h3j=1∑nf′′(ηj)=24nh3[n1j=1∑nf′′(ηj)]=24(b−a)h2f′′(η),η∈[a,b] 3Integral error estimate¶
Using Taylor formula with integral remainder term
f(x)=f(c)+(x−c)f′(c)+∫cx(x−t)f′′(t)dt The error in mid-point rule is
∫abf(x)dx−(b−a)f(c)=∫ab∫cx(x−t)f′′(t)dtdx By change of order of integration
∫ab∫cx(x−t)f′′(t)dtdx=∫cb∫tb(x−t)f′′(t)dxdt−∫ac∫at(x−t)f′′(t)dxdt=∫cb2(b−t)2f′′(t)dt+∫ac2(a−t)2f′′(t)dt Using this estimate, the error of the composite rule is
∣En(f)∣≤4h4∫ab∣f′′(t)∣dt This error is more than that of trapezoidal rule, which seems strange.