Simpson’s Rule

Simpson’s rule estimates a definite integral by fitting parabolas to the curve, two subintervals at a time. With an even number n of subintervals of width Δx, it adds the function values with weights 1, 4, 2, 4, …, 2, 4, 1 and multiplies by Δx/3. It is usually far more accurate than the trapezoidal rule.

Before this lesson: Riemann Sums, Trapezoidal Rule and Definite Integrals

Why parabolas work so well

The trapezoidal rule joins points with straight lines. A curve bends, so straight lines miss some area. Simpson’s rule joins each group of three points with a parabola instead, and a parabola can bend with the curve.

That is why n must be even. Each parabola covers two subintervals, so the subintervals have to come in pairs.

The curve y = f(x) from x = 0 to x = 4 with five points marked at x = 0, 1, 2, 3 and 4. A dashed parabola passes through the first three points and another through the last three. The shaded area under the two parabolas is almost the same as the area under the curve.
Each dashed parabola passes through three points of the curve, so the shaded area hugs the true area.

Simpson’s rule formula

\int_a^b f(x)\,dx \approx S_n = \dfrac{\Delta x}{3}\Big[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 2f(x_{n-2}) + 4f(x_{n-1}) + f(x_n)\Big]

Here \Delta x = \dfrac{b - a}{n}, x_k = a + k\,\Delta x, and n is even. The two ends get weight 1. Inside, the weights alternate 4, 2, 4, 2, … and the last inside point gets 4.

  1. Find Δx = (b − a)/n and list the x-values.
  2. Find f at each x-value.
  3. Multiply by the weights 1, 4, 2, 4, …, 4, 1 and add.
  4. Multiply the sum by Δx/3.

Error bound: if |f^{(4)}(x)| \le K on [a, b], then the error is at most \dfrac{K(b - a)^5}{180n^4}. Doubling n cuts this bound by a factor of 16.

Simpson’s rule examples

Example 1: A parabola is exact

Use Simpson’s rule with n = 2 to estimate \int_0^2 x^2\,dx.

\Delta x = \dfrac{2 - 0}{2} = 1

Find the width.

x_0 = 0, \; x_1 = 1, \; x_2 = 2

List the x-values.

f(0) = 0, \; f(1) = 1, \; f(2) = 4

Square each x-value.

0 + 4(1) + 4 = 8

Use the weights 1, 4, 1 and add.

S_2 = \dfrac{1}{3}(8) = \dfrac{8}{3}

Multiply by Δx/3.

\int_0^2 x^2\,dx = \dfrac{2^3}{3} - 0 = \dfrac{8}{3}

Find the exact value (see fundamental theorem of calculus, part 2).

Answer: S_2 = \dfrac{8}{3}, which is exact. Simpson’s rule is exact for any polynomial of degree 3 or less.

Example 2: Estimating ln 3

Use Simpson’s rule with n = 4 to estimate \int_1^3 \dfrac{1}{x}\,dx. Compare it with the exact value, ln 3.

\Delta x = \dfrac{3 - 1}{4} = 0.5

Find the width.

x = 1, \; 1.5, \; 2, \; 2.5, \; 3

List the x-values.

f = 1, \; \dfrac{2}{3}, \; \dfrac{1}{2}, \; \dfrac{2}{5}, \; \dfrac{1}{3}

Find 1/x at each one.

1 + 4\left(\dfrac{2}{3}\right) + 2\left(\dfrac{1}{2}\right) + 4\left(\dfrac{2}{5}\right) + \dfrac{1}{3}

Apply the weights 1, 4, 2, 4, 1.

= 1 + \dfrac{8}{3} + 1 + \dfrac{8}{5} + \dfrac{1}{3} = 6.6

Multiply and add (see adding and subtracting fractions).

S_4 = \dfrac{0.5}{3}(6.6) = 1.1

Multiply by Δx/3.

\ln 3 \approx 1.098612

The exact value.

1.1 - 1.098612 = 0.001388

Find the error.

Answer: S_4 = 1.1, off by only about 0.0014.

Example 3: An integral with no formula

Estimate \int_0^1 e^{-x^2}\,dx with n = 4. This integral has no antiderivative made of basic functions, so a numerical method is the way to go.

\Delta x = \dfrac{1 - 0}{4} = 0.25

Find the width.

f(0) = 1, \; f(0.25) \approx 0.939413, \; f(0.5) \approx 0.778801

Find e^(−x²) at the first three x-values.

f(0.75) \approx 0.569783, \; f(1) \approx 0.367879

Find the last two.

1 + 4(0.939413) + 2(0.778801) + 4(0.569783) + 0.367879

Apply the weights.

= 1 + 3.757652 + 1.557602 + 2.279132 + 0.367879 = 8.962265

Multiply, then add.

S_4 = \dfrac{0.25}{3}(8.962265) \approx 0.746855

Multiply by Δx/3.

Answer: about 0.74686. The true value is 0.746824…, so the error is about 0.00003.

Example 4: Choosing n with the error bound

How large must n be so that Simpson’s rule estimates \int_1^3 \dfrac{1}{x}\,dx with error at most 0.0001?

