Example: confidence

Textbook notes for Runge-Kutta 2nd Order Method for ...

Chapter Runge-Kutta 2nd Order Method for ordinary Differential Equations After reading this chapter, you should be able to: 1. understand the Runge-Kutta 2nd Order Method for ordinary differential equations and how to use it to solve problems. What is the Runge-Kutta 2nd Order Method ? The Runge-Kutta 2nd Order Method is a numerical technique used to solve an ordinary differential equation of the form ( ) ( )00,,yyyxfdxdy== Only first Order ordinary differential equations can be solved by using the Runge-Kutta 2nd Order Method . In other sections, we will discuss how the Euler and Runge-Kutta methods are used to solve higher Order ordinary differential equations or coupled (simultaneous) differential equations. How does one write a first Order differential equation in the above form? Example 1 Rewrite ( )50, + yeydxdyx in 0)0( ),,(yyyxfdxdy== form.

Oct 13, 2010 · The Runge-Kutta 2nd order method is a numerical technique used to solve an ordinary differential equation of the form . f (x, y), y(0) y 0 dx dy = = Only first order ordinary differential equations can be solved by uthe Runge-Kutta 2nd sing order method. In other sections, we will discuss how the Euler and Runge-Kutta methods are

Tags:

  Methods, Ordinary, Runge, Kutta, Runge kutta, Runge kutta methods

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Textbook notes for Runge-Kutta 2nd Order Method for ...

1 Chapter Runge-Kutta 2nd Order Method for ordinary Differential Equations After reading this chapter, you should be able to: 1. understand the Runge-Kutta 2nd Order Method for ordinary differential equations and how to use it to solve problems. What is the Runge-Kutta 2nd Order Method ? The Runge-Kutta 2nd Order Method is a numerical technique used to solve an ordinary differential equation of the form ( ) ( )00,,yyyxfdxdy== Only first Order ordinary differential equations can be solved by using the Runge-Kutta 2nd Order Method . In other sections, we will discuss how the Euler and Runge-Kutta methods are used to solve higher Order ordinary differential equations or coupled (simultaneous) differential equations. How does one write a first Order differential equation in the above form? Example 1 Rewrite ( )50, + yeydxdyx in 0)0( ),,(yyyxfdxdy== form.

2 Solution ( )50, + yeydxdyx ( )50, = yyedxdyx In this case Chapter ( ) , = Example 2 Rewrite ( )50 ),3sin(222==+yxyxdxdyey in 0)0( ),,(yyyxfdxdy== form. Solution ( )50 ),3sin(222==+yxyxdxdyey ( )50 ,)3sin(222= =yeyxxdxdyy In this case ( )yeyxxyxf22)3sin(2, = Runge-Kutta 2nd Order Method Euler s Method is given by ()hyxfyyiiii,1+=+ (1) where 00=x )(00xyy= iixxh =+1 To understand the Runge-Kutta 2nd Order Method , we need to derive Euler s Method from the Taylor series. ()()()..!31!2131,3321,221,1+ + + +=++++iiyxiiyxiiyxiixxdxydxxdxydxxdxdyyy iiiiii ()()()..),(''!31),('!21),(31211+ + + +=+++iiiiiiiiiiiiixxyxfxxyxfxxyxfy (2) As you can see the first two terms of the Taylor series ()hyxfyyiiii,1+=+ are Euler s Method and hence can be considered to be the Runge-Kutta 1st Order Method .

3 The true error in the approximation is given by ()()..!3,!2,32+ + =hyxfhyxfEiiiit (3) So what would a 2nd Order Method formula look like. It would include one more term of the Taylor series as follows. Runge-Kutta 2nd Order Method ()()21,!21,hyxfhyxfyyiiiiii ++=+ (4) Let us take a generic example of a first Order ordinary differential equation ( )50,32= = yyedxdyx ( )yeyxfx3,2 = Now since y is a function of x, ( )( )( )dxdyyyxfxyxfyxf + = ,,, (5) ()()[]()yeyeyyexxxx333222 + = ()yeexx3)3(222 + = yex952+ = The 2nd Order formula for the above example would be ()()21,!

4 21,hyxfhyxfyyiiiiii ++=+ ()()22295!213hyehyeyixixiii+ + += However, we already see the difficulty of having to find ( )yxf, in the above Method . What runge and kutta did was write the 2nd Order Method as ()hkakayyii22111++=+ (6) where ()iiyxfk,1= ()hkqyhpxfkii11112,++= (7) This form allows one to take advantage of the 2nd Order Method without having to calculate( )yxf, . So how do we find the unknowns 1a, 2a, 1p and 11q. Without proof (see Appendix for proof), equating Equation (4) and (6) , gives three equations. 121=+aa 2112=pa 21112=qa Since we have 3 equations and 4 unknowns, we can assume the value of one of the unknowns. The other three will then be determined from the three equations. Generally the value of 2a is chosen to evaluate the other three constants.

5 The three values generally used for 2a are 21, 1 and 32, and are known as Heun s Method , the midpoint Method and Ralston s Method , respectively. Chapter Here Heun s Method 212=a is chosen, giving 211=a 11=p 111=q resulting in hkkyyii ++=+2112121 (8) where ( )iiyxfk,1= (9a) ()hkyhxfkii12,++= (9b) This Method is graphically explained in Figure 1. Figure 1 Runge-Kutta 2nd Order Method (Heun s Method ). Here Midpoint Method 12=a is chosen, giving 01=a 211=p 2111=q resulting in hkyyii21+=+ (10) where xi xi+1 x y 1+iy predicted yi ( )iiyxfSlope,= ()hkyhxfSlopeii1,++= () ( )[]iiiiyxfhkyhxfSlopeAverage,,21 1+++= Runge-Kutta 2nd Order Method ()iiyxfk,1= (11a) ++=hkyhxfkii1221,21 (11b) Here Ralston s Method 322=a is chosen, giving 311=a 431=p 4311=q resulting in hkkyyii ++=+2113231 (12)

6 Where ()iiyxfk,1= (13a) ++=hkyhxfkii1243,43 (13b) Example 3 A ball at 1200K is allowed to cool down in air at an ambient temperature of 300K. Assuming heat is lost only due to radiation, the differential equation for the temperature of the ball is given by )1081( = dtd where is in K and t in seconds. Find the temperature at 480=t seconds using Runge-Kutta 2nd Order Method . Assume a step size of 240=h seconds. Solution () = dtd ( )() , = tf Per Heun s Method given by Equations (8) and (9) hkkii ++=+2112121 ( )iitfk ,1= ()hkhtfkii12,++= 1200)0(,0,000==== ti ()otfk ,01= Chapter ()1200,0f= () = = ()hkhtfk1002,++= ()() ,2400 ++=f () ,240f= () = hkk ++=21012121 ()() + += () += ,2402400,1101==+=+== htti ()111, tfk= () ,240f= () = = ()hkhtfk1112,++= ()() ,240240 ++=f () ,480f= () = = hkk ++=21122121 ()() + += () += ( ) K The results from Heun s Method are compared with exact results in Figure 2.

7 The exact solution of the ordinary differential equation is given by the solution of a non-linear equation as () = + t The solution to this nonlinear equation at 480=ts is )480(= K Runge-Kutta 2nd Order Method -400040080012000100200300400500 Time, t(sec)Temperature, (K)Exacth=120h=240h=480 Figure 2 Heun s Method results for different step sizes. Using a smaller step size would increase the accuracy of the result as given in Table 1 and Figure 3 below. Table 1 Effect of step size for Heun s Method Step size, h ( )480 tE %t 480 240 120 60 30 -400-20002004006008000100200300400500 Step size, hTemperature, (480) Figure 3 Effect of step size in Heun s Method . Chapter In Table 2, Euler s Method and the Runge-Kutta 2nd Order Method results are shown as a function of step size, Table 2 Comparison of Euler and the Runge-Kutta methods Step size, h )480( Euler Heun Midpoint Ralston 480 240 120 60 30 while in Figure 4, the comparison is shown over the range of time.

8 5006007008009001000110012000100200300400 500600 Time , t (sec)Temperature,AnalyticalRa ls to nMidpointEule rHeun (K) Figure 4 Comparison of Euler and runge kutta methods with exact results over time. How do these three methods compare with results obtained if we found ( )yxf, directly? Of course, we know that since we are including the first three terms in the series, if the solution is a polynomial of Order two or less (that is, quadratic, linear or constant), any of the three methods are exact. But for any other case the results will be different. Let us take the example of ( )50,32= = yyedxdyx. If we directly find ( )yxf, , the first three terms of the Taylor series gives Runge-Kutta 2nd Order Method ()()21,!21,hyxfhyxfyyiiiiii ++=+ where ( )yeyxfx3,2 = ( )yeyxfx95,2+ = For a step size of , using Heun s Method , we find ( ) The exact solution ( )xxeexy324 += gives ( )( )( ) +=eey Then the absolute relative true error is = t % For the same problem, the results from Euler s Method and the three Runge-Kutta methods are given in Table 3.

9 Table 3 Comparison of Euler s and Runge-Kutta 2nd Order methods y( ) Exact Euler Direct 2nd Heun Midpoint Ralston Value t % Appendix A How do we get the 2nd Order Runge-Kutta Method equations? We wrote the 2nd Order Runge-Kutta equations without proof to solve ( )yxfdxdy,=, ( )00yy= ( ) as ()hkakayyii22111++=+ ( ) where ()iiyxfk,1= ( ) ()hkqyhpxfkii11112,++= ( ) and 121=+aa 2122=pa Chapter 21112=qa ( ) The advantage of using 2nd Order Runge-Kutta Method equations is based on not having to find the derivative of ( )

10 Yxf, symbolically in the ordinary differential equation So how do we get the above three Equations ( )? This is the question that is answered in this Appendix. Writing out the first three terms of Taylor series are ( )32221!21hOhdxydhdxdyyyiiiiyxyxii+++=+ ( ) where iixxh =+1 Since ( )yxfdxdy,= we can rewrite the Taylor series as ()()( )321,!21,hOhyxfhyxfyyiiiiii+ ++=+ ( ) Now ( )( )( )dxdyyyxfxyxfyxf + = ,,,. ( ) Hence ()( )32,,,1!21,hOhdxdyyfxfhyxfyyiiiiiiyxyxyx iiii+ + ++=+ ()()( )32,2,,2121,hOhyxfyfhxfhyxfyiiyxyxiiiiii i+ + ++= ( ) Now the term used in the Runge-Kutta 2nd Order Method for 2k can be written as a Taylor series of two variables with the first three terms as ()hkqyhpxfkii11112,++= ()( )2,111,1,hOyfhkqxfhpyxfiiiiyxyxii+ + += ( ) Hence ()hkakayyii22111++=+ ()()( )hhOyfhkqxfhpyxfayxfayiiiiyxyxiiiii + + +++=2,111,121,, () ()()( )3,2112,21221,,hOyfhyxfqaxfhpayxhfaayiii iyxiiyxiii+ + +++= Runge-Kutta 2nd Order Method ( ) Equating the terms in E quation ( ) and Equation ( )


Related search queries