next up previous contents
Next: Richardson Extrapolation Up: Notes on numerical integration Previous: Error of the extended

Digit-shift test

To illustrate the ideas of Section 2.3, the second column of Table 1 displays the result of the trapezoid rule (13) for the integral

displaymath945

as a function of the number of intervals N.

   table288
Table 1: Results of trapezoid and Simpson's integration of tex2html_wrap_inline955 for N intervals

Displayed in this way the data for the trapezoid rule exhibit an interesting pattern: each increase in the number of intervals N by a factor of ten shifts the pattern of digits (``901'') representing the error two places to the right. This is the visual representation of our mathematical analysis: the shifting to the right by two places corresponds precisely to quadratic scaling of the error with h and the pattern of shifting digits represents precisely the prefactor on tex2html_wrap_inline799 in (16),

eqnarray302

Displaying the results of a numerical calculation in this way is a very powerful tool for detecting bugs and correcting errors. The tex2html_wrap_inline799 convergence of the trapezoid rule is quite delicate and even small programming errors will destroy it. The third column of the table, for instance, shows the typical behavior when the factor of 1/2 is forgotten at the end points and/or when dividing by N-1 instead of N. A routine with either bug indeed converges to the correct result, but the convergence is only linear in h and such subtle bugs are easily detected.



Tomas Arias
Sun Mar 5 13:48:24 EST 2000