f(x) = x^{-1}, \; f^{(4)}(x) = 24x^{-5}

Differentiate four times (see higher-order derivatives).

K = 24(1)^{-5} = 24

24/x⁵ is largest on [1, 3] at x = 1.

\dfrac{24(3 - 1)^5}{180n^4} \le 0.0001

Set the bound at most 0.0001.

\dfrac{768}{180n^4} \le 0.0001

24 · 32 = 768.

n^4 \ge \dfrac{768}{180(0.0001)} \approx 42{,}667

Solve for n⁴.

n \ge 14.37

Take the fourth root.

n = 16

Round up to the next even number.

Answer: n = 16 subintervals is enough.

Example 5: Area of a pond

A surveyor measures the width of a pond every 10 meters along its 80-meter length. The widths, in meters, are 0, 18, 26, 30, 32, 29, 24, 15 and 0. Estimate the pond’s area.

\Delta x = 10, \; n = 8

Nine widths give 8 subintervals, an even number.

0 + 4(18) + 2(26) + 4(30) + 2(32) + 4(29) + 2(24) + 4(15) + 0

Apply the weights 1, 4, 2, 4, 2, 4, 2, 4, 1.

= 0 + 72 + 52 + 120 + 64 + 116 + 48 + 60 + 0 = 532

Multiply, then add.

S_8 = \dfrac{10}{3}(532) \approx 1773.3

Multiply by Δx/3.

Answer: the pond’s area is about 1773 square meters. Simpson’s rule works with table data, as long as the points are evenly spaced and n is even.

Common mistakes

MistakeExample of the errorFix
Using an odd nSimpson’s rule with n = 5n must be even, since each parabola covers two subintervals.
Wrong weights1, 4, 4, 4, 1 for n = 4The inside weights alternate: 1, 4, 2, 4, 1.
Using Δx/2\dfrac{\Delta x}{2}\big[f(x_0) + 4f(x_1) + f(x_2)\big]Simpson’s rule uses Δx/3. Δx/2 belongs to the trapezoidal rule.
Counting points as n9 data points, so n = 9n counts subintervals: 9 points give n = 8.
Wrong derivative in the error boundUsing f″ for KSimpson’s bound uses the fourth derivative, |f^{(4)}(x)| \le K.

Related methods

Simpson’s rule from the trapezoidal and midpoint rules

If T_n is the trapezoidal estimate and M_n is the midpoint estimate with n subintervals, then S_{2n} = \dfrac{T_n + 2M_n}{3}. Their errors tend to have opposite signs, and this average cancels most of them.

Comparing the methods

MethodError boundExact for
Midpoint rule\dfrac{K_2(b - a)^3}{24n^2}Lines
Trapezoidal rule\dfrac{K_2(b - a)^3}{12n^2}Lines
Simpson’s rule\dfrac{K_4(b - a)^5}{180n^4}Cubics

Here K₂ bounds |f″| and K₄ bounds |f⁽⁴⁾|. Because Simpson’s error shrinks like 1/n⁴, it usually needs far fewer points.

Practice problems

  1. Use Simpson’s rule with n = 4 to estimate \int_0^4 x^3\,dx.
  2. Use Simpson’s rule with n = 4 to estimate \int_0^{\pi} \sin x\,dx.
  3. Use Simpson’s rule with n = 4 to estimate \int_0^1 \dfrac{1}{1 + x^2}\,dx. Multiply by 4 to estimate π.
  4. For n = 6, how many function values do you need, and what are the weights?
  5. Use Simpson’s rule with n = 2 to estimate \int_2^4 \ln x\,dx. Compare with the exact value, 6 ln 2 − 2.
  6. A car’s speed, in meters per second, is 0, 12, 20, 24 and 26 at t = 0, 2, 4, 6 and 8 seconds. Estimate the distance it travels.
  7. Find the error bound for Simpson’s rule with n = 4 on \int_0^2 e^x\,dx.
  8. How large must n be for Simpson’s rule to estimate \int_0^1 e^x\,dx with error at most 0.000001?
  9. Use Simpson’s rule with n = 2 on \int_{-1}^3 (2x^3 - x + 5)\,dx and explain why the answer is exact.
  10. For \int_0^2 x^4\,dx, T₂ = 9 and M₂ = 5.125. Find S₄ from them, and compare with the exact value.
Show answers

1.

\Delta x = 1; \; f = 0, 1, 8, 27, 64

Find the width and cube each x-value.

0 + 4(1) + 2(8) + 4(27) + 64 = 192

Apply the weights and add.

S_4 = \dfrac{1}{3}(192) = 64

Multiply by Δx/3.

Answer: 64, which is exact, since x³ is a cubic.

2.

\Delta x = \dfrac{\pi}{4}; \; f = 0, \tfrac{\sqrt{2}}{2}, 1, \tfrac{\sqrt{2}}{2}, 0

Find sin x at 0, π/4, π/2, 3π/4 and π (see unit circle).

0 + 4\left(\tfrac{\sqrt{2}}{2}\right) + 2(1) + 4\left(\tfrac{\sqrt{2}}{2}\right) + 0 = 4\sqrt{2} + 2 \approx 7.656854

