Skip to main content

Math 220-2: Kursobjekt

Section 1.22 Numerical integration: techniques

Definition 1.22.1. Trapezoidal rule.

Let \(f\) be an integrable function on \([a,b]\text{,}\) let \(n\) be a positive integer, and let
\begin{equation*} a=x_0\lt x_1\lt x_2\lt \cdots \lt x_n=b \end{equation*}
be partition of \([a,b]\) into \(n\) subintervals of equal length \(\Delta x=\frac{b-a}{n}\text{.}\)
The \(n\)-th trapezoidal estimate of \(\displaystyle\int f(x)\, dx\text{,}\) denoted \(T_n\text{,}\) is defined as
\begin{equation*} T_n=\frac{1}{2}\Delta x(f(x_0)+2f(x_1)+2f(x_2)+\cdots +2f(x_{n-1})+f(x_n))\text{.} \end{equation*}
The trapezoidal estimate is the result of approximating the graph of \(f\) with the polygon passing through the points \(P_0=(x_0, f(x_0)), P_1=(x_1,f(x_1)), \dots, P_n=(x_n, f(x_n))\text{.}\)

Definition 1.22.2. Simpson’s rule.

Let \(f\) be an integrable function on \([a,b]\text{,}\) let \(n=2r\) be an even positive integer, and let
\begin{equation*} a=x_0\lt x_1\lt x_2\lt \cdots \lt x_n=b \end{equation*}
be partition of \([a,b]\) into \(n\) subintervals of equal length \(\Delta x=\frac{b-a}{n}\text{.}\)
The \(n\)-th Simpson’s rule estimate of \(\displaystyle\int f(x)\, dx\text{,}\) denoted \(S_n\text{,}\) is defined as
\begin{equation*} S_n=\frac{1}{3}\Delta x(f(x_0)+4f(x_1)+2f(x_2)+\cdots +2f(x_{n-2})+4f(x_{n-1})+f(x_n))\text{.} \end{equation*}
The Simpson’s rule estimate is the result of approximating the graph of \(f\) over each of the \(r\) subintervals \([x_{2(k-1)},x_{2k}]\) with the unique “parabolic arc” 1  passing through the points
\begin{equation*} P_{2(k-1)}=(x_{2(k-1)}, f(x_{2(k-1)})), P_{2k-1}=(x_{2k-1}, f(x_{2k-1})), P_{2k}=(x_{2k},f(x_{2k}))\text{.} \end{equation*}

Interactive example 1.22.1. Trapezoidal and Simpson’s rule.

Example 1.22.4. Estimating \(\ln 4\).

Let \(f(x)=\frac{1}{x}\text{.}\) Recall that we have by definition \(\ln 4=\int_1^4f(x)\, dx\text{.}\) Compute (a) the \(n=6\) trapezoidal estimate of \(I\text{,}\) and (b) the \(n=6\) Simpson’s rule estimate of \(I\text{.}\)
Solution.

Example 1.22.5. Estimating \(\pi\).

Let \(f(x)=\frac{4}{x^2+1}\text{,}\) and let \(I=\int_0^1f(x)\, dx\text{.}\)
  1. Show that \(I=\pi\text{.}\)
  2. Estimate \(\pi\) using the \(n=6\) trapezoidal estimate of \(I\text{.}\)
  3. Estimate \(\pi\) using the \(n=6\) Simpson’s rule estimate of \(I\text{.}\)
Solution.