Skip to main content
Mathematics LibreTexts

2.5: Numerical Integration

  • Page ID
    163273
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \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}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Definitions

    • Closed Form
    • Numerical Integration
    • Absolute Error
    • Relative Error
    Definition: Absolute Error

    The absolute error, \( E_* \), of a numerical approximation, \( A \), to the true value of the quantity, \( T \), is defined to be\[ E_* = |T - A|. \nonumber \]The notation "\( * \)" is reserved for the method being used. For example, the absolute error if using the Midpoint Rule with \( n = 10 \) to approximate the value of a definite integral is\[ E_M = \left| T - M_{10} \right|. \nonumber \]

    Definition: Relative Error

    The relative error of an approximation is the error as a percentage of the actual value and is given by\[\left| \dfrac{T − A_*}{T}\right| \cdot 100\% = \dfrac{E_*}{|T|} \cdot 100\%. \nonumber \]

    Theorems

    • Midpoint Rule (derive)
    • Trapezoidal Rule (derive)
    • Simpson's Rule (derive)
    • Error Bounds for Midpoint, Trapezoidal, and Simpson's Rules (do not derive)
    Theorem: Midpoint Rule

    Let \( f(x)\) be continuous on \([a,b]\), \( n\) be a positive integer, and \( \Delta x=\frac{b−a}{n}\). If \( [a,b]\) is divided into \( n\) subintervals, each of length \( \Delta x\), and \( m_i = \frac{x_{i - 1} + x_i}{2}\) is the midpoint of the \( i^{\text{th}}\) subinterval, set\[M_n = \sum_{i=1}^n f(m_i) \Delta x = \sum_{i=1}^n f\left(\dfrac{x_{i - 1} + x_i}{2}\right) \Delta x. \nonumber \]Then\[ \lim_{n \to \infty } M_n = \int ^b_af(x)\,dx.\nonumber \]

    Theorem: The Trapezoidal Rule

    Let \(f(x)\) be continuous over \([a,b]\), \(n\) be a positive integer, and \( \Delta x=\frac{b−a}{n}\). If \( [a,b]\) is divided into \(n\) subintervals, each of length \( \Delta x\), with endpoints at \( P=\{x_0,x_1,x_2, \ldots ,x_n\}\), set\[T_n=\dfrac{ \Delta x}{2}\left[f(x_0)+2 f(x_1) + 2 f(x_2) + \cdots + 2 f(x_{n−1}) + f(x_n)\right]. \nonumber \]Then,\[ \lim_{n \to \infty}T_n = \int ^b_af(x)\,dx. \nonumber \]

    Theorem: Simpson's Rule

    Assume that \(f(x)\) is continuous over \([a,b]\). Let \(n\) be a positive even integer and \( \Delta x=\frac{b−a}{n}\). Let \([a,b]\) be divided into \(n\) subintervals, each of length \( \Delta x\), with endpoints at \(P=\{x_0,x_1,x_2, \ldots ,x_n\}\). Set\[S_n = \dfrac{\Delta x}{3}\left[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4) + \cdots +2f(x_{n−2})+4f(x_{n−1})+f(x_n)\right]. \nonumber \]Then,\[\lim_{n \to \infty }S_n= \int ^b_af(x)\,dx.\nonumber \]

    Proof
    WLOG, assume \( x_{i - 1} = -h \), \( x_i = 0 \), and \( x_{i + 1} = h \). The area under the curve is\[ \int_{-h}^{h} Ax^2 + Bx + C  \, dx = \dfrac{h}{3} \left( 2Ah^2 + 6C \right); \nonumber \]however, we also know that\[ \begin{array}{rcl}
    y_0 & = & Ah^2 - Bh + C \\
    y_1 & = & C \\
    y_2 & = & Ah^2 + Bh + C \\
    \end{array} \nonumber \]Thus,\[ y_0 + 4y_1 + y_2 = 2Ah^2 + 6C. \nonumber \]The rest requires adding up the parabolic sections.
    Theorem: Error Bounds for the Midpoint and Trapezoidal Rules

    Let \(f(x)\) be a continuous function over \([a,b]\), where \(f^{\prime\prime}(x)\) exists over this same interval interval. If \(M\) is the maximum value of \(\left|f^{\prime\prime}(x)\right|\) over \([a,b]\), then the upper bounds for the error in using \(M_n\) and \(T_n\) to estimate \(\displaystyle \int ^b_af(x)\, dx\) are

    \[E_M \leq \dfrac{M(b−a)^3}{24n^2} \nonumber \]

    and

    \[E_T \leq \dfrac{M(b−a)^3}{12n^2}. \nonumber \]

    Theorem: Error Bound for Simpson's Rule

    Let \(f(x)\) be a continuous function over \([a,b]\) having a fourth derivative, \( f^{(4)}(x)\), over this interval. If \(M\) is the maximum value of \(\left|f^{(4)}(x)\right|\) over \([a,b]\), then the upper bound for the error in using \(S_n\) to estimate \(\displaystyle \int ^b_af(x)\, dx\) is given by\[E_S \leq \dfrac{M(b−a)^5}{180n^4}. \nonumber \]

    Examples

    Lecture Example \(\PageIndex{1}\)

    Use \( M_4 \), \( T_4 \), and \( S_4 \) to approximate the value of\[ \int_{0}^{2} e^{x^2} \, dx. \nonumber \]If the true value of this integral is approximately \(16.45262776\), compute the absolute error and relative error in your approximations. Which method looks to be better?

    Online Lecture Example \(\PageIndex{2}\)

    Use \( M_{100} \) and \( T_{100} \) to approximate the value of\[ \int_{-2}^{7} \sin\left( \sqrt[3]{1 - x^2} e^{-x} \right) \, dx. \nonumber \]

    Online Lecture Example \(\PageIndex{3}\)

    How large do we have to take \( n \) so that the approximations of \( T_n \), \( M_n \), and \( S_n \) to the integral\[ \int_{0}^{\pi} \sin(x) \, dx \nonumber \]are accurate to within \( 0.00001 \)?

    Online Lecture Example \(\PageIndex{4}\)

    Approximate the surface area of the solid obtained by rotating the given function about the \( x \)-axis using \( S_{10} \).\[ y = x e^x, \quad 0 \leq x \leq 1. \nonumber \]


    This page titled 2.5: Numerical Integration is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Roy Simpson.