Problem Set - Trapezoidal and Simpson approximations

## Problem Set - Trapezoidal and Simpson approximations

Last updates: 7 December 2009

## Trapezoidal and Simpson approximations

 Determine the area of a trapezoid with left edge at $x=l$, right edge at $x=l+\Delta x$, left height $f\left(l\right)$, and right height $f\left(l+\Delta x\right)$. Determine the area of a parabola topped slice with left edge at $x=l$, right edge at $x=l+2\Delta x$, middle at $x=l+\Delta x$, left height $f\left(l\right)$, middle height $f\left(l+\Delta x\right)$, and right height $f\left(l+2\Delta x\right)$. Let $N$ be a positive integer. Show that adding up $N$ trapezoidal slices gives the approximation to ${\int }_{a}^{b}f\left(x\right)dx$ given by $\frac{\Delta x}{2}\left(f\left(a\right)+2f\left(a+\Delta x\right)+2f\left(a+2\Delta x\right)+\cdots +2f\left(b-\Delta x\right)+f\left(b\right)\right)$, where $\Delta x=\frac{b-a}{N}$. Let $N$ be an even positive integer. Show that adding up $N$ parabola topped slices gives the approximation to ${\int }_{a}^{b}f\left(x\right)dx$ given by $\frac{\Delta x}{2}\left(f\left(a\right)+4f\left(a+\Delta x\right)+2f\left(a+2\Delta x\right)+\cdots +4f\left(b-\Delta x\right)+f\left(b\right)\right)$, where $\Delta x=\frac{b-a}{N}$. Compute a trapezoidal approximation with $N=4$ slices for the integral ${\int }_{0}^{2}\left(1+{x}^{2}\right)\mathrm{dx}$ and obtain a bound for the error. Compute a trapezoidal approximation with $N=8$ slices for the integral ${\int }_{0}^{2}\left(1+{x}^{2}\right)\mathrm{dx}$ and obtain a bound for the error. Compute a trapezoidal approximation with $N=4$ slices for the integral ${\int }_{0}^{1}{e}^{-x}\mathrm{dx}$ and obtain a bound for the error. Compute a trapezoidal approximation with $N=8$ slices for the integral ${\int }_{0}^{1}{e}^{-x}\mathrm{dx}$ and obtain a bound for the error. Compute a trapezoidal approximation with $N=4$ slices for the integral ${\int }_{0}^{\pi /2}\mathrm{sin}x\mathrm{dx}$ and obtain a bound for the error. Compute a trapezoidal approximation with $N=8$ slices for the integral ${\int }_{0}^{\pi /2}\mathrm{sin}x\mathrm{dx}$ and obtain a bound for the error. Compute a trapezoidal approximation with $N=4$ slices for the integral ${\int }_{0}^{1}{\left(1+{x}^{2}\right)}^{-1}\mathrm{dx}$ and obtain a bound for the error. Compute a trapezoidal approximation with $N=8$ slices for the integral ${\int }_{0}^{1}{\left(1+{x}^{2}\right)}^{-1}\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=4$ slices for the integral ${\int }_{0}^{2}\left(1+{x}^{2}\right)\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=8$ slices for the integral ${\int }_{0}^{2}\left(1+{x}^{2}\right)\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=4$ slices for the integral ${\int }_{0}^{1}{e}^{-x}\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=8$ slices for the integral ${\int }_{0}^{1}{e}^{-x}\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=4$ slices for the integral ${\int }_{0}^{\pi /2}\mathrm{sin}x\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=8$ slices for the integral ${\int }_{0}^{\pi /2}\mathrm{sin}x\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=4$ slices for the integral ${\int }_{0}^{1}{\left(1+{x}^{2}\right)}^{-1}\mathrm{dx}$ and obtain a bound for the error. Compute a Simpson approximation with $N=8$ slices for the integral ${\int }_{0}^{1}{\left(1+{x}^{2}\right)}^{-1}\mathrm{dx}$ and obtain a bound for the error. Let ${T}_{4}$ be the trapezoidal approximation with $N=8$ slices for the integral ${\int }_{0}^{1}{\left(1+{x}^{2}\right)}^{-1}\mathrm{dx}$. Show that $|f\mathrm{\prime \prime }\left(x\right)|\le 2$ for $x\in \left[0,1\right]$ and that $|{T}_{4}-\frac{1}{4}\pi |\le 1/96<0.0105$. Use the trapezoidal approximation with $N=4$ slices to approximate the integral $\mathrm{log}2={\int }_{1}^{2}{x}^{-1}\mathrm{dx}$. Show that $0.6866\le \mathrm{log}2\le 0.6958$. Use Simpson's approximation with $N=4$ slices to approximate $\mathrm{log}2$. Show that $0.6927\le \mathrm{log}2\le 0.6933$. Compute a trapezoidal approximation with $N=8$ slices for the integral ${\int }_{0}^{1}{e}^{-{x}^{2}}\mathrm{dx}$. Compute a trapezoidal approximation with $N=16$ slices for the integral ${\int }_{0}^{1}{e}^{-{x}^{2}}\mathrm{dx}$. Compute a Simpson approximation with $N=8$ slices for the integral ${\int }_{0}^{1}{e}^{-{x}^{2}}\mathrm{dx}$. Compute a Simpson approximation with $N=16$ slices for the integral ${\int }_{0}^{1}{e}^{-{x}^{2}}\mathrm{dx}$. Compute a trapezoidal approximation with $N=8$ slices for the integral ${\int }_{0}^{\pi /2}\frac{\mathrm{sin}x}{x}\phantom{,}\mathrm{dx}$. Compute a trapezoidal approximation with $N=16$ slices for the integral ${\int }_{0}^{\pi /2}\frac{\mathrm{sin}x}{x}\phantom{,}\mathrm{dx}$. Compute a Simpson approximation with $N=8$ slices for the integral ${\int }_{0}^{\pi /2}\frac{\mathrm{sin}x}{x}\phantom{,}\mathrm{dx}$. Compute a Simpson approximation with $N=16$ slices for the integral ${\int }_{0}^{\pi /2}\frac{\mathrm{sin}x}{x}\phantom{,}\mathrm{dx}$. Derive the midpoint approximation for ${\int }_{a}^{b}f\left(x\right)\phantom{,}\mathrm{dx}$. With $N$ slices it is obtained by adding up the areas of rectangles with height equal to the value of the function at the midpoint of the interval. Show that the error estimate is given by $|{\int }_{a}^{b}f\left(x\right)\phantom{,}\mathrm{dx}-{M}_{N}|\le \frac{{\left(b-a\right)}^{3}}{24{n}^{2}}M$, where $M$ is an upper bound for $|f\mathrm{\prime \prime }\left(x\right)|$ on $\left[a,b\right]$.