CHAPTER 08.03: RUNGE-KUTTA 2ND ORDER METHOD: Ralston's Method: Part 1 of 2
In this segment, we'll talk about how to solve a first-order differential equation by using Ralston's method, and we're going to take an example in this particular segment, so this is part of the Runge-Kutta second-order method. Ralston's method is an example . . . is a part of the . . . is one of the forms of the Runge-Kutta second-order method, and we're going to solve a first-order ordinary differential equation by doing so. And the differential equation which we're going to solve for the example is given as follows, dy by dx is equal to 3 e to the power minus x, minus 0.4 y, y of 0 equal to 5, so that's given to us as the . . . as the differential equation, and we want to use Ralston's method to be able to find out what the solution to this one is. To review what Ralston's method is, it is based on that your value of y at the point where you are trying to go will be given by the point where you were, the value of y where you were, plus 1/3 the value of k1 plus 2/3 the value of k2, times the step size, which is h, where k1 is the slope at the point where you were, which is xi, yi, and k2 is some approximate value of the slope at a point which is about three-quarters away, between the point where you are and where you are trying to go. So k1 and k2 are basically two slopes at this point and this point, and what we are doing, we're giving this one-third weightage, this two-thirds weightage, and using that to calculate what y-sub-i-plus-1 is, and what we're going to do is we're going to assume that h is equal to 1.5 for this example. So if h is equal to 1.5, and what we want to do is we want to find out what y of 3 is. So that's the complete description of the problem here, except for these formulas which I just showed for review, that you are using a step size of 1.5, and you want to find out what the value of y of 3 is, so that means that you're going to take two steps, because the first step will give you the value of y at 1.5, the second step will give you the value at 3, because we are starting from y equal to . . . x equal to 0. So let's go ahead and go through the steps of Ralston's method and see what do we get. So we have i equal to 0, that's what I'm going to assume, i equal to 0, and now, what is the value of x0? x0 is 0, and y0 is 5, because if I'm going to choose my first point to be x equal to 0, then the corresponding value of y is 5. I'm going to find my k1 now. k1 is the value of the function at xi, comma, yi, so it will be x0, comma, y0, and that will be the function itself, which I should have written what the function is, the function is a function of x and y, function of x, comma, y is 3 e to the power minus x, minus 0.4 y, because that's simply the slope of y with respect to x, so that's the function, f, which we know, so it will be f at 0, comma, 5, so that will be 3 e to the power -0, minus 0.4 times 5, and that gives you 1. So that's the value of k1 at x equal to 0. Now let's go ahead and calculate k2. Now, in order to calculate k2, I have to calculate the value of the function at three-quarters away from where I am, so 3 by 4 h, then yi plus 3/4 k1 times h, so that's the corresponding value of x and y which I have to find. So in this case, I will get the value of the function, f, x0 is 0, h is 1.5, yi, I know that is what? This is y0 here, y0 is 5, plus 3 by 4, k1 is what? k1 I just found is 1, and h is 1.5. So you can see that what you are trying to do here, in this second argument which you have, you are trying to find some approximate value of y at x equal to three-quarters away from where you were, because in order to be able to find the value of f, you do need the value of x, you need the value of y. So if I simplify this, I get f at 1.125 and 6.125. So this value of 6.125 which you have is an approximate value of y at this value of x, because that's what you want to be able to use to calculate your value of y at 1.5, this is three-quarters away, between 0 and 1.5. So what do I get here? I get -1.4 . . . let me just substitute those values into the formula, so I'll have 3 e to the power -1.125, minus 0.4 times 6.125, and the value of k2 turns out to be -1.476. So now I have the values of k1 and k2, so I will be able to use them in the formula to calculate my y1. So y1 is equal to y0, plus 1/3 of k1 plus 2/3 of k2, times h. So what is y0? y0 is 5, plus, what is the value of k1 which I just calculated? It was 1, and 2/3 the value of k2 which I just calculated, which was -1.476, and I multiply it by 1.5, because that's my step size of 1.5. So this number here turns out to be 5, plus -0.6507 times 1.5, and this value here turns out to be 4.024. So that is my approximate value of y, y1, which is the approximate value of y at x1, which is nothing but 1.5. The reason why x1 is 1.5 is because x1 is nothing but x0 plus h, x0 is 0, h is 1.5, so x1 is nothing but 1.5. So this 4.024 is just the approximate value of y at x equal to 1.5. |