CHAPTER 08.03: RUNGE-KUTTA 2ND ORDER METHOD: Derivation: Part 2 of 2     Now, the other part which I need to look at is that I defined my k2 as the value of the function at xi plus p1 times h, yi plus q11 times k1 times h.  And what I'm going to do is I'm going to expand this as a Taylor series.  Now, this is a Taylor series in terms of two variables.  So if I have a Taylor series where I want to calculate the value of the function at some point which is a ahead of x and b ahead of y, the first three terms of the Taylor series are given as this, f, x, comma, y, plus a times del f by del x being calculated at x, comma, y, plus b, del f del y being calculated at x, comma, y, plus the order of a squared, comma, b squared terms will be left over.  So that's what's going to happen when I'm going to expand this.  So when I expand this, my x will be xi, my y will be yi, my a will be p1 h, and my b which I have here will be q11 times k1 times h, and I'm only taking the first three terms of the Taylor series of two variables now, so the leftover terms are of the order of a squared and b squared.  So if I do that, and . . . let me write this down.  If I do that, this is what I'm going to get, I'm going to get for k2, I'm going to get the value of the function at xi, comma, yi, that's what I'm going to get, so I'm using my Taylor series expansion, plus for a is p1 h, so it's p1 times h times del f by del x at xi, comma, yi, plus b, which is q11 times k1 times h, which is del f by del y being calculated at xi, comma, yi, plus the order of h squared terms, because I have a squared b squared terms there, so since everything has h in it, so it will be just order of h squared terms.  Now, if I go back to my . . . the formula which I wrote for Runge-Kutta second-order method, which is this, a1 times k1 plus a2 times k2, times h.  I'm going to substitute this expression for k2 in here, and then I'm going to equate it to what I had before, and that's how I'll be able to get all the expressions together.  So if I expand it, this is what I'm going to get, I'm going to get yi, plus a1 times the value of the function at xi, comma, yi, plus a2 times k2, and k2 is . . . times h here, because I have a1 times k1 is nothing but the value of the function at that point, times h, a2 plus k2, I'm going to substitute all of this here, so I'm going to get a2 times the value of the function at xi, comma, yi, times h, h is coming from there, plus a2 p1 h, del f by del x, at xi, comma, yi, times h, plus a2 q11 times k1 times h, del f by del y, at xi, comma, yi, times h, plus order of h cubed terms. The reason why the order of h cubed terms is because it's of the order of h squared right here, this is of the order of h squared right here, so since I'm multiplying by h, I'll have the order of h cubed terms right there.  So what I'm going to do is I'm going to take this expression which I have for y-sub-i-plus-1, this expression which I have for y-sub-i-plus-1, and I'm going to equate it to the terms which I have for . . . which I got previously, which are right here. So let me just take this here. So this is something which I got previously, and . . . this is one expression which I got, and then this is something which I got by using the expansion of the Taylor series of two variables right there.  So once I equate the two, this is what I'm going to get, I'm going to get a1 plus a2 equal to 1, a2 p1 is equal to 1/2, and a2 q11 is equal to 1/2.  It is not very easy to show it on the board, how I get those by equating the terms, because there are so many of those terms, so I would like you to do that as homework, to see that how did I get this expression, this expression, this expression, it's only to basically to equate the terms which are the same from the two expressions, and you easily find out that you get that this has to be equal to 1, this has to be equal to 1/2, and this has to be equal to 1/2, and that's how the Runge-Kutta second-order method equations are derived.  And that's the end of this segment.