Numerical Methods
Numerical Methods
,,.,,,--
.. l + O. l + 2 (0.000 3333) + 0.01 + 0.000001 333 + 0.00001666
: 1.110683993
--+----------Y
Fig. 10.1
= Y 1 hf(x1, Y1l
210 N11mc rfcnl M et11ods 11.1fth Program ln MA 11.AU
y(l\ = Yo+~[J(xo,Yo)+f(x1,Yil]
As the slope of the tangent at (x1 , y 1) is not krio\\11, we ~
the value of y 1 obtained from Eq. (14) in f(x • Y) and then
1 1
it in Eq. (15) to find the modified value of Yi·
To find next modified value of Y,, we put the ,-a1u,.,r •
f( • JI) ) to obtain the modified value of the slope ~t [. 1,'
XI' !:F I
then substitute . f (x- • y ) by J(xl'.•
it in Eq. (15), rep Iacmg 1 1
. h[ ·(
.1Jll
y(2\ = Yo+ 2 J(xo,Yo) + J x,,!t ~
i~ Note that the Euler's method agrees with the Taylor's series
solution up to term in h.
Therefore, Euler's method is the Runge-Kutta method of order
one.
Second order Runge-Kutta method
From Modified Euler's method, we have
•
ri al Methods wit. h Pr<ogram in MA7LAB
216 I
-------__ ,
Nume C r ' -------
[(!~1 +(~)J~h'J
2
= Yo +lif(xo,Yo)+ ~
= Yo + hfo + h 2 fo + O(h 3)
2
... (20)
... (21)
Comparing Eq. (20) and (21), it can be seen that the modified
Euler's
term in method
h2 • agrees With the Taylor's senes solution up to the
where
k1 = hf (Xo, Yo) and
Js = hf (Xo + h. Yo + k )
Third order ~UDge-Kutta method
1
/G, = hf ( Xo + ~ ,Yo + i)
., j
'•,
IC:3 = hf(~ + h. Yo + 21<:i - k )
rourth order Runge-Kutta method 1
k, = hf ( Xo + ~ ' Yo + i)
1s = hf ( Xo + ; . Yo + i)
k4 = hf(Xo + h. Yo + Js)
An important advantage of these methods is that the operation
ls identical whether the differential equation is linear or non-linear.
An important advantage of these methods is that the operation
..[21) ls identical whether he differential equation is linear or non-linear.
ed
Uie Example IO.IO Solve dy = -y where y(O) = lusing Runge-Kutta
dx
method of; (i) Second order; (ii) Third order and (iii) Fourth order
and obtain the values of y(O. l) and y(0.2).
Solution: Here, J(x, y) = - y, Xo = 0, Yo = l. x 1 = 0.1, X:i= 0.2
Q) Second Order Runge-Kutta method
k 1 = hf {x0 , ye) =(0.1) (- Yo) =- (0. l)
k;_ = hf (Xo + h. Yo + k1 )
= _ h (Yo+ k 1) = _ (0.1) (1-0.1) =- 0.09
1
y(O. l) = Y1 = Yo + 2 (ki + k 2 )
k1 = hf (x1 , Y1 ) = h (- y 1 ) =- 0.0904
ki = lif( X1 ~
+ •Y1 + :
1
) =-h(Yi+ i)
0
== -0.1(0.904- · 0904 ) = -0.08588
2
's == kh (xl + h. Y1 + kl) 2Js-
== - h (yl + kl) 2Js -
== - O. l (0.94- 0. 1717+ (0.0904) = - 0.0B2?"
-1
\ Numerical Solution 01 0
:1
d.
,-, mary Differenltal. Equations 219
\
==
0 904
· + ~ (-0.0904 - 0.34352 - 0.08227)
== 0.8179
(iii) Fourth order Runge-Kutta method
kl == hf (JCo, Yo) = - 0.1
Is_ = hf ( X1 + ~ ·Y1 + i)
= -0.1 ( 0.90633- 0.090633) = -0.086101
2
Js = hf (xi + ~ ,Y1 + i)
0.086101)
= -(0.1) ( 0.90633- 2 = -0.08632
Jy'dx = Jf(x,y) dx = j
X4
x0
X4
xo
X
xo
[
Yo+
I
nuyo
A /
+n(n-l)(n-2J_}lQ+
,::\ 2
+-n(n-I)--iF-
,13 ,
'j dx
· 31 .....
j4 y'dx =
7[f(xo,Yo) + n4f(xo,~o) + n(n-1) .12f(xo,Yo)
XQ X
0
3 2f dx
+n(n-I)(n -2) .1 f(xo,Yo)
31 + .....
Using x = Xo + nh, dx - hd
- n, we get
2
nfo + -n A~o
2
f' + l
( n3
- - - -
n 2) 11,
2f'
4
l (n4 2 3)· 2 JO
+-
6 -4- n 3 +n 2 113 fo + ..... .
0
Numc1ical Solution if
o OrcU11nrr1 lJtfJ ~·, ~
,,,,,.-- . . u , nlial l!.</1wttons L223
Y,1 == Yo +h
[
4J + 8
o
·
3
20
l.Vo +--t/· .t0 +~L'\::i
3 JO r j
+.!il\''
45 Jro-....
we neglect fourth and higher d
,-,tlues of differences or er differences and also use the
l1fo == (E - 1) fr == r _ r
1F O J1 Jo
!1:;o == (E - 1)2 fr == f.: _ 2 r r
3 0 2 U1 + Jo
l11o == (E - 1)3 fr - F 3tr
o - J3 - 'J2 + 3fi1 - ro
We get, J,
i
Y4 = Yo + h [ f1 - : f2 + f3] i
4
Y4 = Yo+ h[2f1 - f2 +2J3 ] ... (24)
3
Equation (24) is called the predictor formula which provides the
value of y 4 . To find a better approximation of y 4 , we find the first
a~proximation to /4 = f (Xo + 4h, yJ. Using this value of L in
Sunpson's rule we obtain a better approximation to y4 as
... (25)
We get 4
Y4 = Yo+ h[2f1 - f2 + 2J3]
3
4 5
= 2+ (0. ) (2(1.5680)- 2.2975 ;+- 2(3, 2340)1
3
\\
= 6.8710 . l )
Taking X4 = =
2, y 4 6.8710, we get 1t = f(.\p y~
= 4.4355
-, Numerical Solution of Ordin
ary DUferenttol Eq11r11irms
. 0 Milne Corrector formula 225
tJ~tll~
h
Yn+l = Yn- 1 + (fn- i + 4f. + f. )
3 n 11+1
,re get
= 3 595 o. 5
. + 3 (2.2975 + 4(3.2340) + 4.4355)
= 6.8732
V ing corrected value of y 4 , we get ii = f (x , _
rj s al f F4 • 4 4, Y,v - 4.4336
·•~iJlg this v ue o J 1n corrector formula, we get a bette;
•· .,;niation of y 4 as
appro~•·
h
Y4 = Y2 + 3 (f2 + 4f3 + f4)= 3.595 + 0. 5 (2 2975
3 .
HO. I)[
- 1 f-
3 2(0 0 l') J) 0 0-167 ;;,
- 1.01 897
Taking
x4 - 4 .4, Y 4 = 1.01897. we~
2- tJ~ 2 (1.0 l 7
5x4 5(-1.41
- 0 .04371
Us ing Milne Corrector formula
h
Y n+l - Yn - 1 + 3 (fn -J + 4fn + Jr, 41 )
We get h
Y4 - Y2 + (f2 + 4f 3 + 14 )
3
= 0.04373.
Using this value of -4 in corrector for mula, we get a
approximation of y 4 as