 We are learning numerical methods for initial value problem of a first order ordinary differential equation. In this, we have learnt the Euler method for approximating a solution of a first order initial value problem in our last class. We will continue our discussion on Euler method in this class and study the error involved in the approximate solution computed by the method. Recall that we are interested in solving the initial value problem y dash equal to f of x comma y, where we are given an initial condition y of x naught equal to y naught for some x naught in the interval on which the problem is posed. In the last class, we have studied Euler method for approximating a solution of this initial value problem at some grid points. We had two formulas, one is the Euler forward formula which is given here and another one is the Euler backward formula. In this class, we will study the error involved in the approximate solution obtained using the Euler forward formula. The error analysis for the Euler backward formula can be carried over in a similar way. Let us recall the Euler forward formula first. Given a point x j comma y j and a parameter h greater than 0, the Euler forward formula can be used to obtain the value y j plus 1 which is an approximation to the solution y of this problem at the grid point x j plus 1. This can be done for each j equal to 0 1 2 so on up to some n number of grid points. Observe that we are given x naught and y naught in the problem itself which is the initial condition. Once we fix h and generate the grid points x naught x 1 up to x n say in the interval i, then we can obtain the approximation to the solution y of the given initial value problem at these grid points using this formula. To derive the error involved in the approximate solution y j plus 1 when compared to the exact solution y of x j plus 1, we first use the Taylor's theorem about the grid point x j and write the solution at x j plus 1 as y of x j plus 1 is equal to y of x j plus h into y dash of x j. This is the Taylor polynomial of degree 1 plus you have the reminder term h square by 2 into y double dash of xi j. Since y satisfies the given first order ordinary differential equation y dash equal to f of x comma y we can substitute y dash in this representation by f of x comma y and that gives us y of x j plus 1 equal to y of x j plus h into f of x j comma y of x j plus the reminder term. Now, what we will do is we will bring this y of x j to the left hand side and divide both sides by h and thereby this h will go and you will be left out with only h by 2 in the reminder term and thereby you will get this equation where the left hand side is the approximation for y dash of x j and that is equal to f of x j comma y of x j up to here this is what we have taken as the equation and now instead of having y dash we now have the corresponding finite difference formula and therefore we have this error and if you carefully look at this error you can see that this error goes to 0 as h goes to 0 and what is the order in which this term goes to 0 well you can say that this is of big O of h right in this case we say that the error term is of order h that is big O of h and because of this we can see that Euler method is of order 1 remember the reminder term is given like this and the reminder term as it is is going to 0 with order 2 but because we have divided both sides by h in order to make this left hand side to be an approximation to y dash we got to lose one order here and therefore Euler method finally happens to be of order 1 but what is the truncation error involved in this the truncation error is nothing but the reminder term in the Taylor expansion and therefore we call h square by 2 into y double dash of xi j as the truncation error note that the truncation error is obtained when we use exact solution y of x j while computing in the Taylor expansion right but in the Euler formula we use the approximate value y j while computing y j plus 1 this shows that there are more levels of error involved in computing y j plus 1 one is of course the truncation error and the other one is called the propagation error therefore the mathematical error involved in the forward Euler method has two components one is the truncation error and another one is the propagation error recall that we came across a similar situation in our discussion on performing arithmetic operations with floating point approximations here we are facing a similar kind of situation as I said the mathematical error in the forward Euler method defined as the exact value minus the approximate value involves two levels of errors namely the truncation error and which we have already derived and is given by h square by 2 into y double dash of xi j and the propagation error now given by this expression well how do we get this expression for the propagation error let us see from the Taylor expansion we have seen that y of x j plus 1 is written as y of x j plus h into f of x j comma y of x j remember we had y dash here but then we use the equation to replace y dash by f right plus we had the reminder term which is sitting here and then you have minus the Euler forward formula which is y j plus h into f of x j comma y j so this is what I am writing here precisely you have y of x j minus y j which is coming from here plus h times f evaluated at x j comma exact value that is coming directly from your Taylor expansion of the exact solution minus f of x j comma approximate value of the solution at x j that is y j coming from your forward Euler formula plus of course the reminder term which is coming from your Taylor part is sitting here and finally we have written the mathematical error involved in y j plus 1 as the propagation error plus the truncation error well we can further modify the expression of the propagation error and bring it to a more clear form let us now do this recall the propagation error is given by this expression from the previous slide right we will now use the mean value theorem for f with respect to the second argument let us denote the second argument by z just for the notation clarity by mean value theorem we can find a eta we will denote it by eta eta we will denote it by eta j here lying between the points y of x j which is the exact value of the solution and y j which is the approximate value at x j computed by the Euler forward formula right and thereby we get f of y x j minus f of y j is equal to f of y j minus now we have to differentiate only partially with respect to the second argument times y of x j minus y j this is precisely the mean value theorem for one variable but here it is applied only to the second argument of the function f by fixing the first argument x j let us use this expression in the mathematical error to get mathematical error involved in y j plus 1 if you recall this is nothing but the propagation error plus the truncation error remember we are just writing the truncation error as it is without disturbing it now we are just writing the propagation error which is originally given by this expression in a slightly different way using the mean value theorem what we are doing is just observe that this is nothing but mathematical error involved in y j right that is what we are writing here 1 into mathematical error involved in y j is nothing but the first term in the expression of the propagation error whereas the second term in the propagation error is now written like this and here also you can see that the mathematical error involved in y j is sitting here right therefore this is also mathematical error in y j that is what we are writing here h times this h is already here though f by doh z which is coming from the mean value theorem times m e of y j therefore the mathematical error involved in y j plus 1 can be written as something into the mathematical error in y j that is the propagation error plus the truncation error here you can observe that the mathematical error in y j plus 1 is equal to this into the mathematical error in y j plus the truncation error that is the truncation error at every grid point includes more or less the mathematical error coming from the previous grid point plus a new error that is the truncation error is something new that is getting accumulated at this step right if all these terms are positive say then the mathematical error will keep on increasing because mathematical error at the present grid is something which is coming from the previous grid plus new error so it may keep on increasing as we go on with the grid points if you recall in our previous class we have observed in the numerical solution of an example that as we go on with the grid points the error was increasing gradually now we can see clearly the reason for such a behavior in the numerical solution this is because every time the mathematical error in the present grid is nothing but the mathematical error from the previous grid may be multiplied with some number greater than 1 times surely a new level of error is added here right so that is quite interesting let us try to obtain an estimate that is the upper bound of the absolute value of the mathematical error for this let us assume that modulus of dou f by dou z is less than l at the grid point x j that is this term is bounded by l is what we are now assuming and also we assume that y double dash of x is less than y that is we are also assuming an upper bound for the this term where l and y are fixed positive constants now what we will do is we will take the modulus on both sides of this equation and then use this upper bounds in the appropriate places to get an upper bound for the absolute value of the mathematical error in y j plus 1 and that is given by 1 which is already there plus h into now instead of this term we since we have taken modulus we will put the upper bound here that is l times mod m e of y j plus h square by 2 into mod y double dash now we will put the upper bound here perhaps we will have to write it as strictly less than or we should write a equal sign here and sorry for this error but we will keep this in mind now we see we got this inequality for the mathematical error in y j plus 1 you can observe that the same inequality will hold even for the mathematical error in y j right you simply have to put j instead of j plus 1 then this will become y j minus 1 in order to get the same type of inequality for m e of y j right now we will apply the same inequality for m e of y j and then we will do this right now we will recursively for instance if you apply this inequality for m e of y j you can observe that you will get this expression on the right hand side right how will you get it well this is less than or equal to you already have 1 plus h into l now you will have 1 plus h into l times m e of y j minus 1 right plus h square by 2 y and that is for this term plus you already have h square by 2 into y right so you combine all this you will get this expression on the right hand side when you put the same inequality to m e of y j now we will keep on putting this idea again and again for instance now you can put this inequality that is this inequality in place of m e of y j minus 1 and get an expression after rearranging the terms that will be something more than this right and you keep on going with this idea till you reach y naught at this position and at this stage the right hand side expression will be given like 1 plus h l j plus 1 times into m e of y naught and the right hand side expression the second term will look like this ok you can just write it and see 2 or 3 times if you do this exercise you will see how this pattern is forming and from there you can write this expression on the right hand side so we got this estimate so far in fact we can simplify the right hand side further using some well known formulae namely this one which you can use for this term and we can also use this inequality which is well known in the place of this term and finally we can get the mathematical error in the right hand side error involved in y j plus 1 well I have just written it as y j that does not matter because you can see that now after putting these formulas into this expression and after simplification we can get this as the upper bound and that is clearly independent of y j right we will state the result we have derived so far in the form of a theorem as you can see that we need a bound for y double dash so we have to assume that y is a c 2 function in the interval in which we have posed our initial value problem then we can see that the mathematical error involved in y j can be bounded by this quantity. Let us try to understand this upper bound we may assume that the second term is 0 because y of x naught is actually given to us as the initial condition we also see that the upper bound depends on x n minus x naught thus if x n minus x naught is large the upper bound will be very large irrespective of any j that we are computing right in that way we can see that this estimate is a over estimate and often the actual error is much smaller than what is predicted theoretically. However theoretically this is the estimate that we could obtain so far well we have proved a bound for the mathematical error involved in the approximate solution of the Euler forward method let us take a simple example where the ODE is y dash equal to y and the initial condition is y of 0 equal to 1 that is we have taken x naught is equal to 0 and the interval is taken as 0 comma 1. Let us find the estimate for the mathematical error involved in the forward Euler method using the previous theorem for this first we have to find an upper bound of the partial derivative of f with respect to y you can see clearly that this is equal to 1 right and let us find a bound for y double dash of x also well for this we need to know the solution and from there you can see that the upper bound may be taken as E. So, this is just for the sake of example we are doing then from the estimate we obtained from the previous theorem we can see that the mathematical error is bounded by 2.3354 into h where h is greater than 0 is the discretization parameter remember in the theorem we had 2 terms the second term is not appearing here because we have taken the initial condition as 1 and therefore we assume that there is no error committed in the second term. Therefore, we have directly taken the second term as 0 that is why there is no second term involved in our upper bound here well the bound we obtained above is purely from the theoretical point of view. Let us see how it works numerically first let us write the formula of the Euler forward method for the present example if you recall the forward Euler formula is given like this here you have to take f of x j comma y j is equal to y j that is what is given as the right hand side in our ODE. Therefore, if you take f is equal to y j then the Euler forward formula reduces to this expression since y of 0 equal to 1 we can see that y j is equal to 1 plus h to the power of j why it is so well take y 1 which is equal to 1 plus h into y naught where y naught is equal to 1 that is equal to therefore 1 plus h now if you go to y 2 then y 2 is given by 1 plus h into y 1 and that is equal to 1 plus h into 1 plus h which is coming from here and therefore it will be 1 plus h square similarly you can see that y 3 is equal to 1 plus h q and so on that is why we have written y j equal to 1 plus h to the power of j. Let us take j is equal to 10 and we are interested therefore in y 10 let us take h is equal to 0.1 and of course n is equal to 10 the moment you take h is equal to 0.1 then y j is given by 1.1 to the power of j. Now we are taking j is equal to 10 therefore you can see that y 10 is nothing but 1.1 to the power of 10 and that is given approximately as 2.5937 but y 10 is the approximate value of y of 1 because we are starting from 0 and taking h is equal to 0.1 and going 10 grid points therefore at the end y 10 will be the approximate value of y of 1 and what is the exact value of y of 1 that is nothing but e and it is given by 2.71828 and you can now compare the approximate solution and the exact solution and see what is the mathematical error involved in them well you can directly find the mathematical error now because we have exact solution and approximate solution you can directly take the difference between them and the error is given by 0.12466 whereas the bound that we obtained from our theoretical estimate is actually 0.23354 because in the previous slide we have obtained that right so we have this now you took h is equal to 0.1 therefore we have the upper bound as 0.22 3354 which is theoretically predicted and from the numerical experiment we see that the error is 0.1246 so as we expected the mathematical error involved in the approximation is less than or equal to the theoretically predicted number that is this therefore our numerical example is well in agreement with the theoretical prediction. Finally, let us obtain an estimate for the total error when we include the arithmetic error in our computation. Let us assume that we obtained y j tilde instead of y j due to some floating point error involved in the computation the error in y j tilde when compared to y j is say epsilon j then the total error which is defined as y of x j that is the exact value minus y j tilde now because we are not obtaining y j as we have some rounding error involved in our calculations right therefore we only obtained y j tilde therefore the total error is nothing but the mathematical error which is y of x j minus y j plus the arithmetic error which is y j minus y j tilde. And that will be your total error right so this is the mathematical error and this is the arithmetic error we have already derived an estimate for the mathematical error similarly we can also derive an estimate for the arithmetic error and that can be given with a factor like this remember the mathematical error is this much into this plus this and now the arithmetic error brings in a new term like this right. So, this is the new term coming from the arithmetic error I will leave it to you to derive this it is not very difficult once you understand the derivation of the upper bound of the mathematical error the idea goes exactly the same recall we have also obtained the bound for arithmetic error in certain finite difference formulas the idea will go exactly in a same way but what is interesting for us to observe here is when you take h tending to 0 you can see that the mathematical error which is this times this 1 of course we will always not give that much importance to the second term because that will often depend on the initial condition and the error involved in the initial condition right. So, we will only bother about the actual computation path if you see the mathematical error alone it is this term into this and if you take as h tends to 0 you can see that the mathematical error is nicely tending to 0 right what about the arithmetic error part you can see that the arithmetic error part tends to infinity as h tends to 0 what it says if you have even a small arithmetic error in your calculation that may tend to amplify at least the upper bound here but the fact is it will also amplify the total error if you keep on reducing the grid step size h ok. So, do not think that you keep on reducing h you get better and better approximation just like we discussed in the finite difference formula there will always be a optimal h if you go on reducing h below that optimal h then your total error will tend to increase this is the message we are getting from the upper bound of the total error involved in the forward Euler method remember the same kind of analysis can also be performed for backward Euler method I leave it to you to see that with this cautious note we will close this lecture thank you for your attention.