CHAPTER 08.02: EULER METHOD OF SOLVING ODEs: Example   In this segment, we’re going to use Euler's method to estimate an integral, so Euler's method to find integral of a to b, f of x dx, so we're going to try to find out an estimate of this integral by using Euler's method.  So in this segment, we are going to take an example to show that how that is done. So let's suppose somebody asks you to calculate this integral, 6 x cubed dx, from 5 to 8.  They're asking you to calculate this integral here, and estimate the value of that.  Let's go ahead and se that how we can go about doing this by using Euler's method.  We already know that Euler's method is as follows, dy by dx, that you have to have a differential equation which is given in this particular form here, and of course, you have to have some initial condition being given to you, and then the Euler's formula tells you that it's nothing but . . . y at i plus 1, or the y-sub-i-plus-1 is nothing but the value of y at the previous point, the slope at that particular point, times the step size.  So let's go ahead and see that how we can use this Euler's method here to be able to calculate this . . . this integral here.  So I have to set it up in the . . . in the form which I have, so what I'm going to do is I'm going to say dy by dx is equal to the integrand itself, which is 6 x cubed, I'm going to assume at the lower limit of integration, which is 5, I'm going to assume that the initial condition is 0.  So whatever I get for y of 8 will be, in fact, the approximate value of the integral going from 5 to 8.  So that's the bottom line, that you set up your ordinary differential equation in the form of dy by dx, or the derivative of y with respect to x is equal to the integrand itself, put the initial condition at the lower limit to be 0, and then whatever you get as the value of y at the upper limit will be the value of the integral which you are seeking.  So let's go ahead and choose, for argument's sake, we'll choose h equal to 1.5.  So that means that it will take me two steps to get to eight, because I'll have to go from 5 to 6.5, then I add 1.5 to it and I'll be able to reach 8.  So let's look at step 1. So step 1 is x0 is now 5, y0 is 0, because the value of y which I'm choosing at x equal to 5 is 0, and of course, h is 1.5. So from here, I will get y1 equal to y0, plus the value of the function at x0, comma, y0, times h, that's your Euler's method formula. So y0 is 0, the value of the function at x0 is 5, the value of y0 is 0, h is 1.5. So from here I get 0, plus, what is the value of the function at x equal to 5 and y equal to 0?  It is 6 x cubed, so it's 6 times 5 cubed, times 1.5, and the value here turns out to be 1125. So this we have to understand is that this is the value of y at x equal to x1, and x1 is nothing but adding h to x0, and what is that?  x0 is 5, h is 1.5, so this is nothing but the value at 6.5, but that's not what we are seeking, we are seeking the value of y at 8. So that means that we have reached one intermediate step, which is telling us that the value of y at 6.5 is 1125.  So let's go ahead and take the step 2, and see that what do we get.  So if we have step 2, we get x0 is equal to . . . this is i equal to 1, this is corresponding to i equal to 1, so x1 is 6.5, the corresponding value of y which we just obtained in the previous step is 1125, and h is, of course, 1.5.  So we go back again, and say, hey, what is the Euler's formula for i equal to 1?  y2 is y1, plus the value of the function at x1, comma, y1, times h.  What is y1? 1125, plus the value of the function at x1, which is 6.5, y1 is 1125, times h, which is 1.5.  So we know everything about what we need to know in order to be able to solve this problem.  So we get 1125, plus, what is the value of the function at this value of x and this value of y?  It is the function itself is 6 x cubed, so it'll be 6 times 6.5 cubed, times 1.5, and this value here turns out to be 3597, and that's what you are getting as the approximate value of y at 8. The reason that's the value, approximate value of y at 8 is because y2 is nothing but the value of y at x2, x2 is nothing but what 6.5 plus 1.5 is, because x2 is nothing but what?  x1 plus h, x1 is 6.5, h is 1.5, and that gives you 8, so that's what the value of the integral is.  So the approximate value of the integral which you are getting, 5 to 8, 6 x cubed, is nothing but y of 8 minus y of 5, and that is nothing but 3597, this you are assuming to be 0, so that's why you get 3597 as the approximate value of the integral 6 x cubed dx. I'm going to assign you some exercises to do at home.  So some of the things which you can do is choose h equal to 0.75, and find an estimate of the integral, 3 to 8, 6 x cubed dx, okay?  You can also do calculate the true error for part a, because you will find out that when you choose h to be a smaller number, that the value of the integral which you're going to get will be closer to the exact value, so that will give you some confidence in the method.  The other one was that see if the result matches LRAM, MRAM, or RRAM. If you are not familiar with these acronyms, these are LRAM is the left-hand Riemann sum, from your integral calculus class, MRAM is your midpoint Riemann sum, and RRAM is your right-hand Riemann sum. So if you go ahead and see, try to calculate the value of the integral by using the left-hand Riemann sum, the MRAM Riemann sum, or/and the right-hand Riemann sum, and see that if it coincides with any of the numbers which you are calculating by doing the Euler's method for this integral, and figure out for yourself, is this . . . is this just a coincidence?  Is this just a coincidence?  And if you are able to say, hey, this is not a coincidence, then go ahead and show that why this is not a coincidence, so this is a good exercise for you to do to figure out whether the integral which you are getting by using Euler's method is same as LRAM, MRAM, or RRAM, and if it is, is this just a coincidence? And that's the end of this segment.