CHAPTER 08.03: RUNGE-KUTTA 2ND ORDER METHOD: Background
In this segment, we're going to talk about the Runge-Kutta second-order method of solving ordinary differential equations. And what we're going to do is we're going to just talk about the background, that where does this Runge-Kutta second-order method come from. Now, the differential equation which we are trying to solve, the ordinary differential equation which we are trying to solve by using any of the methods which we learn for ordinary differential equations are based on first-order differential equations of this form, dy by dx is equal to f of x, comma, y, so we know the slope of the dependent variable as a function of the independent variable in terms of a function of x and y, and we are given some initial condition, let's suppose, at 0 to be there. Now, if you look at Euler’s method, Euler's method basically tells us that, hey, in order to be able to solve this particular first-order ordinary differential equation by a numerical method, what you need to do is you need to solve this particular equation here, or you need to use this particular formula here. So what you want to be able to do is that you are using the value of the slope at xi, yi, and then multiplied by the step size, which is the difference between the point where you are to the point where you are going, so that's what the value of h is. So this is the point where you are, and this is the point where you are going, and then that's the value of h, this is the slope, this is the value of the . . . value of y at xi, and then you are able to find out the value of the function at a point ahead. But this involves . . . it's not an accurate method to use. So what we need to do is to maybe find a better accurate method, and that's what Runge and Kutta did by using . . . by calling it the Runge-Kutta second-order method, and be able to get a more accurate way of being able to solve a first-order ordinary differential equation of this particular form. So in order to be able to do that, we do need to look at something called Taylor series, which you must be familiar with by now. So what we have is that we have, for example, the Taylor series for a point at x-sub-i-plus-1, will be given that, hey, give me the value of the function at xi, give me the value of the derivative of y at xi, yi, and this is the difference between where I am, and this is the point where I want to go to, plus 1 by factorial 2, d2y by dx squared, so second derivative of y with respect to x, calculated at xi, comma, yi, and then the difference is this, the square of the difference between where you are and where you want to go, plus, let's suppose another we will write down, third derivative of y with respect to x, calculated at the point xi, comma, yi, and again, the difference is difference between the point where you are going to the difference where the point you're coming from, and cube that value. So if you look at this particular Taylor series expansion of y as a function of x, and so you want to . . . the Taylor series is telling you that, hey, this is the value of y at a particular value of x, x-sub-i-plus-1, if you know the value of the y at xi, if you know the derivative of y at xi, and second derivative, third derivative, and so on and so forth. Now, we already know that dy by dx is equal to f x, comma, y, this is the differential equation which we are trying to solve in the first place. So if I substitute this into this Taylor series, I'm going to get something like this, y-sub-i-plus-1 is equal to yi, plus the value of the function calculated at xi, comma, yi, times h, because this thing, this difference which you have between xi and x-sub-i-plus-1 is nothing but h, which is the step size, as written for the Euler's method. So same thing here, this can be written as h squared, this can be written as h cubed, it's just a difference between the point where you are to the point where you're going, so I'm just going to write that, plus 1 by factorial 2, f prime xi, comma, yi, times h squared, plus 1 by factorial 3, f double-prime xi, comma, yi, times h cubed, and so on and so forth. You can just see that if you just take these first two terms of the series, you are going to get something called the Euler's method, because this is exactly like the Euler's method if you take the first two terms of the Taylor series. So it makes sense that if we want to get more accurate results, what we would like to do is maybe add one more term to it, and that's why it's called the second-order method, because you are adding the second-order terms now, here. So you will have the Euler's method formula part, and then you'll have this additional term from the Taylor series. You can get more accurate results if we add one more term, and so on and so forth. So what Runge-Kutta method has been based on is that, hey, we need to write y-sub-i-plus-1 is equal to yi, plus f of xi, comma, yi, times h, plus 1 by factorial 2, f prime xi, comma, yi, times h squared. So that's what the Runge-Kutta second-order method will be based on, but you are already finding out that there are going to be some issues here, that in order to be able to apply the Runge-Kutta second-order method, we'll have to find the derivative of the function f with respect to x in order to be able to do that, and that can make it quite hairy, because you have to find it symbolically. So I'll give you an example. Let's suppose if you had dy by dx equal to e to the power -2 x, minus 3 y, y of 0 equal to 5, let's suppose. And in this case, we have f x, comma, y is equal to e to the power -2 x, minus 3 y, and if you are going to find f prime of x, comma, y, you've got to understand that, hey, this is finding the derivative of f with respect to x, but where y and x are not independent variables, y is dependent on x, so you have to apply the chain rule to be able to do that, and which is simply del f by del x, plus del f by del y times dy by dx. So that's what is going to allow you to find out the f prime of this one. So if I take the partial derivative of f with respect to x, I'll get -2 e to the power -2 x, if I take the partial derivative of f with respect to y, I get -3, and then dy by dx itself is e to the power -2 x, minus 3 y. So in this case, it becomes -5 e to the power -2 x, plus 9 y. So you can very well see that you have to symbolically find out the f prime value here, and then you can substitute this f prime value back into the formula, and be able to develop the Runge-Kutta second-order method. But that's not what Runge did, what Runge wanted to do was that they wanted to avoid having to find out the derivative of the function f. They wanted to avoid finding f prime, because it involved the symbolic . . . involved a symbolic calculation of the f prime function. So they wrote down the equation like this, they said, hey, we can write down the equation like this, y-sub-i-plus-1 is equal to yi, plus a1 times k1, plus a2 times k2, times h, where k1 is equal to the value of the function at xi, comma, yi, and k2 is, again, the value of the function at some other point, which is given as xi, plus p1 times h, yi, plus q11 k1 times h. So if you just look at this formula now, you will see that, hey, this looks more complicated that what I had before, but one of the things which you've got to appreciate that what they tried to do what that, hey, you don't have to find out the f prime, the derivative of f at all, you don't have to find f prime at all, because you're still getting second-order accuracy by using this particular formula, where k1 and k2 are simply the values of the functions evaluated at certain points, and surely you have unknowns here, a1 is an unknown, a2 is an unknown, which you need to know what it is, p1 is an unknown, and q11 is an unknown, but they gave us these value for a1, a2, p1, and q11 to show us that you are using second-order terms of the Taylor series. So that's the beauty of the Runge-Kutta method, and we'll talk about these, what these unknowns are in the next segment. And that's the end of this segment. |