CHAPTER 07.02: TRAPEZOIDAL RULE: Example

 

In this segment, we're going to take an example to show you how trapezoidal rule works, trapezoidal rule of integration works, so let's look at an example here. So let's suppose somebody's telling you you need to integrate a function from 0.1 to 1.3, 5 x e to the power -2 x, dx. Of course, this particular integral can be found exactly.  This particular integrand which you are seeing here has applications in all kinds of dynamic systems, whether you're talking about circuits, or whether you're talking about spring mass systems, it's a very important integrand which you are seeing there.  However, let's go ahead and see that how we can use trapezoidal rule to be able to find out what the approximate value of this integral is. Now, as we know that trapezoidal rule is telling us that any function which can be integrated from a to b can be approximated by b minus a, times f of a, plus f of b, divided by 2, that's the approximate definition.  Now, here we know what a is, what b is, what the function is, so I'm going to write it down so that it's clear.  a is 0.1, b is 1.3, and the function itself is 5 x e to the power -2 x, that's what we have. So let's go ahead and use the formula, and substitute the values of a, b, and the value of the function into this formula here, and we will get an approximate value of the integral.  So the integral of 5 x e to the power -2 x, dx, going from 0.1 to 1.3 is approximately equal to b minus a, b is 1.3, a is 0.1, the value of the function at a will be 5 times 0.1 e to the power -2 times 0.1, plus 5 times 1.3 e to the power -2 times 1.3, and of course, divided by 2. So it's basically b minus a, times the value of the function at a, plus the value of the function at b, divided by 2, because you're taking the average value of the . . . of the function at a and b, and multiplying it by the width of the interval, and this number here turns out to be 0.53530. Now, if you were going to find the exact value of this function, so in order to be able to see that how good or bad this answer is, to be able to judge the accuracy of trapezoidal rule, in this case, we are going to go ahead and look at what the exact value of the integral is, and the exact value of the integral here turns out to be 0.89387.  How to find this integral is from your differential . . . from your integral calculus class, and you can go ahead and do that as your homework to find out the exact value of this integral.  I'll give you a hint, the hint is to do it by parts.  Do it by parts, and you should be able to find out what the value of the integral is, don't take the shortcut by putting it in Maple, or MATLAB, or something like that, to find out what the exact integral is, but go ahead and use your integral calculus knowledge, and find out what the value of the integral is.  Let's go ahead and find out what true error is, what the relative true error is in this case.  So the true error in this case is exact value, 0.89387, minus 0.53530, and the true error in this case turns out to be 0.35857, that is the true error.  So let's go ahead and calculate what the absolute relative true error is so as to get some kind of a relative judgment on how bad or good this error is. So it is basically the true error divided by true value, times 100, if we are going to calculate it as a percentage. So the true error is 0.35857, divided by the true value, which is 0.89387, times 100, and this number turns out to be 40.11 percent. So you have a huge amount of relative true error which is part of this trapezoidal rule, it turns out to be 40.11, because if you look at the . . . if you draw the function which you are integrating here, let's go ahead and do that.  So it looks like this. So this is how your 5 times x times e to the power -2 x will look like, and if you are at 0.1, which is the lower limit, and then you are at 1.3 as the upper limit . . . 1.3 as the upper limit, this is the kind of straight line you'll be drawing.  This is the kind of straight line you'll be drawing going from 0.1 to 1.3. So you can very well see that what is happening is that the area under the curve which you are calculating by using trapezoidal rule is only this much. This part which you are seeing here, which is not accounted for, by these dotted lines, is the amount of true error which is taking place.  So this trapezoidal rule, that's why it's giving you about 40.11 percent error. So that's the end of this segment.