Approximating an Integral

The rectangle method

The simplest method is exactly the Riemann sum: we replace the area under the curve by a sum of rectangles. We split [a ; b][a \,;\, b] into nn pieces of width Δx=b−an\Delta x = \dfrac{b-a}{n}, and on each one we draw a rectangle.

∫abf(x) dx≈Δx (f(x0)+f(x1)+⋯+f(xn−1))\int_a^b f(x)\,\mathrm{d}x \approx \Delta x\,\bigl(f(x_0) + f(x_1) + \cdots + f(x_{n-1})\bigr)

here using the values at the left endpoint of each piece. Each rectangle's height is the value of ff at one endpoint of the piece.

The flaw is obvious: the flat top of the rectangle fits the curve poorly. There are gaps or overhanging corners, especially where the curve is steep. The error can be significant.

How can we improve it? By increasing nn: the thinner the rectangles, the smaller the error. But convergence is slow — the error is roughly proportional to 1n\dfrac{1}{n}, so to halve it you need about twice as many rectangles.

The idea for doing better, without multiplying the number of points, is to replace the flat top of the rectangle with something that follows the curve: a slanted segment, which gives trapezoids, then a small arc of a parabola, which gives Simpson's rule. That is the subject of the next chapter: fitting the curve better, not just cutting it more finely.