CHAPTER 07.05: GAUSS QUADRATURE RULE: Method of Undetermined Coefficients: Trapezoidal Rule
In this segment, we're going to take the trapezoidal rule, and we're going to derive it from method of undetermined coefficients. This is just one of the ways to derive trapezoidal rule, and the reason why we're discussing it in this segment is because the method of undetermined coefficients becomes the basis for the Gauss quadrature rule. So this is still trapezoidal rule, please don't confuse what I am going to show you in this segment with the Gauss quadrature rule, but it forms the basis for why and how we derive the Gauss quadrature, what is the motivation behind it, and then how do we go about doing so? Now, if you remember trapezoidal rule that you had this formula for calculating the value of the integral that was given as b minus a, times the value of the function at a plus the value of the function at b, divided by 2, and the way we interpreted this was that, hey, we have the width of the interval times some average value of the function, not the exact average value of the function, except for a straight line and constant line, this expression is not going to give you the exact value of the average value of the function. So that's why this is an approximate formula for calculating the value of the integrals. Now, what method of undetermined coefficients tells you is that, can you derive a similar formula for the value of the integral by using something like this, c1 times f of a, plus c2 times f of b? So what you are doing is that you are starting with the formula for the value of the integral to be c1, which is the weight, or the coefficient, of the value of the function at a, plus the c2, which is another coefficient, or the weight, of the value of the function at b. So you are giving some weight to the value of the function at a, we're giving some weight to the value of the function at b. Rather than interpreting it as the width of the interval times an average value of the function, now we are going to use this principle that, hey, I'll give some weight to the value of the function at a, I'll give some weight to the value of the function at b, and I'll be able to find what the approximate formula for an integral is. So what we're going to do is we're going to say, okay, now the unknowns are c1 and c2, so somehow we've got to find c1 and c2 so that we can apply this formula for calculating integrals which can be integrated from a to b. So one of the things which comes into mind is that, hey, what I should do is I should take at least this particular formula, that this formula which is on the right-hand side, should give me the exact value of the integral for, at least for a straight line, because I have two coefficients to find out, so maybe whatever I get by integral calculus by integrating a straight line should be same as what I get here. So somehow if I choose my function for which integral calculus, as well as the formula which is on this right-hand side gives me the same formula, is let's suppose a general straight line, f of x equal to a0, plus a1 x. So what I want to be able to do is, first I will calculate what the exact value of this integral is, from a to b, then I will also calculate the value of the integral by using this approximate formula, I'll equate the two, because I want the integral calculus to give me the same result as I would get by using this formula, which is the case for this formula also, which we have derived earlier, where this particular formula gives you the exact value for a straight line. If your function is a straight line, or a linear polynomial as some people may call it, then this formula here is the exact value which you're going to get by using integral calculus. So let's go ahead and find out what the exact value of the integral is, of a0, plus a1 x, dx. So if I do the exact integration, I get a0 x, plus a1 x squared by 2, lower limit is a, upper limit is b, so eventually it turns out to be a0 times b minus a, plus a1 times b squared minus a squared by 2, so that's what it turns out to be. Now, the formula itself is saying that, hey, the right-hand side of the formula is c1 times f of a, plus c2 times f of b, and I want, once I substitute the value of the function at a and the value of the function at b, I want whatever I'm going to get from here to be same as this. So let me go ahead and do that. What is the value of the function at a for the straight line? It'll be a0, plus a1 times a. What is the value of the function at b? It'll be a0, plus a1 times b. And so if I go ahead and take a0 common, I'll get c1, and then I'll get plus c2 here, and then if I look at the a1 terms the a1 terms are c1 times a, plus c2 times b. So I'm separating the terms which are the coefficients of a0, separating the terms which are the coefficients of a1 there, and the reason why I'm doing that is because I want this expression here . . . this expression here, which is coming from the right-hand side of the approximate formula, and this expression here, which is coming from my integral calculus class, that I want these to be exactly to be the same. And since we know that the equation of the straight line which we chose, the equation of the straight line which we chose is a0, plus a1 x, this a0 and a1 are arbitrary. They can be any numbers which you might be . . . of your choice, a0 can be 50, a1 can be 1000000, but I want this formula to give me the same result as this approximate formula for the straight line. So the only way that is possible is if the . . . whatever a0 is getting multiplied by here is same as what a0 gets multiplied by there. Whatever a1 gets multiplied here should be same as whatever a1 gets multiplied by there, because only then I can say that, hey, this will work for a0 and a1 to be arbitrary So let me write this down just to be sure that you remember this, a0 and a1 are arbitrary. That means that they can be any numbers, any finite numbers as you may please, negative, positive. So from there, what I get is c1 plus c2 is equal to b minus a, that is this, that's c1 plus c2 is equal to b minus a, okay? c1 plus c2 here is equal to b minus a, and then c1 times a, plus c2 times b, which is this, c1 times a, plus c2 times b, to be equal to this, b squared minus a squared, by 2, okay? So this quantity right here is same as this quantity right here, so that I get as b squared minus a squared, by 2. Now, what do I have? I have two equations, two unknowns. I have two equations, two unknowns here, the two unknowns being c1 and c2, everything else is known, we've got a and b, those are simply given by . . . as the limits of integration. So if I solve these two equations, two unknowns, these are simultaneous linear equations, I can find out what the values of c1 and c2 are, and I'm going to get c1 equal to b minus a, divided by 2, and c2 equal to b minus a, divided by 2, which basically is telling me that, hey, by using the method of undetermined coefficients, I have been able to find out the approximate formula for integrating any function, which is given by this, and as you can see, this is not any different, this formula which you are finding out here is not any different from your trapezoidal rule, because if you take b minus a, divided by 2 common, you're going to get f of a plus f of b, so it's not any different from what you got from the trapezoidal rule, but it's a different way of interpreting it, because if you remember your trapezoidal rule, the way you looked at it from a geometrical point of view, when you were trying to integrate a function from a to b, was that it was simply a line which was drawn from point a to point b, and you found area under the curve. The only difference now, here is that what you are doing is that you are finding the midpoint here, and the midpoint will give you a distance of b minus a, divided by 2 here, and b minus a, divided by 2 here, that'll be the distance between the midpoint and the left integral . . . left limit of integration, and b minus a, divided by 2 will be the distance from the midpoint, which is b plus a, divided by 2 to the upper limit of integration, and if you look at it this way, it is this rectangle here, and then you have this rectangle right here, okay? Because what you have is this length, or this height, is f of a, times b minus a, divided by 2, and this is f of b times b minus a, divided by 2. So it's a different way of looking at the same thing. The are which you're going to get from these two rectangles, 1 and 2, will be same as the area which you're going to get under the trapezoids. And that's the end of this segment.