Trapezoidal Rule: Derivation by Method of Undetermined Coefficients

                In this segment, we’ll talk about the trapezoidal rule. We'll derive the trapezoidal rule by a method of undetermined coefficients. So, we have looked at the trapezoidal rule, and you already derived it by some other methods. You must recall this formula then, that the trapezoidal rule is simply calculating the value of the, estimating the value of the integral by using the width of the integral multiplied by the, some average value of the function calculated by calculating the value of the function a and b, the endpoints of the interval of integration, and then finding the average of those two. So, the question arises that hey, why do we need to rederive or derive trapezoidal rule by using a method of undetermined coefficients? The simple reason for that is that it becomes the basis of understanding the gauss quadrature rule. So, let's just concentrate on deriving the trapezoidal rule by undetermined, by the method of undetermined coefficients in this video, and then in a separate lesson, we'll be talking about how that then segues into the two-point gauss quadrature rule.

So, what, the method of undetermined coefficients is as follows: that you have this integral right here, you're going to approximate it by c 1 times f of a plus c 2 times f of b. So, what you're basically doing is you're saying that hey, let the estimate of the integral be given by me calculating the value of the function at a and calculate it as the function of b, but I need to figure out what should I weigh them by. Or what coefficient should I be using; that's why it's called undetermined coefficients because c1 and c2 are undetermined at this point.

                So, let's go and see that how can you find c1 and c2. So, one of the simplest things would be say hey, let the formula be exact for this function. That's a straight line, or a first order polynomial . So, we're going to say that hey, whatever we get from integral calculus, exact integral calculus for the integral of this function will be the same as what we get from this formula. If we're able to do that, then maybe we can find out what c1 and c2 are. So, let's go ahead and do that.

                So, what we have now is that the integral of this function right here is approximately given as c1 times f of a plus c 2 times f of b, and what we are saying is that hey, let it be exact for a naught plus a1 x. So, that means that hey, let's first find out what the exact integral of this particular function is. So, if we do our integral calculus, you will get this. Now we put the upper and lower limit of integration there, we get this expression right here. So, that's what we get from exact integral calculus, let's see what we get from the formula. So, from the formula, what we're going to get is c1 times f of a, so what will be the value of this function at a? It will be a naught plus a1 a. And what would be the value of the function at b? Will be the value of this function at b, will be a naught plus a1 times b. So, what we're basically saying that hey, let this expression be same as this expression because whatever you're going to get from the integral calculus, exact integral calculus will be same as what we get from the formula. So, what does that give us? So, let's go ahead and see what happens there.

                So, what we basically have is we have a naught times b minus a plus a 1 times b squared minus a square by 2 which we got from exact calculus. And then from the from the formula itself, which was c1 times a naught plus a1 times a plus c2 a naught plus a1 times b. However, we want to find c1 and c2 which are the two unknowns, and one might say that hey, you only got one equation here. But what I can do is I can do a little bit of manipulation so, that what, then what I’ll do is I will expand the right-hand side here, and that's what I get. Now once I do that, what I’ll do is I’ll bundle the terms of a naught together, so I will get this: this and this bundle together, and this and this bundle together. I’ll get, right. Now, the reason why I did this bundling together is because I only have one equation but two unknowns. But by bundling it like this, since, since I have not assumed what a naught and a one can be they can be any real number, right? So, I did not put any restrictions on a naught and a one when we said hey, let it be exact for a straight line of the form a naught plus a 1 x. So, since we did not put any restrictions on a naught and a 1 and they can be any number you want to. What that means that b minus a will be same as c1 plus c2, and this b squared minus a squared by 2 will be same as c1a plus c2b. So, we'll get c1 plus c2 is equal to b minus a; we get c1a plus c2b is equal to b squared minus a squared by 2. So, this is equation one and this is equation two. So, we have two equations and two unknowns, they are two linear equations, so this should be easy to solve. Let's go and see how we can go about solving this, these two equations.

                So, we had c1 plus c2 equal to b minus a so what we're going to do is we're going to, the other one was c1 times a plus c2 times b is equal to b squared minus a square by 2. We can multiply this by a, so we can get c1a plus c2a is equal to a times b minus a. Now, if I subtract these two equations, so I subtract this equation from this equation, I will get c2b minus c2a is equal to b squared minus a squared by 2, minus a times b minus a. So, this one, what I can do is I can do b minus a, b plus a divided by 2 minus a times b minus a on the right side, and on the left side what I’ll do is I’ll take c2 common and I’m gonna get b minus a. So, that means that this will cancel with this, so I’ll get c2 is equal to b plus a divided by 2, minus a, and that's b minus a divided by 2. And if I put it back into the c1 plus c2 is equal to b minus a equation, and I substitute b minus a by 2 here, I get c1 is equal to b minus a by 2 as well. So, c1 is b minus a divided by 2, c2 is b minus a by 2, so we have found out what the values of c1 and c2 should be for the method of undetermined coefficients.

                So, what we have obtained is c1 is equal to b minus a divided by 2, c2 is equal to b minus a divided by 2. So, what that does, is that it gives us the formula for the trapezoidal rule which, was started with this expression, to now be this expression here. And this does look like the trapezoidal rule now because if I take b minus a common, I’ll get f of a plus f of b divided by 2. So, this is the most familiar expression which people have about the trapezoidal rule, but it can be also written exactly like this also: this right here. And it's important to graphically look at this because, again, this will help you to figure out what the two-point gauss quadrature rule is. So, if you look at this expression right here, that might look at you, look at, look at you as like this that hey, oh I’m integrating from a to b, this function, right? And this will be a comma f of a this will be a com, b comma f of b. And what I’m doing is that I’m drawing a straight line between these two points, and this is the area of the trapezoid, and that would be this expression right here. That's what most people are familiar with, but let's look at this, let's look at this expression right here. And we're going to do the same thing, we're going to say okay hey, this is the function which we want to integrate from a to b. This is a comma f of a this is b comma f of b, and let's suppose we went to the midpoint right here, which is a plus b divided by 2. And what that does is that this distance here, from the midpoint to a is b minus a divided by 2, and this is also b minus a divided by 2. What I’m going to do is I’m going to take this rectangle right here, and you can see that the area of this rectangle is b minus a divided by 2, which is the width, and the height is f of a, which is right here. And then, I will take this rectangle right here, and here you're finding the width of the rectangle is b minus a divided by 2 and the height is f of b, which is this part right here. So, what I’m trying to say, is that the trapezoidal rule can be viewed as the area under the trapezoid, but it can be also viewed as the sum of the area of these two rectangles: one and two as well. So, keep that in mind when you will be introduced to how to derive the two-point gauss quadrature rule. And that's the end of this segment.