Apply the weights and add.

S_4 = \dfrac{\pi}{12}(4\sqrt{2} + 2) \approx 2.00456

Multiply by Δx/3 = π/12.

Answer: about 2.0046. The exact value is 2.

3.

\Delta x = 0.25; \; f = 1, \tfrac{16}{17}, 0.8, 0.64, 0.5

Find 1/(1 + x²) at 0, 0.25, 0.5, 0.75 and 1.

1 + 4\left(\tfrac{16}{17}\right) + 2(0.8) + 4(0.64) + 0.5 \approx 9.424706

Apply the weights and add.

S_4 = \dfrac{0.25}{3}(9.424706) \approx 0.785392

Multiply by Δx/3.

4(0.785392) \approx 3.14157

The exact integral is π/4, so 4 S₄ estimates π.

Answer: S₄ ≈ 0.785392, and π ≈ 3.14157.

4.

n + 1 = 7

n subintervals have n + 1 endpoints.

1, 4, 2, 4, 2, 4, 1

Ends get 1; inside weights alternate, starting and ending with 4.

Answer: 7 function values, with weights 1, 4, 2, 4, 2, 4, 1.

5.

\Delta x = 1; \; f \approx 0.693147, \; 1.098612, \; 1.386294

Find ln 2, ln 3 and ln 4.

0.693147 + 4(1.098612) + 1.386294 = 6.473889

Apply the weights 1, 4, 1.

S_2 = \dfrac{1}{3}(6.473889) \approx 2.157963

Multiply by Δx/3.

6\ln 2 - 2 \approx 2.158883

The exact value.

Answer: about 2.1580, off by about 0.0009.

6.

\Delta t = 2, \; n = 4

Five speeds give 4 subintervals.

0 + 4(12) + 2(20) + 4(24) + 26 = 210

Apply the weights and add.

S_4 = \dfrac{2}{3}(210) = 140

Multiply by Δt/3.

Answer: about 140 meters (see displacement and total distance).

7.

K = e^2 \approx 7.389056

Every derivative of eˣ is eˣ, largest at x = 2.

\dfrac{e^2(2 - 0)^5}{180(4)^4} = \dfrac{32e^2}{46{,}080}

Use the error bound.

\approx 0.005131

Divide.

Answer: the error is at most about 0.0051.

8.

K = e

The fourth derivative of eˣ is eˣ, largest at x = 1.

\dfrac{e(1 - 0)^5}{180n^4} \le 0.000001

Set up the bound.

n^4 \ge \dfrac{e}{180(0.000001)} \approx 15{,}101.6

Solve for n⁴.

n \ge 11.09

Take the fourth root.

Answer: n = 12, the next even number.

9.

\Delta x = 2; \; f(-1) = 4, \; f(1) = 6, \; f(3) = 56

Find the width and the three values.

S_2 = \dfrac{2}{3}\big(4 + 4(6) + 56\big) = \dfrac{2}{3}(84) = 56

Apply the weights 1, 4, 1 and multiply by Δx/3.

\Big[\tfrac{x^4}{2} - \tfrac{x^2}{2} + 5x\Big]_{-1}^{3} = 51 - (-5) = 56

Find the exact value.

Answer: 56. It is exact because the integrand is a cubic.

10.

S_4 = \dfrac{T_2 + 2M_2}{3} = \dfrac{9 + 2(5.125)}{3}

Use S₂ₙ = (Tₙ + 2Mₙ)/3 with n = 2.

= \dfrac{19.25}{3} \approx 6.41667

Add, then divide.

\int_0^2 x^4\,dx = \dfrac{2^5}{5} = 6.4

The exact value.

Answer: S₄ ≈ 6.4167, off by about 0.0167.

Simpson’s rule FAQ

What is Simpson’s rule?

Simpson’s rule is a way to estimate a definite integral. It fits parabolas through groups of three points and adds the areas under them, using weights 1, 4, 2, 4, …, 4, 1 and the factor Δx/3.

Why does n have to be even in Simpson’s rule?

Each parabola covers two subintervals. To cover the whole interval with parabolas, the subintervals must come in pairs, so n is even.

Is Simpson’s rule more accurate than the trapezoidal rule?

Usually, yes. Its error shrinks like 1/n⁴, while the trapezoidal rule’s error shrinks like 1/n². It is also exact for cubics.

What is the error bound for Simpson’s rule?

The error is at most K(b − a)⁵/(180n⁴), where K is the largest value of |f⁽⁴⁾(x)| on [a, b].

Summary

  • Simpson’s rule: S_n = (Δx/3)[f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)].
  • n must be even; the weights are 1, 4, 2, 4, …, 2, 4, 1.
  • It is exact for polynomials of degree 3 or less.
  • Error bound: K(b − a)⁵/(180n⁴), with K bounding |f⁽⁴⁾|.
  • It works on evenly spaced table data, too.

Previous lesson: Choosing an Integration Technique

Next lesson: Improper Integrals

Back to the Calculus 2 Index