How to calculate the area under a curve?


One easy way to calculate the area under a curve is to divide the area into rectangles. The area under the curve is the shaded region in the graph below. As you adjust the slider which gives you the bounds for the area, so does the value for the area update. This value is exact (up to \(5\) decimal places here) and it's calculated using calculus.

Area: 0.00000

I will now explain how to calculate this area with rectangles. First of all, the curve above is defined by the function \(f(x) = x^2\). I will label the bounds within which we calculate the area as \(a\) and \(b\). Note that the bounds are initially set to \(-1\) and \(1\). If we divide this area into \(N\) rectangles, where every rectangle has a width of \(\Delta x\), then the approximate area under the curve is the sum of the areas of all the rectangles. The more rectangles you use the better the approximation.

Area: 0.00000
Num. of rectangles: 10

As I said, the width of the rectangle (its base) is \(\Delta x\). This \(\Delta x\) can be calculated as:

$$ \Delta x = \frac{b - a}{N} $$

where \(N\) is the number of rectangles which we choose. If we start with \(N = 10\), then the width of each rectangle is \(\Delta x = \frac{1 - (-1)}{10} = 0.2\). So the lower left corner of the first rectangle is at \(x = -1\), the lower left corner of the second rectangle is at \(x = -0.8\), and so on. Written in general terms, the lower left corner of the \(i\)-th rectangle is at:

$$ x_i = a + i\, \Delta x $$

where \(i = 0, 1, 2, \ldots, N-1\). The height of the \(i\)-th rectangle is the value of the function at the point \(x_i\), i.e. \(f(x_i)\). This is called the left method (can you guess what would be the right method?). The area of the \(i\)-th rectangle is then:

$$ \text{Area of the } i\text{-th rectangle} = f(x_i)\, \Delta x $$

The total area under the curve is then the sum of the areas of all the rectangles:

$$ \text{Approximate area} = \sum_{i=0}^{N-1} f(x_i)\, \Delta x $$

This is the approximate area under the curve and this is called the Riemann sum. It's named after the great German mathematician Bernhard Riemann who introduced this concept in the 19th century.

Calculating left Riemann sum between \(x = -1\) and \(x = 1\)

The question now is: will we ever get the exact area under the curve by using the Riemann sum? The answer is yes! And this is a key concept in calculus. Calculus allows us to evaluate quantities in their limit. In this case, the exact area is the limit of the Riemann sum when the width of the rectangles approaches zero, which is the same as the number of rectangles approaching infinity. This is called the definite integral of the function \(f(x)\) between \(a\) and \(b\), and it's denoted as:

$$ \text{Area} = \lim_{\Delta x \to 0} \sum_{i=0}^{N-1} f(x_i)\, \Delta x = \int_{a}^{b} f(x) \, dx $$

There is more to say about definite integrals. For example, the integral can also be negative if the curve is below the \(x\)-axis. So the integral is not just the area under the curve, but it's the signed area under the curve. But let's leave that for another time. Of course we can't make infinitely many rectangles, but we can make a lot of them and in principle we know that as we increase the number of rectangles, the Riemann sum will get closer and closer to the exact area. Being able to calculate continuous things exactly is a powerful tool in mathematics and it's the reason why calculus is so important in physics and engineering. Many processes and phenomena in the everyday world are continuous and therefore can be nicely described with calculus.