Numerical methods for first order differential equations 473
Table 49.16
Euler’s Euler-Cauchy Runge-Kutta
method method method Exact value
x y y y y=x+ 1 +ex
0 2 2 2 20.1 2.2 2.205 2.205171 2.2051709180.2 2.41 2.421025 2.421403 2.421402758
0.3 2.631 2.649232625 2.649859 2.6498588080.4 2.8641 2.89090205 2.891824 2.8918246980.5 3.11051 3.147446765 3.148720 3.148721271Using the above procedure:
- x 0 = 1. 0 ,y 0 = 4 .0 and since h= 0 .2, and the
range is fromx=1.0 to x=2.0, thenx 1 = 1. 2 ,
x 2 = 1. 4 ,x 3 = 1. 6 ,x 4 = 1. 8 ,andx 5 = 2. 0
Letn=0 to determiney 1 :
- k 1 = f(x 0 ,y 0 )=f(^1.^0 ,^4.^0 );since
dy
dx
= 3 ( 1 +x)−y,f( 1. 0 , 4. 0 )= 3 ( 1 + 1. 0 )− 4. 0 =2.0- k 2 =f
(
x 0 +h
2,y 0 +h
2k 1)=f(
1. 0 +0. 2
2, 4. 0 +0. 2
2( 2 ))=f( 1. 1 , 4. 2 )= 3 ( 1 + 1. 1 )− 4. 2 =2.1- k 3 =f
(
x 0 +h
2,y 0 +h
2k 2)=f(
1. 0 +0. 2
2, 4. 0 +0. 2
2( 2. 1 ))=f( 1. 1 , 4. 21 )= 3 ( 1 + 1. 1 )− 4. 21 =2.09- k 4 =f(x 0 +h,y 0 +hk 3 )
=f( 1. 0 + 0. 2 , 4. 1 + 0. 2 ( 2. 09 ))=f( 1. 2 , 4. 418 )= 3 ( 1 + 1. 2 )− 4. 418 =2.182- yn+ 1 =yn+
h
6{k 1 + 2 k 2 + 2 k 3 +k 4 } and when
n=0:y 1 =y 0 +h
6{k 1 + 2 k 2 + 2 k 3 +k 4 }= 4. 0 +0. 2
6{ 2. 0 + 2 ( 2. 1 )+ 2 ( 2. 09 )+ 2. 182 }= 4. 0 +0. 2
6{ 12. 562 }=4.418733A table of values is compiled in Table 49.17. The
working has been shown for the first two rows.Letn=1 to determiney 2 :- k 1 = f(x 1 ,y 1 )=f( 1. 2 , 4. 418733 );since
dy
dx
= 3 ( 1 +x)−y, f( 1. 2 , 4. 418733 )= 3 ( 1 + 1. 2 )− 4. 418733 =2.181267- k 2 =f
(
x 1 +h
2,y 1 +h
2k 1)=f(
1. 2 +0. 2
2, 4. 418733 +0. 2
2( 2. 181267 ))=f( 1. 3 , 4. 636860 )
= 3 ( 1 + 1. 3 )− 4. 636860 =2.263140- k 3 = f
(
x 1 +h
2,y 1 +h
2k 2)= f(
1. 2 +0. 2
2, 4. 418733 +0. 2
2( 2. 263140 ))= f( 1. 3 , 4. 645047 )= 3 ( 1 + 1. 3 )− 4. 645047
=2.254953