 We are considering numerical quadrature formula. So, our function is continuous defined on interval a b. So, it is remain integrable and in order to find approximate value, what we do is we approximate it by a interpolating polynomial. We know how to integrate the polynomial and then we get a approximate value. So, today we are going to consider some of the basic numerical quadrature rules and then we will consider the composite rules. So, let me recall that last time we proved a theorem which is called mean value theorem for integrals and this theorem we are going to use for finding an expression for the error in our numerical integration. So, this was the theorem that our function f is a continuous function. So, since it is continuous it is going to be integrable g is an integrable function. So, the function g need not be continuous it can have finite number of discontinuities, but we assume that g is of the same size same sign on the interval a b. That means either it is bigger than or equal to 0 or it is less than or equal to 0. Then we proved that there exists a point c in the interval a b such that integral a to b f x g x d x is equal to you can take out f as f at c into integral a to b g x d x. The proof was given for the case when g x is bigger than or equal to 0 and the similar proof can be given for g x less than or equal to 0. This theorem will allow us to find a more precise error in the numerical quadrature. So, we have our function f and p n is the interpolating polynomial. If the function itself is a polynomial of degree less than or equal to n then p n is going to be less than or equal to n. So, p n is going to be a polynomial which is equal to the function itself and then there will be no error. So, we say that the quadrature rule this is exact for polynomials of degree less than or equal to n p n interpolates the given function at n plus 1 points. So, this exactitude for polynomials of degree less than or equal to n this is something expected. What can happen that you can have the error to be 0 even for a higher degree polynomial. So, this happens in some cases which we will consider. Now, the function f x is equal to p n x and this is the error. So, the error is the difference of two parts the divided difference based on x 0, x 1, x n, x multiplied by w x. We have already seen that the divided difference is continuous on interval a b. Now, for some specific values of x 0, x 1, x n w x will have the same sign and then we will use mean value theorem for integrals to obtain an error expression. So, first rule which we are going to consider is we choose n is equal to 0 and interpolating polynomial which is going to be a constant polynomial in that we choose x 0 to be left hand point a. So, that gives rise to what is known as a rectangle rule. So, we have x 0 is equal to a, f is defined on interval a b taking real values, f x is equal to f of a plus f of a x, x minus a. So, this is our polynomial. So, this is our polynomial and this is our error. So, integral a to b f x d x is going to be integral a to b f a d x plus integral a to b f of a x, x minus a d x. This is a continuous function provided our function f is differentiable, this is going to be bigger than or equal to 0. So, we get this to be equal to f of a into b minus a plus f of a c integral a to b x minus a d x using the mean value theorem for integral. So, which will be equal to f a into b minus a plus f dash d b minus a plus f of a c integral a to b x minus a d x using the mean value theorem for integrals. So, which will be equal to f a into b minus a plus f dash d b minus a square by 2. So, integral a to b f x d x is approximately equal to f of a into b minus a and the error is f dash d into b minus a square by 2. So, if f is constant function, then it will imply that error is 0 because f dash d will be 0 and this is something expected. If f is constant, then f of a is equal to f of x. So, there is no error to start with and this is known as the rectangle rule. Now, what we are going to do is again look at constant polynomial approximation, but instead of choosing our point x 0 to be left hand point a, we will choose the midpoint. Now, if you choose it to be a midpoint, then our function w x which is x minus a plus b by 2 that is going to take both positive values and negative values. When you are in the interval a to a plus b by 2, w x which is x minus a plus b by 2 will be less than or equal to 0 and when you are on the right hand side of a plus b by 2, it will be bigger than or equal to 0. So, then the mean value theorem for integrals is not applicable, but then this point a plus b by 2, it has the property that integral a to b x minus a plus b by 2 d x that is 0. So, using this property, we will show that if you consider constant polynomial approximation and the interpolation point is chosen to be midpoint, then the error is 0 not only for constant polynomials, but also for linear polynomial. So, we get 1 degree higher exactitude. So, here when we had considered rectangle rule, what we were doing was say this is your function f x, this is point a, this is point b. So, this is f x and this is f x. So, integral a to b f x d x that gives us this area, area which is bounded by x axis, x is equal to a, x is equal to b and above by f x. So, area of this region and in the rectangle rule, we are looking at this rectangle. So, this is our area. So, this much is going to be the error. Now, if you choose the point x 0 to be equal to a plus b by 2, then what we will do is this is our graph of the function. We will look at the midpoint, look at the value and then or rather we are going to look at the area of this rectangle. So, if your function is a straight line and if you are looking at the midpoint, then integral a to b f x d x will be area of this trapezium and the rule if you take x 0 is equal to a plus b by 2, then you are looking at this area. So, this area and this area gets cancelled and then you get error to be equal to 0. So, this is going to be the midpoint rule. So, the only difference between rectangle rule and midpoint rule is that it is the choice of our interpolation point is different. Once you are we are choosing it to be the left hand point and once you are choosing it to be the midpoint, but then if you choose it to be the midpoint, then we get the exactitude for 1 degree higher. Now, this I showed you graphically, but we are going to prove it more rigorously and then whatever technique we are going to use, this we are going to use this technique often. So, that is why for the rectangle rule rather for midpoint rule, I am going to explain this technique in detail and afterwards whenever it occurs, we will be using the same method. So, we have f x is equal to f of a plus b by 2 plus the error a plus b by 2 x into x minus a plus b by 2 and hence integral a to b f x d x is equal to integral a to b f of a plus b by 2 d x plus error integral a to b f of a plus b by 2 d x plus error integral a plus b by 2 x x minus a plus b by 2 d x. Now, continuity of this is no problem x minus a plus b by 2 is less than or equal to 0 in the interval a to a plus b by 2 x minus a plus b by 2 is bigger than or equal to 0 in the interval a plus b by 2 to b and hence mean value theorem for integrals is not applicable. So, we have, so this is what we are considering is known as midpoint rule integral a to b f x d x is approximately equal to f of a plus b by 2 into b minus a and the error to be equal to integral a to b f of a plus b by 2 x minus a plus b by 2 d x. So, this error is equal to integral a to b f of a plus b by 2 d x plus with integral a to b x minus a plus b by 2 d x is equal to 0. Now, we want to make use of this property that integral a to b x minus a plus b by 2 d x is equal to 0. We have error formula for the integral is integral a to b f of a plus b by 2 x. x into x minus a plus b by 2 d x is d x. The coefficient of x minus a plus b by 2 is a function depending on x. If there I had a constant I could take it out of the integration sign, but f of a plus b by 2 x the divided difference it depends on x, but then what we will do is we will use the recurrence formula for the divided difference. That means this divided difference f of a plus b by 2 x we are going to replace by divided difference based on point c and point a plus b by 2 where c is some fixed point and then there is going to be an additional term. So, we have f of look at the divided difference based on three points c a plus b by 2 x. This by the recurrence formula it is f of a plus b by 2 x minus f of c a plus b by 2 divided by x minus c. Hence f of a plus b by 2 x this will be equal to f of c a plus b by 2 plus f of c a plus b by 2 x into x minus c. Now, this we are going to substitute in the error formula here. Now, before we proceed notice that this relation is valid for all x belonging to interval a b whereas, this relation is valid for x not equal to c. So, provided your function f is sufficiently differentiable you have got this. So, this is an important relation and we are going to use such a relation later on. So, we have error to be equal to integral a to b f of c a plus b by 2 into x minus a plus b by 2 d x plus c a plus b by 2 divided by x integral a to b divided difference based on c a plus b by 2 x x minus c x minus a plus b by 2 d x. This will come out of the integration sign and this vanishes. So, now our error it is going to be equal to divided difference based on three points point c point a plus b by 2 and point x multiplied by instead of earlier we had only x minus a plus b by 2. So, now we have got two terms there is x minus c and x minus a plus b by 2. So, far on c we have not put any restriction c can be any point in the interval a b. But now we will like to use mean value theorem. So, the point c we will choose. So, that x minus c into x minus a plus b by 2 is of the same sign. So, the simplest choice is put c is equal to a plus b by 2. So, that you will get x minus a plus b by 2 square and that will be always bigger than or equal to 0. Now, look at instead of divided difference based on two points f of a plus b by 2 x we have got divided difference based on three points. And if your f is sufficiently differentiable this divided difference will be equal to f double dash at some point say eta divided by 2. So, in the error formula instead of first derivative second derivative value is appearing and then if the second derivative is identically 0 the error will be 0. Now, second derivative identically 0 that means the function should be a polynomial of degree less than or equal to 1. So, thus we are approximating our function f by constant polynomial, but the error in the numerical quadrature it is equal to 0 not only for constant polynomial constant polynomial it is expected that the error has to be 0, but we get the error to be 0 also for linear polynomial. So, let us continue. So, our error is equal to integral a to b f of c a plus b by 2 x x minus c x minus a plus b by 2 d x choose c is equal to a plus b by 2. So, the error will be integral a to b f of a plus b by 2 a plus b by 2 x x minus a plus b by 2 square d x this is equal to a plus b by 2 a plus b by 2 a plus b by 2 a plus b by 2 is continuous at the moment assume that it to be continuous let us prove it in a minute and this is going to be bigger than or equal to 0. So, we have got f of use mean value theorem for integrals. So, this implies that it is equal to f of a plus b by 2 a plus b by 2 say some point d integral a to b x minus a plus b by 2 square d x. So, this will be equal to f double dash eta divided by 2 and the integration of this will give us b minus a by 2 square and then we are going to have 2 times or other cubic here and then 2 times. So, this will be equal to f double dash eta divided by 8 b minus a cube. So, this is the error in the midpoint rule and error is equal to 0 for polynomials of degree less than or equal to 1. So, now, let us show continuity of this theorem. So, we have got f of a plus b by 2 a plus b is divided difference. So, we had already shown the continuity of divided difference when our points are distinct points. Now, what is happening is our point is repeated. So, we have got divided difference based on x 0 repeated twice and then x and x varies over interval a b. So, x also can take value to be equal to x 0. So, in order to prove this continuity of this divided difference, we will have 2 cases. One will be when x is not equal to x 0 and when x is equal to x 0. So, we will have 2 different definitions. So, the continuity means we will have to just prove the continuity at point x 0. At other points, it is going to follow from our continuity of divided difference when the points are distinct. So, let us look at the divided difference f of x 0, x 0, x. This our definition is it will be f double dash x 0 divided by 2 when x is equal to x 0. When x 0 is repeated thrice, this is how we define divided difference and then we will have f of x 0, x minus f dash x 0 divided by x minus x 0. So, this is how we define divided difference. So, let us assume that f belongs to c 2 a b that is 2 times continuously differentiable. So, this is continuous is fine because f of x 0, x is going to be continuous, f dash x 0 is continuous or it is a constant actually divided by x minus x 0 and our x is not equal to x 0. So, it is a quotient of 2 continuous function and hence it will be continuous. Now, look at the continuity at x 0. So, let us look at limit as x tends to x 0 of f of x 0 x minus f dash x 0 divided by x minus x 0. This will be limit x tending to x 0. The divided difference f x 0 x will be f x minus x 0 divided by x minus x 0. So, it will be f x minus f x 0 minus f dash x 0 into x minus x 0 square divided by x minus x 0 square. Here it should be only x minus x 0, here it should be square. Now, use extended mean value theorem to obtain this as limit x tending to x 0 f double dash of c x x minus x 0. So, x 0 square divided by 2 and whole thing divided by x minus x 0 square, where c x lies between x and x 0. So, when x tends to x 0 f double dash being continuous, this is going to be equal to f double dash x 0. So, this proves that the limit x tending to x minus x 0 square divided difference even when x 0 is repeated twice, it is continuous. So, we considered the constant polynomial approximation. The next we are going to consider linear. So, in order to fit a polynomial of degree less than or equal to 1, we will need two interpolation points. So, those two interpolation points, we will choose to be two end points of the interval point A and point B and then you join it by straight line. So, look at that area of the trapezium and that will give us a rule. So, that is known as the trapezoidal rule. Next, we will consider instead of two points, look at three points. So, the three points will be left end point A, right end point A plus B by 2 and the midpoint, right end point B and the midpoint A plus B by 2. So, we choose our points to be symmetric. You fit a parabola and you know how to integrate polynomial of degree 2. So, that will give us a rule which will involve function f of A, value of the function at A, value of the function at A plus B by 2 and value of the function at B. So, when you consider linear interpolation trapezoidal rule, we will see that it is exact for polynomials of degree less than or equal to 1. That means there is no error if your function happens to be a polynomial of degree less than or equal to 1 and that is something expected. When you can look at the polynomial of degree 2 and choosing our points to be A, B and A plus B by 2, what is expected is error should be 0 if the polynomial, if the function which we are approximating is a polynomial of degree 2. But then we will get not only exactitude for quadratic polynomials, but also cubic polynomial and the reason is once again as in the case of midpoint rule, we had integral A to B x minus A plus B by 2 dx is equal to 0 and we exploited this property to get exactitude for one higher degree. So, same thing is true for quadratic polynomial that when you look at the function w x, our w x is x minus x 0 x minus x 1 x minus x n, where x 0 x 1 x n are the interpolation points. So, integral x minus A x minus A plus B by 2 x minus B dx is equal to 0. So, we will use this property to get exactitude for quadratic and the recurrence relation for the divided difference to get exactitude for cubic polynomials. Now, for trapezoidal such a thing is not possible. So, it was possible for constant polynomial for even for the second degree polynomial, such a thing is not possible for all even degree interpolation. So, when you consider even degree polynomial interpolation and you choose your interpolation points to be in a symmetric manner, then we get exactitude for one degree higher. So, let us look at the trapezoidal rule, the derivation of trapezoidal rule is straight forward and when you fit a parabola with points as A, B and A plus B by 2 that is known as Simpson's rule. So, first trapezoidal rule, our interpolation point is x 0 is equal to A, x 1 is equal to B, then f x is equal to f of A plus f of A B x minus A. So, this is our p 1 x plus error f of A B x x minus A x minus B. So, this is our trapezoidal rule. So, integral A to B f x d x will be equal to integral A to B p 1 x d x plus integral A to B f of A B x w x d x, this is our w x. This divided difference is continuous, w x is going to be less than or equal to 0 on interval A B. So, we will get this to be equal to, now integration of this. So, that will be f of A into B minus A plus divided difference based on A B into f of A into B minus A plus divided difference based on A B into B minus A. So, x minus A square by 2, you have to evaluate between A and B plus, now we use mean value theorem for integrals to get f of A B C integral A to B w x d x. So, this will be equal to f of A into B minus A plus F B minus F A plus F B minus F A plus F A plus F A minus F A divided by B minus A into B minus A square by 2 plus the error. Now, the reason I have integrated or I have performed disintegration in detail is that the same results we are going to use for Simpson's rule. So, now, so error is equal to integral A to B plus w x d x multiplied by f of A B C. So, this will be equal to integral A to B x minus B x minus A d x and f double dash d divided by 2 provided your function is twice differentiable. Now, this integral we will calculate using integration by parts. So, it will be x minus B x minus A square by 2 between A and B minus integral A to B x minus A square by 2 d x and this is going to be equal to x minus A square by 2 d x. This term will be 0 and this will give us B minus A cube divided by 6. All this multiplied by f double dash d by 2 and here is a negative sign. So, this will be negative. So, this is the error minus f double dash d by 12 B minus A cube. So, this is the error in the trapezoidal rule and integral A to B p 1 x d x it was equal to f of A into B minus A plus f B minus f A divided by B minus A into B minus A square by 2. So, when you simplify this 1 B minus A and you are going to have integral A to B f x d x to be approximately equal to B minus A by 2 f A plus f B. So, graphically you have got this to be your function. You are looking at this area. Now, you are joining it by straight line. So, area of this trapezius rule that is the B minus A by 2 f A plus f B and this much is going to be the error. So, this was the trapezius rule. So, when you compare the midpoint rule and the trapezius rule in the midpoint you evaluate function only at the midpoint and then you got it to be exact for polynomials of degree less than or equal to 1. In the trapezium you are evaluating at two end points and then again the error is 0 if f is a polynomial of degree less than or equal to 1. So, at this stage it seems that midpoint rule should be preferred over the trapezium rule, but afterwards when we consider the composite rules there we will see that there is not much difference in the function evaluation. For the basic rule yes for the midpoint you need only one function evaluation for trapezium you need two function evaluations, but when you consider the composite the two end points they are going to be common to adjoining intervals and that is how if you need n function evaluations in case of midpoint rule composite midpoint rule for composite trapezium you will need n plus 1 and then n is supposed to be large. So, there is not much difference between n and n plus 1. So, the trapezium rule and the midpoint rule they are going to be on par. On the other hand between rectangle and the midpoint rule we will see that the midpoint rule is to be preferred because for the composite rule it is going to give you one higher degree convergence. Let us look at now the Simpson's rule where we are going to consider interpolating polynomial of degree less than or equal to 2 and you interpolate at 3 points the left end point midpoint and the right end point. Your x 0 is equal to a, x 1 is equal to a plus b by 2 and x 2 to be equal to b. f x is now our polynomial interpolation it does not depend on the order like what we want is whether I consider the points like x 1, x 2, x 3 in the order a, a plus b by 2, b or in the order a, b and a plus b by 2 the interpolating polynomial is unique. So, the result is not going to change for the trapezium we have already found the polynomial of degree less than or equal to 1 which interpolates our given function at a and b. So, what let us do is just add one more point a plus b by 2. So, let us write our p 2 to be polynomial of degree less than or equal to 2 interpolating in the order a, b and then a plus b by 2. So, you will have f x is equal to f of a plus f of a b divided difference based on x minus a. So, this is our polynomial of degree 1 and then f of a b a plus b by 2 multiplied by x minus a x minus b. So, this is our p 2 plus the error is going to be a b a plus b by 2 x, x minus a x minus b x minus a plus b by 2. So, integral a to b f x d x is equal to integral a plus b by 2. So, integral a to b p 2 x d x this was our p 2 x plus the error term and that error is integral a to b f of a b a plus b by 2 x w x d x. Now, w x in this case it is going to be both positive and negative values. The divided difference based on points a a plus b by 2 b x that is going to be continuous, but we are multiplying by w x which takes both positive and negative values. So, mean value theorem for integral is not applicable, but integral a to b x minus a x minus a plus b by 2 x minus b d x is going to be 0. So, that is the fact we are going to use. So, before that let us find out the formula for integral a to b p 2 x d x and then look at the error. So, our integral a to b p 2 x d x is integral a to b f of a plus f of a b x minus a plus f of a b plus f of a b x minus a plus f of a b a plus b by 2 x minus a x minus b d x. So, the first two terms we have already seen that it is b minus a by 2 f a plus f b. Here f of a b a plus b by 2 that will come out of the integration sign. So, it is a b a plus b by 2 and what remains is integral a to b x minus a x minus b d x. So, this will be equal to b minus a by 2 f a plus f b plus the divided difference I can write it is a b a plus b by 2 and we had already calculated this integral. So, that was minus b minus a cube divided by 6. Now, this divided difference is going to be equal to a b minus 2 times f of a plus b by 2 plus f of a divided by b minus a by 2. So, you simplify and check that you are going to get it to be equal to b minus a by 6 f of a plus 4 times f of a plus b by 2 plus f of b. So, this is Simpson's rule. So, now, we look at the error in the Simpson's rule. This is the expression w x is taking both the signs. Now, look at integral a to b x minus a x minus a plus b by 2 x minus b d x. In order to evaluate this integral, I do this change of variable. We have used the same change of variable earlier. So, you look at y is equal to x minus a plus b by 2, k is equal to b minus a by 2, then y minus k, y plus k is nothing but x minus a, y minus k is x minus b and x minus a plus b by 2 is y. So, this is going to be integral minus k to k y cube minus k square y d y. Y cube is a odd function, y is a odd function. So, their integral over minus k to k is going to be 0. So, that proves that integral a to b w x is going to be equal to 0. Next, you look at this f of a a plus b by 2 b x. I cannot take this out of integration sign because there is dependence on x, but then I look at the recurrence formula and introduce a point c. So, this divided difference based on a a plus b by 2 b x is going to be equal to divided difference based on c a a plus b by 2 b plus divided difference based on 5 points c a a plus b by 2 b x and then multiplied by x minus c. I substitute in this formula. Now, this divided difference is independent of x. So, it comes out of the integration sign and then integral a to b w x d x is 0. So, this goes away. So, you are left with this. Now, if you want to use mean value theorem x minus c into w x that should have the same sign. In w x we had term x minus a x minus b and x minus a plus b by 2. So, the term x minus a plus b by 2 it makes w x take both positive and negative values. x minus a and x minus b they do not cause any problem. x minus a will be always bigger than or equal to 0 x minus b will be always less than or equal to 0. Now, we are looking at x minus c into x minus a plus b by into d x. So, if I choose c to be equal to a plus b by 2 then I will have x minus c into w x to be x minus a x minus b and x minus a plus b by 2 whole square. So, then you are going to have this x minus c into w x to be always less than or equal to 0 and the coefficient of it which is the divided difference based on c a a plus b by 2 b and x that is a continuous function. So, we will use mean value theorem and then we will get the error to have a term which contains fourth derivative of the function and then we have got the error to be equal to f 4 eta divided by 4 factorial integral a to b x minus a x minus a plus b by 2 square x minus b d x and thus a constant again you substitute you make the same change of variables integrate and then we obtain error to be minus f 4 eta divided by 90 into b minus a by 2 raise to 5 because of the fourth derivative appearing. If your f is a cubic polynomial fourth derivative will be 0 and the error will be 0. Thus, we have the exactitude for cubic polynomials even though we were substituting only a quadratic polynomial. Now, in the next lecture we are going to consider the composite rules and also what is known as corrected trapezoidal rule.