7
08.04.1 Chapter 08.04 Runge-Kutta 4th Order Method for Ordinary Differential Equations After reading this chapter, you should be able to 1. develop Runge-Kutta 4 th order method for solving ordinary differential equations, 2. find the effect size of step size has on the solution, 3. know the formulas for other versions of the Runge-Kutta 4 th order method What is the Runge-Kutta 4th order method? Runge-Kutta 4 th order method is a numerical technique used to solve ordinary differential equation of the form ( ) () 0 0 , , y y y x f dx dy = = So only first order ordinary differential equations can be solved by using the Runge-Kutta 4 th order method. In other sections, we have discussed how 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 () 5 0 , 3 . 1 2 = = + y e y dx dy x in 0 ) 0 ( ), , ( y y y x f dx dy = = form.

R-K 4th.pdf

Embed Size (px)

Citation preview

08.04.1 Chapter 08.04Runge-Kutta 4th Order Method forOrdinary Differential Equations After reading this chapter, you should be able to 1.develop Runge-Kutta 4th order method for solving ordinary differential equations, 2.find the effect size of step size has on the solution, 3.know the formulas for other versions of the Runge-Kutta 4th order method What is the Runge-Kutta 4th order method? Runge-Kutta4thordermethodisanumericaltechniqueusedtosolveordinarydifferential equation of the form ( ) ( )00 , , y y y x fdxdy= =So only first order ordinary differential equations can be solved by using the Runge-Kutta 4th order method.In other sections, we have discussed how Euler and Runge-Kutta methods are usedtosolvehigherorderordinarydifferentialequationsorcoupled(simultaneous) differential equations. How does one write a first order differential equation in the above form? Example 1Rewrite ( ) 5 0 , 3 . 1 2 = = +y e ydxdyx in0) 0 ( ), , ( y y y x fdxdy= =form. 08.04.2 Chapter 08.04 Solution ( ) 5 0 , 3 . 1 2 = = +y e ydxdyx ( ) 5 0 , 2 3 . 1 = =y y edxdyx In this case ( ) y e y x fx2 3 . 1 , = Example 2 Rewrite ( ) 5 0 ), 3 sin( 22 2= = + y x y xdxdyey in0) 0 ( ), , ( y y y x fdxdy= =form. Solution ( ) 5 0 ), 3 sin( 22 2= = + y x y xdxdyey ( ) 5 0 ,) 3 sin( 22 2== yey x xdxdyy In this case ( )yey x xy x f2 2) 3 sin( 2,=The Runge-Kutta 4th order method is based on the following ( )h k a k a k a k a y yi i 4 4 3 3 2 2 1 1 1+ + + + =+(1) where knowing the value of iy y =at ix , we can find the value of 1 +=iy yat 1 + ix , and i ix x h =+1 Equation (1) is equated to the first five terms of Taylor series ( ) ( ) ( )( )41 ,4431 ,3321 ,221 , 1! 41! 31! 21i i y xi i y x i i y x i i y x i ix xdxy dx xdxy dx xdxy dx xdxdyy yi ii i i i i i + + + + =++ + + + (2) Knowing that ( ) y x fdxdy, =andh x xi i= +1 ( ) ( ) ( ) ( )4 ' ' ' 3 ' ' 2 '1,! 41,! 31,! 21, h y x f h y x f h y x f h y x f y yi i i i i i i i i i+ + + + =+ (3) Based on equating Equation (2) and Equation (3), one of the popular solutions used is ( )h k k k k y yi i 4 3 2 1 12 261+ + + + =+ (4) Runge-Kutta 4th Order Method 08.04.3 ( )i iy x f k ,1 =(5a) + + = h k y h x f ki i 1 221,21(5b) + + = h k y h x f ki i 2 321,21(5c) ( ) h k y h x f ki i 3 4, + + =(5d) Example 3 Aballat1200Kisallowedtocooldowninairatanambienttemperatureof300K.Assumingheatislostonlyduetoradiation,thedifferentialequationforthetemperatureof the ball is given by( ) ( ) K 1200 0 , 10 81 10 2067 . 28 4 12= = dtd where isinKandt inseconds.Findthetemperatureat480 = t secondsusingRunge-Kutta 4th order method.Assume a step size of 240 = hseconds. Solution ( )8 4 1210 81 10 2067 . 2 =dtd ( ) ( )8 4 1210 81 10 2067 . 2 , = t f( )h k k k ki i 4 3 2 1 12 261+ + + + =+ For0 = i ,00 = t ,K 12000 = ( )0 0 1, t f k =( ) 1200 , 0 f =( )8 4 1210 81 1200 10 2067 . 2 = 5579 . 4 = + + = h k h t f k1 0 0 221,21( ) ( ) + + = 240 5579 . 4211200 , 240210 f( ) 05 . 653 , 120 f =( )8 4 1210 81 05 . 653 10 2067 . 2 = 38347 . 0 = + + = h k h t f k2 0 0 321,21( ) ( ) + + = 240 38347 . 0211200 , 240210 f( ) 0 . 1154 , 120 f =08.04.4 Chapter 08.04 ( )8 4 1210 81 0 . 1154 10 2067 . 2 = 8954 . 3 =( ) h k h t f k3 0 0 4, + + = ( ) ( ) 240 894 . 3 1200 , 240 0 + + = f( ) 10 . 265 , 240 f =( )8 4 1210 81 10 . 265 10 2067 . 2 = 0069750 . 0 =h k k k k ) 2 2 (614 3 2 1 0 1+ + + + = ( ) ( ) ( ) ( )240 069750 . 0 8954 . 3 2 38347 . 0 2 5579 . 4611200 + + + + =( ) 240 1848 . 2 1200 + =K 65 . 675 =1is the approximate temperature at 1t t = h t + =0 240 0 + = 240 =( ) 2401 = K 65 . 675 ForK 65 . 675 , 240 , 11 1= = = t i( )1 1 1, t f k =( ) 65 . 675 , 240 f =( )8 4 1210 81 65 . 675 10 2067 . 2 = 44199 . 0 = + + = h k h t f k1 1 1 221,21 ( ) ( ) + + = 240 44199 . 02165 . 675 , 24021240 f ( ) 61 . 622 , 360 f = ( )8 4 1210 81 61 . 622 10 2067 . 2 = 31372 . 0 = + + = h k h t f k2 1 1 321,21( ) ( ) + + = 240 31372 . 02165 . 675 , 24021240 f( ) 00 . 638 , 360 f =( )8 4 1210 81 00 . 638 10 2067 . 2 = Runge-Kutta 4th Order Method 08.04.5 34775 . 0 =( ) h k h t f k3 1 1 4, + + = ( ) ( ) 240 34775 . 0 65 . 675 , 240 240 + + = f( ) 19 . 592 , 480 f =( )8 4 1210 81 19 . 592 10 2067 . 2 = 25351 . 0 =h k k k k ) 2 2 (614 3 2 1 1 2+ + + + = ( ) ( ) ( ) ( ) 240 25351 . 0 34775 . 0 2 31372 . 0 2 44199 . 06165 . 675 + + + + =( ) 240 0184 . 26165 . 675 + =K 91 . 594 =2is the approximate temperature at 2t t = h t + =1 240 240 + = 480 = ( ) 4802 =K 91 . 594 Figure 1 compares the exact solution with the numerical solution using the Runge-Kutta 4th order method with different step sizes. -4000400800120016000 200 400 600Time,t(sec)Temperature,h=120Exacth=240h=480(K) Figure 1 Comparison of Runge-Kutta 4th order methodwith exact solution for different step sizes. 08.04.6 Chapter 08.04 Table 1 and Figure 2 show the effect of step size on the value of the calculated temperature at 480 = tseconds. Table 1Value of temperature at time,480 = t s for different step sizes -20002004006008000 100 200 300 400 500Step size, hTemperature,(480) Figure 2Effect of step size in Runge-Kutta 4th order method. In Figure 3, we are comparing the exact results with Eulers method (Runge-Kutta 1st order method),Heunsmethod(Runge-Kutta2ndordermethod),andRunge-Kutta4thorder method. TheformuladescribedinthischapterwasdevelopedbyRunge.Thisformulaissameas Simpsons 1/3 rule, if( ) y x f ,were only a function of x .There are other versions of the 4th order method just like there are several versionsof the second order methods.The formula developed by Kutta is ( )h k k k k y yi i 4 3 2 1 13 381+ + + + =+(6) where ( )i iy x f k ,1 = (7a) + + =1 231,31hk y h x f ki i(7b) + + =2 1 331,32hk hk y h x f ki i(7c) ( )3 2 1 4, hk hk hk y h x f ki i+ + + =(7d) Step size,h ( ) 480 tE % | |t480 240 120 60 30 -90.278 594.91 646.16 647.54 647.57 737.85 52.660 1.4122 0.033626 0.00086900 113.94 8.1319 0.21807 0.0051926 0.00013419 Runge-Kutta 4th Order Method 08.04.7 This formula is the same as the Simpsons 3/8 rule, if( ) y x f ,is only a function ofx . 02004006008001000120014000 100 200 300 400 500Time, t(sec)Temperature,(K)Exact4th order HeunEuler Figure 3Comparison of Runge-Kutta methods of 1st (Euler), 2nd, and 4th order. ORDINARY DIFFERENTIAL EQUATIONS TopicRunge-Kutta 4th order method SummaryTextbooknotesontheRunge-Kutta4thordermethodfor solving ordinary differential equations. MajorGeneral Engineering AuthorsAutar Kaw Last RevisedOctober 13, 2010 Web Sitehttp://numericalmethods.eng.usf.edu