Exercise: trapezoid and midpoint
Comparing composite trapezoid, simple midpoint and composite midpoint, with absolute and relative errors.
Comparison on a short integral
Compute . Compare composite trapezoid with , simple midpoint and composite midpoint with .
The exact value is:
For composite trapezoid with , and the nodes are :
For simple midpoint, the centre of the full interval is :
For composite midpoint with , the centres are and :
The absolute and relative errors are:
In this example, composite midpoint with two subintervals is the most accurate of the three. The improvement comes from using two centres instead of one rectangle for all of [0,1].
Using only interior points
Compute I=∫_0^{π/2} sin(x)e^{-x} dx with composite midpoint using n=4 and n=8.
The exact value is the same as in the previous exercise:
The midpoint approximations are:
Their absolute errors are:
The error decreases when the number of subintervals increases, but here it remains larger than Simpson's for the same refinement.