346 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES () () 1.07152 0.075 1.07152 0.025 1.07152 0.075 − =+ + 1.09324= ⇒ 4 1.09324 y = at () 40 4 0 4 0.025 0.1 xx h =+=+× = Hence, (0.1) 1.0932 y = . Ans. Example 18. Given dy xy dx =+ with initial condition y(0) = 1. Find y(.05) and y(.1) correct to 6 decimal places. Sol. Using Euler’s method, we obtain () () 0 110 00 , yyyhfxy==+ = 1 () .05 0 1 1.05 ++= We improve 1 y by using Euler’s modified method () () () 1 0 00011 1 ,, 2 h yy fxyfxy =+ + ()( ) .05 1 0 1 .05 1.05 2 =+ + + + 1.0525.= () () () =+ + + + 2 1 .05 1 0 1 .05 1.0525 2 y =1.0525625 () ()( ) 3 1 .05 1 0 1 .05 1.0525625 2 y =+ + + + 1.052564= () ()( ) =+ + + + 4 1 .05 1 0 1 .05 1.052564 2 y 1.0525641= . Since, () () 34 11 1.052564 yy== correct to 6 decimal places. Hence we take 1 1.052564 y = i.e., we have () .05 1.052564y = Again, using Euler’s method, we obtain () () ==+ 0 21 11 2 , yyyhfxy () 1.052564 .05 1.052564 .05 =+ + 1.1076922.= We improve 2 y by using Euler’s modified method () ()() =+ ++ + 1 2 .05 1.052564 1.052564 .05 1.1076922 .1 2 y 1.1120511.= () ()() 2 2 .05 1.052564 1.052564 .05 1.1120511 .1 2 y =+ ++ + 1.1104294.= NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 347 () ()() =+ ++ + 3 2 .05 1.052564 1.052564 .05 1.1104294 .1 2 y 1.1103888.= () ()() =+ ++ + 4 2 .05 1.052564 1.052564 .05 1.1103888 .1 2 y 1.1103878.= () ()() =+ ++ + 5 2 .05 1.052564 1.052564 .05 1.1103878 .1 2 y 1.1103878.= Since, () () 45 22 1.1103878, yy== correct to 7 decimal places. Hence, we take 2 1.1103878. y = Therefore, we have () .1 1.110388,y = correct to 6 decimal places. Ans. Example 19. Find y(2.2) using Euler’s method for 2 , dy xy dx =− where y(2) = 1. (Take .1h= ) Sol. By Euler’s method, we obtain, () () ()() 2 0 10 00 1 , 1 .1 2 1 .8. yyyhfxy==+ =+− − = This value of 1 y is improved by using Euler’s modified method () () () () 10 0001 11 ,, 2 h yy fxyfxy =+ + () ( )( ) {} =+ − +− 22 0.1 1 2 1 2.1 .8 2 .8328= Similarly () () ( )( ) {} 222 1 0.1 1 2 1 2.1 .8328 2 y =+ − +− .8272= () () ( )( ) {} 22 3 1 0.1 1 2 1 2.1 .8272 2 y =+ − +− .8281= () () ( )( ) {} 22 4 1 0.1 1 2 1 2.1 .8281 2 y =+ − +− =.8280 () () ( )( ) {} 22 5 1 0.1 1 2 1 2.1 .8280 2 y =+ − +− = .8280 Since () () 45 11 0.8280. yy== Hence, we take 1 .828 y = at 1 2.1 x = Now, if 2 y is the value of y at 2.2.x = Then, we apply Euler’s method to compute () 2.2 ,y i.e., we obtain () () 0 21 11 2 , yyyhfxy==+ ()() 2 .828 .1 2.1 .828 =+− = .68402 348 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES Now, using Euler’s modified formula, we obtain () ()()()( ) 221 2 0.1 .828 2.1 .828 2.2 .68402 2 y =+ − +− .70454= () ()()( ) =+ − +− 22 2 2 0.1 .828 ( 2.1) .828 2.2 .70454 2 y .70141.= () ()()()( ) 22 3 2 0.1 .828 2.1 .828 2.2 .70141 2 y =+ − +− .70189.= () ()()()( ) 22 4 2 0.1 .828 2.1 .828 2.2 .70189 2 y =+ − +− .70182= () ()()()( ) 22 5 2 0.1 .828 2.1 .828 2.2 .70182 2 y =+ − =− .70183= Since, () () 45 22 .7018 yy== , correct to 4 decimal places. Hence, we have () 2.2 .7018.y = Ans. Example 20. Find y(.2) and y(.5) Given () 10 dy =log x+y dx with initial condition y = 1 for x = 0. Sol. Let () ( ) 10 ,log dy fxy x y dx == + and .2h = By Euler’s formula, we have () () 0 10 00 1 , yyyhfxy==+ () 1.2log01 1. =+ + = Now, we improve this value by using Euler’s modified formula and thus we obtain () () () () 10 0001 11 ,, 2 h yy fxyfxy =+ + () ( ) {} 0.2 1log01log.21 2 =+ + = + 1.0079= () () ( ) {} 2 1 0.2 1 log 0 1 log .2 1.0079 2 y =+ + + + 1.0082= () () ( ) {} 3 1 0.2 1 log 0 1 log .2 1.0082 2 y =+ + + + 1.0082= NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 349 Since, () () 23 11 1.0082 yy== . Hence, we take 1 1.0082 y = at .2x= , i.e., () .2 1.0082y = . Ans. Again using Euler’s formula, we obtain () () 0 21 11 2 y yyhfxy==+ + () 1.0082 0.3 log 0.2 1.0082 1.0328 =+ + = To improve 2 y , we use Euler’s modified formula and we obtain y (1) 2 ()() =+ +++ 0.3 1.0082 log 1.0328 .5 log .2 1.0082 2 1.0483= () ()() 2 2 0.3 1.0082 log 1.0483 .5 log .2 1.0082 2 y =+ + + 1.049= () ()( ) =+ +++ 3 2 0.3 1.0082 log 1.049 .5 log .2 1.0082 2 y 1.0490= Since () () 32 22 1.0490, yy== we take 2 1.0490 y = , i.e., () .5 1.0490y = . Ans. Example 21. Using Euler’s modified method, compute y(0.1) correct to six decimal figures, where 2 dy xy dx =+ with y = .94 when x = 0. Sol. By Euler’s method, we have () () 0 10 00 1 , yyyhfxy==+ () .94 .1 0 .94 =+ = 1.034= Now, we improve y 1 by using Euler’s modified formula and we obtain () () () () 10 0001 11 , 2 h yy fxyfxy =+ + =.94 + 01 2 0 94 1 1 034 2 . ++ + bg a f {} = 1.0392 y (2) 1 () () {} 2 0.1 .94 0 .94 .1 1.0392 2 =+ + + + =1.03946 () () () {} 23 1 0.1 .94 0 .94 .1 1.03946 2 y =+ + + + 1.039473= () () () {} 2 4 1 0.1 .94 0 .94 .1 1.039473 2 y =+ + + + 1.0394737= 350 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES Since, () () 34 11 1.039473, yy== correct to 6 decimal places Hence, we have () .1 1.039473.y = Ans. Example 22. Using Euler’s modified method, solve numerically the equation dy xy dx =+ with y(0) = 1 for 0 ≤ x ≤ 0.6, in steps of 0.2. Sol. The interval 0.2h = By Euler’s method, we obtain () () 0 10 00 1 , yyyhxy==+ () 1 0.2 0 1 1.2. =+ + = The value of () 0 1 y , thus obtained is improved by modified method. () () () () 1 0001 11 ,, 2 n n h yyfxyfxy + =+ + By considering n = 0, we obtain y 1 (1) = y 0 + h 2 BN O BN O(,) (,) 00 11 + ()() 0.2 1010.21.2 2 =+ + + + 1.2295= By considering 1n= , we obtain () ()() 2 1 0.2 1 0 1 0.2 1.2295 2 y =+ + + + 1.2309.= By considering 2n= , we obtain () ()() =+ + + + 3 1 0.2 1 0 1 0.2 1.2309 2 y 1.2309.= Since () () 23 11 1.2309 yy=== . Hence, we take 1 1.2309 y = at 0.2x = and proceed to compute y at 0.4x= . Again, applying Euler’s method, we obtain () () 0 2 2 1.2309 0.2 0.2 1.2309 1.49279 yy== + + = Now, we apply modified method for more accurate approximations and we obtain () ()() 1 2 .2 1.2309 2 1.2309 0.4 1.49279 2 y =++ ++ 1.52402= () ()() 2 2 .2 1.2309 2 1.2309 0.4 1.52402 2 y =++ ++ 1.525297= NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 351 () ()() 3 2 .2 1.2309 2 1.2309 0.4 1.525297 2 y =++ ++ 1.52535= () ()() 4 2 .2 1.2309 .2 1.2309 0.4 1.52535 2 y =+ ++ 1.52535= Since, () () 34 22 1.52535 yy== . Hence, we take 2 1.52535 y = at 0.4x= . To find the value of () 3 yy = for 0.6x= , we apply Euler’s method to have () () == + + 0 3 3 1.52535 .2 4 1.52535 yy = 1.85236 For better approximations, we use Euler’s modified formula and we obtain () ()() =++ ++ 1 3 .2 1.52535 .4 1.52535 0.6 1.85236 2 y 1.88496= () ()() 2 3 .2 1.52535 .4 1.52535 0.6 1.88496 2 y =++ ++ 1.88615= () ()() 3 3 .2 1.52535 .4 1.52535 0.6 1.88615 2 y =++ ++ 1.88619= () ()() =++ ++ 4 3 .2 1.52535 .4 1.52535 0.6 1.88619 2 y 1.88619,= correct to 5 decimal places. Since, () () 34 33 1.88619. yy== Hence, we take 1.88619y = at 0.6x= . Ans. PROBLEM SET 7.1 1. Solve by Taylor’s method, () ,01yx yy ′′′′′ =+ = . Computer () 0.1 .y [Ans. 1.11146] 2. Solve by Taylor’s method, () 2 ;01 dy x yy dx y =− = . Also compute () 0.1y .[Ans. 1.0954] 3. Given differential equation 2 1 dy dx xy = + with () 44.y = Obtain () 4.1y and () 4.2y by Taylor’s series method. [Ans. 4.005. 4.0098] 4. Apply Picard’s method to find the third approximation of the solution of dy dx = x + y 2 with the condition y(0) = 1. [Ans. = 1 3 2 4 3 23 ++ + +xx x ] 5. Using Picard’d method, obtain the solution of () () 3 1;03 dy xxyy dx =+ = Compute the value of () 0.1y and () 0.2y .[Ans. 3.005, 3.020] 352 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES 6. Solve the following initial value problem by Picard method y dy xe dx = with () 00y = , compute () 0.1y .[Ans. 0.0050125] 7. Use Picard’s method to approximate y when 0.2,x = given that dy xy dx =− with () 01y = . [Ans. 0.0837] 8. Use Picard’s method to approximate the value of y when 0.1x = , given that 2 3 dy xy dx =+ with () 01y = .[Ans. 1.12721] 9. Solve by Euler’s method () 2 0, 0 1, 0.1 dy yy h dx −= = = and [0,0.3]x∈ .[Ans. y(0.3) = 0512] 10. Apply Euler’s method to find the approximate solution of () ,01, 0.1 dy xyy h dx =+ = = and [] 0,1x ∈ .[Ans. 3.1874] 11. Obtain by Euler’s modified method for the numerical solution for () 1y of 1 dy y dx x − = + with () 32y = and 0.1h = .[Ans. y(1) = 0.94771] 12. Using Euler’s modified method, solve 1 dy y dx =− with y (0) = 0 in the range 00.2x≤≤ (take 0.1h = ). [Ans. y(0.1) = 0.09524, y(0.2) = 0.1814076] 7.6 RUNGE-KUTTA METHOD The method is very simple. It is named after two german mathematicians Carl Runge (1856-1927) and Wilhelm Kutta (1867-1944). These methods are well-known as Runge-Kutta Method. They are distinguished by their orders in the sense that they agree with Taylor’s series solution upto terms of h r where r is the order of the method. It was developed to avoid the computation of higher order derivations which the Taylors’ method may involve. In the place of these derivatives extra values of the given function () ,fxy are used. (i ) First order Runge-Kutta method Consider the differential equation () , dy fxy dx = ; () 00 yx y = (1) By Euler’s method, we know that () 10 00 0 0 , yyhfxy yhy ′ =+ =+ (2) Expanding by Taylor’s series, we get () 2 10 00 0 2! h yyxhyy y ′′′ =+=++ + (3) It follows that Euler’s method agrees with Taylor’s series solution upto the terms in h. Hence Euler’s method is the first order Runge-Kutta method. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 353 (ii ) Second order Runge-Kutta method Consider the differential equation () ,; dy fxy dx = () 00 yx y = Let h be the interval between equidistant values of .x Then the second order Runge-Kutta method, the first increment in y is computed from the formulae () () 100 001 2 12 , , 1 () 2 khfxy xhyk khf ykk = ++ = ∆= + Then, 10 xxh=+ () 10 0 12 1 2 yy yy kk =+∆=+ + Similarly, the increment in y for the second interval is computed by the formulae, () () 111 2111 12 , , 1 () 2 khfxy khfxhyk ykk = =++ ∆= + and similarly for other intervals. (iii ) Third order Runge-Kutta method This method agrees with Taylors’ series solution upto the terms in 3 h . The formula is as follows: () 10 1 2310 1 4; 6 yy k kkxxh =+ + + =+ where, () 100 , khfxy = 1 200 , 22 kh khfx y =++ () 30021 ,2 khfxhy kk =++− Similarly for other intervals. (iv) Fourth order Runge-Kutta method This method coincides with the Taylor’s series solution upto terms of 4 h . Consider the differential equation () , dy fxy dx = with initial condition () 00 yx y = . Let h be the interval between equidistant values of x . Then the first increment in y is computed from the formulae. () 100 , khfxy = 1 200 , 22 k h khfx y =++ 354 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES 2 300 , 22 k h khfx y =++ () 4003 , khfxhyk =++ Then () 10 1 2 34 1 22 6 yy k k kk =+ +++ and 10 xxh=+ Similarly, the increment in y for the second interval is computed by () 111 , khfxy = 1 211 , 22 k h khfx y =++ 2 311 , 22 k h khfx y =++ () 4113 , khfxhyk =++ Then, () 21 1 2 34 1 22 6 yy k k kk =+ +++ and 21 xxh=+ and similarly for the next intervals. Runge-Kutta Method for Simultaneous First Order Equations Consider the simultaneous equations () 1 ,, dy f xyz dx = () 2 ,, dy f xyz dx = With the initial condition () 00 yx y = and () 00 zx z = . Now, starting from () 000 ,, xyz , increments k and l in y and z are given by the following formulae: () 11000 ,, ; khfxyz = () 12000 ,, ; l hf xyz = 11 210 0 0 ,, 222 kl h khfx y z =+++ ; 11 220 0 0 ,, 222 kl h lhfx y z =+++ 22 310 0 0 ,, 222 kl h khfx y z =+++ ; 22 320 0 0 ,, 222 kl h lhfx y z =+++ () 410 0303 ,, khfxhykzl =+++ ; () 420 0303 ,, lhfxhykzl =+++ Hence, () 10 1 2 34 1 22 ; 6 yy k k kk =+ +++ () 10 1 2 34 1 22 6 zz l l ll =+ +++ To compute 22 ,, yz we simply replace () 000 ,, xyz by () 111 ,, xyz in the above formulae. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 355 Example 1. Apply Runge-Kutta Method to solve. () 1/3 dy =xy ,y 1 =1 dx to obtain y(1.1). Sol. Here, 00 1, 1 xy== and 0.1h = . Then, we can find () 100 , khfxy = ()() 1/3 0.1 1 1 0.1 == 1 200 , 22 k h khfx y =++ 1/3 0.1 0.1 0.1 1 1 0.10672 22 =+ + = 2 300 , 22 k h khfx y =++ 1/3 0.1 0.10672 0.1 1 1 0.10684 22 =+ + = () 4003 , khfxhyk =++ ()( ) 1/3 0.1 1 0.1 1 0.10684 0.11378 =+ + = 0.11378= ∴ () () 01234 1 1.1 2 2 6 yykkkk =+ + + + () 1 1 0.1 2 0.10672 2 1.0684 0.11378 6 =+ +× +× + 1 0.10682 1.10682=+ = . Ans. Example 2. The unique solution of the problem yxy ′ =− with y 0 = 1 is 2 /2 x ye − = . Find approximately the value of y (0.2) using one application of Runge-Kutta method of order four. Sol. Let 0.2,h = we have 0 1 y = when x 0 = 0. () 100 , khfxy = () 0.2[ 0 1] 0 == 1 200 , 22 k h khfx y =++ () 0.2 0.2 0 1 0 0.02 2 =−+ +=− 2 300 , 22 kh khfx y =++ 0.2 0.02 0.2 0 1 0.0198 22 =−+ − =− . Using Picard’d method, obtain the solution of () () 3 1;03 dy xxyy dx =+ = Compute the value of () 0.1y and () 0.2y .[Ans. 3.005, 3.020] 352 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES 6 + 1.0394 737= 350 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES Since, () () 34 11 1.039473, yy== correct to 6 decimal places Hence, we have () .1 1.039473.y = Ans. Example 22. Using. the order of the method. It was developed to avoid the computation of higher order derivations which the Taylors’ method may involve. In the place of these derivatives extra values of the given