CHAPTER 08.02: EULER METHOD OF SOLVING ODEs: Derivation

 

In this segment, we're going to talk about the derivation of Euler's method is a way of solving ordinary differential equations of the first-order. So the kind of differential equations you'll be able to solve by using Euler's method are of this form, dy by dx is equal to some function of x and y, and you are given some initial condition of y at some point. In this case, I'm just writing it to be 0, but that's not necessarily the case. So one of the things which you've got to understand about Euler's method is that it is only going to be able to solve differential equations which look like this.  So the first thing is that it has to be first-order, has to be able to be written in this particular form.  Keep in mind that y is the dependent variable, x is the independent variable, and then some initial condition has to be given, one initial condition has to be given, and in this case, we are choosing it to be 0, but keep in mind, again, that's not necessary that the initial condition is given at x equal to 0, it can be given at any other point. This is a common myth which students develop, is that the initial condition is suppose to be given at x equal to 0.  So let's go ahead and see that, first we're going to see that this might look a little bit foreign to some students, that, hey, what does this form mean?  Let's go ahead and take a typical differential equation, which you must have been exposed to in your ordinary differential equations course. So you may have a differential equation like this. So what this means is that to be able to write in this particular form, I'm going to rewrite it as dy by dx is equal to 3 e to the power minus x, minus 0.4 y, y of 0 equal to 5, and this is what turns out to be the function of x, comma, y. Again, keep in mind that x and y are not independent variables, y is dependent on x, so this is a different function from what you might be exposed to, where you put the arguments of the function to be two independent variable, let's suppose, but here that's not the case.  y is a dependent variable on x.  Again, also the fact that this f, many times when people see f, they think that, hey, this is the thing which I have to find.  No, no, in a differential equation, you’re trying to find out what the dependent variable is as a function of the independent variable.  So when you look at a differential equation of this particular form, what you want to . . . what is asked of you to do is to find the value of y at any given value of x, so x somebody chooses, and they are asking you to find out what the value of y is.  So let's look at what Euler's method is all about. And we'll look at it from a graphical point of view, and that's how we're going to derive the formula for Euler's method.  Now, as I said that in the Euler's method, based on the differential equation which we just wrote, is that you're trying to find y as a function of x. So let's suppose that function looks like something like this.  Now, keep in mind that, although I am drawing this function here as a function of x, the only thing which I know about y is the initial condition, is the initial value, because if you look at this, I know dy by dx is equal to f of x, comma, y, and y of 0 is equal to some number, y0 let's suppose.  So keep in mind that I don't know what y is, because that's the whole point about solving the differential equation, I want to know y as a function of x, and the only thing which I know is, I do know f, of course, and I know what the initial value is.  So the reason why I'm drawing this particular function is to give you an idea that how the numerical methods work, but keep in mind that when I am drawing this function, y as a function of x, the only thing which I actually know about the function is the initial value of y at x equal to 0, in this case.  But since I know what the derivative of y with respect to x is at any point, because it is given to me as a function of x, comma, y, what I can do is I can just say, hey let me draw the slope at that particular point.  So if I draw the slope at that particular point, what I can say is, hey, let's suppose if this point is x1, and this point is x0, which is 0 in my case, then what I can do is I can choose this to be my approximate value of y which I'm going to get, because I do know the slope, I know the initial value, so I should be able to calculate some approximate value of y, so in this case, I will consider this coordinate to be x1, comma, y1.  Now, what I'm going to take the value of the slope there, because I know that the slope is given by the value of the function at x, comma, y, take the slope there, and draw that line, and then I'll say, hey, let me choose some point, x2, and just draw it like this here, and say, hey, okay, then this is the point which is the approximate value of y at x2, so that coordinate here will be x2, comma, y2.  Now, keep in mind that when you are drawing the slope here, when you were drawing the slope here, for example, you knew the exact value of the slope, because you knew the exact value of y, because that's the initial condition which is given to you.  However, when you're at x1, the value of x1 is known exactly, but the value of y, which is y1 in this case, is an approximate value of y, it's not an exact value of y.  So you're using some approximate slope to calculate the value of y at a point ahead.  So that's how Euler's method works, it's just simply use the information from the first derivative of y with respect to x, and uses that information to keep on calculating the values of ys at different values of x, just like you're seeing it here.  So what I'm going to do is I'm going to now show you the general formula, so that way we can write down the general formula and later on do an example. So let's look at this graph again.  So what we are trying to do is we are trying to solve the differential equation which is of this particular form, of course with some initial condition y0, and as we are saying that, hey, the only thing which I know is the initial value of y, that's all I know about this function, and  I also know what the derivatives of the function, y, are . . . or the . . . or the dependent variable, y, are at different values of x.  So let's suppose if I am at some point here.  So as I am going through the process as I showed you in the earlier figure, that if I'm at the process here, I'm at some xi point, and I calculate this as my approximate value of y at that particular point, so this coordinate here is xi, comma, yi.  So what I'm going to do is I'm going to calculate the slope based on this value, so I'll put the value of x equal to xi, y equal to yi which I've calculated, I'll be able to get the slope, I can draw the slope, I can choose some other point, x-sub-i-plus-1 here, and what's going to happen is that this value here will turn out to be my next estimate of y at a point x-sub-i-plus-1.  So that's how that's going to be calculated.  Now, I can very well see that this is nothing but rise over run formula again, because this is the . . . this is the slope here, so let's suppose if this angle is phi, then what I will get is that tangent of phi is simply equal to y-sub-i-plus-1 minus yi, divided by x-sub-i-plus-1 minus xi.  But I know that tangent of phi is nothing but what?  The value of the function at xi, comma, yi, because that's the value, that's how I get the slope, because this is the first derivative of y with respect to x is given by this particular function of x and y, so all I have to do is to substitute the value of xi and yi in here, to be able to get what the slope is, and it will give me this. And now, what I have to understand is that I know this function, f, I know where I am going, I know where I am coming from, I know this value, and this is the only unknown. So if I rewrite this formula, I get y-sub-i-plus-1 is equal to  yi, plus the value of the function at xi, comma, yi, times x-sub-i-plus-1 minus xi.  And many times, what you will find out is that this thing here is called the step size, and that might be denoted by h.  So . . . so h is simply the difference between the point where we're at, and where you are trying to go.  So the Euler's formula, what they will do is they will rewrite it like this, they will say, hey, y-sub-i-plus-1 is equal to yi, plus the value of the function at xi, comma, yi, times h. And this formula which you are seeing here is Euler's method. So all it's trying to do is that you know how the derivative of the dependent variable, y, with respect to x is behaving, that is given by the function, f, this is the step size which you are taking, this is the value at the point where you are starting from, or where you are at, and it gives you the value of the dependent variable at the point where you are going.  So I can surely say here, I should, you know, for completion, I'll say where h is equal to x-sub-i-plus-1 minus xi.  and that's the end of this segment.