Skip to main content
Mathematics LibreTexts

Numerical Integration

  • Page ID
    497
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Review of Left and Right Sums

    We first encourage you to review left and right sums in class. For more information click here

    The Midpoint Approximation

    To get a better approximation of , for example,

    \[ \int_2^5x^2 \, dx \]

    we could instead use the y-value of the midpoint of each interval as the height. We will use six rectangles.

    numint15.gif

    Notice that the first midpoint is at 2.25 and each rectangle width

    \[ \Delta x = \dfrac{5-2}{6} = 0.5.\]

    The new numbers are as follows:

    \[2.25 + 0(0.5), 2.25 + 1(0.5), 2.25 + 2(0.5), 2.25 + 3(0.5), 2.25 + 4(0.5), 2.25 + 5(0.5)\]

    so that the y-coordinates are

    \[(2.25 + 0(0.5))^2, (2.25 + 1(0.5))^2, (2.25 + 2(0.5))^2, (2.25 + 3(0.5))^2, (2.25 + 4(0.5))^2, (2.25 + 5(0.5))^2.\]

    We see that the ith rectangle has y-coordinate:

    \(\text{height} = (2.25 + i(.5))^2\).

    To get the area of the ith rectangle we multiply the height by the base:

    \((2.25 + i(.5))^2(.5)\).

    Finally to get the total area we add the terms up:

    \(S(2.25 + i(.5))^2(.5) = 38.9975\).

    The true solution is 37.66... . The left endpoint approximation would have yielded 33.875 and the right endpoint approximation would have yielded 44.375. We see that for this case, the midpoint approximation yields a closer approximation.

    This approximation is called the midpoint approximation and is given in general by:

    Definition: The Midpoint Approximation

    \[\int_{a}^{b} f(x) dx \approx \dfrac{b-a}{n} \sum_{i=1}^n f(\dfrac{x_{i-1}+x_i}{2}) = \dfrac{b-a}{n}\sum_{i=1}^n f\left(\dfrac{b-a}{2n}+\dfrac{b-a}{n}i \right). \]

    The Trapezoidal Approximation

    A fourth method involves the trapezoidal rule which geometrically calculates the area of the trapezoid with base on the x-axis and heights \(f(x_i)\) and f(x_{i+1}). The area of the trapezoid is

    \[ \dfrac{\Delta x}{2} \left[ f(x_i) + f(x_{i+1}) \right] \]

    or the base times the average of the heights. Adding up all the trapeziods gives:

    Definition: The Trapezoidal Approximation

    \[ T(n) = \dfrac{b-a}{2n} \left[f(x0) + 2f(x_1) + 2f(x_2) +...+ 2f(x_{n-1}) + f(x_n) \right]. \]

    We can compare this with the true answer of 7.8475.

    \[ \int_3^13 \sqrt{1+x^3}\, dx.\]

    Error

    The error in approximating an integral can be found by subtracting the true value from the estimated value. The graphs show that the error is directly inked to the concavity of the integrand. Without proof, bounds for the errors using the midpoint and trapezoid approximations are:

    \[ |E_M| \le \dfrac{B(b - a)^3 }{24n^2} \]

    \[ |E_T| \le \dfrac{B(b - a)^3 }{12n^2}. \]

    Where

    \[ B = \text{max} |f ''(x)|.\]

    we are guaranteed to have an error less than 0.001.

    Simpson's Estimate

    We saw that the Trapezoidal and Midpoint estimates provided better accuracy than the Left and Right endpoint estimates. It turns out that a certain combination of the Trapezoid and Midpoint estimates is even better.

    Definition: Simpson's Approximation

    Let \(f(x)\) be a function defined on \([a,b]\). Then

    \[ S(n) = \dfrac{T(n)}{3} + \dfrac{2M(n)}{3}\]

    where \(T(n)\) and \(M(n)\) are the Trapezoidal and Midpoint Estimates. \(S(n)\) is called Simpson's Estimate for the integral.

    Geometrically, if \(n\) is an even number then Simpson's Estimate gives the area under the parabolas defined by connecting three adjacent points. Let \(n\) be even then using the even subscripted \(x\) values for the trapezoidal estimate and the midpoint estimate, gives

    \[\begin{align} S(n) &= \dfrac{1}{3}\Big[\dfrac{(b-a)}{2n} \big( f(x_0) +2f(x_2) +...+ f(x_{2n-2}) +f(x_{2n}) \big)\Big] \\ &\;\;\; + \dfrac{2}{3}\Big[\dfrac{b-a}{n}\big( f(x_1)f(x_3)+f(x_5)+...+f(x_{2n-1}) \big) \Big] \\ &= \dfrac{b-a}{3n}\Big(f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+4f(x_5)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n) \Big) \end{align}\]

    Notice the
    1 2 4 2 4 ... 2 4 2 4 1
    pattern.

    \[ = 0.3426.\]

    \[ \int _2^18 \dfrac{1}{x}\,dx.\]

    Error in Simpson's Estimate

    Without proof, we state

    Let

    \[ M = \text{max} |f''''(x)| \]

    and let \(E_S\) be the error in using Simpson's estimate. Then

    \[ |E_S| \le \dfrac{M(b - a)^5 }{180n^4}.\]

    Hence, if we choose \(n = 6\) we are guaranteed two decimals of accuracy.

    with \(n = 5\), determine the maximum errors that occur using the midpoint, the trapezoidal, and Simpson's approximation.

    Larry Green (Lake Tahoe Community College)


    This page titled Numerical Integration is shared under a not declared license and was authored, remixed, and/or curated by Larry Green.

    • Was this article helpful?