The error inherent in a Riemann sum

Suppose we have a monotone, increasing function $f$ defined over an interval $[a,b]$ and we'd like to use a left and right Riemann sums, $L_n$ and $R_n$, to estimate $$\int_a^b f(x)\, dx.$$ If $n$ represents the number of terms in the sum, how large must $n$ be to ensure our error does not exceed some pre-prescribed tolerance?

Since the function is increasing, we certainly know that $$L_n \leq \int_a^b f(x)\, dx \leq R_n.$$ This implies that $$0 \leq \int_a^b f(x)\, dx - L_n \leq R_n - L_n$$ and $$L_n - R_n \leq \int_a^b f(x)\, dx - R_n \leq 0.$$ In both cases, the term in the middle is the actual error and we have that $$\text{error}\leq \left|R_n-L_n\right|.$$

But, there is a very simple interpretation of $R_n-L_n$ - it is the total area of the rectangles shown in red below, which yields $$\text{error}\leq \left|f(b)-f(a)\right|\frac{b-a}{n}.$$

By the mean value theorem, we know that $$\frac{f(b)-f(a)}{b-a} = f'(c)$$ for some $c$ between $a$ and $b$. Thus, if $M$ is an upper bound for $|f'|$ on the interval, then we know that $$\text{error}\leq \frac{\left|f(b)-f(a)\right|}{b-a}\cdot\frac{(b-a)^2}{n} \leq M\frac{(b-a)^2}{n}.$$ The nice thing about this last formulation is that it holds whether $f$ is monotone or not!

Sums and error bounds

Here are four approximating sums and error bounds that the inquiring calculus student should know. In these forumulae,

• $a$ and $b$ are the endpoints of the interval over which we integrate,
• $n$ is the number of subintervals we break the interval into and, therefore, the number of terms in the sum,
• $\displaystyle \Delta x = \frac{b-a}{n}$ is the common length of the sub-intervals,
• $x_i = a + i\,\Delta x$,
• $M_1$ is an upper bound for $f'$ over $[a,b]$, and
• $M_2$ is an upper bound for $f''$ over $[a,b]$.
MethodFormulaError
Right sum
$\displaystyle \sum_{i=1}^{n} f(x_{i})\Delta x$
$\displaystyle \text{error} \leq M_1\frac{(b-a)^2}{n}.$
Left sum
$\displaystyle \sum_{i=1}^{n} f(x_{i-1})\Delta x$
$\displaystyle \text{error} \leq M_1\frac{(b-a)^2}{n}.$
Trapezoidal sum
$\displaystyle \sum_{i=1}^{n} \frac{f(x_i) + f(x_{i-1})}{2}\Delta x$
$\displaystyle \text{error} \leq M_2\frac{(b-a)^3}{12n^2}.$
Midpoint sum
$\displaystyle \sum_{i=1}^{n} f\left(\frac{x_{i} + x_{i-1}}{2}\right)\Delta x$
$\displaystyle \text{error} \leq M_2\frac{(b-a)^3}{24n^2}.$