Back to the on-screen lesson ·

The trapezoid, midpoint and Simpson rules

Three quadrature rules from integrating an interpolant, the degree each is exact on, and the weighted combination in which two of the errors cancel.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

By the end of this lesson you will be able to apply the trapezoid, midpoint and Simpson rules, state the degree of polynomial each integrates exactly, explain why Simpson's rule reaches one degree higher than the curve it fits, and say why a cubic is a useless test of it.

2. What you already know

You can integrate a polynomial exactly, and you know that an interpolating polynomial agrees with a function at its nodes. A quadrature rule is what you get by integrating the interpolant instead of the function.

3. The words this lesson uses

A quadrature rule estimates an integral as a weighted sum of function values. Its degree of exactness is the highest degree of polynomial it integrates exactly. A panel is one subinterval; a rule is composite when it is applied to each panel and the results added. A rule is closed when it samples the endpoints and open when it does not.

4. The trapezoid, midpoint and Simpson rules

Integrate the interpolant rather than the function. Through the two endpoints that gives the trapezoid rule $\dfrac{b-a}{2}\big(f(a) + f(b)\big)$, exact on straight lines, with error $-\dfrac{(b-a)^{3}}{12}f''(\xi)$ — too large when the curve bends upwards, because the chord lies above it. Through the single midpoint it gives the midpoint rule $(b-a)f\!\left(\tfrac{a+b}{2}\right)$, also exact on straight lines, with error $+\dfrac{(b-a)^{3}}{24}f''(\xi)$: the opposite sign and half the size. Those two facts together are the whole of Simpson's rule, because the weighted average that cancels both errors is $\dfrac{2M + T}{3} = \dfrac{b-a}{6}\big(f(a) + 4f(\tfrac{a+b}{2}) + f(b)\big)$. Simpson's rule fits a parabola and is exact to degree three: the cubic part of the error is odd about the midpoint and integrates away for free. Its error is $-\dfrac{(b-a)^{5}}{2880}f^{(4)}(\xi)$, so a quartic is the first integrand it gets wrong — and therefore the first honest test of an implementation.

Another way: picture

Draw a curve bending upwards over one panel. The chord from end to end sits above it, leaving a sliver of overestimate; the flat line at the midpoint height sits below, leaving a sliver of underestimate that is half the size. Weight them two to one in favour of the smaller error and the slivers cancel.

Another way: steps

  1. Choose the rule and, for Simpson, an even number of panels.
  2. Compute the panel width and the sample points.
  3. Apply the weights: $1, 1$; or $1$ at the middle; or $1, 4, 2, 4, \ldots, 1$.
  4. Multiply by the width over $2$, $1$ or $3$ as the rule requires.

5. The mistake to watch for

The degree of exactness of a rule is not the degree of the curve it fits. Simpson's rule fits a parabola and integrates cubics exactly; the Gauss rules do better still with the same number of samples. The extra degree comes from symmetry, not from the fit, and it is the reason a test of quadrature code must use a polynomial above the rule's degree of exactness — a cubic test of Simpson's rule reports zero error at every panel count and measures nothing whatever.

6. Why the two errors are in the ratio two to one

  1. Over one panel the trapezoid error is $-\tfrac{h^{3}}{12}f''$ and the midpoint error is $+\tfrac{h^{3}}{24}f''$.

    Opposite signs, sizes in the ratio 2:1.

  2. So $\tfrac{2M + T}{3}$ has error $\tfrac{2(h^{3}/24) - h^{3}/12}{3} f'' = 0$ to this order.

    The leading terms annihilate.

  3. What is left is the $f^{(4)}$ term, and the combination is Simpson's rule.

    Two crude rules make one good one.

7. Simpson on a cubic

  1. $\int_0^{2} x^{3} = 4$. Simpson: $\tfrac{2}{6}(0 + 4 \times 1 + 8) = 4$.

    Exact.

  2. Trapezoid gives $\tfrac{2}{2}(0 + 8) = 8$ and midpoint gives $2 \times 1 = 2$.

    Errors $+4$ and $-2$.

  3. And $\tfrac{2 \times 2 + 8}{3} = 4$: the cancellation, in numbers.

    The ratio holds exactly here.

8. Your turn: the trapezoid and midpoint estimates of $\int_0^{1} x^{2}$

  1. Trapezoid: $\tfrac12(0 + 1) = \tfrac12$, against the true $\tfrac13$.

  2. Midpoint: $1 \times \tfrac14 = \tfrac14$, an error of $-\tfrac{1}{12}$ against the trapezoid's $+\tfrac16$.

  3. Your turn: work this step out. Its working is at the end of the packet.

    And $\tfrac{2 \times \frac14 + \frac12}{3} = \tfrac13$: Simpson, exact.

9. Guided practice

Estimate $\displaystyle\int_0^{2} x^{3}\,dx$, whose exact value is $4$, by each of the three rules on the whole interval. Give the estimate and the error of each, as fractions where they are not whole numbers.

EstimateError
Trapezoid rule
Midpoint rule
Simpson's rule

10. Guided practice

Simpson's rule on $[0, 4]$ fits a parabola through the two ends and the midpoint. On which polynomials does it give the exact integral?

11. Practice

Four rules are applied to $\displaystyle\int_0^{6} f$ with a curve that bends upwards throughout. Match each to what it does.

Exact on constants only, with an error proportional to the panel widthExact on straight lines, and too large on a curve bending upwardsExact on straight lines, and too small by half as muchExact on cubics, although it only ever fits a parabola
The left endpoint rule
The trapezoid rule
The midpoint rule
Simpson's rule

12. Practice

Simpson's rule is to be applied with about $18$ panels. Put the five steps into order.

Number the steps in order (write the number in the box):

13. Somewhere new

Apply Simpson's rule on the whole interval to $\displaystyle\int_0^{1} x^{4}\,dx$. By how much does it miss the exact value? Give a fraction.

Answer:

14. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

15. Test question

Estimate $\displaystyle\int_0^{5} x^{2}\,dx$ by the trapezoid rule on two equal panels, and give the error. Write each as a fraction where it is not a whole number.

Estimate est, error err

16. What you can do now

You can apply all three rules and give the degree of exactness and the error sign of each. Say in your own words why Simpson's rule is the weighted average of the other two.

Working for the steps left to you

8. Your turn: the trapezoid and midpoint estimates of $\int_0^{1} x^{2}$, step 3