next up previous contents
Next: Programming Up: C. Trapezium rule for Previous: Trapezium rule   Contents

Extended trapezium rule

To make this rule useful, break the curve to be integrated into many small intervals (small h). Then use the trapezium rule many times, like this (see figure C.5):

Figure C.5: The curve f (x) is now approximated by a series of short straight lines which each form a trapezium. Summing the area of these trapezia gives an approximation of the total area under the curve between a and b.
\includegraphics[width=8cm]{trapint2}


$\displaystyle \int_{{a}}^{{b}}$f (x)dx = h$\displaystyle \left(\vphantom{ \frac{1}{2} f_1 + \frac{1}{2} f_2}\right.$$\displaystyle {\frac{{1}}{{2}}}$f1 + $\displaystyle {\frac{{1}}{{2}}}$f2$\displaystyle \left.\vphantom{ \frac{1}{2} f_1 + \frac{1}{2} f_2}\right)$    ..A  
    + h$\displaystyle \left(\vphantom{\frac{1}{2} f_2 + \frac{1}{2} f_3}\right.$$\displaystyle {\frac{{1}}{{2}}}$f2 + $\displaystyle {\frac{{1}}{{2}}}$f3$\displaystyle \left.\vphantom{\frac{1}{2} f_2 + \frac{1}{2} f_3}\right)$ ..B  
    + h$\displaystyle \left(\vphantom{\frac{1}{2} f_3 + \frac{1}{2} f_4}\right.$$\displaystyle {\frac{{1}}{{2}}}$f3 + $\displaystyle {\frac{{1}}{{2}}}$f4$\displaystyle \left.\vphantom{\frac{1}{2} f_3 + \frac{1}{2} f_4}\right)$ ..C  
    + h$\displaystyle \left(\vphantom{\frac{1}{2} f_4 + \frac{1}{2} f_5}\right.$$\displaystyle {\frac{{1}}{{2}}}$f4 + $\displaystyle {\frac{{1}}{{2}}}$f5$\displaystyle \left.\vphantom{\frac{1}{2} f_4 + \frac{1}{2} f_5}\right)$ ..D  
    + O$\displaystyle \left(\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right.$$\displaystyle {\frac{{(b-a)^3 f''}}{{N^2}}}$$\displaystyle \left.\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right)$  

Generalise the formula to N points:

$\displaystyle \int_{{x_1}}^{{x_N}}$f (x)dx = h$\displaystyle \left[\vphantom{
\frac{1}{2}f_1 + f_2 + f_3 + ... + f_{N-1} + \frac{1}{2}f_N }\right.$$\displaystyle {\frac{{1}}{{2}}}$f1 + f2 + f3 + ... + fN-1 + $\displaystyle {\frac{{1}}{{2}}}$fN$\displaystyle \left.\vphantom{
\frac{1}{2}f_1 + f_2 + f_3 + ... + f_{N-1} + \frac{1}{2}f_N }\right]$ + O$\displaystyle \left(\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right.$$\displaystyle {\frac{{(b-a)^3 f''}}{{N^2}}}$$\displaystyle \left.\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right)$

= h$\displaystyle \left[\vphantom{ \frac{1}{2}(f_1+f_N) + \sum_{i=2}^{N-1}f_i }\right.$$\displaystyle {\frac{{1}}{{2}}}$(f1 + fN) + $\displaystyle \sum_{{i=2}}^{{N-1}}$fi$\displaystyle \left.\vphantom{ \frac{1}{2}(f_1+f_N) + \sum_{i=2}^{N-1}f_i }\right]$ + O$\displaystyle \left(\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right.$$\displaystyle {\frac{{(b-a)^3 f''}}{{N^2}}}$$\displaystyle \left.\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right)$

Note that h is still the width of a single interval, so

h = $\displaystyle {\frac{{b-a}}{{N-1}}}$

The approximation error is now

O$\displaystyle \left(\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right.$$\displaystyle {\frac{{(b-a)^3 f''}}{{N^2}}}$$\displaystyle \left.\vphantom{ \frac{(b-a)^3 f''}{N^2}}\right)$

b - a and f'' are normally fixed parameters of the problem. You can see that increasing N will improve the accuracy.


next up previous contents
Next: Programming Up: C. Trapezium rule for Previous: Trapezium rule   Contents
RHUL Dept. of Physics