Approximating Area Under Curves

What precisely do we mean when we say “the area under the curve?” I think this is best explained via example.

[Present pictures of various functions with axes, with the expected area shaded.]

Notice, in each case, we’re just taking points on the curve and tracing down (or up) to the x-axis. Anything traced is what we say to be “under the curve.” So, if you prefer, you can think of “under the curve” to mean “between the curve and the x-axis.”

We can express each of these areas as a definite integral, by taking the left bound and making it the lower bound of the integral, taking the right bound and making it the upper bound of the integral, and then taking the function as the integrand. Of course, we also append dx.

How do we now determine the area under the curve? Well, if you have either an easy-enough function or the Fundamental Theorem of Calculus, you can compute it exactly, but I’d like to focus here on approximating these areas.

The strategy will be to draw a bunch of rectangles on the graph and add up their areas. If we pick suitable rectangles, this can give a decent approximation. Here are some examples of what these rectangles could look like. [Show functions with area shaded and rectangles overlaid.]

First, we pick or are given some number of rectangles to use, say 4. Now, these rectangles could, in principle, be of different widths, but in this class you’ll only really be dealing with rectangles of identical width. This makes things a bit easier. To determine the width of each identical width rectangle, we just need to divide up the total width of the area we’re approximating into 4 equal pieces. This is handled by the following formula: \Delta x = \frac{b-a}{n} where a and b are the lower and upper bounds of our region, respectively, and n is the number of rectangles we want to use. \Delta x is the resulting width of each rectangle. Be careful to not switch a and b in the numerator! Doing so will give you the wrong sign, plus or minus, of rectangle width, giving you a negative answer when you’re supposed to get a positive answer, and vice versa.

In the case we see here, a = 4 and b = 12. So \Delta x = \frac{12 - 4}{4} = 2.

Now let’s draw the rectangles. We have a few different possibilities! Perhaps we want to draw the rectangles like this:

[Left endpoints]

wherein the left corners of our rectangles coincide with the function. [emphasize left corners with animation]

Or, we could draw the rectangles like this:

[Rescale rectangles to get right-endpoints]

where we can see that, now, it’s the right corners which touch the function.

The final method we’ll consider is the one where not the left or right, but the middle of each rectangle lines up with the function.

[Rescale rectangles to get middle sample points]

This one is less common, but is still useful to know.

For the sake of keeping things concrete, let’s focus on left endpoints right now. Our goal is to add up all the areas of the rectangles. In order to do this, we need both the height and width of each rectangle. We already know the widths, \Delta x = 2, so all that’s left is the heights. Notice again that, using left endpoints, we need the left corner of each rectangle to touch the function. The height of this corner is the same as the height of the rectangle, so all that we need to do is find the value of the function at the left endpoint of each rectangle. In this case, that gives us heights f(4) = 16, f(6) = 36, f(8) = 64, and f(10) = 100.

x f(x)
4 16
6 36
8 64
10 100
12 144

If it helps you to remember, think about why we can have each of 4, 6, 8, and 10 as sample points when considering left endpoints, but not 12. If we placed a rectangle whose left edge was at 12, so that the left corner would line up with the function, then the rectangle would extend outside of the region we’re trying to estimate the area of. This is undesirable.

Now that we have the heights and widths, just add everything up, and that gives us the approximation A\approx \Delta x\cdot f(4) + \Delta x\cdot f(6) + \Delta x\cdot f(8) + \Delta x\cdot f(10) = (2)(16) + (2)(36) + (2)(64) + 2(100) = 432.

Right endpoints is going to be the same kind of thing, except now we keep x=12 as a sample point and throw out x=4.

x f(x)
4 16
6 36
8 64
10 100
12 144

This gives us A\approx (2)(36) + (2)(64) + (2)(100) + (2)(144) = 688.

For midpoints, we don’t use 4, 6, 8, 10 or 12. Instead, we take the half-way points between each of these values, and use those. In this case, that’s 5, 7, 9, and 11, giving us

x f(x)
5 25
7 49
9 81
11 121

and A \approx (2)(25) + (2)(49) + (2)(81) + (2)(121) = 552.