If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Riemann approximation introduction

Approximating the area under a curve using some rectangles.  This is called a "Riemann sum". Created by Sal Khan.

Want to join the conversation?

  • leaf orange style avatar for user Student
    Hey Sal, I have a question. Are Riemann sums actually useful for anything once you know how to integrate? It seems a lot easier to just learn integration.
    (91 votes)
    Default Khan Academy avatar avatar for user
    • purple pi pink style avatar for user Charlie Auen
      Riemann sums are useful when we are dealing with real world data, but we don't know the exact pattern it is following. To integrate, you need to know the function, but you can use Riemann sums as an approximation whenever you know some of the data points.
      (69 votes)
  • hopper jumping style avatar for user PrimeNoodles
    With my limited knowledge of calculus, the Riemann sums seem pretty inefficient, since you'll always have some space not covered by the rectangles. Is there a way that you can get an exact answer, or is this the best that has been come up with at this time? Of course, I don't know much in calculus yet, since I've only done Alg. 1&2, Geo., and PreCal, so there might be a construct that I don't know of that would answer my question. Thanks to any who will answer this! :)
    (10 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Just Keith
      You need to do differential calculus before integral calculus.

      But, to answer your question, yes there is a way to get an exact answer. It is what happens when you split the area up into infinitely many rectangles of infinitesimally small widths. That way, you have no error at all. It is called a definite integral.

      But, you really do need to master differential calculus first or you will be lost.
      (30 votes)
  • starky ultimate style avatar for user cia d.
    Why did Sal construct 4 rectangles? Why not 5, 6 etc... or is 4 rectangles given in the problem?
    (9 votes)
    Default Khan Academy avatar avatar for user
    • hopper cool style avatar for user POWA
      Most of the practice problems of integral calculus asked for 4 equal subsections so I believe it was a choice made by him in this example. Just like you mentioned it is oftentimes already given in the problem. With more rectangles you get a better approximation of the function.
      (12 votes)
  • blobby green style avatar for user Wyatt Butson
    How do you know how many pieces you're suppose to split it in? Like what number are you suppose to divide b-a by?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • leaf blue style avatar for user Stefen
      The number of pieces you use is a function the accuracy (how close to the actual value of the area) you want.
      While this technique has it's place in numerical analysis, you are going to see that as the number of pieces you split the interval into approaches infinity, the value of the result of the sum approaches the actual value of the area - and that this is the foundation for the concept of integration - which is the next section of this track.
      (10 votes)
  • blobby green style avatar for user j.loves.bus
    Wouldn't finding the over-estimate and the under-estimate of the curve, adding them together, and dividing by two give a more accurate estimate of the area? Though it still wouldn't be completely accurate.
    (6 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user jordan_benoit
    At seconds, how do you know that you need four rectangles?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • hopper cool style avatar for user POWA
      We can choose how many rectangles we like.

      The approximation will improve with more rectangles.

      The best approximation comes with infinite rectangles.

      This can be done by using infinitesimal width on the rectangles.

      I hope this was a little helpful!
      (9 votes)
  • duskpin tree style avatar for user mebble
    If the area under the curve is below the x-axis, would it have a negative value?
    (5 votes)
    Default Khan Academy avatar avatar for user
  • starky sapling style avatar for user 20leunge
    Is there a way to find the area above the function up to a certain range?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user TheAlphaKnight3123
    Are Riemann sums the ones using left endpoints because I asked this question in a different video and im not sure if this video is the one that has now answered my question.
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf blue style avatar for user Chris
      Riemann sums can have a left, right, middle, or trapezoidal approximations. The most accurate are usually the trapezoidal and middle rectangle approximations because they only give up a small amount of area. However, Riemann sums will usually give more accurate approximations based on the number of rectangles and trapezoids; for example, an approximation using 4500 left rectangles will be better than simply using four rectangles to express the area under a curve. Similarly, an infinite number of rectangles will have a more accurate approximation of the area instead of simply using 4500 rectangles.
      (2 votes)
  • male robot hal style avatar for user Sumit Chaturvedi
    In physics I have seen that often in deriving equations the sigma sign(for addition) is replaced in the subsequent steps by the integral sign. Can someone please tell me more about this
    (2 votes)
    Default Khan Academy avatar avatar for user

Video transcript

What we're going to try to do in this video is approximate the area under the curve y is equal to x squared plus 1 between the intervals x equals 1 and x equals 3. And we're going to approximate it by constructing four rectangles under the curve of equal width. So let's first think about what those rectangles look like, so four rectangles of equal width. So it looks like that, like that, and like that. And I haven't really defined the top of the rectangles just yet. But let's think about what those widths have to be if they're going to be equal width. And we can call that width delta x. So this distance right over here, we're going to call that delta x. So delta x is going to have to be the total distance that we're traveling in x. So we finish at 3. We started at 1. And we want four equal-width rectangles. So it's going to be equal to 1/2. So for example, this first interval between the boundary between the first rectangle and the second is going to be 1.5. Then we go 1/2 to 2. Then we go to 2.5. And then we go 1/2 to 3. Now, let's think about how we'll define the height of the rectangles. For the sake of this video-- we'll see in future videos that there's other ways of doing this-- I'm going to use the left boundary of the rectangle to define the height-- or the function, I should say. I'm going to use the function evaluated at the left boundary to define the height. So for example, for the first rectangle, this point right over here is f of 1. And so I will say that that is the height of our first rectangle. Then we go over here to the left boundary of the second rectangle. We're now looking at the function evaluated at 1.5. So that is f of 1.5. That's the height. And so we get our second rectangle. Then, we get-- I can keep going like this-- we get, for this third rectangle, we have the function evaluated at 2. So that's right over here. That's f of 2. And so then we get our third rectangle. And then, finally, we have our fourth rectangle, the function evaluated at 2.5. So the function evaluated at 2.5 is the height. So this is f of 2.5. Remember, in each of these, I'm just looking at the left boundary of the rectangle and evaluating the function there to get the height of the rectangle. Now that I've set it up in this way, what is the total approximate area using the sum of these rectangles? And clearly, this isn't going to be a perfect approximation. I'm giving up on a bunch of area here. Let me see if I can color that in with a color that I have not used. So I'm giving up. I'm giving up this area. I'm giving up this area. I'm giving up that area. I'm giving up that area there. But this is just an approximation, and maybe if I had many more rectangles, it would be a better approximation. So let's figure out what the areas of each of the rectangles are. So the area of this first rectangle is going to be the height, which is f of 1, times the base, which is delta x. The area of the second rectangle is going to be the height, which we already said was f of 1.5, times the base, times delta x. The height of the third rectangle is going to be the function evaluated at its left boundary, so f of 2-- so plus f of 2 times the base, times delta x. And then, finally, the area of the third rectangle, the height is the function evaluated at 2.5, so plus-- that's a different color than what I wanted to use. I wanted to use that orange color-- so plus the function evaluated at 2.5 times the base. This is going to be equal to our approximate area-- let me make it clear-- approximate area under the curve, just the sum of these rectangles. So let's evaluate this. So this is going to be equal to f of-- it's going to be equal to the function evaluated at 1. 1 squared plus 1 is just 2, so it's going to be 2 times 1/2. Plus the function evaluated at 1.25. 1.25 squared is 2.25. And then you add 1 to it, it becomes 3.25. So plus 3.25 times 1/2. And then we have the function evaluated at 2. Well, 2 squared plus 1 is 5, so it's 5 times 1/2. And then finally, you have the function evaluated at 2.5. 2.5 squared is 6.25 plus 1. So that's 7.25 times 1/2. And just to make the math simpler, we can factor out the 1/2. So this is going to be equal to-- write 1/2 in a neutral color-- 1/2 times 2 plus 3.25 plus 5 plus 7.25, which is equal to 1/2 times-- let's see if I can do this in my head. 2 plus 5 is easy. That's 7. 3 plus 7 is 10. And then we have 0.25 plus 0.25, so it's going to be 10.5 plus 7 is 17.5. So 1/2 times 17.5, which is equal to 8.75, Which, once again, gives us an approximation. And clearly, the way I've drawn it right over here, for the function we're using, it's going to be an underestimate, because we've given up all that pink area that I had colored in before. It's an underestimate, but it's an approximation of the area under the curve. In the next few videos, we're going to try to generalize this to situations where we have an arbitrary function and we have an arbitrary number of rectangles. And we'll also start-- in videos after that, we'll look at rectangles where we define the height not by the left boundary, but by the right boundary, or by the midpoint. Or maybe we don't use rectangles at all. Maybe we might use things like trapezoids. Anyway, have fun.