 Hi, we are learning quadrature formulas to approximate a given integral. In this, we have already seen rectangular rule, midpoint rule and trapezoidal rule and also their composite versions. In today's class, we will learn Simpson's rule. Simpson's rule is obtained by integrating the corresponding quadratic polynomials. Interpolating the integrand at three specific nodes, recall that we obtain the quadrature rules by first approximating the given integrand by its interpolating polynomial of certain degrees by supplying the nodes explicitly. That way, today we will take the number of nodes as 3, that is n is equal to 2. By this, we have to give three nodes x naught x 1 and x 2. Therefore, our quadrature formula will be f of x naught w naught plus f of x 1 w 1 plus f of x 2 w 2. If you write the interpolating polynomial p 2 in the Lagrange form, you get this expression for the interpolating polynomial with n is equal to 2. The idea is to integrate this polynomial and thereby, you will have integral a to b for the Lagrange formula and they give you w naught w 1 and w 2. So, this is the idea that we have been following to derive the quadrature rules and that leads to this expression. Now, let us see how to choose the nodes because we can choose different nodes to get different quadrature formulas. For Simpson's rule, we have to choose the nodes like this. They are equally spaced in the interval a to b and they are x naught equal to a, x 1 is the midpoint of the interval a b and x 2 is b. Once you get this, you plug in this into this expression and you have to perform these integrals. That is what is the difficult job that we have right now. For that, we will use a change of variable in order to make this calculation little simple and calculate these three integrals and see how they look like. First, let us take integral a to b l naught of x dx, l naught is the Lagrange polynomial with k equal to 0 and its expression is given like this and therefore, this is the integrand. You can see that it is a quadratic polynomial. Therefore, you can explicitly integrate it and just to make the calculation simple, we will make this change of variable here and then integrate it to get the expression for the integral as b minus a by 6. Similarly, we have to evaluate this integral as well as this integral. Let us see how they come out to be. For the second integral, it is integral a to b l 1 of x dx. You can again write the expression for l 1 of x and then use the change of variable similar to what you did with l naught and you can see that finally, that integral will reduce to 4 by 6 into b minus a and a similar calculation will also give us integral a to b l 2 of x dx. Again, it is equal to b minus a by 6. Now, you just have to plug in this value into the integral a to b p 2 of x dx. Remember, integral p 2 of x dx is given like this where you just have to put this value in the first term and this value in the second term and this value in the third term and that gives you the required Simpson's rule given by this formula and that is obtained by simply integrating p 2 of x with x naught equal to a that is what is shown here x 1 is equal to the midpoint of the interval a and b and x 2 equal to b. If you choose the nodes like this, then the corresponding rectangle rule is what is called the Simpson's rule. Let us see the geometrical interpretation of the Simpson's rule. Suppose, your function f of x is graphically looking like this, then integral a to b f of x dx is the area under the graph of the function f of x between the interval a to b. That is the geometrical interpretation of the integral and that is shown in the light red color here and this is the region which you have to find the area and that gives you the integral a to b f of x dx. This is precisely what we want to find, but Simpson's rule takes the quadratic polynomial interpolating the function f at the nodes a a plus b by 2 somewhere I am just roughly placing it is the midpoint of the interval a to b and then b. For instance, the graph of the interpolating polynomial is given roughly by this white solid line, then the Simpson's rule gives us the area under the graph of p 2 of x. This is just a roughly drawn graph for the quadratic polynomial interpolating the function f of x just to illustrate the geometry of the Simpson's rule. Now, let us see how the mathematical error can be derived. Remember the mathematical error involved in the Simpson's rule is going to include the area covered in this place and the area covered in this place. So, these two things are going to be precisely contributing to our mathematical error and by definition the mathematical error involved in the Simpson's rule is nothing, but the exact value that is integral a to b f of x dx minus the value obtained from the Simpson's rule which is precisely the integral a to b p 2 of x dx. Therefore, this is the basic definition of the mathematical error involved in the Simpson's rule. As we did in other cases, we can also get an expression for this mathematical error for that you have to assume that f is a c 4 function in the interval a to b. Once you have that, then the mathematical error can also be represented by this expression. That is what the theorem says. It can be written as minus fourth derivative of the function f evaluated at an unknown point eta, where eta lies between the numbers a and b into b minus a to the power of 5 divided by 2,880. So, that is the expression for the function expression that you can obtain for the mathematical error. Whereas, this is the basic definition of the mathematical error. The proof is not very difficult, but it is little bit involved. Therefore, we will omit this proof for our course. However, we have given the proof in our notes interested students can go through the proof. Let us take an example. We will again consider the same integral which we have been working with the other quadrature formulas also. We will consider evaluating the integral 0 to 1 1 by 1 plus x into dx. Here f is taken as 1 by 1 plus x. The exact value of this integral is log 2 and numerically you can approximately take it as 0.693147 and there are more terms, but we have just rounded it up to here. Now, let us apply the Simpson's rule and see how the value comes out of the Simpson's rule for this integral. For that we have to take the formula for the Simpson's rule that is b minus a by 6 that is 1 by 6 here into f of a you can check that f of a a 0. Therefore, f of a is 1 plus 4 times f of a plus b by 2 that is 0.5 that turns out to be 8 by 3 plus f of b. Now, you just calculate this you will get the value of the integral as 25 by 36 if you use the Simpson's rule that is only an approximate number and that in the decimal form it gives you 0.694444 you can see that the error involved in this is roughly 0.001297. Of course, this is strictly speaking also involving the arithmetic error because we are representing all these numbers after a rounding approximation. Therefore, we should ideally call it as total error, but just with a little abuse of notation we are just calling it as mathematical error only, but you have to bear in mind that strictly speaking this is the total error. If you recall we have derived composite quadrature rules for both rectangle and trapezoidal rule we will also derive the composite Simpson's rule now. What is the basic idea of any composite quadrature rule? I hope you have seen the previous videos you know the idea very well you just have to introduce a partition to your interval a to b it can be non uniform partition also, but we have been taking only uniform partitions just for the sake of simplicity. Here also we will take a uniformly spaced partition with the length size of each partition as h and therefore, you can introduce the partition points as x i i equal to 0 1 2 up to some n where x i minus x i minus 1 is equal to h and also we will make sure that a is equal to x naught and b is equal to x n. Now here there is a catchy point when you are deriving the Simpson's rule remember you need 3 nodes in order to define the Simpson's rule. Therefore, when you take the partition you need 3 nodes in that interval suppose you take some point as a and some other point as b there should be one point in between these 2 nodes in order to define the Simpson's rule. Therefore, you have to take the pieces of the Simpson's rule as x i minus 1 to x i plus 1. So, that x i comes as a node point because you are only given the nodes and you are supposed to find the formula based only on those nodes you cannot generate a new node in order to evaluate the integral. You have to somehow manage them with the nodes given to you therefore, you cannot take x i and x i plus 1. If you take like that that is suppose you are taking this as x i to x i plus 1 then you can clearly see that there is no node between these 2 right, but you need a in between node in order to define Simpson's rule. Therefore, this way of taking nodes are not correct you have to take x naught and then x 2 this as 1 piece although you have x 1 as a node in your partition you have to take this as 1 interval and similarly x 2 to x 4 you have to choose although x 3 is a node you cannot take x 2 to x 3 then you cannot apply the Simpson's rule in the interval x 2 to x 3 you can only apply Simpson's rule in the interval x 2 to x 4 like that it goes that clearly says that the number of node points that you take in the interval in order to apply composite Simpson's rule you need that number to be of even number. So, to make sure that we need even number of nodes let us take the number of nodes as 2 n. So, that is something which you have to remember always the number of nodes that is needed for us to generate composite Simpson's rule should be a even number. Now, once you make sure then your integral a to b f of x dx can be first broken into the smaller integrals taken on the intervals x 2 i to x 2 i plus 2. Therefore, there is one node always sitting in between these two that is the idea. Once you split this integral a to b f of x dx into integrals of this form remember this is very important you should not forget it this is very important for Simpson's rule you can go back and observe that this complication is not there in trapezoidal rule as well as in the rectangle rule right. So, therefore, you have to keep this in mind when you are working with composite Simpson's rule then once you make the choice of your intervals properly then you can easily get the formula for the composite Simpson's rule by applying the Simpson's rule for each of this integrals right and that is given by this expression and now you have to take that with this summation right. You can see that that gives you 2 into h because your interval is always x naught 2 x 2 and then x 2 to x 4 like that you are jumping 2 h length in each sub interval right that is why you see that here you have instead of b minus a you have 2 h divided by 6 and then the Simpson's formula is applied here. After a suitable rearrangement of these terms you can finally get the formula for the composite Simpson's rule like this you can carefully go through and see how I have rearranged these terms in order to get this nice looking formula and this is the composite Simpson's rule well like this you can keep on choosing n is equal to 3, 4, 5 and so on and also for every given n you can also choose nodes at different positions in order to get different quadrature rules. We have only given 3 cases rectangle rule of course we have also given midpoint rule and then we have given trapezoidal rule for n is equal to 1 and Simpson's rule for n equal to 2 you can keep on going like this and you can generate many such quadrature rules. Let us see another way of deriving this quadrature rules called method of undetermined coefficients. This is particularly important when you go to derive Gaussian quadrature rules that is why we are first introducing this method. If you recall we have the quadrature rule in this form you know how this form comes out I am not going to repeat that all the quadrature rules that we have derived so far. We will look finally in this form for a suitably chosen set of nodes for a given n and the weights W i's are computed by W i's by integrating the corresponding Lagrange polynomials right. Now in this we are given these nodes right we are given these nodes and the weights are to be found right and this weights are found by just directly integrating the Lagrange polynomials. Now there is another way to find this weights that is what we will be doing here and this way of finding weights is what we call as method of undetermined coefficients. Let us see how to find this W i's instead of going for integrating the Lagrange polynomial. What you do is first of course we are given the n plus 1 node points that is given to us and then we have to find this weights right and so far we are doing it using the interpolating polynomials right. There is another way to do it let us see how to do that we first fix this nodes and then to get the corresponding weights we will impose certain conditions. What are those conditions we will say that this rule is exact for polynomials of degree less than or equal to n. This is the important point remember this is the exact integral right this is the exact integral and this is the approximation for the exact integral that is why we have put this symbol approximately equal to right. So this left hand side is not exactly equal to the right hand side but in this condition what we are saying is this will be exactly equal if this integrand happens to be a polynomial of degree less than or equal to n that is what we are imposing as a condition. And this will obviously give us n plus 1 equations involving x naught x 1 up to x n and also w naught w 1 up to w n. In this x i's are known to us therefore we can treat this system of equations with unknown as w i's in that way we will get a linear system of equations with unknown vector as w whose coordinates are w naught w 1 up to w n. Now you solve this system if it is possible and you get the weights this is the alternate way to get weights and this approach is what we call as the method of undetermined coefficient. This method is well understood through certain examples. So let us try to understand this method through this simple example. We want to find the quadrature rule for evaluating an approximate value of this integral a to b f of x dx for that we want to propose the quadrature rule in this form. In this what we are doing we are taking x naught as a x 1 as the midpoint of the interval a to b and x 2 as b. If you recall we have already learnt how to derive the expressions for w naught w 1 and w 2 you will get the using the corresponding interpolating polynomial and we have in fact called that quadrature formula as Simpson's rule in our previous slides. We will take the same situation that is the same set of nodes and we have n is equal to 2 here because we have 3 nodes. Now instead of going for the method of interpolating polynomials now we will go with the method of undetermined coefficients and try to get this weights w naught w 1 w 2 by imposing the condition that this will give you the exact value to this integral that is this will be exactly equal to the right hand side. If this function f happens to be a polynomial of degree something less than or equal to 2 right. So, this is the condition that we will impose and you can clearly see that this condition is equivalent to the condition that the formula is exact for the polynomials which are coming from the monomial basis of the space of all polynomials of degree less than or equal to 2. Remember the set of all polynomials of degree less than or equal to 2 forms an vector space and the functions 1 x x square will form a basis for this vector space. In general if this is some n this is the then the set of all polynomials of degree less than or equal to n will form a vector space and the set of functions 1 x x square up to x n will form a basis for this vector space and this basis is called the monomial basis. Now instead of applying this idea that is this condition on some general polynomial of degree less than or equal to 2 you can apply this condition on each member of the monomial basis that is the idea. Remember if you apply this condition to each of this polynomials you will get a linear equation for each polynomial right. So, that is the way to get a system of linear equations. Now let us see how to do that remember this is the integral that we want to evaluate and this is the quadrature formula that we are proposing to approximate the value of this integral. In this what you have to do is first take f of x equal to 1 remember it just take what happens when this integrand happens to be the constant function f of x equal to 1 for all x. In this case as per our condition this quadrature formula should give exact value. Therefore, this is the imposed condition under the method called method of undetermined coefficients. So, you are just imposing this condition right on the right hand side you have to take f of a equal to 1 and f of a plus b by 2 equal to 1 and similarly f of b equal to 1 because you are now considering your integrand to be the constant function f of x equal to 1 for all x that gives you the right hand side as w naught plus w 1 plus w 2 and that should be equal to the left hand side integral which is integral a to b. Now, your function is just 1 therefore, we are putting 1 dx you can explicitly compute the left hand side and that gives you this equation this is the first equation for our system. Now, you have to impose our second condition what is the second condition the second condition is that when the integrand happens to be the identity map that is f of x equal to x for all x then again it is a polynomial of degree less than equal to 2 right. Therefore, your integral value and the value obtained from this formula they should be exactly equal that is what you are imposing here the integral is integral a to b x dx and the right hand side formula now gives you this expression they both should be exactly equal that is what the condition that we are demanding right. And again that gives us this equation you can observe that these 2 or equations with unknowns as w naught w 1 and w 2 and you can also see these are linear in w right. And finally, you have to impose the condition that f of x equal to x square then what happens again you will have integral a to b x square dx is exactly equal to the right hand side expression where you have to put f of x equal to x square there that is why you have a square and this and this right and again you evaluate this integral explicitly and that gives you another equation. Similarly, if n is equal to 3 then you have to impose this condition with 1 x x square and x cube and similarly for any given n you have to accordingly take the monomial basis of that vector space all polynomials of degree less than equal to whatever n that we give ok. And then you have to impose these conditions 1 by 1 that is f of x equal to 1 f of x equal to x f of x equal to x square and so on f of x equal to x cube you have to put and so on whatever n you are given up to that you have to put each case will give you a linear equation and thereby you will have a linear system of equations. In the present case we have taken n is equal to 2 therefore our linear system will have 3 equations which we have just now derived and these 3 equations are given like this. You see that the unknown vector in this is equal to w naught w 1 and w 2 and what is the right hand side vector b and that is given like this right. So, that is the right hand side vector b. Now you can solve this linear system to get the weights w naught w 1 and w 2 and that is not very difficult you can explicitly solve it in fact and your weights are given like this. And if you recall that that will lead to this formula by imposing these weights into this expression you get this formula and this is nothing, but the Simpson's rule right. In fact, method of undetermined coefficient will lead to a quadrature rule which is exactly the same as the corresponding quadrature rule derived by integrating the corresponding interpolating polynomial of the function f. So, what I am trying to say is these 2 methods that is the method of undetermined coefficients and the method by directly integrating the interpolating polynomials. These 2 methods will finally lead to the same quadrature formula that is all. Only the way we derive these weights are different in the interpolating polynomial case we are integrating the Lagrange polynomials and getting these weights. Whereas, in the method of undetermined coefficients we are imposing the condition that the quadrature rule is exact for polynomials of degree less than or equal to n whatever the n that we choose. And with that we are applying this condition on the corresponding monomial basis and we are getting a linear system out of that and that linear system will give you the weights again right that is the method of undetermined coefficients. Whatever may be the method finally, the quadrature rule will be the same that is the idea. We will see why we have introduced this method of undetermined coefficients when we know that the final expression that is the formula is going to be the same as we did with the interpolating polynomials right. But there is a major advantage with this method of undetermined coefficients. We will discuss this in the next class. Thank you for your attention.