CHAPTER 07.06: DISCRETE DATA INTEGRATION: Trapezoidal Rule   In this segment, we're going to talk about how to integrate discrete functions. That means that the functions are given at only fixed number of points, a finite number of points, and the method which we're going to use is called the trapezoidal rule. Trapezoidal rule is also used for integrating continuous functions, so it's the same formula which is being used, but we can use it also for finding out the integrals of discrete functions.  So in order to illustrate this, we're going to take an example.  Let's suppose somebody gives us velocity for a body, let's suppose in this case a rocket, at different times.  The units of time being second, the units of velocity being meters per second, and let's suppose you are given these values of the velocity at different times, and those are given at 0, 10 . . . 0, 10, 15, 20, 22.5, and 30, and these are the values of the velocity which are given, 0, 227.04, 362.78, 517.35, 602.97, and 901.67. So if somebody is telling you go ahead and find out what the distance covered by this rocket is from 11 to 16 seconds. How do I go about doing that by using trapezoidal rule?  That is the question which will be answered in this segment here.  So if I'm going to find out what the distance covered from 11 to 16 seconds, so I'm going to just draw this graphically.  I want to find out what the distance covered is from 11 to 16 seconds, and I'm going to use trapezoidal rule.  If I look at the data here, I know the value of the velocity at 10, but I don't know the value of the velocity at 11. I know the value of the velocity at 15 and 20, but I don't know the value of the velocity at 16, so somehow I have got to be able to do that, and also, between 11 and 16, I do know the value of the function at 15, so I do know it at 15, so that data point, then I know the value at 10, and I know the value at 20.  So I'm showing you these data points 11 to 15 . . . 11 to 16, that's what I want to be able to integrate it from, 11 to 16, but the data points which I know are at 10, 15, and 20 So I know the value of the velocity at 10, I know the value of the velocity at 20.  So what that means is that if I draw a straight line between 10 and 15, that makes it a trapezoid, and that's why it's called the trapezoidal rule, rule, but I don't want the value of the distance covered from 10 to 15, I want the value of the distance covered from 11 to 15.  Same thing here, I can draw a straight line between the value of the velocity at 15 to 20, like this, but I don't want to find out the area of this trapezoid, because that'll give me the area from 15 to 20, but I want to find it from 15 to 16.  So what I want to do is I want to find this area of the trapezoid, and I want to find this area of the trapezoid, because that's what's going to give me an approximate value of the integral going from 11 to 16.  So what that means is that I have to find out what the value of some velocity at 11 is and what the value of the velocity at 16 is, because only then I'll be able to find out what the value of the integral is from 11 to 16.  So how do I go about doing that? It is by saying that, hey, I'm going to draw a straight line from 10 to 15, and from there I'll find the value of the velocity at 11.  Same thing, I'm going to draw a straight line from 15 to 20, and find out what the value of the velocity at 16 is, because once I have that information, I should be able to find out what the value of the . . . approximate value of this integral is from 11 to 16.  So let's put that on the board here.  So what I want to do is I want to integrate the value of the velocity from 11 to 16, and I know that I'll have to break it up into two parts, I'll have to break it up into from 11 to 15, and then the other part is going to go from 15 to 16. Now, if I was going to apply trapezoidal rule, I need to know what the value of the velocity at 11 is and 15 is, what the value of the velocity at 15 is, and the value of the velocity at 16.  I do know what the value of the velocity at 15 is, but I don't know what the value of the velocity at 11 and 16, so I've got to find that.  So how am I going to do that?  I'm going to find that by using linear interpolation. So that means that the value of the velocity at 11 will be given by what is happening between 10 and 15. So the value of the velocity at 10 is 227.04, plus, what is the value of the slope?  It is 27.148 times t minus 10. So this is what the straight line approximation is between 10 and 15, and I'm going to ask you to do it as homework, to take the velocity at 10, take the velocity at 15, and confirm that this is the velocity expression, the linear velocity expression, going from 10 to 15. And when I take the value of the velocity at 11, because it is valid between 10 and 15, I will get 254.19 meters per second, so that's the approximate value of the velocity which I am getting at 11 seconds. Same thing, again I'm going to give it . . . assign it as homework, is go ahead and find out what the value of the velocity expression is between 15 and 20, what is the linear interpolant approximation from 15 to 20?  And again, that is your homework, and you get 362.78, plus 30.913 times t minus 15, so that's your homework, find out the linear interpolant which approximates the velocity from 15 to 20.  Now, again, since this interpolant is valid between 15 and 20, I can use this to find out my approximate value of the velocity at 16, which turns out to be 393.69 meters per second.  So these values which I didn't know are simply being found by drawing a linear line, or a straight line from the two immediate points which are surrounding that point, 11 is between 10 and 15, I'll find this linear interpolant, find the corresponding velocity, I'll find this linear interpolant going between 15 and 20, and find out the velocity at 16, I get that number.  So now I can use my trapezoidal rule formula to calculate my approximate value of the integral.  So the integral, again, is going from 11 to 16, it is exactly equal to the integral going from 11 to 15, of the velocity, the integral going from 15 to 16, of the velocity.  And now I'm going to use my trapezoidal rule formula for this integral, and then again for this integral, and that's where this approximation is coming from.  So the trapezoidal rule formula tells me it is the width of the interval, which is 15 minus 11 for the first integral, times the value of the velocity at 11, plus the value of the velocity at 15, divided by 2, because that's what trapezoidal rule is, it's the width of the interval times the . . . times the average value of the velocity . . . approximate average value of the velocity, calculated by calculating the velocity at the lower limit and the velocity at the upper limit, plus, same thing for the second integral, which is 16 minus 15, which is the width of that interval, times the value of the velocity at 15, plus the value of the velocity at 16, divided by 2. So here I get 4 times the value of the velocity at 11, which I calculated approximately to 254.19, the value of the velocity at 15 is given as a data point itself, which is 362.78, divided by 2, because that's the average now, plus 1, times the value of the velocity at 15, which is 362.78, plus the approximate average . . . approximate velocity which I calculated from that linear interpolation curve, which is 393.69, divided by 2, and when I calculate this number, I get 1612.2 meters, that's what I get as my value for the integral of the velocity from 11 to 16.  Now, how good is this?  Again, all these six data points which I showed you, they were derived from . . . the six data points were derived from the exact formula, they were derived from the exact formula, which was given as the velocity is 2200 log, 14 times 10 to the power 4, divided by 14 times 10 to the power 4, minus 2680 t, minus 9.8 t, that's what it was calculated from.  So you can use that expression to calculate your exact, from 11 to 16, calculate your exact integral, and then find out what the relative true error in this case is.  And that should give you some confidence in saying that, hey, why does this method work better than the average velocity method.  And that's the end of this segment.