Read · 8 min
Before Diving In
Now that we've covered extrema, let's move on to a more complex topic.
Before diving into this lesson, you may want to review how to find the derivative of a function, using a derivative test, and using integrals. If you haven't covered these topics yet, no worries! You have plenty of time before you will learn this complicated stuff.
Riemann Sums and Convexity
In this explanation, we're going to unite the concepts of Riemann Sums and Convexity. The reason we do this is because convexity helps us understand how powerful Riemann Sums are. But we're not going to assume knowledge of anything about Riemann Sums, so let's begin with some definitions, and we'll talk about convexity later.
A Riemann Sum is an approximation of an integral based on evaluating the function you're integrating at particular points.
There are different types of Riemann Sums but constructing any of them follows roughly the same pattern:
i) Pick an interval over which you're integrating your function
ii) Break that interval into (equally-sized) sub-intervals; for example, we can break into and
iii) Make a rectangle with one side on the x-axis and the opposite parallel to the x-axis, while the other two sides are parallel to the y-axis. The height of this rectangle will be determined on which type of Riemann Sum we use, so we'll get back to this later. The widths of the rectangles are the intervals we constructed in part ii).
iv) Calculate the areas of all the rectangles made in step iii) and add them.
This answer will be our "guess" as to the value of the integral. Sometimes our guess is close, and sometimes it's not; it depends on certain characteristics of the function. It also, of course, depends, on which type of Riemann Sum we use, and how many rectangles we use.
I'm going to introduce all three types of Riemann Sums and do a bunch of calculations with the same function so we can compare how all three types of sums work.
I'm going to first talk about the Midpoint Riemann Sum. The Midpoint Riemann Sum is one for which we evaluate the function we're integrating at the midpoint of each interval, and use those values to determine the heights of the rectangles.
Our example function is going to be where we integrate over the interval We also get to choose the sizes of the rectangles, so for now we'll have each one be unit, for a total of three rectangles.
The midpoints of our mini-intervals are and This means our key step is to evaluate the function at these three points:
Now, these are the heights of the three rectangles. We know they all have length because we know their "horizontal" side lengths are along the intervals and Therefore, the total area is
Mentally take note of this value as we'll look to compare it to the values of the other Riemann Sums. Speaking of which, let's define them.
The Left Riemann Sum uses the left-endpoints of the mini-intervals we construct and evaluates the function at THOSE points to determine the heights of our rectangles. Let's calculate the Left Riemann Sum for the same function. The left endpoints of the intervals are and So we evaluate there:
So the heights of our rectangles are and The widths of the rectangles are still unit each because we didn't change our intervals. Then the area is
Finally, the Right Riemann Sum uses the right-endpoints of the mini-intervals we construct and evaluates the function at THOSE points to determine the heights of our rectangles. For our particular example, the right endpoints are and We already computed and while Then the total area is
So in summary, the Left Riemann Sum has value the Middle Riemann Sum has value and the Right Riemann Sum has value
Congratulations! You've now computed some simple Riemann Sums, of each of the three main types we want to talk about here. But this leaves a few questions unanswered.
The first is, why do we care about Riemann Sums? Couldn't we just have easily calculated
Well in this case, yes, but let's say you instead are asked to integrate
Yikes! That's not going to be fun. And I doubt it's possible to compute exactly. But you can use the same Riemann Integral Technique to get an ESTIMATE of what the value is. Oftentimes in industry an exact value isn't necessary, and an approximation is enough, so one can do a calculation like the ones we just showed you. It's also worth noting that especially if you have big numbers or a lot of rectangles, these calculations are usually done on a computer.
Here's another question you might think about: how many rectangles do we need? We can use as many as we want, but as we add more, the widths of them will be smaller, and we will have to sum more areas. If we get to using so many, we will get very close to the exact value of the integral. This is exactly why we care about limits, and it so turns out that the integral will equal the exact same thing as any of the Riemann Sums if we approach infinitely many rectangles (and of course, the individual area of each rectangle will go to zero, but we gain more and more rectangles, so these effects essentially cancel each other out).
If you're looking for a big fancy formula, you won't have to use one in practice for this, but it's helpful for understanding what's going on. Here's a formula for using Left Riemann Sums to find the value of the integral for a function
The important things are this: is the total length of the interval you're integrating over, and we evaluate at the beginning of each mini-interval. The exact locations are determined as a weighted average between the two endpoints of the big interval, and
The last thing I want to talk about is how good our approximations are. That is, how close can we get to the actual value of an integral using a Riemann Sum? There are so many functions that it ultimately depends. I'm going to explore this from two different dimensions.
The first goes back to the formula we just talked about:
Well, there is a near-identical one for the Right Riemann Sum:
Both formulas involve limits, which eventually equal the same value: But the expressions inside the limits are different, so what gives?
What this means we should expect is that, as we get closer to the exact value of the values of the Riemann sums we use to estimate this value should get close to EACH OTHER. If two Riemann sums have values close to that of then their values are close to each other as well. How close?
We do a quick calculation to help answer this question. Pick a large representing a Riemann Sum with many rectangles. Then we ask about the difference between the values of the Left and Right Riemann Sums. The formulas for the Left and the Right Riemann Sums are
and to get them we just pull the expressions out of the limits from the formulas for the exact value of the integral To find how the two estimates of this integral differ, we subtract one from the other and take an absolute value (think of the difference as a distance, perhaps between two points on the number line; distances are always regarded as nonnegative numbers by convention). So we define this distance to be and we plug in the values of and to get
What do we do now? Well this is something called a telescoping series, because most of the terms cancel out between the two sums. The only terms that are left are
If is large, then this number is going to be quite small. It says that if is large, the Left and Right Riemann Sums have almost the same value.
Finally, I want to do another calculation that is specific to when we integrate convex functions. A convex function is one defined so that for any and any
Colloquially, convex functions curve upward. and are examples of convex functions. They are plentiful and worth investigating a bit more in detail. We're going to show a nice inequality is true if is a convex function. Again we state the formula for the Right Riemann Sum used to estimate
Notice that and are both between and because and are positive and This means if is convex we can do the following for each in the sum:
Essentially we're using the definition of convexity where and
Now it's time for some algebra. Multiply both sides by which is also positive.
Now we sum both sides of this inequality over all between and The lesser side is just the definition of so
Why is this helpful? Well, notice both terms in the sum have factors that don't depend on
If we evaluate both of the sums left, we get
Finally, we can factor and cancel out some factors of
Why is this helpful? Well, if we don't care about the exact value of the Riemann Sum and an estimate is good enough for us, this expression only involves evaluating twice, even if there were a lot of rectangles. In some sense, we are giving up some accuracy to save a lot of time.
In summary, if a math problem is hard, look for clever ways to make it easier. Once you unlock the tools of calculus it becomes more apparent how you can do this.








