Problem 30, Section 8.7

First of all, calculate the exact error: since you can calculate the exact integral, you can find the true error by subtracting your estimate from this value (I=8.12481).

I also calculated the ratios of the errors, to see if I could discern a pattern in their change. Doubling the step-size cuts the error by a factor of 4 for trapezoid and midpoint; it cuts the error by a factor of 16 for Simpson's rule. This is as it should be, given the form of the error terms.

trapezoidal midpoint Simpson's
n=6 8.583514 7.896632 8.136885
n=12 8.240073 8.067259 8.125593
e_n=6 -0.458704 0.228178 -0.012075
e_n=12 -0.115263 0.057551 -0.000783
ratios 3.979627 3.964824 15.427180

Here's a plot of the errors, for the two cases of n=6 and n=12. Trapezoidal errors are the greatest, then midpoint errors; you can see that if you double the midpoint error and add it to the trapezoidal error, the result should be about 0. This is the idea of Simpson's rule.

Just for fun, here's a plot of the ratios of n=6 errors divided by n=12 errors. You see that they're about a factor of 4 for a doubling of the number of steps n.

I used freely-available Xlispstat to generate these results (here's the xlispstat code I wrote to work this example). Ask me about it if you'd like to put xlispstat on your computer!


Website maintained by Andy Long. Comments appreciated.