 we are discussing numerical integration. In this, we have developed a method called rectangle rule. In this lecture, we will develop another method called trapezoidal rule. If you recall, rectangle rule was obtained by approximating the integrand by the interpolating polynomial of degree 0, whereas trapezoidal rule is obtained by approximating the integral integrand by the interpolating polynomial of degree less than or equal to 1. Recall, our interest is to evaluate the value of the integral integral a to b f of x dx. To approximate this value, we will first approximate the function f by the corresponding interpolating polynomial of degree n at some specified node points x naught x 1 up to x n. Then, we will integrate the polynomial p n in the interval a to b in order to get an approximate value of our original integral. That is the idea. If we write the polynomial in the Lagrange form and take the integral, we will get this form and this is the general form of the numerical integration formula or quadrature rule, where x naught x 1 up to x n are given to us and we have to find the weights w naught w 1 up to w n, which are obtained by integrating the Lagrange polynomial. In this, we will now take n is equal to 1 and thereby we will only have the first two terms. If you recall, the corresponding polynomial of degree less than or equal to 1 can be written in this form. Remember, I am just writing it in the Newton's form, whereas here we have written it in the Lagrange form and then took the integral. It does not matter as we know both these formulas will lead to the same interpolating polynomial. Now, we will take the integral of the polynomial p 1 of x over the interval a to b and that is what we will call as the formula for the trapezoidal rule. Let us evaluate this integral and see how it simplifies. Well, you can do it directly and see that it simplifies to this form, where we have taken x naught equal to a and x 1 equal to b and that leads to the trapezoidal rule. Remember, a particular rule in this format will be obtained by first fixing n and not only that, we have to also fix the nodes. So, in that way trapezoidal rule is obtained by taking n equal to 1, x naught equal to a and x 1 equal to b and the formula is given like this. It is obtained by directly integrating this polynomial over the interval a to b. I will leave it to you to do this calculation and get this formula. It is a very simple calculation. Let us now try to understand the trapezoidal rule from the geometric point of view. The original integral that is integral a to b f of x d x, generally we denote it by i of f is nothing but the area under the graph of the function f. Suppose, if the graph of the function f is given like what is shown in the red solid line in this figure, then i of f is precisely the area covered by the shaded region shown in this figure. Now, what the trapezoidal rule does is instead of taking the function f, it is taking its interpolating polynomial approximation of degree less than or equal to 1. By that it is precisely taking the line joining these two points and thereby it is taking the area covered by this region shown in the green color. That is what the trapezoidal rule precisely gives us as an approximate value to the original integral that we are interested in. You can clearly see what is the error that trapezoidal rule commits mathematically. In this example you can see that the trapezoidal rule has included this area which is not there in the original integral, but it excluded this area which was there in the original integral. These areas will contribute in the mathematical error of the trapezoidal rule which is defined as the difference between the exact value and the approximate value. So, this is the trapezoidal rule which we generally denote by i t of f and that is precisely the exact integral of the interpolating polynomial of f of degree less than equal to 1. In order to have a better understanding we can get an expression for the mathematical error as we did in the rectangle rule. Let us put this formula in the form of a theorem and call this theorem as error-entrapezoidal rule. In order to derive the formula for the mathematical error we have to assume that f is a c 2 function that is f is twice continuously differentiable function. Then you can write the mathematical error involved in the trapezoidal rule which is by definition given by this and we can obtain an expression for this. Although I use the word formula I generally do not prefer to use that word because this expression involves an unknown eta. This is always the case in any method that we have seen so far there is always an unknown involved in the mathematical error. Therefore, including that unknown the expression for the mathematical error can be written as minus f double dash of eta into b minus a cube by 12 where eta is some unknown number in the interval a comma b. Let us see how to prove this theorem for that first you take a point x in the interval a comma b which is not equal to a and not equal to b and then construct the quadratic polynomial interpolating the function f at the points x naught equal to a x 1 is equal to x and x 2 is equal to b or we may write x 1 is equal to b. Remember in the interpolation we do not need to worry about in what way we are arranging this nodes just to have a clear idea I am just taking it as x naught equal to a x 1 equal to b and x 2 equal to x and then I am writing the quadratic polynomial interpolating the function f at these nodes and that is given by this with t here t here and t here. Now in this interpolating polynomial if I put t is equal to x then you will get p 1 of x is equal to f of x that is precisely the interpolation condition at t equal to x that is why we have written f of x is equal to this expression and remember this is nothing but p 1 of x that is what I am replacing here if you recall the same kind of derivations we have also used in the rectangle rule in order to get an expression for the mathematical error in the rectangle rule right. The same idea we are following in the proof of the error formula for trapezoidal rule also once you have this you can now take the integral on both sides to get integral a to b f of x dx is equal to integral a to b p 1 of x dx that is what finally simplified to the trapezoidal rule in our case when we took the nodes as a and b right that is why I have used the notation it of f plus integral a to b of this part of the expression. So that is what is written here now you can see that the mathematical error by definition is i of f minus i t of f right therefore that can be now written as this expression that is what I am writing in this step and now let us try to rewrite this expression in order to get the formula that we have stated in the theorem for that again we have to use the second mean value theorem for integration you just recall the statement of the second mean value theorem for integration in that we have two functions f and g they are continuous functions and g is of one sign that means either g is greater than equal to 0 or less than equal to 0 for all x in the interval a to b then just imagine that this is replacing f of x in the statement of the second mean value theorem and this is replacing g of x in the second mean value theorem for integration then the second mean value theorem says that you can find a xi such that f of xi can come out of the integral and you can write this expression as f of xi into integral a to b g of x dx right for that of course we have to assume that this map is a continuous map one can assume it because in fact it is true you can prove this using a theorem called hermit ginochi formula we have not discussed this theorem in our class however I have given this theorem with proof in our notes you can read the theorem and try to understand the proof of the theorem using the theorem you can show that the map that takes x to the divided difference of a function f of any order for that of course you need certain conditions on f you can get that from the hermit ginochi formula once those conditions on f are satisfied then you can say that the map that takes x to the divided difference of any order here we are using only the divided difference of order 2 that is why I have put like this but it is true for divided difference of any order you can say that this map is continuous we will not go into the details of this justification but we will simply assume this and it is always true that this map is continuous and also you can see that this expression is negative that is because x belongs to the interval a to b right therefore you can apply the second mean value theorem for integration and you can pull out this part of the integrand outside the integral with an unknown quantity eta this is how we are first landing up with an unknown here and then the remaining part of the integrand is kept in the integral and that can be easily integrated right it is not a problem at all now you see this is not the expression we have stated in the theorem right we still need to do one more step let us see what it is again if you go back to our previous chapter we have derived an expression for the mathematical error involved in the interpolating polynomials if you carefully go through the proof you can see that this divided difference can be written in this form the proof of this formula can be obtained by carefully going through the proof of the error formula for interpolating polynomials so now I am going to use this expression for this term remember this is true for divided difference of any order now you see in the general formula you have n plus 1 nodes plus one more extra here you have this plus 1 therefore here you have to take n is equal to 1 in order to match this expression with this and therefore you have second derivative on the right hand side. If you recall in the last slide we have this expression for the mathematical error now we want to put this formula into this term for that you have to take n is equal to 1 right because this corresponds to x naught and this corresponds to x 1 and this eta corresponds to x therefore n is equal to 1 that will make us to put f of a comma b comma eta as f double dash of sum xi divided by 2 factorial right so that is what will come if you use this formula and that is precisely what we want to show in our theorem that is the mathematical error is equal to f double dash of well I have used the notation eta here into b minus a cube by 12 how this b minus a cube by 12 is coming well that comes by directly integrating this term and of course you have 2 here also you can do this calculation that is you can explicitly evaluate this integral and you can see that that will precisely be the expression that we want to show in our theorem and this completes the proof of the trapezoidal rule let us take the integral 0 to 1 1 by 1 plus x dx you can easily evaluate this integral and you can see that the value of this integral is log 2 which can be approximately taken as this number now let us try to evaluate an approximate value of this integral using the trapezoidal rule you know the trapezoidal rule you just put a is equal to 0 b equal to 1 and f of x equal to 1 by 1 plus x in the expression of the trapezoidal rule formula you will get the value from the trapezoidal rule as 0.75 and therefore the error involved in this approximation is roughly minus 0.0569 we may call this as the mathematical error although there are some rounding error involved in it you should actually call it as total error just for the sake of simplicity we are calling it as mathematical error here and now let us try to compare the error that we obtained from the theorem that we got in the previous case here we got the value of the mathematical error exactly from our computation right we got it explicitly because we have fixed f we have fixed a and we have also fixed 1 and the integral is something very easy for us to evaluate therefore we know the exact value also up to certain rounding error we know it exactly therefore in this particular example you can get the mathematical error more explicitly now let us go to the expression that we derived theoretically for the mathematical error in the trapezoidal rule and we will try to see whether the theoretical result is well comparing with the computed result for that we have to find an upper bound and a lower bound for this expression well how will you do that you know what is b b is 1 a is 0 therefore this term can be explicitly calculated in order to get a lower and upper bound for the mathematical error you just have to find the lower bound and upper bound for this term we know what is f so you differentiate it twice and then find the minimum and maximum of that function in the interval 0 to 1 and that gives us a lower bound which can be approximately taken like this and the upper bound which can be taken like this and now you can see that the computational result that we got is well agreeing with the theoretical bound that we got through this expression this is just to cross check how our theoretical analysis is well coinciding with the computed data just to have a justification for this we have given this example next let us go on with the composite trapezoidal rule if you recall in the last class we have derived the composite rectangle rule the idea of deriving composite trapezoidal rule is exactly the same in order to improve the approximation in the quadrature formula you can go to apply the quadrature formula on a partition of your interval a to b that is the idea of composite rule of any quadrature formula the first step is to break the interval a to b into smaller subintervals that is you first introduce a partition to the interval on which we want to perform the integration and then apply the quadrature rule on each subinterval more precisely we will try to derive the composite trapezoidal rule on a equally spaced partition this is just for the sake of simplicity you can also derive the composite rule for any quadrature formula on a non uniformly partitioned grids also let us take some value for n then you will have the partition x naught x 1 up to x n given by a plus j h where j runs from 0 to n where h is given by b minus a by n why because we are just considering equally spaced nodes that is why we have taken h like this once you have this you can write your integral as sigma j equal to 0 to n minus 1 integral x j to x j plus 1 f of x dx and now once you have this you can apply any quadrature rule on this integral which is restricted to each of the subintervals remember we have done this in the last class also there we have applied a rectangle rule for each of this integrals now we will apply trapezoidal rule for each of this integrals remember this is the trapezoidal rule restricted to the subinterval x j to x j plus 1 since the length of the interval is h we have h here right therefore you can write this expression now replacing the exact integral by this approximate expression you get this expression on the right hand side now you can just rearrange the terms in this expression to get the composite trapezoidal rule given by this formula let us take n is equal to 2 and try to evaluate the approximate value of the integral 0 to 1 1 by 1 plus x dx recall we have obtained an approximate value of this integral using trapezoidal rule also now we will use composite trapezoidal rule with n is equal to 2 and see how we are getting the approximation recall the exact value is log 2 which may be taken approximately as this number and the composite trapezoidal rule with the partition as x naught which is equal to 0 x 1 equal to 1 by 2 and x 2 equal to 1 can be obtained as this number recall you just have to put x naught equal to 0 x 1 equal to half and x 2 as 1 in this formula with n is equal to 2 here and then a direct calculation will give you this number what is the error now you can directly see that the error involved in this approximation when compared to this as the exact value is given by this formula if you go back to the previous example the trapezoidal rule gave us this error right you can clearly see that the composite trapezoidal rule with n is equal to 2 gave us a better approximation when compared to the trapezoidal rule remember trapezoidal rule is nothing but the composite trapezoidal rule with n is equal to 1 that is all similarly if you take n is equal to 3 4 5 and so on you will tend to get better and better approximation to this value in that way you can generate a sequence i n t of f observe that we have used the notation i 2 t of f for the composite trapezoidal rule with n is equal to 2 similarly we will use the notation i t 3 of f for the composite trapezoidal rule with n is equal to 3 and so on in that way you are getting a sequence of numbers like this for each n you are getting a sequence of real numbers and we expect this sequence to converge to the exact value of the integral i of f in this case in this particular example i of f is this and i 2 t of f is this similarly you can get i t 3 of f that will be some number and so on in that way you are getting a sequence now the question is does this sequence converges to this number as n turns to infinity that is the question the answer is s it will converge how will you prove that you will take this quantity i n t of f minus i of f or may be the other way round and that is the mathematical error involved in this and you can obtain the mathematical error by imposing the mathematical error for each of this term remember this is the trapezoidal rule for this particular integral you know how to get the mathematical error for this when compared to the exact value this right the expression is derived in our previous theorem now you have to put that expression for this particular integral and then sum all those errors from j equal to 0 to n minus 1 you can see that that mathematical error will involve something with h to the power of something divided by something right from here you can see that as n tends to infinity you obviously know that h tends to 0 because it is nothing but b minus a by n right therefore as n tends to infinity h tends to 0 that will imply that this term will go to 0 right this is how you can prove the convergence of the composite trapezoidal rule to the exact value of the integral a similar proof can also be given for rectangle rule I will leave it to you to prove these results with this we will end this class and thank you for your attention.