 In this class we will start a new chapter on numerical integration and differentiation. We will develop some numerical methods to find approximate value of an integral which is also called quadrature formulas. And we will also develop some methods to approximate derivatives of a given function which are called finite difference formulas. In this lecture, in particular we will develop rectangle rule and trapezoidal rule for approximating an integral of a given function. Therefore, our problem in this section is to evaluate integral a to b f of x dx for some nice given function f defined on the interval a to b. The process of approximating the value of the integral is usually referred to as numerical integration or quadrature formula. We will use the notation i f to denote the exact value of the integral a to b f of x dx. The idea is to first look for a simpler function that can approximately represent the given function f and then we want to find the integral of that simple function and consider the value of this integral as an approximation to our original integral. So, that is the broad idea of developing numerical methods for integration or quadrature formulas. Now, the question is what kind of functions that we will consider as an approximation to our given function. Of course, we already studied such approximations through polynomial interpolations. If you recall, we are given n plus 1 nodes x naught x 1 up to x n with that we will first construct a polynomial that interpolates the function f at these nodes. Once you have this interpolating polynomial then you can go for finding the integral of this polynomial and consider that as the approximate value to your original integral. So, that is the idea. Once you have this idea then you have scope to develop many methods for instance you can give a value of n and then you give nodes you get a polynomial. Different value of n gives different polynomials and also for a fixed n if you choose different nodes that also can lead to different interpolating polynomial for your given function. Each such choices can lead to a quadrature formula. In this way you can find many different quadrature formulas. Here we will try to develop few numerical integration formulas. Let us see how this integral will look like. When you go to integrate the polynomial if you recall p n of x can be written in this form. If you recall I am writing it in the Lagrange form and now I will integrate this polynomial on the interval a to b and that can be written as sigma i equal to 0 to n f of x into integral of the Lagrange polynomials. Why it is so? We are just taking the integral inside the summation i equal to 0 to n f of x i integral a to b Lagrange polynomial of x dx. So, this is what we are denoting by i of l i here. Now this can be written as f of x naught and then integral of the Lagrange polynomial at 0 is what we call as w naught and similarly w 1 and so on up to w n can be defined as w i is equal to integral of the corresponding Lagrange polynomials. So, this is how a general formula for the numerical integration will look like if you go with this idea. That is you first fix a n and also fix n plus 1 nodes. So, these are given to us. So, this is given to us and all these are given to us. With this you will generate the interpolating polynomial for the function f and then you will integrate that polynomial and the formula finally will look like this. Let us take some specific values of n and some specific choice of the nodes and see how these formulas look like. Let us start with the simplest formula called rectangle rule. Recall our general integration formula or the quadrature rule will look like this. In that we will take n is equal to 0 and therefore our integration formula will be simply f of x naught into w naught. So, these are not there for us and now you can get different formulas for different choice of x naught. Now let us go to integrate this formula. You can see that the integral of the polynomial p naught that is the interpolating polynomial of degree 0 will be simply b minus a into f of x naught. Here you can see that different choice of x naught will lead to different methods with the choice of n is equal to 0. Let us take x naught is equal to a. You can see that the corresponding formula will be b minus a into f of a and this is called the rectangle rule. Let us see how this formula will look like geometrically. Let the red solid line indicates the graph of the function f of x and our interest is to find the integral a to b f of x dx. Geometrically it is nothing but the area under the graph of the function f of x in the interval a to b. So, that is what is shown in this shaded region. Therefore, integral a to b f of x dx is what is given here and now let us see what this rectangle rule gives. The rectangle rule is nothing but the area of the rectangle which sides as a b and 0 to b. Therefore, the rectangle rule gives the area of this rectangle that is precisely given by b minus a into f of a. So, our aim is to get this entire area, but the rectangle rule is only giving us this much of area. Now, what is the error involved in the rectangle rule you can see that there are some region which are newly included in our area and this region is excluded in our area. Therefore, the error involved in the approximation of the integral by the rectangle rule is going to take care of this region and then a small region which is included here. Mathematically, this is i of f minus i of p naught and that is what is going to be the error involved in the rectangle rule. We use a special notation for the rectangle rule and that is i r into f. Therefore, the error involved in the rectangle rule is the difference between the exact value and the approximate value and we call this as mathematical error. We can derive an expression for the mathematical error involved in the rectangle rule. Let us state it as a theorem. For this, we need our function s to be continuously differentiable function defined on the interval a b. Then the mathematical error involved in the rectangle rule which is denoted by m e r of f can be written in the form f dash of eta into b minus a square divided by 2 for some eta in the interval a to b. Let us see how to prove this theorem. For this, you first take a point x which is not equal to a. Why we are specifically excluding a? Because a is already included in the formula as the node of the interpolating polynomial. Precisely, we have to take x to be different from the node that is used in the quadrature rule. Here, the node is a. Therefore, we are excluding that and taking any x in the interval open interval a to b and consider the polynomial p naught of x plus f of a comma x into x minus a. If you recall, this is nothing but p 1 of x and if you recall p 1 of t can be written as p naught of x plus f of x of t plus f of a comma x into t minus a where the polynomial p 1 of t is the interpolating polynomial of f at the node points x naught which is actually a in our case and x. Now, you put t is equal to x by the interpolating condition. You can see that p 1 of x is equal to f of x. So, that is the idea of why we have written f of x in this form. Why we are interested in this form? Because from here, you can write f of x minus p naught of x equal to something and then you take the integral, you will precisely get your mathematical error. So, that is the idea. Now, what you do is you bring this p naught to the left hand side and write f of x minus p naught of x is equal to f of a comma x into x minus a and then you take the integration on both sides, you will get the mathematical error on the left hand side equal to integral a to b f a x into x minus a into d x. Now, let us see how to rewrite this integral in order to get our formula for the mathematical error. For that we will use the mean value theorem for integration. If you recall, you have two functions f of x and g of x and if you know that g is greater than or equal to 0 or equivalently you can also take g to be less than or equal to 0, then you can write integral a to b f of x g of x as f of some zeta into integral a to b g of x d x. So, you can bring the function f outside the integral by appropriately choosing the xi where xi is some number lying between a and b. So, that is what the mean value theorem for integration says. Now, you can see that x minus a is greater than 0 because we have chosen x in the interval a to b and a is excluded in the interval therefore, this is greater than or equal to 0. So, you can just put the divided difference of f at the nodes a and x in the place of f in the theorem and put x minus a in the place of g in the theorem. You can see that the first term of the integrand will come out of the integral with a unknown xi and then you are left out with only this integral which can be easily integrated right. Now, again you can see by the definition of the divided difference this is nothing but f of xi minus f of a divided by xi minus a. Again, you can put the mean value of theorem for differentiation and you can say that there exist a eta such that this is equal to f dash of eta. So, that is precisely the mean value theorem for derivatives and I am just putting this in this place to get my mathematical error equal to f dash of eta and then I am evaluating this integral and then writing it here as b minus a square divided by 2 right. So, this is what the mathematical error expression that we wanted to prove and we have achieved it and this completes the proof of the theorem. So, this is all about the rectangle rule. Now, it is very simple for you to evaluate an approximate value of the integral through rectangle rule. You simply have to use this formula let us try to change the position of the node. If you recall in the rectangle rule we have taken the node x naught as a. Now, you can choose that x naught as any point in the interval a to b. In particular, you can take b as the node then you will get it another method and here we will take x naught is equal to the midpoint of the interval a to b and we will get an important formula called midpoint rule. So, in midpoint rule we will only take x naught is equal to a plus b by 2 that is the only difference in the midpoint rule otherwise we are taking n is equal to 0 and thereby we are approximating the function f by the interpolating polynomial of degree 0 right. But to construct p naught in the rectangle rule we have taken the node as a. Now, we are taking the node as a plus b by 2 you can clearly see that that choice of x naught will give us this formula and this is called the midpoint rule. I leave it to you to see the geometrical interpretation of the midpoint rule and also I leave it to you to derive the mathematical error involved in the midpoint rule. The next is a composite rectangle rule. What is the idea of composite rectangle rule? If you recall when we were discussing polynomial interpolations we have introduced piecewise polynomial interpolations right. Piecewise polynomial interpolations have their own advantages. The same idea can be adopted in the numerical integration also instead of approximating the function f of x by one single polynomial in the interval a to b you can approximate it by piecewise polynomial. Then you will get a composite rule of whatever interpolating polynomial that you use. Let us see in the case of rectangle rule how to derive the composite version of the rectangle rule. For that you have to break the interval a to b into smaller subintervals remember this is what we do in the piecewise linear or any piecewise interpolating polynomial. First we will subdivide the given interval into some n number of points and then in each piece we will put an interpolating polynomial of certain degrees right. So, that is the idea. Similarly here also we will break the interval into smaller subintervals and then apply the rectangle rule on each subinterval. I hope the idea is clear it is a very simple idea. Let us derive the formula in general. First you have to break this interval into some n number of subintervals for that we will define our h that is the length of each subinterval. For the sake of simplicity we will take the subintervals with equal length as h defined by b minus a by n and then we will define the partition points that is the nodes x j equal to a plus j into h where j equal to 0 1 2 up to n these are the nodes but now we will not put one interpolating polynomial in the entire interval but we will put polynomial of degree 0 in each subinterval and then we will integrate them. Now what we will do is we have this integral this is what we want to evaluate. Now we will break that interval into n p's for that we will first write a which is equal to x naught and b is x n just for the convenience and then we will go to write this integral as the sum of the integrals over the subinterval. So, this is a very elementary property of the integration. Now what you do is you go to put the rectangle rule on each of the subintervals that is you take each of this integral and put the rectangle rule remember rectangle rule is b minus a here b is x j plus 1 and a is x j and the difference is precisely h into f of x naught is what we have defined in the rectangle rule here x naught means the lower limit in the integral right and you have to evaluate the function f at this lower limit and that is what is sitting here. Therefore, each integral in this sum is approximated by this quantity and thereby we have the formula like this and this is the composite rectangle rule. Next we will see how to derive a quadrature formula using linear interpolating polynomial and we will also see how to derive quadrature formula with a quadratic interpolating polynomial. We will continue our discussion in the next class. Thank you for your attention.