 Last time we have considered Romburg integration. Today we are going to show that first step in the Romburg integration is nothing but Simpson's rule. So, we assume that our function f is four times differentiable. We look at corrected composite trapezoidal rule. In the corrected composite trapezoidal rule when we remove or get rid of the term h square that is the first step of Romburg integration and that first step gives us Simpson's integration. So, our function f is four times continuously differentiable. We look at a uniform partition of interval a b. So, t 0, t 1, t n these are equidistant points h is length of subinterval which is going to be b minus a by n and in addition let us assume that n is even. Composite trapezoidal rule associated with this partition is given by at two end points the weight is h by 2 so h by 2 f a plus f b and at the interior partition points that means t 1, t 2, t n minus 1 the weight is going to be h. So, this is the composite trapezoidal rule. Now, integral a to b f x d x is t n plus term h square by 12 f dash a minus f dash b plus term of the order of h raise to 4. If you look at f dash a minus f dash b by 12 there is no h coming into picture. So, this term is independent of the partition. Now, you look at composite trapezoidal rule with partition of the length of the subinterval let it be 2 h and number of subinterval let them be n by 2. So, integral a to b f x d x is t n by 2 plus h will be replaced by 2 h square by 12 f dash a minus f dash b and term of the order of h by 2 raise to 4, but in the order the constant is there. So, we can one can say that it is of the order of h raise to 4. The first step of Rumberg integration is obtained by multiplying this equation by 4 subtracting this equation and dividing throughout by 3 and we have seen that integral a to b f x d x is equal to t n 1 plus term of the order of h raise to 4. So, now we are going to look at t n 1 and show that this t n 1 is nothing but Simpson's rule associated with the partition with n by 2 intervals and length to be equal to 2 h. So, it is a straight forward calculation, but what it shows is when you have f to be sufficiently differentiable, integral a to b f x d x minus t n, t n is the composite trapezoidal rule. We have got asymptotic series expansion with the terms of the type c 1 h square plus c 2 h raise to 4 plus c 4 h raise to 6 and so on. So, we have got only even degrees of h. Now, once we show that the first step of Rumberg integration is nothing but the Simpson integration that will mean that even for composite Simpson integration we have got this asymptotic series expansion. So, now let us look at t n 1. So, our t n is given by this formula in t n by 2. t n by 2 will consist of points t 0, t 2, t 4, t 6 and t n, only even order points. So, t n by 2 will be h times f a plus f b, the length of sub interval now it is going to be t 0 to t 2. So, that is going to be 2 h. So, it will be plus 2 h and now only even suffixes. So, it will be summation i goes from 2 to n minus 2 i even f t i. Our t n 1 is 4 times t n minus t n by 2 divided by 3. So, here you are multiplying by 4 and then subtracting. So, that will give you h by 3 f a plus f b plus odd terms they are going to come only from here. So, that is why you have 4 h by 3 summation i goes from 1 to n minus 1 i odd f t i plus there are even order terms here, even order terms here. You are multiplying this by 4 and then subtracting this and dividing by 3. So, that is why you get 2 h by 3 summation i goes from 2 to n minus 1 f t i i even. So, see our partition now is t 0, t 2, t 4, t 6, t n, t 1, t 3, t 5 these are going to be midpoints of our intervals and if you look at composite Simpson rule associated with partition t 0, t 2, t 4 it is nothing but this. So, thus we have shown that the first step of Humberg integration gives us composite Simpson rule. Now, we are going to start a new topic which is numerical differentiation. The idea is similar as in the case of numerical integration in order to integrate. We had we do not know how to integrate any continuous function. So, we look at interpolating polynomial, integrate it. So, there is some error involved. So, we obtain approximation. So, similar thing we are going to do here that if you have a polynomial then you can differentiate. So, approximate your function f by a polynomial and then hope that the derivative of polynomial at some point say a that will give you an approximation to f dash of a. Now, in numerical differentiation we will face some difficulties which we did not face in case of numerical integration. Numerical differentiation which I am going to describe now which allows us to find an approximation to the derivative f dash at a or the second derivative or higher order derivative. These formulae they are important in solution of differential equations. So, approximate solution of differential equations when one considers that is where we are going to use this formulae. As such as I said there is going to be some difficulty in the numerical differentiation rule. Suppose you want to find f dash of a then what should be done? So, instead of interpolating polynomial what one should do is look at some different polynomial approximation. Say look at least square approximation by polynomials. So, that part we have not considered so far, but we have considered cubic spline interpolation. So, instead of interpolating polynomial look at cubic spline interpolation of your function. So, in the cubic spline interpolation what we did was we looked at interval a b subdivided into equal sub intervals and then we tried to fit a piece wise cubic function. So, on each sub interval our function was a cubic polynomial or a polynomial of degree less than or equal to 3. And at the partition points because now we have got look at the two sub intervals. So, on one interval you have got a polynomial of degree less than or equal to 3 on another it is another polynomial of degree less than or equal to 3. So, we want that both of them they should join at in such a manner that overall we have got two times differentiable function. So, that gave rise to a tridiagonal system to solve and then we could obtain a cubic piece wise cubic polynomial which is overall two times differentiable which interpolates the given function at the partition points and in addition we had two end points. So, this cubic spline interpolation it gives acceptable approximation to the derivative of function. But today what we are going to do is we are going to look at our interpolating polynomial of appropriate order and get the derivatives and see what is the difficulty one faces in case of numerical differentiation. We are going to slightly make change notation the only change is our function earlier it was defined on interval a b. So, we will say that it is defined on interval c d and a will be interior point of our interval. So, our m is to find approximation to f dash of a. So, f is from c d to r real valued function a is interior point m is to approximate f dash of a. So, approximate f by an interpolating polynomial p n of degree less than or equal to n and f dash a is approximately equal to p n dash a. The simplest case is going to be take n is equal to 0 that means approximate your function by a constant polynomial. So, the derivative is going to be 0. So, then you get an approximation that is not really a very accurate approximation. So, instead of n is equal to 0 let us look at n is equal to 1. That means x 0 and x 1 we are going to choose two interpolation points fit the polynomial of degree less than or equal to 1 and then its derivative will give you approximation to f dash of a. And the starting point is going to be function f x is equal to interpolating polynomial plus an error take the derivative the derivative of the polynomial will give you approximation to f dash of a. And this approximation will depend which interpolation points you are going to choose. So, our interpolation points x 0 and x 1 they will give rise to two formally which we are going to consider. So, in one case we are trying to approximate f dash of a. So, x 0 and x 1 the points which you are taking as interpolation points it is logical that you should choose them in the vicinity of point a. So, suppose I choose x 0 is equal to a and x 1 to be equal to a plus h where h is going to be a small number. So, that will give us a formula which is known as forward difference formula. And another formula which we are going to consider there instead of choosing the points to be a and a plus h we will try to choose our points symmetrically. So, a is the point at which we want to find the derivative. So, we can choose point to be say a minus h and a plus h. And then we will see which one gives us a better error estimate x 0 and x 1 are distinct points in c d f x is equal to f x 0 plus divided difference based on x 0 x 1 into x minus x 0. And then this is the error term the divided difference based on x 0 x 1 x multiplied by w x w x is x minus x 0 x minus x 1 take derivative of both the sides. So, you will have f dash x is equal to p 1 dash x plus derivative of this error term p 1 dash x will be nothing but divided difference based on x 0 x 1 plus you apply product rule. So, you get d by d x is equal to f of x 0 x 1 x multiplied by w x plus the divided difference into w dash x the divided difference f x 0 x 1 is going to provide approximation to f dash of x and this is a error term. So, in the error term derivative of the divided difference x 0 x 1 x is appearing. We have already seen continuity of divided differences if your function f is once differentiable then the divided difference based on x 0 x 1 x this is a continuous function you are assuming x 0 and x 1 to be distinct point. So, this part we have already seen now we are going to show that if f is twice differentiable then the derivative of the divided difference based on x 0 x 1 x is going to be a divided difference based on points x 0 x 1 x x. So, this result now we will first prove so that we can estimate our error in numerical differentiation. So, first we look at divided difference based on x 0 and x x 0 is going to be a fixed point. So, this g I define g of x to be equal to divided difference based on x 0 and x which is going to be equal to f x minus f f x 0 divided by x minus x 0 if x not equal to x 0 and equal to f dash x 0 if x is equal to x 0. So, this is my function g and I want to find g dash x there will be two cases x not equal to x 0 and x is equal to x 0 when x is not equal to x 0 we have to we have a quotient of two functions. So, we will use standard formula for calculating the derivative when our point x is equal to x 0 then our function g is defined differently at x 0 it is f dash x 0 at x not equal to x 0 it is the quotient f x minus f x 0 divided by x minus x 0. So, when I want to calculate the derivative of g at x 0 I will have to go from the definition I will have to proceed from the definition that g dash x 0 will be limit as h tends to 0 of g of x 0 plus h minus g x 0 divided by h. So, we will consider these two special separate cases and show that the derivative of divided difference based on x 0 x is nothing but the divided difference based on x 0 x x. So, first the case x not equal to x 0 g dash x will be x minus x 0 square then denominator multiplied by derivative of the numerator x 0 is fixed. So, it is f dash x minus numerator f x 0 and then the derivative of the denominator that is going to be 1. Now, 1 x minus x 0 we cancel. So, we will have f dash x upon x minus x 0 here 1 x minus x 0 we associate with f x minus f x 0. So, f x minus f x 0 divided by x minus x 0 that gives us divided difference of f based on x 0 x. Now, this is nothing but the divided difference based on x 0 x x that is the recurrence formula. This is nothing but divided difference of f based on x comma x. So, that is f dash x minus divided difference based on these two points and divided by x minus x 0. So, we have proved the claim for x not equal to x 0. Now, look at x is equal to x 0 and apply the definition. So, consider g of x 0 plus h minus g x 0 divided by h this is going to be equal to by our definition of g x it will be f of x 0 x 0 plus h minus g of x 0 is f dash x 0 divided by h this quotient is nothing but f of x 0 plus h minus f x 0 minus h times f dash x 0 and then divided by h square writing for f of x 0 x 0 plus h f of x 0 plus h minus f x 0 divided by h. We are assuming function to be two times differentiable. So, for the numerator we can apply extended mean value theorem. So, that extended mean value theorem gives us numerator to be equal to h square divided by 2 f double dash c and then this h square where t is going to lie between x 0 and x 0 plus h our h can be bigger than 0 or less than 0. So, our c will be in the interval x 0 to x 0 plus h if h is bigger than 0 or it will be in the interval x 0 plus h x 0 if h is less than 0. Now, we are going to let h tend to 0. So, when h tends to 0 c which lies between x 0 and x 0 plus h that will tend to x 0 and using that we get the f double dash c by 2 that will be tending to f double dash x 0 plus h by 2 which by definition of divided difference is f divided difference of f based on x 0 x 0 x 0 x 0 repeated thrice and thus g dash x 0 is f of x 0 x 0 x 0. We had already proved that g dash of x is a divided difference of f based on x 0 x x and now that formula is valid for x is equal to x 0. Now, what we wanted was the derivative of divided difference based on x 0 x 1 x because that is what comes into picture in the linear approximation. We have proved that the divided difference of f x 0 x its derivative is nothing but add 1 x x star. So, now, let us look at the divided difference based on x 0 x 1 x and try to find its derivative. So, x 0 and x 1 these are distinct points. You look at f of x 0 x 1 x our divided difference is symmetric. About its arguments that means the order of x 0 x 1 x will not matter. So, the divided difference based on x 0 x 1 x will be same as divided difference based on x 0 x x 1. So, now our g x is divided difference based on x 0 x x 1 by the current formula this is f of x x 1 minus f of x 0 x divided by x 1 minus x 0 and now we want to look at the derivative of this denominator is constant. Derivative of f x x 1 will be nothing but add 1 x x star. So, it is going to be f x 1 comma x comma x minus divided difference based on x 0 x 1 divided difference derivative of f of x 0 x that will be f x 0 x x and then divided by x 1 minus x 0. So, again by the recurrence formula we get g dash x to be the divided difference based on x 0 x 1 x x. So, that proves our claim and now we go back to our formula for finding approximate value of f dash of a. So, our function f is defined on interval c d takes real values a is an interior point x 0 and x 1 are two distinct points in the interval c d we are fitting a polynomial of degree 1 and then we have got error term you differentiate both the side. So, f x is equal to f x 0 plus f x 0 x 1 x minus x 0 and this is the error term. So, the error term has this divided difference and our function w x take the derivative of both the sides f x 0 is constant. So, f dash x will be equal to divided difference x 0 x 1 plus now the derivative of this we know that it is nothing but add 1 x star x. So, it will be f x 0 x 1 x x multiplied by w x we are applying product rule plus f of x 0 x 1 x into w dash x w dash x will be nothing but x minus x 0 plus x minus x 1. So, now we want to choose our x 0 and x 1. So, we are going to choose them in the vicinity of our point a. So, the first case is choose x 0 to be equal to a and x 1 is equal to a plus h. So, when you do that our w x is x minus x 0 x minus x 1 x is equal to x 0 is equal to a. So, w a is going to be equal to 0 and w dash a will be this will be 0 this will be a minus a minus h. So, it is minus h now f dash a is approximately equal to divided difference based on a and a plus h which is f of a plus h minus f a by h and the error is going to be equal to w at a is 0. So, there will be no contribution from this term that will be only from here. So, it will be f of a a plus h a into minus h now function f because it is 2 times differentiable it will be minus h f double dash c divided by 2. So, in fact this c it should be something say f double dash of psi this c and this c they are not the same it is minus h f double dash of psi divided by 2. So, this is discretization error and this is known as forward difference formula. So, now let us look at the case when you choose your 2 interpolation points symmetrically. So, our point will be a minus h and a plus h and we will see that in this case the discretization error is going to be of the order of h square so for forward difference we had only the error to be less than or equal to constant times h it will be now less than or equal to constant times h square. I recall that f dash x is the divided difference based on x 0 x 1 plus the term containing divided difference based on x 0 x 1 x x into w x plus divided difference based on x 0 x 1 x and w dash x w x is product of x minus x 0 x minus x 1 the derivative of w dash is x minus x 0 plus x minus x 1. If we choose x to be equal to a x 0 to be equal to a minus h x 1 it is to be equal to a plus h then w at a will not be 0 it will be equal to minus h square, but now w dash a is equal to 0 that gives us f dash a to be approximately equal to f of x 0 x 1 plus x 1 plus x 1 plus x 1 that is f of a plus h minus f of a minus h divided by 2 h and in the error w dash a is 0 so this term will not be there. So, you will have only this term which gives us f a minus h a plus h a a multiplied by w dash w a which is minus h square. So, you have minus h square f 3 c third derivative again evaluated at some point divided by 6. Now, when one looks at these formulae which we obtained they are something expected like look at the forward difference formula. We had f dash a to be approximately equal to f of a plus h minus f a divided by h. Now, it is expected that from the definition limit of f of a plus h minus f a divided by h as h tends to 0 is equal to f dash a. So, may be I do not have to do all these interpolating polynomials and then obtain this formula. This formula is available from the definition. Similarly, the other formula the other formula was f of a plus h minus f of a minus h divided by 2 h. So, now, this formula is available from the definition I can write as f of a plus h minus f a divided by h plus f of a minus f of a minus h divided by h and then whole thing divided by 2. So, this will tend to f dash a this will tend to f dash a and hence this will tend to f dash a because you are dividing by 2. So, both these formulae central difference formulae and forward difference formulae we could have written from the definition. The reason I went through this interpolating polynomial is that gives us a general method that now the same idea we are going to use for calculating the second derivative and we had idea about the discretization error like no doubt these quotients or these approximations they approximate to f dash a. So, for h small enough you are going to get a approximation, but we could tell that central difference formula in which case the interpolation points are symmetrically placed that formula is to be preferred because the discretization error in that case is h square as compared to the discretization error h in case of forward difference formulae. So, now let us look at the approximation and approximation of second derivative. Now, you are going to fit if you fit a polynomial of degree less than or equal to 1 and take it second derivative then the second derivative is going to be 0 and it is a crude approximation f double dash a. So, instead of a polynomial of degree less than or equal to 1 we should at least look at polynomial of degree less than or equal to 2. So, we will consider three distinct points x 0, x 1, x 2 fit a parabola take it second derivative and that will approximate f double dash of a. In this case again the points x 0, x 1, x 2 which we are going to choose we will choose them in the vicinity. So, one choice can be x 0 is equal to a x 1 is equal to a plus h x 2 is equal to a plus 2 a. So, that will give us forward difference formulae the other will be you place them symmetrically. Now, in this case you can choose a your points to be x 0 is a minus h x 1 is equal to a and x 2 is equal to a plus h. So, that will give you central difference formulae. Now, here when we try to look at the error is going to have a divided difference term which is based on x 0, x 1, x 2, x. Now, we are going to take two derivatives. So, the first derivative the proof is similar what we have proved is f of x 0, x the divided difference its derivative is nothing but a divided difference based on x 0, x x. If you consider the divided difference f of x 0, x 1, x its derivative is divided difference based on x 0, x 1, x x you have to just add 1 x. Similarly, divided difference of f based on x 0, x 1, x x 0, x 1, x 2, x 2, x 2 x, its derivative will be obtained by adding one more extra. Now, we are going to take the second derivative. So, we will need to take the derivative of divided difference based on x 0, x 1, x 2, x repeated twice. Its derivative will be the divided difference x 0, x 1, x 2, x repeated thrice. The proof is similar and what we are going to do is we will do it as a tutorial problem. So, at present assume that the derivative of f x 0, x 1, x 2, x it will be divided difference based on x 0, x 1, x 2, x x and it is the derivative of this divided difference based on x 0, x 1, x 2, x comma x that will be 2 times divided difference based on x 0, x 1, x 2, x repeated thrice. So, this derivative it is not only just add one x extra, but there is also term 2 coming into picture. Now, we are choosing three distinct points and the interval a, b should be interval c d, then this is the quadratic polynomial in the which is written using divided differences. This part is the error, take the first derivative. So, f dash x will be equal to p 2 dash x plus we need to take the derivative of this, use the product rule. So, first the derivative of this term. So, it is going to be x 0, x 1, x 2, x x, w x plus this term as it is multiplied by w dash x. So, that is our first derivative. The second derivative will be f double dash x is equal to p 2 double dash x plus derivative of this is going to be 2 times divided difference based on x 0, x 1, x 2, x repeated thrice multiplied by w x as it is. Then this multiplied by w dash x, derivative of this multiplied by w dash x. So, that together gives us 2 times divided difference based on x 0, x 1, x 2, x x into w dash x and lastly this divided difference multiplied by w double dash x. So, f double dash x is approximately equal to p 2 double dash x and this is going to be the error term. W dash x will be given by three terms x minus x 0, x minus x 1 plus x minus x 0, x minus x 2 plus x minus x 1, x minus x 2 and the second derivative is given by this formula. If I choose x 0 to be equal to a, then w at a is going to be 0. Now, if I choose x 1 is equal to a plus h, x 2 is equal to a plus 2 h, then w dash a will be minus 2 h square and w double dash a will be minus 6 h. If the x 1 and x 2 are chosen symmetrically, then w at a is already 0, w dash a will be equal to minus h square and w double dash a is going to be equal to 0. This is because w double dash x is given by this formula x minus x 0 is already 0, x minus x 1 will be minus h, x minus x 2 will be plus h. So, that is why w double dash is a is 0. This choice is going to give us forward difference formula and this is going to give us central difference formula. So, in the first case when we are choosing our points to be a, plus h, a plus 2 h, f double dash a is approximately equal to f a minus 2 times f of a plus h plus f of a plus 2 h divided by h square. The 2 gets cancelled with the 2 in the denominator for the divided difference and now for the error term, we have only w at a is equal to 0. So, we have this divided difference multiplied by 2 h square plus this divided difference multiplied by minus 6 h. So, you have f 4 c by 6 h square minus f triple dash d by into h and if you have chosen them to be symmetrically, then we had w at a to be 0, w double dash a to be 0. So, there is only one term and then you have got f 4 c divided by 12 into h square. So, when we look at the discretization error, if the points are a, a plus h, a plus 2 h, then the discretization error is less than or equal to constant times h because we have got 2 terms. One term contains h square, one term contains h, but then the term which contains h that is going to decide the rate. So, you have got this to be less than or equal to constant times h. If your points are symmetric, then the discretization error is less than or equal to constant times h square. So, we have got formally for the first derivative for the second derivative. This when we have fitted a polynomial of degree less than or equal to 2, that it can give us a formula for f dash a also, but what I wanted to do was illustrate that using interpolation points, we can obtain approximations to first derivative, second derivative and so on. And as I mentioned before, these approximations are going to be important in the numerical solution of differential equation. Now, look at our problem f dash a. I want to find f dash of a. So, our approximation is either f of a plus h minus f a divided by h or f of a plus h minus f of a minus h divided by 2 a. Both these quotients, they converge to f dash a as h tends to 0. So, what I have to do is choose my h to be small enough in order to have desired accuracy, because we have convergence. Both these divided differences, they tend to f dash a as h tends to 0. So, choose h small enough and then you will get the desired accuracy. Now, when you try to do it in practice, you face certain difficulty. Now, what are the difficulties? You look at your f of a plus h minus f of a minus h say divided by 2 h. You are going to make h small. So, when your h is small enough, f of a plus h and f of a minus h, they are going to be about equal. They are going to be near each other. So, you are going to subtract two numbers which are approximately equal. Now, as we have noticed that when you divide, when you subtract two numbers using computer, if the two numbers are approximately the same, then you will get a loss. Then there is loss of accuracy or there is loss of significant digits and then you are going to divide by h. So, you are dividing by a small number. So, this two facts they combine to make our divided difference approximation not as good as the average as we will like it to be. So, here for the divided difference approximation of f dash a, the two difficulties are you are dividing going to divide by a small number and you are going to subtract two numbers which are approximately the same. So, we have got f dash of a is equal to f of a plus h minus f of a minus h by 2 h and this was the discretization error. In calculations, we instead of f of a plus h, we will have f of a plus h plus even and f of a minus h plus e 2, where e 1 and e 2 are round off errors. So, instead of computing this quotient, what you will be computing will be f of a plus h plus e 1 minus f of a minus h plus e 2 divided by 2 h. So, this is nothing but f of a plus h minus f of a minus h divided by 2 h plus e 1 minus e 2 by 2 h. Substituting here, you have f dash a is equal to f dash computed minus e 1 minus e 2 by 2 h minus this. Now, even and e 2 are round off errors, there is no reason why they should cancel, they will increase and you are dividing by a small number. So, this term does not decrease, this is going into 0. So, this is the difficulty one faces. So, when you reduce h up to a certain stage, you will get better and better approximation, but after a certain stage, even if you reduce your h, instead of getting a better approximation, you will get worse approximation. So, in the next lecture, I will once again compare this phenomena with the phenomena in the composite numerical integration and then we will be considering solution of linear equations. So, thank you.