The continuous function \(f\) maps the real interval \[\begin{equation*} a \le x \le b \end{equation*}\]

into a subset of the positive real numbers. Derive the trapezium rule for the approximate evaluation of the area under the curve \(y = f(x)\) between \(x=a\) and \(x=b\), using \((n-1)\) points of subdivision at a distance \(h = (b-a)/n\) apart.

Consider the following diagram.

Area under a curve approximated by a series of trapezia

In this diagram, we start with the graph of \(y = f(x)\) between \(x=a\) and \(x=b\). This is shown in black. Our goal is to approximate the area under this curve; this is the region in blue (and purple, where it overlaps with the red region).

We then fix an integer \(n\), define \(h = (b-a)/n\), and divide the interval \(a \le x \le b\) into \(n\) equal parts (of length \(h\)) by marking the points at \(a+h\), \(a+2h\), and so on. We then draw line segments between \((a,f(a))\) and \((a+h,f(a+h))\); between \((a+h,f(a+h))\) and \((a+2h,f(a+2h))\); and so on. This is the (piecewise linear) curve in dark red.

The trapezium rule says that the area under the red curve (the region in light red; this is a sequence of trapezia) is approximately the same as the area under the original graph, with the approximation becoming more exact as \(n\) increases. We will write this symbolically: \[\begin{align*} &\text{area of the first trapezium} + \text{area of the second trapezium} + \dotsb + \text{area of the last trapezium}\\ &= \frac{f(a) + f(a+h)}{2} h + \frac{f(a+h) + f(a+2h)}{2} h + \dotsb + \frac{f(b-h) + f(b)}{2} h \\ &= \frac{h}{2} \left( f(a) + 2f(a+h) + 2f(a+2h) + \dotsb + 2f(b-h)+ f(b) \right) \\ &\approx \int_a^b f(x) \:dx. \end{align*}\]
Hence obtain an approximation to the integral \[\begin{equation*} I = \int_3^5 x \ln x \:dx \end{equation*}\]

using the points of subdivision given in the following table:

\(x\) \(3.0\) \(3.5\) \(4.0\) \(4.5\) \(5.0\)
\(x \ln x\) \(3.296\) \(4.385\) \(5.545\) \(6.768\) \(8.047\)
In the above, \(a = 3\), \(b = 5\), \(f(x) = x \ln x\), and \(h = 0.5\). Hence, \[\begin{align*} \int_3^5 x \ln x \:dx &\approx \frac{0.5}{2} \left( f(3) + 2f(3.5) + 2f(4) + 2f(4.5) + f(5) \right) \\ &= \frac{1}{4} \left( 3.296 + 2 \times 4.385 + 2 \times 5.545 + 2 \times 6.768 + 8.047 \right) \\ &= 11.18475\\ &= 11.2 \quad\text{to $3$ s.f.} \end{align*}\]

We can, in fact, integrate \(x \ln x\) exactly using integration by parts. We find \(\int_3^5 x \ln x \:dx = 11.17421860\!\ldots\), so the above approximation is not bad.