Numerical Integration

Calculus 2

Overview

When working with Riemann sums, we use a left endpoint, right endpoint, or midpoint to set up our rectangles. These rectangles are occasionally equally spaced (Δx=(ba)/n\Delta x = (b-a)/n), but this may not always be the case.

The approximations we found using these rectangles were decent, but why settle for decent?

This leads us to ask the questions:

  1. What ways are we able to improve the area approximation a Riemann sum gives us?
  2. Would shapes other than rectangles prove to be more useful?

The Trapezoidal Rule

With the Trapezoidal Rule, we use trapezoids instead of rectangles to better fit the region. That is, we move from using rectangles to approximate area (which corresponds to using constant functions to fit f(x)f(x)) to using trapezoids to approximate area (which corresponds to using linear functions to fit f(x)f(x)).

Recall that the area of a trapezoid with heights h1h_1 and h2h_2 and width ww is given by:

A=12w(h1+h2)=w(h1+h22).A = \frac{1}{2} w (h_1 + h_2) = w \left( \frac{h_1 + h_2}{2} \right).

The area of an arbitrary trapezoid is given by:

Ak=12(f(xk)+f(xk+1))Δx=12(f(xk)+f(xk+1))ban=ba2n(f(xk)+f(xk+1)).\begin{aligned} A_k &= \frac{1}{2} (f(x_k) + f(x_{k+1})) \cdot \Delta x \\ &= \frac{1}{2} (f(x_k) + f(x_{k+1})) \frac{b-a}{n} \\ &= \frac{b-a}{2n}(f(x_k) + f(x_{k+1})). \end{aligned}

Therefore, an approximation of the area of the entire region can be found by adding up/accumulating the area of all trapezoids of the form above. That is:

A=abf(x)dxba2n(f(x0)+f(x1))   +ba2n(f(x1)+f(x2))      + . . .          +ba2n(f(xn2)+f(xn1))            +ba2n(f(xn1)+f(xn))=ba2n( (f(x0)+f(x1))+(f(x1)+f(x2))+ . . . +(f(xn2)+f(xn1))+(f(xn1)+f(xn)) )=ba2n( f(x0)+2f(x1)+2f(x2)+ . . . +2f(xn2)+2f(xn1)+f(xn) )\begin{aligned} A &= \int_a^b f(x)dx\\ &\approx \frac{b-a}{2n}(f(x_0)+f(x_1))\\ & \ \ \ +\frac{b-a}{2n}(f(x_1)+f(x_2))\\ & \ \ \ \ \ \ +\ . \ . \ . \ \\ & \ \ \ \ \ \ \ \ \ +\frac{b-a}{2n}(f(x_{n-2})+f(x_{n-1}))\\ & \ \ \ \ \ \ \ \ \ \ \ \ +\frac{b-a}{2n}(f(x_{n-1})+f(x_{n}))\\ &= \frac{b-a}{2n}( \ (f(x_0)+f(x_1)) + (f(x_1)+f(x_2)) + \ . \ . \ . \ + (f(x_{n-2})+f(x_{n-1})) + (f(x_{n-1})+f(x_{n})) \ )\\ &= \frac{b-a}{2n}( \ f(x_0) + 2 \cdot f(x_1) + 2 \cdot f(x_2) + \ . \ . \ . \ + 2 \cdot f(x_{n-2}) + 2 \cdot f(x_{n-1}) + f(x_{n}) \ ) \end{aligned}

Note the 1-2--2-1 pattern for the Trapezoidal Rule.

Example 1

Use the Trapezoidal Rule with n=4n=4 to estimate 12x2dx.\int_1^2 x^2 \, dx. Compare the estimate with the exact value.

View Answer

75322.344\frac{75}{32} \approx 2.344 (compared to 732.333\frac{7}{3} \approx 2.333).


Simpson's Rule

With Simpson's Rule, we use parabolas instead of trapezoids to better fit the region. That is, we move from using trapezoids to approximate area (which corresponds to using linear functions to fit f(x)f(x)) to using parabolas to approximate area (which corresponds to using quadratic functions to fit f(x)f(x)).

We won't go through the full derivation for this rule. However, the area of the parabolic section given by the points (xk,f(xk))(x_k,f(x_k)), (xk+1,f(xk+1))(x_{k+1},f(x_{k+1})), and (xk+1,f(xk+1))(x_{k+1},f(x_{k+1})) is given by:

Ak=13(f(xk)+4f(xk+1)+f(xk+2))Δx=13(f(xk)+4f(xk+1)+f(xk+2))ban=ba3n(f(xk)+4f(xk+1)+f(xk+2))\begin{aligned} A_k &= \frac{1}{3}(f(x_k)+4f(x_{k+1})+f(x_{k+2}))\cdot \Delta x\\ &= \frac{1}{3}(f(x_k)+4f(x_{k+1})+f(x_{k+2})) \frac{b-a}{n}\\ &= \frac{b-a}{3n}(f(x_k)+4f(x_{k+1})+f(x_{k+2})) \end{aligned}

Therefore, an approximation of the area of the entire region can be found by adding up/accumulating the area of all parabolic sectors of the form above. That is:

A=abf(x)dxba3n(f(x0)+4f(x1)+f(x2))   +ba3n(f(x2)+4f(x3)+f(x4))      + . . .          +ba3n(f(xn2)+4f(xn1)+f(xn))=ba3n(f(x0)+4f(x1)+2f(x2)+4f(x3)+2f(x4)+ . . . +2f(xn2)+4f(xn1)+f(xn))\begin{aligned} A &= \int_a^b f(x)dx\\ &\approx \frac{b-a}{3n}(f(x_0)+4f(x_1)+f(x_2))\\ & \ \ \ +\frac{b-a}{3n}(f(x_2)+4f(x_3)+f(x_4))\\ & \ \ \ \ \ \ +\ . \ . \ . \ \\ & \ \ \ \ \ \ \ \ \ +\frac{b-a}{3n}(f(x_{n-2})+4f(x_{n-1})+f(x_{n}))\\ &= \frac{b-a}{3n}(f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+ \ . \ . \ . \ +2f(x_{n-2})+4f(x_{n-1})+f(x_n)) \end{aligned}

Note the 1-4-2--2-4-1 pattern for Simpson's Rule.

Also note that the number of subintervals, nn, must be even to apply Simpson's Rule because each parabolic arc uses two subintervals.

Example 2

Use Simpson's Rule with n=4n=4 to estimate 025x4dx.\int_0^2 5x^4 \, dx. Compare the estimate with the exact value.

View Answer

3851232.083\frac{385}{12} \approx 32.083 (compared to 3232).


Error Bounds

When using approximation methods, it is important to determine how accurate the results are. While we may not know the exact error, we can compute an upper bound for the error.

Error Formulas

Example 3

Find an upper bound for the error in estimating 025x4dx\int_0^2 5x^4 \, dx using Simpson's Rule with n=4n=4. What value of nn should we pick so that the error is within 0.0010.001 of the true value?

View Answer

ES112|E_S| \leq \frac{1}{12}; n42533412.086n \geq 4 \sqrt[4]{\frac{2 \cdot 5^3}{3}} \approx 12.086.


© 2023 - 2024 CalcPrep

[Contact][Privacy Statement][Terms of Use]

Last Updated: 12/14/2024

AP® and CLEP® are trademarks registered by the College Board, which is not affiliated with, and does not endorse, this website.