Stony Brook MAT 122 Fall 2017
Lecture 32: Riemann sums
November 10, 2017

Start   Do you have any questions for me? Do you see there's a new 'My Math Lab' up?
And, did I put up the paper homework? No I'll do it today. So there will be a new paper home work up after today's class.
Ok.
Is the board well enough lit? Should I up this another notch?
There we go.
Ok. Now its a little brighter.
0:32So we talked about anti-derivatives and integrals.
So remember, an integral is working backwards, we use the words interchangeably, but they aren't really interchangeable.
The anti-derivative is just the process of going backwards.
The integral is what you're doing with the anti-derivative.
So one of the major things you can do with an integral is that they stand for area.
So this is sort of a geometry thing. So if you wanted to find the area under the curve, you'd use an integral to do it.
1:01So let's take something obvious.
Let's say we have the line y = 2x, and we want to find the area from x =0, to x=4.
So you would integrate 2xdx.
1:31And what you're going to want to do is find that answer at 4, and subtract the answer at 0.
Ok? And you symbolize that by putting numbers here and here, and these are called definite integrals.
So remember we had the plus C? That's called an indefinite integral because you don't know what C could be until you do an initial condition.
With a definite integral, you don't get a +C. Because what would happen really is the C in the first term and the C in the second term would subtract, and they'd go away.
2:03So we'll work this out in a second, so a definite integral can do actual numbers.
So what is the integral of 2x? Its x^2, and then what we do is write it with a line like that.
And that says plug in 4, plug in 0 and subtract.
Cause if we had done the x^2 + C, and we plugged in 4, we'd get 16+C, and if we plugged in 0, we'd get 0+C, and the Cs would cancel anyway.
2:39Cause I said. So the indefinite part, the C part no longer matters when you're doing a definite integral.
Ok? And it says the area under the curve y = 2x from 0 to 4 is 16.
Well what does y =2x look like? y=2x looks like this.
Right? That's the line y=2x, keep going,
3:03And at x = 0, its 0, and at x=4, this height is 8, This is just the line y=2x, So what is this area under here.
What's the area of the triangle?
And the area of that triangle is 1/2(base)(height), which is 16.
So you didn't really need it, you don't need high-powered calculus to find the area under a line like that, thats really easy.
3:34But of course, you're going to need the calculus if you want to find the area under something messier.
And that's, that's what we're going to do today.
Alright, but just to be sure we get the joke, Let's do, let's set this up.
Ok? So for these you use something called Riemann sums.
So imagine now we just have some curve.
4:00It looks like that. We want to find the area underneath the curve. When I say underneath that means between the curve and the x-axis.
Well if we look at the bottom of the curve, we know that this area is definitely less than the area under the whole curve.
And this area, if i drew 2 rectangles,
4:33is still less but is getting better.
Because now I have less error. Ok, let's do it again, let me just redraw the curve.
If I have 1 rectangle underneath, I have all this space unaccounted for.
If I draw 2 rectangles underneath, I have less space that I haven't gotten right. So my error drops.
What if I did 4 rectangles underneath there.
5:04What if I chopped this into 4 rectangles, like this.
Something like that. Now I only have this much error.
And so on, so if I do enough rectangles, then I start to get close. But suppose I did 8 rectangles.
Well what do you mean by rectangles? What are you talking about? How are we going to figure that out?
5:37Alright see the rectangles? We're starting to fill up that space under the curve.
If we did 16 rectangles, or 32, remember calculus is all about limits so if we do an infinite amount of rectangles, we'll get exactly the area underneath.
So let's think of a process we can do this that it will make sense.
So pick something nice and easy and figure out the area underneath.
6:04What if we had just y=x^2, by the way, the real value in doing this is to understand the intellectual process.
So you will have stuff that you do in the business world that you won't be able to figure out exactly what's going on but you can do approximations.
And so to understand the approximation process is very important.
You may not actually be able to figure out the right answer, but you will be very very very very close using techniques like this.
6:33This whole limit process, where, you break it up. You take something that's smooth, and you break it up into chunks.
And you make the chunks smaller and smaller and more and more of them, and eventually, you get a very good approximation.
You know, imagine, to digress for a second, if you wanted to find, do you know how archimedes found pi?
It's the same process as what we're about to do.
7:00He said, well, I have a circle, and this is less than the area of a circle, you don't have to copy this down.
That's bigger than the area of a circle, and he said, ok, let's take a circle, and put a hexagon inside.
And let's put a hexagon outside.
Now we're starting to get closer to the area of a circle. He said now let's put an octagon inside and an octagon outside.
7:31So as you can imagine, as you add more and more sides to the polygon, it looks more and more like a circle.
And he found at some point you get this magic number that just kept showing up, and that's pi.
But you can approximate very well. Even about a 32 sided polygon is going to get pretty close to a circle.
It's not exact, but try drawing one, and seeing how close you get to a circle. 32 sides is a lot.
So back to this, so let's see if we can figure out how to get the area
8:02Ah, let's do x^2+1, sorry, correct that in your notes.
So x^2 +1 looks like this, we're only doing the first quadrant, from x=0, to x=4.
Ok, so that's 4, and by the way that's 17, because it's x^2+1.
8:30And what I want to do is I want to approximate the area underneath.
So well, let's fill in some of these rectangles, let's say I want to use 4 rectangles.
And these rectangles should be the same width.
So each of those rectangles should have a width of 1. Because the whole x axis is 4.
9:02And how could I find the height of the rectangle? Well the simplest thing to do is to use the curve.
And what I'm going to do is go up the left side of the curve. So when i'm at 0-1, I'm going to come up with the height by finding f(0).
And then I'm going to say the width is 1, and the height is f(0).
9:31In the next rectangle, the width again is 1, because it goes from 1-2, And now to get the height I plug 1 into the equation, because I'm going up to here on the curve.
So that's going to be f(1).
And the next one I go to 2, I go up to the curve, You all see what I mean by going up to the curve? I'm going to start at each of these intervals and go up the left hand side and pick that coordinate.
10:03And where it intersects the curve is the height of the rectangle. So I'm using from 0-1, 1-2, 2-3, and from 3-4.
And each time I take the left side of the interval. I could do the right side. We will in a second.
And the width of each of these rectangles is 1, so for the height of this rectangle I plug in 2.
And the last one we're gonna plug in 3.
10:30So that's f(0)=1, f(1)=2, f(2)=5, f(3)=10. Add that up, you get 18.
So we know the area if I draw those 4 rectangles.
11:00So I can say it's approximately 18. It's bigger than 18 cause it has leftover space.
I didn't account for this area in here.
You say, ok, it's about 18. Remember we knew exactly how to do it, we can do that with an integral in a minute.
What if i go the other way? What if? Notice how each of those rectangles is underneath the curve, is inscribed in the curve.
11:30Let's do it again, Let's do it again, but this time, let's gauge those rectangles by using the right side of the integral. I could use any point in there to create the rectangle.
By the way, this height, is really just a y value.
So let's say this time we get the height by looking from 0-1, saying the base is 1, and the height will come from plugging 1 into the curve.
12:13Now let's get the height by plugging in 2, just like before. Now let's plug in 3, and let's plug in 4.
12:36Now notice, each of these rectangles go above the curve.
Cause when we think about the curve, we know the curve is going up, so when I hit the curve from the left side, we go underneath it, but as I hit the curve from the right side, I go above it.
So I take the interval that creates the rectangle, 0-1, 1-2, 2-3,3-4,
13:02and I plug in the right-hand value, and I end up above the curve. That's because the curve is going up.
Ok? If the curve was going down it would be the other way around.
It's not really that important, but let's figure out what these values are.
f(1)=2, f(2)=5, f(3)=10, and f(4)=17.
13:30That comes out to 34.
So the first time I guessed the area was 18, but the second time I guessed the area is 34, but I know the first one is too big and the second one is too big, so you could average.
If you average you get 26.
And remember how I told you how to find the exact area?
The exact area is if I just took the integral.
Which would be the integral of x^2+1 dx from 0-4
14:06That's x^3/3+x from 4-0, So that's (4^3/4+4)-(0^3/3+0) = 25 1/3
14:32So halfway between 18 and 34 was 26, that's a pretty good guess.
So if you just found 4 rectangles underneath, and made a guess at the area, and if you found 4 rectangles above and made a guess of the area and averaged them, you're already pretty close, you only had to use 4 rectangles. You know you're not getting it right with 4.
What if we use more rectangles?
So let's practice this again and do 8 rectangles.
15:04I'll make it a little wider so it's a little easier to see.
Ok? So same principle as before.
So if we did the left end of the integral, they're called left hand rectangles.
15:34Well first of all, each of these rectangles is the same width.
The width of each of these, forget my bad artistry, is 1/2. How do you come up with 1/2?
Well, the interval from 0-4 is 4 units long And there's going to be 8 rectangles so 4/8 is 1/2.
Ok? It's a 1/2, then 1, 3/2, 2 and so on, so each of these is 1/2 wide.
16:03And I get the height by plugging the left side of each of these intervals into the equation cause that's the y value.
The x value is the, the width is the difference in x values.
And the height is the y value.
And I can use the left side, I can use the right side, I can use the middle, I can use 1/3 of the way in, it doesn't really matter.
Ok? You just sort of want to be consistent because it makes the math easier.
So the width of each of these is 1/2, and the left most rectangle, the left side is f(0).
16:37Then we have 1/2 f(1/2) 1/2 f(1), 1/2, f(3/2), And so on. So again, each rectangle, you look at the base. And you say each base is 1/2 wide.
And you get the y value which gives you the height,
17:02I plug in the left side of each of these intervals. Each of the divisions of the x axis.
So the last one would be 1/2*f(7/2) You with me so far? Some of you look numb. Some of you have seen this. Depends if you took calculus. If you took BC calculus you saw this. AB maybe.
17:31So f(0) = 1, f(1/2) = 5/4, f(1)=2, f(3/2) = 13/4,
18:04Then when we plug in f(2) = 5, f(5/2) = 29/4, f(3)=10, f(7/2) = 53/4
18:49We won't ask you to do something this painful without a calculator.
So you get 1/2+5/8+1+13/8+5/2+29/8+5+53/8 =
19:08Which gives you 12.5+9, wait that's too small.
19:32I'll make everything eighths.
Hmm, I messed up my arithmetic somewhere.
20:02Oh maybe not, I take it back, I didn't. Ok, so that is 19.
I could have messed up arithmetic, it's still low, but it's better than 18, it's a better guess.
So you know, the smart people come along and say just do an infinite number for these. So there's a little fudge involved in that.
Let's have you practice one now. Make sure you understand the basic principle.
20:31So say I have a curve, I'll give you a nice easy one, y=x^2+x, and you want to find the area under the curve from x=0 to x=4, using 4 left hand rectangles and do it again using right hand rectangles.
21:28Ok, take a few minutes.
21:30If you're a little confused, remember, each of these rectangles going from 0-4, are cutting the interval into 4 units, each with a width of 1.
Ok? And then to get the height you're going to plug in the left side of each of those cuts, each of those intervals, into y , that'll give you height, and then multiply them together.
You're going to plug in 0,1,2,3 if you're doing the left side, and you're going to plug in 1,2,3,4 if you're doing the right side.
22:04Alright that's long enough.
What does this look like first of all? x^2+x, well it kinda looks like the other curves.
When x is 1, you're at 2, when x is 0, you're at 0.
And you get up to about there. It's about 20.
22:32So if you want to do left hand rectangles, which I'll abbreviate at LHR, Is by cutting this into 4 identical slices. And I'll get each rectangle by going to the left side of each of those intervals.
going up the curve. So the first one I just go up to 0, And then you go up to here, and then here and here. Ok?
23:01So the width of each of those would be 1.
f(0)+f(1)+f(2)+f(3).
You plug those in, f(0) is 0, f(1) is 2, f(2) is 6, f(3) is 12.
23:40So you should get 20.
So what if I wanted to do right hand side rectangles?
24:07Well, again, they're each 1 wide, but now I get the height of the rectangle by going to the right side of the interval and going up.
So I would start here and go across this way.
And then, like that. Ok?
Kinda hard to picture, but the book draws this much better than I have.
24:30So each one is 1 wide, and I add f(1), f(2),f(3) and f(4).
So that's 1*2+1*6+1*12+1*20
25:06And you get 40.
So for example, if this were an exam question, or a homework question. We might say find the area using the Left hand rectangles, using the right hand rectangles, and then find the actual area.
So right now you say one way I get the area it's 20, the other way I get the area it's 40, so a good guess is 30. It's probably somewhere around 30.
25:31So when getting the actual area, you would go from 0-4, and take the integral of x^2+x dx.
That is x^3/3+x^2/2 from 4 to 0.
Plug in 4 and plug in 0. So you get (4^3/3+4^2/2)-0.
26:06Which is 88/3, which is not quite 30, because 30 is 90/3.
That's 29/3, pretty close though.
So as I said before, you can make a good guess just by plugging in on each side.
You do not do + C, because as I said this is what's called a definite integral. Ok? So when you have actual numbers to plug in, you no longer need to use the + C.
26:42Cause you get a definite answer, as I said before. So one thing that people did because they were very clever was I could just do an infinite number of these and make them infinitesimally thin.
We're not going to do that, in this class. But when you do and you play with that and you make them smaller and smaller, you end up with the integral.
27:00That's really what happens. The math technique isn't that complex, but it's a little bit.
Um, and of course, this could be more fun, because we could give you e, or log or something really painful.
But I wouldn't do that to you. And remember what I told you. Area underneath is very useful to know, for example if you were doing total profit or total cost or something like that.
27:30So suppose, I don't know how many of you have taken economics, but you'll see this some place in the business world, That you know that your marginal cost for manufacturing something was x^2+x and you chopped it up into rectangles, so when you do marginal cost, with units, this would be units, remember marginal cost is a derivative, so this would be cost/unit, and now you've got a bunch of these rectangles
28:05that you're adding up. When you add up the rectangles, you get an area and what are the units of these rectangles?
Its units on the bottom and cost/unit on the side, I showed this to you before, and when you multiply them together, you get cost.
So in other words, if this is the derivative curve, and these are the numbers of units, and you put them together, you end up with a total.
28:37So the integral is a very useful way to find totals of things.
So for example, suppose I told you, You say 'why bother to do all this estimating?' because you want to understand how the estimating works.
One of the things about integrals is you can't integrate everything. You can differentiate pretty much anything but you cannot integrate pretty much anything.
29:02Now in this class, we do very simple functions, but you could rapidly, in the business world, run into functions where you can't, so all you can do is do a good approximation.
Suppose that the marginal cost for making jackets at this company is .0003x^2-.2x+50 where x is the number of jackets
29:44And I want to find the total cost of making 400 jackets approximating using 4 right hand rectangles.
30:13So turn that into a little bit of english and make sure you can do it.
This is your cost equation, you'll get some picture that looks like this, you end up with 400 and you want to estimate the total cost.
30:30So you're going to cut this, 100,200,300 and 400.
And you use the right side of each interval.
Let's see if you can figure that out. By all means use your calculators. Your phones have a calculator if you didn't know. But I think you did.
Let's see if everyone really understands what I mean by right and left hand of the interval.
What you're doing is you're creating rectangles, and each time you create a rectangle, you use the x axis for the base,
31:04and then you're going up the curve and using the curve for the height.
So where you hit the curve is the height. For example, for the 200-300 height, We use the right hand side, the right of 200-300 is 300, we go up the curve and cross, and that helps us figure out how tall our rectangle is.
What about going from 100-200? I go to 200 and I go across. From 0-100, I go to 100 and go across. 400 I go across. Got the idea?
31:39If it was the left side, i would be doing the left hand value. And going across, I'd get underneath the curve because the curve is going up.
So the width of each of these is 100, and I get the height of the first one by doing f(100).
And then 100*f(200). You could factor out these hundreds.
32:05And then 100*f(300) And 100*f(400).
So the height of each of these is found by plugging into the equation.
It's hard to do in my head. Anybody get an answer?
32:39Well, ok. Somewhere between 900 and 49,000.
You get 9,000. Wow. Well maybe you're correct. The answer key to the book says 12,200.
But that doesn't mean the book is correct, I can do it really fast.
Huh. The book is wrong, I got 9,000.
So whoever got 9,000 good job, if you got 900, you probably just messed up a decimal place.
33:03Alright, so, enough of this for today, there is a my math lab that is due next week, and I'm sorry but there's homework over the weekend, but it's a paper homework and I will post it this afternoon.
And it'll be due next week. Have a nice weekend.