Trapezoidal Rule

We will obtain the trapezoidal rule (approximation) from averaging the right and left endpoint approximations: $$${\int_{{a}}^{{b}}}{f{{\left({x}\right)}}}{d}{x}\approx\frac{{1}}{{2}}{\left({L}_{{n}}+{R}_{{n}}\right)}=\frac{{1}}{{2}}{\left({\sum_{{{i}={1}}}^{{n}}}{f{{\left({x}_{{{i}-{1}}}\right)}}}\Delta{x}+{\sum_{{{i}={1}}}^{{n}}}{f{{\left({x}_{{i}}\right)}}}\Delta{x}\right)}$$$.

Rewriting it we obtain the trapezoidal rule: $$${\int_{{a}}^{{b}}}{f{{\left({x}\right)}}}{d}{x}\approx{T}_{{n}}=\frac{{\Delta{x}}}{{2}}{\left({f{{\left({x}_{{0}}\right)}}}+{2}{f{{\left({x}_{{1}}\right)}}}+{2}{f{{\left({x}_{{2}}\right)}}}+\ldots+{2}{f{{\left({x}_{{{n}-{1}}}\right)}}}+{f{{\left({x}_{{n}}\right)}}}\right)}$$$.trapezoidal rule

It is called trapezoidal because as appeared this formula gives approximation by approximating area not with rectangles but trapezoids, with height of trapezoid $$$\Delta{x}$$$ and lengths of bases $$${f{{\left({x}_{{{i}-{1}}}\right)}}}$$$ and $$${f{{\left({x}_{{i}}\right)}}}$$$. Thus the area of i-th trapezoid is $$$\Delta{x}{\left(\frac{{{f{{\left({x}_{{{i}-{1}}}\right)}}}+{f{{\left({x}_{{i}}\right)}}}}}{{2}}\right)}$$$. Adding all trapezoids will give the trapezoidal rule.

It is worth noting that if function is concave up then trapezoidal rule overestimates integral, if function is concave down then trapezoidal rule underestimates integral.

Example 1. Use Trapezoidal Rule to approximate value of $$${\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x}$$$ with $$${n}={5}$$$.

Here $$${a}={1}$$$, $$${b}={2}$$$, $$${f{{\left({x}\right)}}}=\frac{{1}}{{{x}}^{{2}}}$$$ and $$${n}={5}$$$. So, $$$\Delta{x}=\frac{{{b}-{a}}}{{n}}=\frac{{{2}-{1}}}{{5}}={0.2}$$$.

So, $$${\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{\left({d}{x}\right)}\approx{T}_{{n}}=\frac{{0.2}}{{2}}{\left({f{{\left({1}\right)}}}+{2}{f{{\left({1.2}\right)}}}+{2}{f{{\left({1.4}\right)}}}+{2}{f{{\left({1.6}\right)}}}+{2}{f{{\left({1.8}\right)}}}+{f{{\left({2}\right)}}}\right)}=$$$

$$$={0.1}{\left(\frac{{1}}{{{1}}^{{2}}}+\frac{{2}}{{{\left({1.2}\right)}}^{{2}}}+\frac{{2}}{{{\left({1.4}\right)}}^{{2}}}+\frac{{2}}{{{\left({1.6}\right)}}^{{2}}}+\frac{{2}}{{{\left({1.8}\right)}}^{{2}}}+\frac{{1}}{{{2}}^{{2}}}\right)}\approx{0.505783}$$$.

In the Left Endpoint, Right Endpoint note we found for this example $$${L}_{{n}}={0.580783}$$$ and $$${R}_{{n}}={0.430783}$$$.

So, $$$\frac{{1}}{{2}}{\left({L}_{{n}}+{R}_{{n}}\right)}=\frac{{1}}{{2}}{\left({0.580783}+{0.430783}\right)}={0.505783}={T}_{{n}}$$$ as expected.

True value of integral is $$${I}={\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x}={0.5}$$$.

So, the trapezoidal rule overestimates integral as expected (function $$${f{{\left({x}\right)}}}=\frac{{1}}{{{x}}^{{2}}}$$$ is concave up on $$${\left[{1},{2}\right]}$$$).

When we approximate integral we will always have some error: $$${E}={\int_{{a}}^{{b}}}{f{{\left({x}\right)}}}{d}{x}-{A}{p}{p}$$$ where $$${A}{p}{p}$$$ is approximation and $$${E}$$$ is error.

Error bound for the trapezoidal rule. Suppose $$${\left|{f{''}}{\left({x}\right)}\right|}\le{M}$$$ for $$${a}\le{x}\le{b}$$$ then $$${\left|{E}\right|}\le\frac{{{M}{{\left({b}-{a}\right)}}^{{3}}}}{{{12}{{n}}^{{2}}}}$$$.

Example 2. How large should we take n in order to guarantee that the trapezoidal rule approximation for $$${\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x}$$$ are accurate to within 0.0002?

Here $$${a}={1}$$$, $$${b}={2}$$$, $$${f{{\left({x}\right)}}}=\frac{{1}}{{{x}}^{{2}}}$$$.

Then $$${f{'}}{\left({x}\right)}=-\frac{{2}}{{{x}}^{{3}}}$$$ and $$${f{''}}{\left({x}\right)}=\frac{{6}}{{{x}}^{{4}}}$$$.

Therefore $$${\left|{f{''}}{\left({x}\right)}\right|}\le{6}$$$ for $$${1}\le{x}\le{2}$$$.

Thus, $$$\frac{{{6}{{\left({2}-{1}\right)}}^{{3}}}}{{{12}{{n}}^{{2}}}}>{0.0002}$$$ or $$${{n}}^{{2}}>\frac{{1}}{{{0.0004}}}$$$.

So, $$${n}>\frac{{1}}{\sqrt{{{0.0004}}}}={50}$$$.

So, we need to take $$${n}={51}$$$.