The trapezoid rule is a very simple method for estimating integrals. The idea is to approximate the area under a curve by a bunch of thin trapezoids and add up the areas of the trapezoids as suggested in the image below.

This is an old idea, probably older than the formal definition of an integral. In general it gives a crude estimation of the integral. If the width of the trapezoids is *h*, the error in using the trapezoid rule is roughly proportional to *h*^{2}. It’s easier to do better. For example, Simpson’s rule is a minor variation on the trapezoid rule that has error proportional to *h*^{5}.

So if the trapezoid rule is old and inaccurate, why does anyone care about it? Here are the surprises.

- You can still get a publication out of the trapezoid rule! In 1994, a doctor published a paper reinventing the trapezoid rule. Not only did the editors not recognize this ancient algorithm, the paper has been cited many times since it was published. (Update: more about the trapezoid paper here.)
- Although the trapezoid rule is inefficient in general, it can be shockingly efficient for periodic functions.
- The trapezoid rule can also be shockingly efficient for analytic functions that go to zero quickly, so called double exponential functions.

The last two observations are more widely applicable than you might think at first. What if you want to integrate something that isn’t periodic and isn’t a double exponential function? You may be able to do a change of variables that *makes* your integrand have one of these special forms. The article Fast Numerical Integration explains an integration method based on double exponential functions and includes C++ source code.

The potential efficiency of the trapezoid rule illustrates a general principle: a crude method cleverly applied can beat a clever technique crudely applied. The simplest numerical integration technique, one commonly taught in freshman calculus, can be extraordinarily efficient when applied with skill to the right problem. Conversely, a more sophisticated integration technique such as Gauss quadrature can fail miserably when naively applied.

**Related posts**:

I have to admit, I used it fairly recently to estimate the percentage points of distributions (a gamma curve in this case). I switched between this and simpsons rule, but this gave me the number of decimal places I needed without evaluating the function too many times.

I did this first before attacking some of the numerical recipes and to get something going. It did become a bottle neck as I was searching for the ML estimate of the parameter, and that’s when I implemented all of those antiquated numerical recipes; translated from FORTRAN and GOTO laden C –I took some effort and removed all of those constructs. I should probably distribute that code somewhere, not really sure where though.

That doctor’s paper is just depressing. Good grief, he even named it after himself!

I have to disagree: Simpson’s formula depends on the midpoint, which trapezoid rule does not need.

IMO, there’s nothing at all wrong publishing a new take on a well-known procedure or rule, particularly in mathematics. However, taking credit for it either indicates poor scholarship, or arrogance and fraud. The lack of scholarship might have been the basis for suggesting the paper be rewritten, thereby improving its quality, but there’s nothing wrong with taking a different approach.

John,

There is (at least) one more important application, which is estimating areas under an unknown curve, such as measuring a surrogate of exposure to drug after it has been taken. In that case, blood samples are taken on a schedule, and the trapezoidal rule is used to estimate the area under the curve. Of course, we assume these curves have an exponential form in the tail.

John,

The double exponential integration material is quite interesting.

Minor correction: Reference [3] in your Double exponential integration should be Masatake Mori, not Masataka Mori.