Transcription of Runge-Kutta 4th Order Method for Ordinary …
1 Chapter Runge-Kutta 4th Order Method for Ordinary 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-Kutta 4th Order Method is a numerical technique used to solve Ordinary differential equation of the form dy = f (x, y ), y (0) = y 0. dx 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 used to solve higher Order Ordinary differential equations or coupled (simultaneous).
2 differential equations . How does one write a first Order differential equation in the above form? Example 1. Rewrite dy + 2 y = x , y (0 ) = 5. dx in dy = f ( x, y ), y (0) = y 0 form. dx Chapter Solution dy + 2 y = x , y (0 ) = 5. dx dy = x 2 y, y (0 ) = 5. dx In this case f ( x, y ) = x 2 y Example 2. Rewrite dy ey + x 2 y 2 = 2 sin(3 x), y (0 ) = 5. dx in dy = f ( x, y ), y (0) = y 0 form. dx Solution dy ey + x 2 y 2 = 2 sin(3 x), y (0 ) = 5. dx dy 2 sin(3 x) x 2 y 2. = , y (0 ) = 5. dx ey In this case 2 sin(3 x) x 2 y 2. f ( x, y ) =. ey The Runge-Kutta 4th Order Method is based on the following yi +1 = yi + (a1k1 + a2 k 2 + a3 k 3 + a4 k 4 )h (1). where knowing the value of y = y i at xi , we can find the value of y = yi +1 at xi +1 , and h = xi +1 xi Equation (1) is equated to the first five terms of Taylor series dy 1 d2y 1 d3y ( ) ( ) (xi +1 xi ).
3 2 3. yi +1 = yi + xi , yi xi +1 x i + 2 xi , yi xi +1 xi + 3 xi , yi dx 2! dx 3! dx 4. (2). 1d y + 4 xi , yi (xi +1 xi )4. 4! dx dy Knowing that = f ( x, y ) and xi +1 xi = h dx 1 1 1. y i +1 = y i + f ( xi , y i )h + f ' ( xi , y i )h 2 + f '' ( xi , y i )h 3 + f ''' ( xi , y i )h 4 (3). 2! 3! 4! Based on equating Equation (2) and Equation (3), one of the popular solutions used is 1. y i +1 = y i + (k1 + 2k 2 + 2k 3 + k 4 )h (4). 6. Runge-Kutta 4th Order Method k1 = f ( x i , y i ) (5a). 1 1 . k2 = f xi + h, yi + k1h . 2 2 (5b). 1 1 . k 3 = f xi + h, y i + k 2 h (5c). 2 2 . k 4 = f ( x i + h, y i + k 3 h ) (5d). Example 3. A ball at 1200 K is allowed to cool down in air at an ambient temperature of 300 K.
4 Assuming heat is lost only due to radiation, the differential equation for the temperature of the ball is given by d . = 10 12 ( 4 81 108 ), (0 ) = 1200 K. dt where is in K and t in seconds. Find the temperature at t = 480 seconds using runge - kutta 4th Order Method . Assume a step size of h = 240 seconds. Solution d . dt (. = 10 12 4 81 10 8 ). (. f (t , ) = 10 12 4 81 10 8 ). 1. i +1 = i + (k1 + 2k 2 + 2k 3 + k 4 )h 6. For i = 0 , t 0 = 0 , 0 = 1200K. k1 = f (t0 , 0 ). = f (0,1200 ). = 10 12 (1200 4 81 10 8 ). = 1 1 . k 2 = f t0 + h, 0 + k1h . 2 2 . 1 1 . = f 0 + (240 ),1200 + ( ) 240 . 2 2 . = f (120, ). = 10 12 ( 4 81 10 8 ). = 1 1 . k 3 = f t 0 + h, 0 + k 2 h.
5 2 2 . 1 1 . = f 0 + (240 ),1200 + ( ) 240 . 2 2 . = f (120, ). Chapter (. = 10 12 4 81 108 ). = k 4 = f (t0 + h, 0 + k3 h ). = f (0 + 240,1200 + ( ) 240 ). = f (240, ). (. = 10 12 4 81 108 ). = 1. 1 = 0 + ( k1 + 2 k 2 + 2 k 3 + k 4 ) h 6. 1. = 1200 + ( + 2( ) + 2( ) + ( ))240. 6. = 1200 + ) 240. (. = K. 1 is the approximate temperature at t = t1. = t0 + h = 0 + 240. = 240. 1 = (240). K. For i = 1, t1 = 240, 1 = K. k1 = f (t1 , 1 ). = f (240, ). (. = 10 12 4 81 10 8 ). = 1 1 . k 2 = f t1 + h, 1 + k1h . 2 2 . 1 1 . = f 240 + (240), + ( )240 . 2 2 . = f (360, ). (. = 10 12 81 108 ). = 1 1 . k3 = f t1 + h, 1 + k 2 h . 2 2 . 1 1 . = f 240 + (240 ), + ( ) 240 . 2 2.
6 = f (360, ). (. = 10 12 4 81 10 8 ). Runge-Kutta 4th Order Method = k 4 = f (t1 + h, 1 + k3 h ). = f (240 + 240, + ( ) 240). = f (480, ). = 10 12 ( 4 81 10 8 ). = 1. 2 = 1 + ( k1 + 2 k 2 + 2 k 3 + k 4 ) h 6. 1. = + ( + 2( ) + 2( ) + ( )) 240. 6. 1. = + ( ) 240. 6. = K. 2 is the approximate temperature at t = t2. = t1 + h = 240 + 240. = 480. 2 = (480). K. Figure 1 compares the exact solution with the numerical solution using the Runge-Kutta 4th Order Method with different step sizes. 1600. Temperature, (K). 1200. h=120. 800 Exact h=240. 400. h=480. 0. 0 200 400 600. -400. Time,t(sec). Figure 1 Comparison of Runge-Kutta 4th Order Method with exact solution for different step sizes.
7 Chapter Table 1 and Figure 2 show the effect of step size on the value of the calculated temperature at t = 480 seconds. Table 1 Value of temperature at time, t = 480 s for different step sizes Step size, h (480) Et | t | %. 480 240 120 60 30 800. Temperature, (480). 600. 400. 200. 0. 0 100 200 300 400 500. -200. Step size, h Figure 2 Effect of step size in Runge-Kutta 4th Order Method . In Figure 3, we are comparing the exact results with Euler's Method ( Runge-Kutta 1st Order Method ), Heun's Method ( Runge-Kutta 2nd Order Method ), and Runge-Kutta 4th Order Method . The formula described in this chapter was developed by runge . This formula is same as Simpson's 1/3 rule, if f ( x, y ) were only a function of x.
8 There are other versions of the 4th Order Method just like there are several versions of the second Order methods . The formula developed by kutta is 1. y i +1 = y i + (k1 + 3k 2 + 3k 3 + k 4 )h (6). 8. where k1 = f (xi , yi ) (7a). 1 1 . k 2 = f xi + h, yi + hk1 (7b). 3 3 . 2 1 . k 3 = f xi + h, yi hk1 + hk 2 (7c). 3 3 . k 4 = f (xi + h, y i + hk1 hk 2 + hk 3 ) (7d). Runge-Kutta 4th Order Method This formula is the same as the Simpson's 3/8 rule, if f ( x, y ) is only a function of x . 1400. Temperature, (K) 1200. 4th Order 1000. 800. Exact 600. Heun 400. 200 Euler 0. 0 100 200 300 400 500. Time, t(sec). Figure 3 Comparison of Runge-Kutta methods of 1st (Euler), 2nd, and 4th Order .
9 Ordinary differential equations . Topic Runge-Kutta 4th Order Method Summary Textbook notes on the Runge-Kutta 4th Order Method for solving Ordinary differential equations . Major General Engineering Authors Autar Kaw Last Revised October 13, 2010. Web Sit