The midpoint and trapezoidal rules and which over- or underestimates, Simpson's rule and its weights, absolute and relative error, the error-bound formulas, and choosing the number of subintervals to meet a tolerance.
Subject: Calculus II · 69 slides · symbolic lesson
Open the interactive version of this deck
Title
Calculus II · Section 3.6
When there is no antiderivative, add up heights, and know how far off you are
Objectives
Every technique in this chapter so far has ended with an antiderivative. Many integrals have none you can write down. This lesson approximates them, and, just as important, says how good the approximation is.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 316 — learning objectives 3.6.1 to 3.6.5
Everything in Chapter 3 so far has been about finding antiderivatives: by parts, trigonometric integrals, substitutions, partial fractions. This section admits the uncomfortable truth that for many integrands there is no antiderivative you can write down, and for data from the real world there is not even a formula to integrate.
So the question changes from what is the exact value to how close can you get, and how do you know. The first half of that question has three answers, the midpoint, trapezoidal and Simpson rules, which are all ways of adding up a handful of function values with sensible weights.
The second half is where the real skill lies. You will learn to say which direction an estimate errs in, to measure its error when you know the answer, and, most usefully, to guarantee its accuracy in advance when you do not.
Warm-up
Discussion prompt
Volume 1 defined the definite integral as a limit. Write down a Riemann sum for f on the interval from a to b, and say which choices go into it.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 316 — Riemann sums recalled
Write your answer before revealing it. This is the definition from Volume 1 that the whole lesson rests on, and it is worth being able to state precisely.
A Riemann sum needs two choices: a partition of the interval into pieces, and one sample point in each piece. Multiply the function's value at each sample point by the width of its piece and add. As the pieces shrink, every such sum approaches the integral.
Notice what that means: any single Riemann sum is already an approximation to the integral. The rules in this lesson do not replace the definition; they are particular, cleverly chosen Riemann sums, or averages of them, picked so that the approximation is good even when the pieces are not very small.
Section
Part 1
Concept
Figure (svg): The bell-shaped curve y equals e to the minus x squared, drawn from minus 2.2 to 2.2, with the region under it between x equals 0 and x equals 1 shaded.
\[ \int_0^1 e^{-x^2}\,dx \]
The integrand is continuous, so this integral exists. But no function built from powers, exponentials, logarithms and trigonometric functions has derivative e to the minus x squared, so the Fundamental Theorem gives you nothing to evaluate.
The same happens with data: a surveyor or a sensor gives you heights at a few points and no formula at all.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 316 — introduction
Look at the shaded region. It is a perfectly ordinary area under a smooth, positive curve, and it certainly has a value. Yet no function built from the ones you know has e to the minus x squared as its derivative. That is a theorem, not a failure of cleverness, so no technique from this chapter will ever crack it.
This integral is not an oddity. It is the heart of the normal distribution in statistics, and tables of its values have been computed for centuries by exactly the methods of this lesson.
The second situation is even more common in practice. An engineer measuring a flow rate every minute, or a surveyor measuring a width every hundred metres, has numbers but no formula. The Fundamental Theorem is useless there too. You need methods that use only values of the function.
Intuition
Figure (svg): Three copies of the same hump-shaped curve over one wide interval from a to b. Left: a flat rectangle at the curve's midpoint height. Middle: a trapezoid whose top is the chord joining the two end values. Right: a dashed parabola through the two ends and the midpoint, almost on top of the curve.
Cut the interval into pieces and, on each piece, swap the curve for a shape whose area you know: a flat top, a sloped top, or a parabola. Each rule in this lesson is one of those choices.
\[ \int_a^b f(x)\,dx \approx \sum_{i} w_i\, f(x_i) \]
All three end up as a weighted sum of function values. Only the sample points and the weights differ, and that difference decides the accuracy.
The three panels show the single idea behind every rule in this lesson. On a stretch of the interval, swap the curve for a simpler shape whose area you can compute exactly, then add those areas.
On the left the shape is flat: a rectangle as tall as the curve at the middle. In the middle it is a trapezoid, whose slanted top joins the curve's values at the two ends. On the right it is a parabola through three points of the curve. With one wide piece the flat and sloped shapes miss badly, while the parabola is already close to the true area of 3.65.
Look at the formula underneath. Each rule ends up as a weighted sum of heights. Once you see them that way, comparing the rules is just comparing where they sample and how they weight what they find.
Section
Part 2
Concept
Figure (svg): A positive curve over the interval from a to b, split into four equal subintervals. On each one a rectangle rises to the curve's height at the subinterval's midpoint, marked with a dot, so each rectangle's top crosses the curve.
Use equal widths and sample each subinterval at its midpoint.
\[ \Delta x = \frac{b-a}{n}, \qquad m_i = \frac{x_{i-1} + x_i}{2} \]
\[ M_n = \sum_{i=1}^{n} f(m_i)\,\Delta x \]
Midpoint rule (Theorem 3.3) — If f is continuous on the interval from a to b, the midpoint sums tend to the integral as n grows without bound.
\[ \lim_{n\to\infty} M_n = \int_a^b f(x)\,dx \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 316 — Theorem 3.3 and Figure 3.13
The midpoint rule is the Riemann sum with the most natural choices: equal widths, and the sample point in the middle of each piece. You already met it in Volume 1; here it becomes a tool with a name and a theorem.
Look at the picture. Each rectangle's top crosses the curve at its midpoint, so on one side of the midpoint the rectangle rises above the curve and on the other side it falls below. On a smooth curve those two slivers are nearly the same size, which is why the midpoint rule is surprisingly accurate.
Theorem 3.3 says that for a continuous function the midpoint sums approach the integral as the number of pieces grows. That is reassuring, but it does not tell you how many pieces are enough. The error bounds in Part 6 will.
Worked example
Estimate the integral with four subintervals, then compare with the exact value.
\[ \int_0^1 x^2\,dx, \qquad n = 4 \]
Find the width
Why: The interval has length one, cut into four.
\[ \Delta x = \frac{1 - 0}{4} = \frac14 \]
List the midpoints
Why: Halfway along each quarter.
\[ m_i = \frac18,\; \frac38,\; \frac58,\; \frac78 \]
Square each midpoint
Why: The function is x squared.
\[ f(m_i) = \frac{1}{64},\; \frac{9}{64},\; \frac{25}{64},\; \frac{49}{64} \]
Add the heights
Why: Common denominator 64.
\[ \frac{1 + 9 + 25 + 49}{64} = \frac{84}{64} \]
Multiply by the width
Why: Every rectangle has the same width, so it factors out.
\[ M_4 = \frac14 \cdot \frac{84}{64} = \frac{21}{64} \approx 0.3281 \]
Figure (svg): The parabola y equals x squared from 0 to 1 with four midpoint rectangles, of heights one sixty-fourth, nine sixty-fourths, twenty-five sixty-fourths and forty-nine sixty-fourths, their midpoints marked at one eighth, three eighths, five eighths and seven eighths.
Check against the exact value
Why: The Fundamental Theorem gives one third; the midpoint estimate is off by one part in 192.
\[ \int_0^1 x^2\,dx = \frac13, \qquad \left|\frac13 - \frac{21}{64}\right| = \frac{1}{192} \approx 0.0052 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 317 — Example 3.39
This example deliberately uses an integral you can do exactly, so that you can see how good the estimate is. Work through it one line at a time: width, midpoints, heights, sum, and multiply by the width.
Keeping fractions makes the arithmetic clean. The heights are the squares of one eighth, three eighths, five eighths and seven eighths, all over 64, and their numerators add to 84. One quarter of 84 over 64 is 21 over 64.
In the picture you can see why the answer is slightly low: the parabola bends upward, so on each rectangle the part poking above the curve is a little smaller than the part falling short. The check shows the shortfall is exactly one part in 192, about half a hundredth. Keep that number; the next part of the lesson explains exactly where it comes from.
Worked example
Estimate the length of the curve below with six midpoint rectangles.
\[ y = \tfrac12 x^2, \qquad 1 \le x \le 4 \]
Write the arc-length integral
Why: From Section 2.4.
\[ L = \int_1^4 \sqrt{1 + \left(\frac{dy}{dx}\right)^2}\,dx \]
Differentiate
Why: The derivative of one half x squared.
\[ \frac{dy}{dx} = x \;\Longrightarrow\; L = \int_1^4 \sqrt{1 + x^2}\,dx \]
Find the width and midpoints
Why: Three units cut into six.
\[ \Delta x = \tfrac12, \quad m_i = \tfrac54,\, \tfrac74,\, \tfrac94,\, \tfrac{11}{4},\, \tfrac{13}{4},\, \tfrac{15}{4} \]
Evaluate the integrand at each midpoint
Why: Four decimal places, as in the book.
\[ 1.6008,\; 2.0156,\; 2.4622,\; 2.9262,\; 3.4004,\; 3.8810 \]
Add and multiply by the width
Why: The six heights total 16.2862.
\[ M_6 \approx \tfrac12(16.2862) = 8.1431 \]
Figure (svg): The parabola y equals one half x squared drawn from x equals 1 to x equals 4, a thick arc rising from height one half to height 8, with a dashed straight chord between its ends for comparison.
Check against the exact length
Why: A trigonometric substitution (Section 3.3) gives the exact value; the estimate is low by less than 0.003.
\[ L = \left[\tfrac{x}{2}\sqrt{1+x^2} + \tfrac12\ln\left(x + \sqrt{1+x^2}\right)\right]_1^4 \approx 8.1458 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, pp. 317-318 — Example 3.40
The arc-length formula from Chapter 2 often produces integrals that are hard or impossible to evaluate, which makes it a natural customer for numerical methods. Here the integrand is the square root of one plus x squared.
The work is organised the same way as before. Three units cut into six gives width one half, and the midpoints run from five quarters to fifteen quarters in steps of one half. Evaluate the square root at each, add the six values, and halve the total.
This integral can in fact be done exactly with a trigonometric substitution, which is how the check works: the exact length is about 8.1458, so six rectangles came within three thousandths. The picture of the arc gives a quick sanity test too. An arc must be longer than the straight chord between its ends, and the chord is about 8.078, so an answer near 8.15 is believable.
Picture it
Figure (svg): The curve y equals the square root of 1 plus x squared from 1 to 4, nearly a straight line, with six midpoint rectangles of width one half under it.
The integrand of Example 3.40 is nearly a straight line over this interval. On a straight piece, the part of a midpoint rectangle above the line exactly matches the part below it, so the midpoint rule is exact for every linear function. Here the curve bends only slightly, and the estimate is correspondingly close.
This is the integrand from Example 3.40 with its six midpoint rectangles. Look at how nearly straight the curve is over this stretch. That is the reason the estimate is so good.
Think about a truly straight line first. On each rectangle, the line rises above the rectangle's top on one side of the midpoint and dips below it on the other, by exactly the same triangle. The two triangles cancel, so the midpoint rule gives the exact area under any straight line, with any number of rectangles.
Errors therefore come only from bending. A curve that barely bends, like this one, leaves only small errors. That observation will turn into the error bounds of Part 6, where the second derivative, which measures bending, controls everything.
Worked example
\[ \int_1^2 \frac{1}{x}\,dx, \qquad n = 2 \]
Find the width and midpoints
Why: Two halves of the interval from 1 to 2.
\[ \Delta x = \frac12, \qquad m_1 = \frac54, \quad m_2 = \frac74 \]
Evaluate one over x there
Why: Reciprocals of the midpoints.
\[ f\left(\tfrac54\right) = \frac45, \qquad f\left(\tfrac74\right) = \frac47 \]
Add the heights
Why: Common denominator 35.
\[ \frac45 + \frac47 = \frac{28 + 20}{35} = \frac{48}{35} \]
Multiply by the width
Why: Half of 48 over 35.
\[ M_2 = \frac12 \cdot \frac{48}{35} = \frac{24}{35} \approx 0.6857 \]
Check against the exact value
Why: The integral is ln 2; the estimate is low by less than a hundredth.
\[ \int_1^2 \frac{dx}{x} = \ln 2 \approx 0.6931, \qquad 0.6931 - 0.6857 = 0.0074 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 318 — Checkpoint 3.22
With only two rectangles this is a short computation, and the exact answer, the natural log of 2, is known, so you can judge the result.
The midpoints of the two halves are five quarters and seven quarters, and their reciprocals are four fifths and four sevenths. Adding those over the common denominator 35 gives 48 over 35, and half of that is 24 over 35, about 0.6857.
The check shows the estimate is low by about seven thousandths. That is not an accident. The curve one over x bends upward, just like the parabola in Example 3.39, and in both cases the midpoint rule came out low. Hold on to that pattern; Part 4 turns it into a rule.
Section
Part 3
Concept
Figure (svg): A positive curve over the interval from x zero to x four, split into four equal subintervals. Each piece is a trapezoid: vertical sides at the endpoints, and a slanted top joining the curve's heights at the two ends.
Join the curve's heights at the two ends of a subinterval by a straight chord. The region under the chord is a trapezoid: its parallel sides are the two heights and its width is the subinterval's width.
\[ \text{area} = \tfrac12 h(b_1 + b_2) \]
\[ \text{first trapezoid} = \tfrac12\,\Delta x\,\bigl(f(x_0) + f(x_1)\bigr) \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, pp. 318-319 — Figure 3.14
The midpoint rule replaces the curve by a flat top on each piece. The trapezoidal rule replaces it by a slanted top: the straight chord joining the curve's values at the two ends of the piece.
The region under a chord is a trapezoid lying on its side. Its two parallel sides are the vertical heights at the ends, and its width is the width of the piece. The area of a trapezoid is its width times the average of its parallel sides, which gives one half times the width times the sum of the two end values.
Look at the picture. Where the curve bends upward the chord rides above it, and where it bends downward the chord cuts beneath. Unlike the midpoint rectangle, the chord's error has one sign on each piece. That will matter shortly.
Concept
Write out all four trapezoids for n equal to 4 and add.
\[ \tfrac12\Delta x\bigl(f_0 + f_1\bigr) + \tfrac12\Delta x\bigl(f_1 + f_2\bigr) + \tfrac12\Delta x\bigl(f_2 + f_3\bigr) + \tfrac12\Delta x\bigl(f_3 + f_4\bigr) \]
Take out the common factor one half of the width. Each interior value is the right side of one trapezoid and the left side of the next, so it appears twice; the two end values appear once.
\[ = \tfrac12\Delta x\bigl(f_0 + 2f_1 + 2f_2 + 2f_3 + f_4\bigr) \]
Trapezoidal rule (Theorem 3.4) — With equal widths and endpoints from a to b, the trapezoidal sums tend to the integral as n grows without bound.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 319 — derivation and Theorem 3.4
Write out the four trapezoid areas in full, as on the slide, before simplifying. The pattern is much easier to understand than to memorise.
Every term carries the same factor, one half of the width, so take it out. Then look at which function values remain. The first value appears only in the first trapezoid and the last only in the last. But each interior value is the right side of one trapezoid and the left side of the next, so it appears twice.
That is the whole reason for the weights one, two, two, two, one. If you ever forget the formula, draw three trapezoids side by side and count how many of them touch each point. This is Theorem 3.4, and like the midpoint rule it converges to the integral as the number of pieces grows.
Notation
Annotate
On: \( T_n = \frac{\Delta x}{2}\bigl(f(x_0) + 2f(x_1) + \cdots + 2f(x_{n-1}) + f(x_n)\bigr) \)
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 319 — equation 3.11
Step through the annotations and connect each part of the formula to the picture of trapezoids.
The factor in front is the width divided by two. The two comes from the average in the trapezoid area formula, and it is the part most often lost. The end values carry weight one because each belongs to a single trapezoid; every interior value carries weight two because two trapezoids share it.
The last annotation compares the rules' costs. The trapezoidal rule samples at the endpoints, one more point than the number of pieces; the midpoint rule samples in between, exactly one point per piece. Both are cheap, and later you will see that Simpson's rule uses exactly the trapezoidal rule's points, just with different weights.
Concept
Figure (svg): Two panels for y equals x squared on 0 to 1 with four subintervals. Left: rectangles using each subinterval's left endpoint, all under the curve, total 0.21875. Right: rectangles using the right endpoint, all poking above the curve, total 0.46875.
\[ L_n = \sum_{i=1}^{n} f(x_{i-1})\,\Delta x, \qquad R_n = \sum_{i=1}^{n} f(x_i)\,\Delta x \]
The left sum uses every point except the last; the right sum every point except the first. Add them and every interior point appears twice, the ends once: exactly the trapezoidal weights.
\[ T_n = \tfrac12\bigl(L_n + R_n\bigr) \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 319 — the observation after Theorem 3.4
The two panels show the left and right Riemann sums from Volume 1 for x squared with four pieces. On this rising curve the left rectangles all sit under the curve and the right rectangles all poke above it.
Now add the two sums. The left sum uses every point except the last, and the right sum every point except the first. So in the total, each interior point appears twice and each end point once. Halve the total and you have exactly the trapezoidal rule.
This is more than a curiosity. It shows why the trapezoidal rule is better than either one-sided sum: when one is too low and the other too high, their average lands between them. For this example the left sum is 0.21875 and the right sum 0.46875, and their average is 0.34375, which is the next example's answer.
Worked example
Estimate the same integral as Example 3.39, now with trapezoids.
\[ \int_0^1 x^2\,dx, \qquad n = 4 \]
List the endpoints and the width
Why: Five points for four subintervals.
\[ P = \left\{0,\, \tfrac14,\, \tfrac12,\, \tfrac34,\, 1\right\}, \qquad \Delta x = \tfrac14 \]
Write the rule
Why: One half of the width is one eighth.
\[ T_4 = \tfrac18\Bigl(f(0) + 2f\bigl(\tfrac14\bigr) + 2f\bigl(\tfrac12\bigr) + 2f\bigl(\tfrac34\bigr) + f(1)\Bigr) \]
Substitute the squares
Why: Each value is the point squared.
\[ T_4 = \tfrac18\Bigl(0 + 2\cdot\tfrac1{16} + 2\cdot\tfrac14 + 2\cdot\tfrac9{16} + 1\Bigr) \]
Add inside the bracket
Why: In eighths: 0, 1, 4, 9 and 8.
\[ 0 + \tfrac18 + \tfrac48 + \tfrac98 + \tfrac88 = \tfrac{22}{8} = \tfrac{11}{4} \]
Multiply by one eighth
Why: The trapezoidal estimate.
\[ T_4 = \tfrac18 \cdot \tfrac{11}{4} = \tfrac{11}{32} = 0.34375 \]
Figure (svg): The parabola y equals x squared from 0 to 1 with four trapezoids whose slanted tops join the points at 0, one quarter, one half, three quarters and 1; each top sits slightly above the curve.
Check with the average of the left and right sums
Why: The left sum is 7 over 32 and the right sum 15 over 32; their average agrees.
\[ \tfrac12\left(\tfrac{7}{32} + \tfrac{15}{32}\right) = \tfrac{11}{32} \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 320 — Example 3.41
This is the same integral as Example 3.39, so you can compare the two rules directly. The five endpoints are zero, one quarter, one half, three quarters and one, and the factor in front is one half of one quarter, which is one eighth.
Substituting the squares and doubling the three interior ones, the bracket becomes a sum of eighths: zero, one, four, nine and eight eighths, which is 22 eighths or eleven quarters. One eighth of that is 11 over 32.
The check uses the previous slide. The left sum is 7 over 32 and the right sum 15 over 32, and their average is exactly 11 over 32. In the picture, notice the thin red slivers between each chord and the curve: the chords all lie above this upward-bending curve, so the trapezoidal estimate comes out too high, while the midpoint estimate came out too low.
Worked example
\[ \int_1^2 \frac{1}{x}\,dx, \qquad n = 2 \]
List the endpoints and the width
Why: Three points.
\[ x_0 = 1,\; x_1 = \tfrac32,\; x_2 = 2, \qquad \Delta x = \tfrac12 \]
Write the rule
Why: One half of the width is one quarter.
\[ T_2 = \tfrac14\Bigl(f(1) + 2f\bigl(\tfrac32\bigr) + f(2)\Bigr) \]
Substitute the reciprocals
Why: The middle value is two thirds, doubled.
\[ T_2 = \tfrac14\Bigl(1 + \tfrac43 + \tfrac12\Bigr) \]
Add inside the bracket
Why: In sixths: 6, 8 and 3.
\[ 1 + \tfrac43 + \tfrac12 = \tfrac{17}{6} \]
Multiply by one quarter
Why: The trapezoidal estimate.
\[ T_2 = \tfrac{17}{24} \approx 0.7083 \]
Check against ln 2 and the midpoint estimate
Why: The exact value lies between the two estimates, just as the next part of the lesson will predict.
\[ M_2 = 0.6857 < \ln 2 = 0.6931 < 0.7083 = T_2 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 320 — Checkpoint 3.23
Two trapezoids on the interval from one to two. The points are one, three halves and two, and the factor in front is one half of one half, one quarter.
The middle value is two thirds, doubled to four thirds. Adding one, four thirds and one half gives seventeen sixths, and a quarter of that is 17 over 24, about 0.7083.
The check places this beside the midpoint estimate from Checkpoint 3.22. The midpoint estimate was low, the trapezoidal estimate is high, and the exact value, the natural log of 2, sits between them. You have now seen this happen twice, on two different upward-bending curves. The next part of the lesson explains why it must happen, and turns it into a way of trapping an unknown integral.
Trap
A common slip with Example 3.41:
\[ T_4 = \tfrac14\bigl(f_0 + 2f_1 + 2f_2 + 2f_3 + f_4\bigr) \]
\[ = \tfrac14 \cdot \tfrac{11}{4} = 0.6875 \]
Wrong: twice the right answer.
The doubled interior weights only make sense with the one half in front: each trapezoid is the width times the AVERAGE of its two sides. A sanity check catches it at once: 0.6875 is bigger than the right sum, 0.46875, which is impossible.
\[ T_4 = \tfrac{\Delta x}{2}\bigl(\cdots\bigr) = \tfrac{11}{32} \]
This is the most common arithmetic slip with the trapezoidal rule, and it doubles the answer. It happens because the weights one, two, two, two, one are memorised without the reason for them.
The two in the weights and the one half in front belong together: each trapezoid is its width times the average of its two sides, and the average is where the one half comes from. Drop it and every trapezoid counts twice.
Two quick checks catch it. First, a trapezoidal estimate always lies between the left and right sums, and 0.6875 is bigger than both. Second, the curve never rises above one on this interval of length one, so the area cannot exceed one half by much. A glance at the size of an answer is always worth the second it takes.
Section
Part 4
Concept
Figure (svg): One subinterval of the concave-up curve y equals e to the x, from 0 to 1.6, magnified. The chord joining the ends lies above the curve. The tangent line at the midpoint 0.8 lies below it. A dashed horizontal line at the midpoint height marks the top of the midpoint rectangle.
On a subinterval where the curve bends upward, every chord lies above the curve, so the trapezoid holds too much area.
The midpoint rectangle has the same area as the trapezoid under the tangent line at the midpoint, because the tangent tilts area from one half to the other without changing the total. An upward-bending curve lies above its tangents, so the rectangle holds too little.
\[ f'' > 0 \;\Longrightarrow\; M_n < \int_a^b f(x)\,dx < T_n \]
\[ f'' < 0 \;\Longrightarrow\; T_n < \int_a^b f(x)\,dx < M_n \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 319 — Figure 3.15 and the discussion before it
This magnified picture explains everything you have noticed so far. Start with the chord, the top of the trapezoid. On a curve that bends upward every chord lies above the curve, so each trapezoid includes an extra lens of area, shaded red. The trapezoidal rule overestimates.
The midpoint rectangle needs one more idea. Tilt the flat top of the rectangle about its midpoint until it becomes the tangent line there. The triangle you add on one side equals the triangle you remove on the other, so the area does not change. The rectangle has the same area as the trapezoid under the tangent. And an upward-bending curve lies above its tangent lines, so the midpoint rule underestimates.
Flip the curve over and both directions flip. That gives the two lines at the bottom of the slide: with a positive second derivative the integral is trapped between the midpoint estimate below and the trapezoidal estimate above, and with a negative second derivative the order reverses.
Picture it
Figure (svg): Two panels of the same concave-up curve with two subintervals. Left: trapezoids, with the error drawn as red lenses between each chord and the curve, all on one side. Right: midpoint rectangles, with the error drawn as red slivers, one above and one below the curve in each subinterval.
Every trapezoid on an upward-bending curve overshoots, so its errors pile up. Each midpoint rectangle overshoots on one half of its subinterval and falls short on the other, so its errors largely cancel. That is why the book expects the midpoint rule to be the more accurate of the two.
Both panels show the same upward-bending curve with two pieces, and the red regions are the errors.
On the left, every red lens lies between a chord and the curve, and every one of them is extra area. The trapezoid's errors all have the same sign, so they simply add up.
On the right, each midpoint rectangle has a red sliver above the curve on one half and a red sliver below the curve on the other half. One counts as too much and the other as too little, so they largely cancel, leaving only a small net error. That is the picture behind the book's remark that the midpoint rule tends to be more accurate than the trapezoidal rule, and the next slide makes the comparison exact.
Concept
Take one subinterval of width h, starting at a, under y equal to x squared, and compute all three areas.
\[ \int_a^{a+h} x^2\,dx = a^2h + ah^2 + \tfrac13 h^3 \]
\[ h\left(a + \tfrac h2\right)^2 = a^2h + ah^2 + \tfrac14 h^3 \]
\[ \tfrac h2\bigl(a^2 + (a+h)^2\bigr) = a^2h + ah^2 + \tfrac12 h^3 \]
Subtract: the midpoint rectangle is short by one twelfth of h cubed, the trapezoid long by one sixth. Opposite signs, and the trapezoid's error is twice the midpoint's.
\[ \int - M = \tfrac{1}{12}h^3, \qquad T - \int = \tfrac16 h^3 \]
With four pieces of width one quarter, the midpoint error is four times one twelfth of one sixty-fourth: one over 192, exactly what Example 3.39 found.
This short calculation turns the picture into numbers. Take a single piece of width h under the parabola, starting at some point a, and compute the exact area, the midpoint rectangle and the trapezoid.
Expanding each one, the terms with a squared and with a match in all three. They differ only in the last term: one third of h cubed for the exact area, one quarter for the rectangle, one half for the trapezoid. So the rectangle falls short by one twelfth of h cubed and the trapezoid overshoots by one sixth. Opposite signs, and the trapezoid's error is exactly twice the rectangle's.
The final line checks this against Example 3.39. Four pieces, each short by one twelfth of one sixty-fourth, total one over 192, exactly what you found there. For general curves the factor of two is only approximate, but it explains the 24 and the 12 you will see in the error bounds.
Prediction
\[ \int_0^{\pi} \sin x\,dx = 2, \qquad n = 4 \]
Predict first
The sine curve bends downward on the whole interval. Before computing anything, where do T₄ and M₄ fall relative to the exact value 2?
Correct: T₄ < 2 < M₄
Why: Concave down reverses both rules: the chords now cut under the arch, so the trapezoids come up short, and the tangents at the midpoints lie above the arch, so the midpoint rectangles hold too much. The numbers agree: T₄ is about 1.8961 and M₄ about 2.0523.
\[ T_4 \approx 1.8961 < 2 < 2.0523 \approx M_4 \]
Commit to one option before revealing. You have the tools to answer without any arithmetic.
The sine curve over the interval from zero to pi is an arch, bending downward everywhere. Every chord cuts beneath an arch, so the trapezoids leave out area and the trapezoidal rule is too low. Every tangent line lies above an arch, and the midpoint rectangle has the same area as the region under its tangent, so the midpoint rule is too high.
The numbers confirm it: about 1.896 for the trapezoids and about 2.052 for the midpoint rule, on either side of the exact 2. If you chose the other order, you probably remembered the concave-up rule without the reason. Rebuild it from the chord and the tangent each time and it cannot come out backwards.
Sorting
Sort into buckets
For each integral, decide from the concavity alone whether T_n overestimates or underestimates.
For each item, decide the sign of the second derivative on the given interval, then use it. You are sorting by concavity, and the concavity decides the trapezoidal rule's direction.
The exponential, one over x on positive values and x cubed on positive values all bend upward, so their chords lie above them and the trapezoidal rule overestimates. The natural log, the square root and cosine on the first quarter-turn all bend downward, so the trapezoidal rule underestimates.
Notice that the interval matters. x cubed bends upward for positive x but downward for negative x, and cosine bends downward only where cosine is positive. The sign of the second derivative must hold on the WHOLE interval before the direction is guaranteed, which is exactly what the error-analysis slide in a moment will test.
Worked example
No antiderivative exists for one over ln x. Trap the integral between two estimates.
\[ \int_2^4 \frac{dx}{\ln x}, \qquad n = 4 \]
Find the concavity
Why: Differentiate one over ln x twice; for x above 1 every factor is positive.
\[ f''(x) = \frac{\ln x + 2}{x^2(\ln x)^3} > 0 \]
Compute the midpoint estimate
Why: Width one half, midpoints 2.25, 2.75, 3.25, 3.75; the heights total 3.82667.
\[ M_4 = \tfrac12(1.23315 + 0.98853 + 0.84842 + 0.75657) \approx 1.9133 \]
Compute the trapezoidal estimate
Why: Endpoints 2, 2.5, 3, 3.5, 4; the weighted total is 7.76373.
\[ T_4 = \tfrac14\bigl(1.44270 + 2(2.79984) + 0.72135\bigr) \approx 1.9409 \]
Trap the integral
Why: Concave up: the midpoint rule is low, the trapezoidal rule high.
\[ 1.9133 < \int_2^4 \frac{dx}{\ln x} < 1.9409 \]
Figure (svg): Two panels of the falling, concave-up curve y equals one over ln x from 2 to 4. Left: four midpoint rectangles. Right: four trapezoids whose chords lie above the curve.
Check with finer estimates
Why: Exercise 318's eight trapezoids and a Simpson estimate with a thousand subintervals both land inside the trap.
\[ T_8 \approx 1.9271, \qquad S_{1000} \approx 1.9224 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 327 — Exercises 317 and 318
One over ln x is another integrand with no elementary antiderivative, so this is a genuine use of the method: you do not know the answer, and you want two numbers that certainly surround it.
The concavity comes first, because without it the two estimates are just two estimates. The second derivative has numerator ln x plus 2 and denominator x squared times ln x cubed, and for x above one every one of those pieces is positive. So the curve bends upward on the whole interval.
Then the two rules are routine arithmetic, and the concavity tells you which is which: the midpoint estimate, about 1.9133, is too low, and the trapezoidal estimate, about 1.9409, too high. The check shows both finer estimates landing inside that interval. The width of the trap, under three hundredths, is itself an honest error estimate that needed no knowledge of the true value.
Error analysis
Annotate
On: \( f''(0) = -2 < 0 \;\Longrightarrow\; T_2 < \int_0^2 e^{-x^2}\,dx < M_2 \)
Figure (svg): The curve y equals e to the minus x squared from 0 to 2.2. The part from 0 to about 0.71 is shaded one colour and labelled concave down; the part beyond is shaded another colour and labelled concave up. The inflection point at x about 0.71 is marked, and the two trapezoid chords of T₂ on 0 to 2 are drawn dashed.
Read the claim and try to find the flaw before revealing the annotations. The arithmetic is not where the problem lies.
The second derivative was checked at a single point. For the bell curve it is negative near zero but positive beyond about 0.71, as the picture shows with its two shaded regions. A bracket needs one concavity on the whole interval, and this interval has both. The chords of the two trapezoids show it: the first lies under the curve, the second over it.
Here the conclusion happens to come out true, which makes the mistake dangerous. Stretch the interval to three and the same reasoning puts the numbers in the wrong order. The fix is simple: split the integral at the inflection point, where the concavity changes, and trap each piece separately.
Counterexample
Discussion prompt
The book says the midpoint rule tends to be more accurate than the trapezoidal rule. Find an integral and an n for which the trapezoidal rule is more accurate.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 319 — tends to be more accurate
Try to build the counterexample yourself before revealing it. The hint is in the pictures you have seen: the midpoint rule depends on a single value in the middle of each piece.
A wiggly curve with one wide piece does the job. On the interval from zero to pi, sine of 3x has a trough exactly at the midpoint, so the single midpoint rectangle has height minus one and area minus pi. The trapezoid uses the two end values, both zero, and gets zero. The true value is two thirds, so the trapezoid is much closer.
The lesson is about the word tends. The comparison between the rules comes from the behaviour of a smooth curve on a small piece where the concavity is fixed. With pieces too coarse to follow the curve, either rule can be terrible and either can win. Enough pieces restores the usual order.
Section
Part 5
Concept
Suppose the true value is A and your estimate is B.
Absolute error — The distance between the estimate and the true value, in the same units as the quantity.
\[ \text{absolute error} = |A - B| \]
Relative error — The absolute error as a fraction, or percentage, of the size of the true value.
\[ \text{relative error} = \left|\frac{A - B}{A}\right| \cdot 100\% \]
An error of 0.01 is excellent on an answer near 100 and useless on an answer near 0.02. The relative error is the figure that tells you which.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 320 — definition of absolute and relative error
Two different questions hide behind how far off. The absolute error answers how many units away the estimate is. The relative error answers how large that is compared with the thing being measured.
The relative error divides the absolute error by the size of the true value, and is usually quoted as a percentage. That makes it independent of units, and it lets you compare the quality of estimates of very different quantities.
The example in the last line is the reason both exist. An error of one hundredth on an answer near one hundred is a hundredth of a percent, excellent. The same error on an answer near two hundredths is fifty percent, useless. When someone quotes an absolute error without the size of the answer, you cannot tell which case you are in.
Worked example
\[ A = \int_0^1 x^2\,dx = \frac13, \qquad B = M_4 = \frac{21}{64} \]
Subtract
Why: Common denominator 192.
\[ \frac13 - \frac{21}{64} = \frac{64 - 63}{192} = \frac{1}{192} \]
Record the absolute error
Why: Already positive.
\[ |A - B| = \frac{1}{192} \approx 0.0052 \]
Divide by the true value
Why: Dividing by one third is multiplying by 3.
\[ \frac{1/192}{1/3} = \frac{3}{192} = \frac{1}{64} \]
Convert to a percentage
Why: One sixty-fourth is 0.015625.
\[ \frac{1}{64} = 0.015625 \approx 1.6\% \]
Check against the parabola formula
Why: The error per subinterval is one twelfth of h cubed, and there are four subintervals of width one quarter.
\[ 4 \cdot \frac{1}{12}\left(\frac14\right)^3 = \frac{4}{768} = \frac{1}{192} \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, pp. 320-321 — Example 3.42
This returns to the midpoint estimate of Example 3.39 and measures its error both ways. The true value is one third and the estimate 21 over 64.
Over the common denominator 192 the difference is one over 192, about 0.0052. For the relative error divide by one third, which is the same as multiplying by three, giving one over 64, about 1.6 percent.
The check reconnects this to the parabola calculation. There, each piece of width h was short by one twelfth of h cubed. With four pieces of width one quarter, that is four times one twelfth of one sixty-fourth, which is one over 192. The error is not just measured; it is explained.
Worked example
\[ A = \frac13, \qquad B = T_4 = \frac{11}{32} \]
Subtract
Why: Common denominator 96.
\[ \frac13 - \frac{11}{32} = \frac{32 - 33}{96} = -\frac{1}{96} \]
Take the absolute value
Why: The minus sign says the estimate is too high.
\[ |A - B| = \frac{1}{96} \approx 0.0104 \]
Divide by the true value
Why: Multiply by 3.
\[ \frac{1/96}{1/3} = \frac{3}{96} = \frac{1}{32} \]
Convert to a percentage
Why: One thirty-second is 0.03125.
\[ \frac{1}{32} = 0.03125 \approx 3.1\% \]
Check against the midpoint error
Why: The trapezoidal error should be twice the midpoint error, and opposite in sign.
\[ \frac{1}{96} = 2 \cdot \frac{1}{192} \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 321 — Example 3.43
The same measurement for the trapezoidal estimate, 11 over 32. The subtraction comes out negative, and that sign carries information: the true value minus the estimate is negative, so the estimate is too high, exactly as the concavity predicted.
The absolute error is one over 96, about 0.0104, and dividing by one third gives one over 32, a relative error of about 3.1 percent.
The check compares the two examples. One over 96 is exactly twice one over 192, and the two errors have opposite signs. That is the factor of two you derived for parabolas, now seen in the book's own numbers, and it points straight at Simpson's rule: if the two errors are in the ratio two to one with opposite signs, a suitable weighted average of the two estimates should cancel them.
Worked example
\[ A = \ln 2 \approx 0.6931, \qquad B = \frac{24}{35} \approx 0.6857 \]
Subtract
Why: Using the four-place values the book gives.
\[ |A - B| \approx |0.6931 - 0.6857| = 0.0074 \]
Divide by the true value
Why: A little over one hundredth.
\[ \frac{0.0074}{0.6931} \approx 0.0107 \]
Convert to a percentage
Why: About one percent.
\[ \text{relative error} \approx 1.1\% \]
Check which estimate this is
Why: The book calls 24 over 35 the T₂ value, but it is M₂ from Checkpoint 3.22. T₂ is 17 over 24, with twice the error.
\[ \left|\ln 2 - \tfrac{17}{24}\right| \approx 0.0152 \approx 2.2\% \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 321 — Checkpoint 3.24
Here the true value is ln 2 and the estimate is 24 over 35, both rounded to four places as the book gives them. The absolute error is about 0.0074, and dividing by 0.6931 gives about 0.0107, a relative error of a little over one percent.
The last step deserves attention. The book says this estimate came from the trapezoidal rule with two pieces, but look back at the two checkpoints: 24 over 35 was the midpoint estimate, and the trapezoidal estimate was 17 over 24. It is a small slip in the book, and noticing it is good practice.
The trapezoidal estimate's own error is about 0.0152, roughly twice the midpoint error again, and on the high side. Once more the two rules err in opposite directions, with the trapezoid about twice as far off.
Comparison
\[ \int_1^2 \frac{dx}{x} = \ln 2 \approx 0.693147 \]
Comparison matrix
| rule | estimate | absolute error | relative error |
|---|---|---|---|
| M₂ | 0.6857 | 0.0074 | 1.1% |
| T₂ | 0.7083 | 0.0152 | 2.2% |
| S₂ | 0.6944 | 0.0013 | 0.19% |
The third row is Simpson's rule with two subintervals, coming in Part 7. It uses the same three points as the trapezoidal estimate.
Fill in each blank before checking. You have the true value, the natural log of 2 to six places, and each estimate; the absolute error is the distance between them and the relative error that distance divided by 0.693.
The midpoint and trapezoidal rows repeat the last three slides. The third row previews Simpson's rule, which you are about to meet. It uses exactly the same three points as the two-piece trapezoidal rule, yet its error is about 0.0013, around a tenth of the trapezoid's, a relative error under two tenths of a percent.
Nothing about Simpson's rule costs more: same points, same number of function evaluations. The improvement comes entirely from the weights, which is the strongest argument in this lesson for understanding where weights come from.
Section
Part 6
Concept
Examples 3.42 and 3.43 cheated: they knew the exact answer. If you knew it, you would not be approximating. What you need is a guarantee computed from the function alone.
Error bounds (Theorem 3.5) — If f has a second derivative on the interval, and M is the largest value of its absolute value there, then the errors of the midpoint and trapezoidal rules are at most the amounts below.
\[ \text{Error in } M_n \le \frac{M(b-a)^3}{24n^2} \]
\[ \text{Error in } T_n \le \frac{M(b-a)^3}{12n^2} \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 321 — Theorem 3.5, equations 3.12 and 3.13
The examples so far measured errors against known answers, which is a little like checking a map by visiting the place. In real use you are approximating precisely because you cannot find the exact value, so the error cannot be computed. What you can do is bound it.
Theorem 3.5 gives the bounds. They need one number from the function: the largest value of the absolute value of the second derivative on the interval, called M. The second derivative measures how sharply the curve bends, and bending is the only thing that makes these rules wrong, as the straight-line slide showed.
Notice the two bounds differ only by the 24 and the 12. The midpoint bound is half the trapezoidal bound, matching the factor of two you have now seen several times. The book states the theorem without proof, but the parabola calculation shows where both constants come from.
Notation
Annotate
On: \( \text{Error in } T_n \le \frac{M\,(b-a)^3}{12\,n^2} \)
Take the pieces one at a time; each one tells you something practical.
M is the worst-case bending on the interval. A curve that bends sharply somewhere makes the bound large, even if it is gentle elsewhere. The cube of the interval's length means long intervals are expensive: doubling the length at a fixed number of pieces multiplies the bound by eight.
The n squared in the denominator is the payoff for work. Double the number of pieces and the bound drops to a quarter; multiply by ten and it drops to a hundredth. That is why a modest n often suffices. And because the bound is an inequality, the actual error is usually smaller still; the bound is a guarantee, not a prediction.
Worked example
\[ \int_0^1 x^2\,dx, \qquad n = 4 \]
Find the second derivative
Why: Differentiate x squared twice.
\[ f''(x) = 2 \;\Longrightarrow\; M = 2 \]
Substitute into the midpoint bound
Why: The interval has length 1.
\[ \text{Error in } M_4 \le \frac{2(1)^3}{24(4)^2} = \frac{2}{384} = \frac{1}{192} \]
Do the same for the trapezoidal bound
Why: Equation 3.13 has 12 in the denominator.
\[ \text{Error in } T_4 \le \frac{2(1)^3}{12(4)^2} = \frac{1}{96} \]
Check against the actual errors
Why: These are exactly the errors of Examples 3.42 and 3.43. For x squared the second derivative is constant, so the bounds cannot be improved.
\[ \left|\tfrac13 - M_4\right| = \tfrac{1}{192}, \qquad \left|\tfrac13 - T_4\right| = \tfrac{1}{96} \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 322 — Checkpoint 3.25
The book asks for Equation 3.13, the trapezoidal bound, but applies it to the midpoint estimate. The slide does both, because comparing them is instructive.
For x squared the second derivative is 2 everywhere, so M is 2. The midpoint bound, with 24 in the denominator, gives one over 192, and the trapezoidal bound, with 12, gives one over 96.
Now the check. These are exactly the actual errors from Examples 3.42 and 3.43. The bounds are usually generous, but here they are exact, because the second derivative of a parabola is constant: the worst-case bending is the bending everywhere. That also confirms the constants 24 and 12 are the right ones; no smaller numbers would work.
Worked example
Choose n so the midpoint rule is guaranteed to be within 0.01.
\[ \int_0^1 e^{x^2}\,dx \]
Differentiate once
Why: Chain rule.
\[ f'(x) = 2x\,e^{x^2} \]
Differentiate again
Why: Product rule on 2x times e to the x squared.
\[ f''(x) = 2e^{x^2} + 4x^2e^{x^2} = 2e^{x^2}(1 + 2x^2) \]
Bound it on the interval
Why: Both factors increase with x, so the maximum is at x equal to 1.
\[ |f''(x)| \le 2 \cdot e \cdot 3 = 6e \]
Figure (svg): The second derivative 2 e to the x squared times 1 plus 2 x squared, plotted from 0 to 1: it rises from 2 at x equals 0 to about 16.31 at x equals 1, where a dot marks its maximum and a dashed line marks the level 6e.
Set the bound at most 0.01
Why: The interval has length 1.
\[ \frac{6e(1)^3}{24n^2} \le 0.01 \]
Solve for n
Why: Multiply out, then take the square root.
\[ n^2 \ge \frac{600e}{24} = 25e \;\Longrightarrow\; n \ge 5\sqrt e \approx 8.24 \]
Round up
Why: n must be a whole number at least 8.24.
\[ n = 9 \]
Check with nine rectangles
Why: Nine midpoint rectangles give 1.45987 against an accurate value of 1.46265: well within 0.01.
\[ |1.46265 - 1.45987| \approx 0.0028 < 0.01 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 322 — Example 3.44
This is the most practical use of the error bound: deciding how much work to do before doing it. The integrand e to the x squared has no elementary antiderivative, so there is nothing to compare with; the bound is your only guarantee.
Finding M takes two derivatives. The chain rule gives the first, and the product rule the second, which factors as two e to the x squared times one plus two x squared. Both factors grow with x, so on the interval the largest value is at x equal to one, as the graph shows: two times e times three, or six e.
Put M into the midpoint bound, require it to be at most one hundredth, and solve: n squared must be at least 25e, so n is at least about 8.24. Round up to 9. The check computes the actual estimate with nine rectangles and compares it with an accurate value: the error is under three thousandths, comfortably inside the guarantee.
Trap
From Example 3.44:
\[ n \ge 8.24 \]
\[ \Longrightarrow n = 8 ? \]
Wrong. 8 is less than 8.24.
n is the smallest whole number at least 8.24, which is 9. With 8 the guarantee is broken: the bound comes out above 0.01. Always round a required n up, and check the integer on each side.
\[ \frac{6e}{24(8)^2} \approx 0.0106 > 0.01 \]
\[ \frac{6e}{24(9)^2} \approx 0.0084 < 0.01 \]
The inequality says n must be at least 8.24. The instinct to round to the nearest whole number gives 8, and 8 is not at least 8.24.
The right side of the slide shows what that costs. With eight pieces the bound is just over one hundredth, so the guarantee you set out to buy is gone. With nine it is about 0.0084, safely under.
Two habits protect you. Round a required count up, always, whatever the decimal. And when the answer is close to a whole number, substitute the integers on each side back into the bound, as the slide does. It is also true that eight rectangles would in fact be accurate enough here, but you could only know that by computing the answer you do not have.
Step zero
\[ \int_0^1 \sqrt{1+x^2}\,dx, \quad \text{trapezoidal rule, error} \le 0.01 \]
Discussion prompt
Exercise 330 asks for n. Before you touch the error bound, what is M here, and at which x on the interval does it occur?
Answer before revealing. This slide exists because the previous example trains an expectation that the maximum is at the right-hand end, and here it is not.
Differentiating the square root of one plus x squared once gives x over the square root; differentiating again, and simplifying, gives one over one plus x squared to the three halves. That is positive, and it decreases as x grows, because its denominator grows.
So on the interval from zero to one, the largest value is at the left end, x equal to zero, where it equals one. Finding M always means finding the maximum of the absolute value of the derivative on the whole interval, by whatever method that takes: checking where it increases or decreases, or checking critical points and endpoints.
Worked example
\[ \int_0^1 \sqrt{1+x^2}\,dx, \qquad \text{error} \le 0.01 \]
Record M
Why: From the previous slide: the maximum of the second derivative, at x equal to 0.
\[ M = f''(0) = 1 \]
Set the trapezoidal bound at most 0.01
Why: The interval has length 1.
\[ \frac{1 \cdot 1^3}{12n^2} \le 0.01 \]
Solve for n squared
Why: Multiply both sides by n squared and divide by 0.01.
\[ n^2 \ge \frac{1}{0.12} \approx 8.33 \]
Take the square root and round up
Why: The next whole number.
\[ n \ge 2.89 \;\Longrightarrow\; n = 3 \]
Check with the exact value
Why: The exact integral is one half of the square root of 2 plus ln of 1 plus root 2; three trapezoids miss it by less than 0.01.
\[ T_3 \approx 1.15435, \quad \int_0^1\sqrt{1+x^2}\,dx \approx 1.14779, \quad \text{error} \approx 0.0066 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 328 — Exercise 330
With M equal to one from the previous slide, the rest is the same routine as Example 3.44, now with the trapezoidal bound and its 12.
Setting one over twelve n squared at most one hundredth gives n squared at least about 8.33, so n is at least about 2.89. Round up: three trapezoids are enough.
The check is possible here because this integral can be done exactly by a trigonometric substitution: it is one half of root 2 plus the log of one plus root 2, about 1.14779. Three trapezoids give about 1.15435, off by about 0.0066, inside the promised hundredth. Notice that the estimate is too high, which you could have predicted: the second derivative is positive, so the curve bends upward and the chords sit above it.
Tweak it
Parameter explorer
The curve shows the gap between y = sin(πx) and the chords of the trapezoidal rule with n subintervals on [0, 1]. Slide n from 2 upward. How does the tallest bump shrink when n doubles?
\[ \text{largest gap} \le \frac{\pi^2}{8 \cdot {n}^2} \]
The curve on this slide is not the function itself but the gap between the sine arch and the chords of the trapezoidal rule, piece by piece. Each bump is one piece's error, seen from the side.
Start at n equal to 2 and move the slider up slowly. The bumps multiply, but each gets much lower. At 2 the tallest bump is about 0.21, at 4 about 0.07, at 8 about 0.019. Doubling n cuts the height to roughly a quarter.
That quartering is the n squared in the error bound, made visible. The formula in the readout is the height bound behind it: the largest gap is at most the maximum of the second derivative, pi squared, times the square of the width over eight. Because both the height and the width of each bump shrink, the total error shrinks like one over n squared.
Section
Part 7
Concept
Figure (svg): A curve over x zero to x four, split into four subintervals. Over the first pair, x zero to x two, a dashed parabola passes through the three points on the curve; over the second pair, x two to x four, another dashed parabola passes through the next three points. The regions under the parabolas are shaded in two colours.
The midpoint rule replaces the curve by constants on each piece; the trapezoidal rule by straight lines. Simpson's rule goes one step further: through each pair of neighbouring subintervals it fits the parabola through three points of the curve, and integrates that.
\[ \int_{x_0}^{x_2} f(x)\,dx \approx \int_{x_0}^{x_2} (Ax^2 + Bx + C)\,dx \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, pp. 322-323 — Figure 3.16
The midpoint rule fits constants and the trapezoidal rule fits straight lines. The natural next step is to fit parabolas, and that is Simpson's rule.
A straight line is fixed by two points, which is why each trapezoid uses one piece. A parabola needs three points, so each parabola spans two neighbouring pieces: the two ends and the point where they meet. Look at the picture. The first parabola covers the first pair of pieces, the second covers the next pair, and each hugs the curve far more closely than a chord could.
Two consequences follow at once. You integrate each parabola instead of the curve, and parabolas are easy to integrate. And because the pieces are used in pairs, the number of pieces must be even.
Concept
Slide the pair so its middle point is at 0; sliding does not change an area. The three points are at minus h, 0 and h, where h is the width.
\[ \int_{-h}^{h}(Ax^2 + Bx + C)\,dx = \left[\tfrac{A}{3}x^3 + \tfrac{B}{2}x^2 + Cx\right]_{-h}^{h} \]
\[ = \tfrac{2A}{3}h^3 + 2Ch = \tfrac{h}{3}\bigl(2Ah^2 + 6C\bigr) \]
Now add the three heights, counting the middle one four times:
\[ f(-h) + 4f(0) + f(h) = (Ah^2 - Bh + C) + 4C + (Ah^2 + Bh + C) \]
\[ = 2Ah^2 + 6C, \quad \text{the same bracket as the area} \]
\[ \int_{x_0}^{x_2} p(x)\,dx = \tfrac{\Delta x}{3}\bigl(f(x_0) + 4f(x_1) + f(x_2)\bigr) \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 324 — the derivation of Simpson's rule
This derivation looks like it will be messy, and the book's version with general points is. Sliding the pair sideways so that its middle point sits at zero makes it short, and sliding does not change any area.
With the points at minus h, zero and h, integrate the parabola. The odd power, B times x, integrates to zero over a symmetric interval, leaving two A over three times h cubed plus two C h. Factor out h over three to get h over three times two A h squared plus six C.
Now evaluate the parabola at the three points and weight the middle one by four. The B terms cancel between the two ends, and what remains is exactly the same bracket, two A h squared plus six C. So the area is h over three times the first value plus four times the middle value plus the last. The parabola's coefficients have disappeared entirely; only the three heights remain.
Concept
Add the formula over each pair. Where two pairs meet, the shared endpoint collects a 1 from each side.
\[ \tfrac{\Delta x}{3}(f_0 + 4f_1 + f_2) + \tfrac{\Delta x}{3}(f_2 + 4f_3 + f_4) = \tfrac{\Delta x}{3}(f_0 + 4f_1 + 2f_2 + 4f_3 + f_4) \]
Figure (svg): Two bar charts of the weights on f of x sub i for n equal to 8. Left, trapezoidal rule: 1, then seven bars of height 2, then 1. Right, Simpson's rule: 1, 4, 2, 4, 2, 4, 2, 4, 1, alternating tall and short.
Simpson's rule (Theorem 3.6) — For a positive EVEN number of subintervals of equal width, the Simpson sums tend to the integral as n grows.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 324 — Theorem 3.6
One parabola covers two pieces. For more pieces, add the one-parabola formula over each pair, as in the first line of the slide.
Every point in the middle of a pair collects weight four. The points where two pairs meet belong to two parabolas, the end of one and the start of the next, so they collect a one from each, weight two. The very first and last points belong to one parabola each, weight one.
The bar charts compare the result with the trapezoidal weights on the same nine points. The trapezoidal rule weights every interior point equally; Simpson's rule alternates four and two. Same points, same work, different weights, and as you will see, a dramatically smaller error. That is Theorem 3.6, and its hypothesis includes the word even.
Notation
Annotate
On: \( S_n = \frac{\Delta x}{3}\bigl(f_0 + 4f_1 + 2f_2 + 4f_3 + \cdots + 4f_{n-1} + f_n\bigr) \)
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 324 — equation 3.14
Connect each annotation to the parabola derivation you just saw.
The factor in front is a third of the width, not a half, because it came from the area under one parabola. The fours sit at the odd-numbered points, which are the middles of the parabolas, and the twos at the even-numbered interior points, where two parabolas meet.
The last annotation is the one to check every time. The pattern must begin with one, four and end with four, one. That only happens when the number of pieces is even. If you count your weights and find the pattern ending two, one or four, four, the number of pieces is odd and the formula you have written is not Simpson's rule.
Concept
On one pair of width 2h, the midpoint rule with one rectangle and the trapezoidal rule with one trapezoid give:
\[ M_1 = 2h\,f_1, \qquad T_1 = h\,(f_0 + f_2) \]
Weight the midpoint twice as heavily, as its smaller error deserves:
\[ \tfrac23 M_1 + \tfrac13 T_1 = \tfrac{4h}{3}f_1 + \tfrac{h}{3}(f_0 + f_2) = \tfrac{h}{3}(f_0 + 4f_1 + f_2) \]
\[ S_{2n} = \tfrac23 M_n + \tfrac13 T_n \]
Check with Examples 3.39 and 3.41: two thirds of 21 over 64 plus one third of 11 over 32 is 64 over 192, exactly one third. The two errors, in the ratio two to one with opposite signs, cancel.
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 325 — the weighted-average relation
Here is a second route to Simpson's rule, and it connects everything in the lesson. Take one pair of pieces, total width two h. As a single piece, its midpoint rectangle has area two h times the middle value, and its trapezoid has area h times the sum of the end values.
You know the trapezoid's error tends to be about twice the midpoint's, with the opposite sign. So weight the midpoint estimate twice as heavily: two thirds of one plus one third of the other. The arithmetic on the slide shows that this weighted average is exactly the Simpson formula.
The check uses the book's numbers from Examples 3.39 and 3.41. Two thirds of 21 over 64 plus one third of 11 over 32 comes to exactly one third, the true value. For a parabola the ratio of errors is exactly two to one, so the cancellation is perfect.
Concept
Error bound for Simpson's rule — If M is the largest absolute value of the fourth derivative of f on the interval, the error in the Simpson estimate is at most the amount below.
\[ \text{Error in } S_n \le \frac{M(b-a)^5}{180n^4} \]
Two consequences. Doubling n divides the bound by sixteen, not four. And every cubic has fourth derivative zero, so Simpson's rule is EXACT for cubics, even though it only fits parabolas.
\[ f(x) = Ax^3 + Bx^2 + Cx + D \;\Longrightarrow\; f^{(4)} = 0 \;\Longrightarrow\; S_n = \int_a^b f(x)\,dx \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 325 — equation 3.15
Simpson's bound looks like the others but with three important changes: the fourth derivative instead of the second, the fifth power of the interval's length, and the fourth power of n.
The fourth power of n is the practical headline. Doubling the number of pieces divides the bound by sixteen, where the midpoint and trapezoidal bounds only fell by four. For demanding accuracy that difference is enormous.
The fourth derivative carries a surprise. Every cubic has fourth derivative zero, so the bound is zero and Simpson's rule gives the exact integral of every cubic, not just every parabola. That is one degree better than the rule was designed for, and the next example shows why.
Worked example
Use Simpson's rule with two subintervals, and bound its error.
\[ \int_0^1 x^3\,dx \]
Find the width and the points
Why: Two subintervals of the unit interval.
\[ \Delta x = \tfrac12, \qquad x_0 = 0,\; x_1 = \tfrac12,\; x_2 = 1 \]
Write the rule
Why: Weights 1, 4, 1, times one third of the width.
\[ S_2 = \tfrac13 \cdot \tfrac12\Bigl(f(0) + 4f\bigl(\tfrac12\bigr) + f(1)\Bigr) \]
Substitute the cubes
Why: One half cubed is one eighth.
\[ S_2 = \tfrac16\left(0 + 4\cdot\tfrac18 + 1\right) = \tfrac16 \cdot \tfrac32 = \tfrac14 \]
Bound the error
Why: The fourth derivative of x cubed is zero, so M is zero.
\[ \text{Error in } S_2 \le \frac{0 \cdot 1^5}{180 \cdot 2^4} = 0 \]
Figure (svg): The cubic y equals x cubed and the parabola y equals 1.5 x squared minus 0.5 x on 0 to 1, meeting at x equals 0, one half and 1. Between 0 and one half the parabola dips below the cubic; between one half and 1 it rises above it. The two gaps are shaded in different colours.
Check with the Fundamental Theorem
Why: The bound promised an exact answer, and it is.
\[ \int_0^1 x^3\,dx = \left[\tfrac{x^4}{4}\right]_0^1 = \tfrac14 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 325 — Example 3.45
This example tests the surprise from the previous slide. With two pieces the points are zero, one half and one, the factor in front is one sixth, and the weights are one, four, one. The value at one half is one eighth, four times that is one half, and the bracket totals three halves. One sixth of three halves is one quarter.
The error bound needs the fourth derivative of x cubed, which is zero, so the bound is zero: Simpson's rule claims to be exact. The Fundamental Theorem confirms it.
The picture shows how this is possible. The parabola through the three points is a different curve from the cubic: it dips below the cubic on the left half and rises above it on the right. But the two gaps have exactly the same area, one sixty-fourth each, and they cancel. That happens for every cubic, because the difference between a cubic and its parabola is symmetric about the middle point in just this way.
Worked example
\[ L = \int_1^4 \sqrt{1+x^2}\,dx, \qquad n = 6 \]
Find the width and the points
Why: Seven points, half a unit apart.
\[ \Delta x = \tfrac12, \qquad x_i = 1,\; \tfrac32,\; 2,\; \tfrac52,\; 3,\; \tfrac72,\; 4 \]
Write the weights
Why: 1, 4, 2, 4, 2, 4, 1, times one sixth.
\[ S_6 = \tfrac16\bigl(f_0 + 4f_1 + 2f_2 + 4f_3 + 2f_4 + 4f_5 + f_6\bigr) \]
Substitute the values
Why: Five decimal places each.
\[ \tfrac16\bigl(1.41421 + 4(1.80278) + 2(2.23607) + 4(2.69258) \]
\[ \qquad + 2(3.16228) + 4(3.64005) + 4.12311\bigr) \]
Add and divide by six
Why: The weighted total is 48.87566.
\[ S_6 \approx \tfrac{48.87566}{6} \approx 8.14594 \]
Check against the exact length
Why: Simpson misses by about 0.00017; the midpoint rule with the same six subintervals missed by 0.0027, sixteen times more.
\[ |8.14577 - 8.14594| \approx 0.00017, \qquad |8.14577 - 8.14307| \approx 0.0027 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, pp. 325-326 — Example 3.46
This is the arc-length integral from Example 3.40, now with Simpson's rule, so the two rules can be compared on the same problem with the same six pieces.
The points run from one to four in steps of one half. Write the weights one, four, two, four, two, four, one first, then substitute the values, then add. The long line is split over two lines on the slide; the weighted total is 48.87566, and dividing by six gives about 8.14594.
The check compares both rules with the exact length, 8.14577. Simpson's rule misses by about two ten-thousandths; the midpoint rule with six pieces missed by about 27 ten-thousandths, more than ten times as much. Simpson used seven function values and the midpoint rule six, so the extra accuracy cost almost nothing.
Worked example
\[ \int_1^2 \frac{dx}{x}, \qquad n = 2 \]
Write the rule
Why: Width one half, so the factor is one sixth.
\[ S_2 = \tfrac16\Bigl(f(1) + 4f\bigl(\tfrac32\bigr) + f(2)\Bigr) \]
Substitute the reciprocals
Why: Four times two thirds.
\[ S_2 = \tfrac16\left(1 + \tfrac83 + \tfrac12\right) \]
Add inside the bracket
Why: In sixths: 6, 16 and 3.
\[ 1 + \tfrac83 + \tfrac12 = \tfrac{25}{6} \]
Multiply by one sixth
Why: The Simpson estimate.
\[ S_2 = \tfrac{25}{36} \approx 0.69444 \]
Check two ways
Why: The weighted average of M₁ and T₁ gives the same number, and the error against ln 2 is about 0.0013, far below the midpoint and trapezoidal errors.
\[ \tfrac23\cdot\tfrac23 + \tfrac13\cdot\tfrac34 = \tfrac{25}{36}, \qquad |0.69444 - 0.69315| \approx 0.0013 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 326 — Checkpoint 3.26
Two pieces again on the interval from one to two, so the factor is one sixth and the weights one, four, one. The middle value is two thirds, and four times it is eight thirds.
Adding one, eight thirds and one half gives twenty-five sixths, and one sixth of that is 25 over 36, about 0.69444.
The check does two things. It confirms the weighted-average relation: the one-rectangle midpoint estimate is two thirds, the one-trapezoid estimate three quarters, and two thirds of the first plus one third of the second is 25 over 36 again. And it compares with the natural log of 2: the error is about 0.0013, against about 0.0074 for the midpoint rule and 0.0152 for the trapezoidal rule with the same number of pieces.
Worked example
Return to the integral with no antiderivative. Estimate it with Simpson's rule on four subintervals and bound the error.
\[ \int_0^1 e^{-x^2}\,dx, \qquad n = 4 \]
Find the width and the heights
Why: Points 0, one quarter, one half, three quarters, 1.
\[ 1,\; 0.939413,\; 0.778801,\; 0.569783,\; 0.367879 \]
Weight and add
Why: Weights 1, 4, 2, 4, 1; the width one quarter over 3 is one twelfth.
\[ S_4 = \tfrac{1}{12}(8.962265) \approx 0.746855 \]
Find the fourth derivative
Why: Differentiate four times; the polynomial factor collects the chain-rule terms.
\[ f^{(4)}(x) = (16x^4 - 48x^2 + 12)\,e^{-x^2} \]
Bound it
Why: On the interval its absolute value is largest at x equal to 0, where it equals 12.
\[ M = 12 \;\Longrightarrow\; \text{Error} \le \frac{12}{180 \cdot 4^4} = \frac{1}{3840} \approx 0.00026 \]
Check against the accurate value
Why: The integral is 0.746824 to six places; the actual error, 0.000031, is well inside the guarantee.
\[ |0.746855 - 0.746824| \approx 0.000031 < 0.00026 \]
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 327 — Exercise 311's integrand on a new interval
This brings the lesson back to where it started, the integral with no antiderivative, and does the complete job: an estimate and a guarantee.
The estimate is routine: five heights, weights one, four, two, four, one, and a factor of one twelfth. The guarantee is where the work is. Differentiating e to the minus x squared four times, the chain rule produces a polynomial factor, 16 x to the fourth minus 48 x squared plus 12. On the interval from zero to one its absolute value is largest at zero, where it equals 12. That value goes into Simpson's bound.
The bound is about 0.00026, so the estimate 0.746855 is certainly correct to three decimal places. The check uses an accurate value from tables: the actual error is about 0.00003, nearly ten times smaller than guaranteed. Bounds are pessimistic by design.
Picture it
Figure (svg): Error against n on logarithmic axes for the integral of one over x from 1 to 2, with n equal to 2, 4, 8, 16, 32. The trapezoid and midpoint errors fall along two parallel lines, the midpoint line lower; the Simpson errors fall along a line twice as steep.
The errors for the integral of one over x from 1 to 2, with n doubling from 2 to 32. The midpoint and trapezoidal errors fall by a factor of four per doubling, the midpoint always about half the trapezoid. Simpson's errors fall by sixteen: at n equal to 32 it is correct to seven decimal places.
Both axes of this plot are logarithmic, so equal steps across mean doubling n, and equal steps down mean dividing the error by the same factor. On such axes an error that behaves like a power of n becomes a straight line.
The trapezoidal and midpoint lines are parallel, one step down per doubling equal to a factor of four, which is the n squared in their bounds. The midpoint line sits just below the trapezoidal one, a factor of two, all the way along.
The Simpson line is twice as steep, a factor of sixteen per doubling, the n to the fourth. At 32 pieces Simpson's rule is correct to about seven decimal places, while the other two are still wrong in the fifth. If you need high accuracy, the steepness of the line matters far more than where it starts.
Trap
Exercise 301 asks for Simpson's rule with three subintervals. Forcing the pattern:
\[ S_3 \overset{?}{=} \tfrac{\Delta x}{3}(f_0 + 4f_1 + 2f_2 + f_3) \]
Wrong: that pattern is not Simpson's rule.
With three subintervals the parabolas cannot pair them up: the last one is left alone, and the weights no longer come from any parabolas. The weights must run 1, 4, 2, 4, …, 4, 1, which needs an even n. Use n equal to 2 or 4, or cover the odd subinterval with a different rule.
\[ n \text{ even: } 1, 4, 2, 4, \ldots, 2, 4, 1 \]
The book's own Exercise 301 asks for Simpson's rule with three pieces, and the only honest answer is that the rule does not apply as stated. This slide is here so that you notice when a problem asks for something impossible.
Three pieces cannot be grouped into pairs, so the last piece has no parabola. Forcing the alternating pattern onto four points produces weights one, four, two, one, which do not come from any parabolas and do not integrate even a straight line correctly.
What to do instead: use an even number of pieces, or treat the odd piece separately, with a trapezoid or with a different three-point formula, and add. The quick test is the one from the notation slide. The weights must end four, one.
Estimation
\[ \int_0^1 e^{-x^2}\,dx, \quad \text{error} \le 10^{-6} \]
Predict first
The trapezoidal bound (with M = 2) demands n = 409. What does Simpson's bound (with M = 12) demand?
Correct: About 18
Why: Twelve over 180 times n to the fourth must be at most one millionth, so n to the fourth is at least 66,667 and n is at least 16.07. Simpson needs an even n, so 18. The fourth power beats the square by a factor of more than twenty in work.
\[ \frac{2}{12n^2} \le 10^{-6} \iff n \ge 408.2, \qquad \frac{12}{180n^4} \le 10^{-6} \iff n \ge 16.07 \]
Commit to a guess first. The trapezoidal count, 409, sets your expectation, and most people guess something in the hundreds.
Work Simpson's bound through. The fourth derivative's largest value is 12, the interval has length one, so twelve over 180 times n to the fourth must be at most one millionth. That gives n to the fourth at least about 66,667, and n at least about 16.07.
Now two roundings. Up, because n must be at least 16.07, which gives 17. And then up again to an even number, because Simpson's rule needs one, so 18. At 16 the bound is just above one millionth, so rounding really matters. Eighteen function evaluations against four hundred and ten for the same guarantee: that is what the fourth power buys.
Real world
Figure (svg): Surveyed boundary of a lot: eleven measured points from x equals 0 to 1000 metres, heights falling from 125 to 0, joined by straight segments. The region under them is shaded as ten trapezoids.
Discussion prompt
Exercise 343: a surveyor measures the width of a lot every 100 metres, from 125 m at one end down to 0 at the other. Estimate the area with the trapezoidal rule, then with Simpson's rule (n = 10 is even).
OpenStax Calculus Volume 2, §3.6 Numerical Integration §3.6, p. 329 — Exercise 343
Here the function is a set of measurements: the width of a lot every hundred metres. There is no formula, no antiderivative, and no derivative to bound, only numbers.
The trapezoidal rule needs only those numbers: the ends weighted once, the nine interior widths twice, and the whole multiplied by half the spacing. With eleven points there are ten pieces, an even number, so Simpson's rule also applies: weight four on the odd-numbered widths and two on the even-numbered interior ones, times a third of the spacing.
The two estimates, 89,250 and 89,500 square metres, differ by about a quarter of a percent. With no formula there is no error bound to compute, so agreement between two different rules is the best evidence of accuracy available. It is also a reminder that the surveyor's measurements themselves are probably not accurate to better than that.
Section
Part 8
Pattern
Figure (svg): A flow diagram. Start: is an antiderivative available? Yes leads to the Fundamental Theorem. No leads to choosing a rule: data at equally spaced points or a formula. Then bound the second or fourth derivative, solve the error bound for n, round up (to an even number for Simpson), and compute.
This is the order to work in. The flow diagram shows the decisions and the list gives the details.
First, try for an antiderivative; an exact answer beats any approximation. If there is none, Simpson's rule is almost always the right choice, because it uses the same function values as the trapezoidal rule and is far more accurate.
To guarantee accuracy, bound the right derivative, the second for the midpoint and trapezoidal rules and the fourth for Simpson, over the whole interval, then solve the bound for n and round up, to an even number for Simpson. Finally, whenever the second derivative keeps one sign, use the midpoint and trapezoidal estimates together to trap the answer. With data only, there is no derivative to bound, and comparing two rules is the practical check.
Matching
Match the pairs
Why: All four are weighted sums of function values. The midpoint rule samples between the endpoints; the other three sample at them and differ only in the weights. The left sum ignores the last point, the trapezoidal rule halves the two ends, and Simpson's rule alternates four and two for parabolas.
Match each rule before checking. The aim is to see all four as members of one family: weighted sums of function values.
The midpoint rule is the only one that samples between the endpoints, and it weights each sample equally. The left Riemann sum samples at the endpoints but ignores the last one entirely. The trapezoidal rule uses every endpoint, halving the ends. Simpson's rule uses every endpoint too, with the alternating four and two, and a factor of a third of the width instead of a half.
If you can reconstruct these weights from pictures, rectangles, trapezoids and parabolas, you never need to memorise a formula from this section.
Ranking
\[ \int_0^1 e^{-x^2}\,dx \approx 0.746824, \qquad n = 4 \]
Put in order
All four estimates use n = 4. Order them from the smallest error to the largest.
Why: The errors are about 0.00003 for Simpson, 0.0019 for the midpoint rule, 0.0038 for the trapezoidal rule and 0.075 for the left sum. The midpoint error is half the trapezoid's, as the error bounds suggest, and Simpson's is sixty times smaller again.
All four estimates use four pieces on the same integral, so the ranking isolates the effect of the rule. Order them before checking, using what you know rather than subtracting.
Simpson's rule should be best by far, and it is: its error is about three hundred-thousandths. The midpoint rule should beat the trapezoidal rule by about a factor of two, and it does, about 0.0019 against 0.0038. The left sum, which has no cancellation of any kind, is worst, off by 0.075.
Notice that the midpoint rule overestimates and the trapezoidal rule underestimates here, even though the bell curve changes concavity at about 0.71. On this interval the downward-bending part dominates. The ranking is reliable; the direction, as the error-analysis slide warned, is not guaranteed.
Check
Check your understanding
On the interval from a to b, the second derivative of f is positive. What must be true?
Answer: A
Why: A positive second derivative means the curve bends upward. Its chords lie above it, so the trapezoidal rule overestimates, and its tangents lie below it, so the midpoint rule underestimates. The integral is trapped between them.
Answer from the pictures rather than from memory: chord above an upward-bending curve, tangent below it.
The trapezoid's top is a chord, which lies above the curve, so the trapezoidal rule is too big. The midpoint rectangle has the same area as the region under the tangent at the midpoint, which lies below the curve, so the midpoint rule is too small. The integral is trapped between them.
The last option is worth a thought. The whole value of this fact is that it needs no knowledge of the integral, only the sign of the second derivative, which is usually easy to find.
Check
Check your understanding
Bound the error in T₄ for the integral of x³ from 0 to 2.
Answer: A
Why: The second derivative is 6x, largest at x equal to 2, so M is 12. The bound is 12 times 2 cubed over 12 times 4 squared, which is 96 over 192, one half. The actual error is 0.25, inside the bound.
Three ingredients: the second derivative's maximum, the interval's length, and the constant 12. The second derivative of x cubed is 6x, which on the interval from zero to two is largest at two, so M is 12.
Twelve times two cubed is 96; twelve times four squared is 192; the bound is one half. The actual error, 0.25, sits inside it, as it must.
Each distractor is a real slip. One uses the midpoint constant 24. One confuses the trapezoidal bound with Simpson's, which would be zero for a cubic. And one puts the maximum of the function in place of the maximum of its second derivative.
Check
Check your understanding
You double the number of subintervals in Simpson's rule. By what factor does the error bound shrink?
Answer: D
Why: Simpson's bound has n to the fourth power in the denominator, and two to the fourth is sixteen. The midpoint and trapezoidal bounds have n squared, so they shrink by four.
Look at the power of n in the denominator of Simpson's bound: it is four. Doubling n multiplies n to the fourth by two to the fourth, which is sixteen.
Each of the other options belongs to a different rule. One over n errors, the factor two, belong to the one-sided Riemann sums; one over n squared, the factor four, to the midpoint and trapezoidal rules. The eight is a mix-up with the fifth power of the interval length.
This is why the log-scale plot showed Simpson's errors falling twice as steeply. For any serious accuracy requirement, the power of n is the most important number in an error bound.
Explain it to yourself
Discussion prompt
The midpoint rule is exact for every straight line, and Simpson's rule is exact for every cubic, even though a parabola cannot match a cubic. Explain both in two or three sentences.
Write your explanation before revealing. Both halves rest on the same idea: an error that is positive on one half of a piece and negative on the other, by exactly the same amount.
For the midpoint rule and a straight line, the two triangles between the line and the rectangle's top are mirror images, so they cancel. For Simpson's rule and a cubic, the difference between the cubic and the parabola through three points is a cubic that vanishes at all three points, and it is odd about the middle point: positive on one side, negative on the other, with equal areas. You saw exactly that in the picture for Example 3.45.
The error bounds say the same thing in one line: they vanish when the relevant derivative is zero. The second derivative of a line is zero, and so is the fourth derivative of a cubic.
Exit ticket
\[ \int_1^3 \frac{dx}{x} \]
Discussion prompt
Without computing any estimate: does the trapezoidal rule overestimate or underestimate this integral? And what n guarantees an error of at most 0.001?
This combines the two skills from the second half of the lesson: predicting the direction of an error without computing, and choosing n from a bound.
The second derivative of one over x is two over x cubed, positive on the whole interval, so the curve bends upward and the trapezoidal rule overestimates. Its largest value is at the left end, x equal to one, so M is two.
The interval has length two, so the bound is two times eight over twelve n squared, which simplifies to four over three n squared. Requiring that to be at most a thousandth gives n squared at least about 1333, so n at least about 36.5, and rounding up gives 37. At 36 the bound is just over a thousandth, so the rounding direction decides the answer.
Recap
| rule | formula | error bound | exact for |
|---|---|---|---|
| midpoint Mₙ | Δx (f(m₁) + … + f(mₙ)) | M(b − a)³ / (24n²), M = max |f″| | lines |
| trapezoidal Tₙ | (Δx/2)(f₀ + 2f₁ + … + 2fₙ₋₁ + fₙ) | M(b − a)³ / (12n²), M = max |f″| | lines |
| Simpson Sₙ (n even) | (Δx/3)(f₀ + 4f₁ + 2f₂ + … + 4fₙ₋₁ + fₙ) | M(b − a)⁵ / (180n⁴), M = max |f⁽⁴⁾| | cubics |
\[ f'' > 0: \; M_n < \int_a^b f < T_n, \qquad S_{2n} = \tfrac23 M_n + \tfrac13 T_n \]
Next, Section 3.7 lets an interval or an integrand run off to infinity: the improper integral.
Stewart, Calculus: Early Transcendentals 8e, §7.7 Approximate Integration §7.7, pp. 514-526 — the same material in Stewart
Three rules, each a weighted sum of function values: rectangles at the midpoints, trapezoids on the endpoints, and parabolas over pairs of pieces. The table puts each rule's formula, its error bound and the functions it gets exactly right side by side.
Two relations tie them together. When the second derivative keeps one sign, the midpoint and trapezoidal estimates trap the integral between them. And Simpson's rule is two thirds of the midpoint estimate plus one third of the trapezoidal estimate, which is why it cancels so much error.
The practical skill is using the bounds before computing: find the largest value of the right derivative, solve for n, and round up. The next section keeps the integral but lets the interval or the integrand become infinite, and asks when the area is still finite.
Want this taught 1-on-1? Alexander tutors Calculus II — $55/session, free consultation.