% This is lecture no. 15 of MH1101/: Calculus II.

\chapter{Error Bounds}%
\label{cha:error_bounds}

Approximations such as the midpoint and trapezoidal rule may overestimate or underestimate the true values of definite integrals.
Error bounds give an upper bound on the absolute error.

\begin{definition}
	Error.
	The \textbf{error} in using an approximation is the amount that needs to be added to the approximation to make it exact:
	\[
		\text{Error} = \text{True value} - \text{Approximation}
	.\]
\end{definition}

We denote the error of an approximation as $E_k$ where $k$ is the name of the approximation.
\begin{exmp}
	The error of the midpoint approximation is denoted as such:
	\[
	E_M = \int_{a}^{b} f(x) \ud x - M_n
	.\]
\end{exmp}
The following theorem gives an upper bound on the error in both the trapezoidal and midpoint rules as discussed in lecture \ref{cha:midpoint_rule_&_trapezoidal_rule}.
\begin{thrm}
	Error bounds for Trapezoidal and Midpoint Rules.
	Suppose $|f^{\prime\prime}(x)|\leqslant K$ for $a\leqslant x\leqslant b$.
	Then:
	\[
		|E_T|\leqslant \frac{K(b-a)^3}{12n^2}\qquad |E_M|\leqslant \frac{K(b-a)^3}{24n^2}
	.\]
\end{thrm}
\begin{exmp}
	Find $n$ such that the midpoint rule approximation $M_n$ approximates the following integral with an absolute error of at most 0.0001:
	\[
		\int_{1}^{4} \sqrt{x} \ud x
	.\]
	\begin{sol}
		Let $f(x)=\sqrt{x}$.
		First, we must find a number $K$ such that $|f^{\prime\prime}(x)|\leqslant K\ \forall x\in[1,4]$.
		\[
			f(x)=\sqrt{x}\implies f^{\prime}(x)= \frac{1}{2}x^{-\frac{1}{2}}\implies |f^{\prime\prime}(x)|= \frac{1}{4}x^{-\frac{3}{2}}
		,\]
		and thus, $|f^{\prime\prime}(x)|$ is decreasing on $[1,4]$ which implies that its maximum occurs at the left endpoint $x=1$.
		Therefore, we choose the following:
		\[
			K = |f^{\prime\prime}(x)|=\frac{1}{4}
		.\]
		By the error bound theorem we have:
		\[
			|E_M|\leqslant \frac{K(b-a)^3}{24n^2}= \frac{27}{96n^2}\leqslant 0.0001
		.\]
		Thus the absolute error is at most $0.0001$ if
		\begin{align*}
			n^2 & \geqslant \frac{27\times 10^{4}}{96}\\
			    & = 2812.5\\
			\therefore n & \geqslant \sqrt{2812.5}\\
				     & = 53.033
		\end{align*}
		So we choose $n=54$.
	\end{sol}
\end{exmp}

