0% found this document useful (0 votes)
443 views

R-K Method

This document discusses numerical methods for solving ordinary differential equations. It describes the Euler method and improved Euler method. It also introduces the Runge-Kutta method, which does not require higher-order derivatives and only requires evaluating the function at intermediate points.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
443 views

R-K Method

This document discusses numerical methods for solving ordinary differential equations. It describes the Euler method and improved Euler method. It also introduces the Runge-Kutta method, which does not require higher-order derivatives and only requires evaluating the function at intermediate points.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

6 UseModitl I

0-2).
1 , .

( 0 . 2 ) ,

( 0 ) =

y get y
t+Y» method,

(t Euler
Euler

log

Modificd given
(0-4)
M a t i f i e d

(0-2), y
y - y( ) =1.
Using

find y
7 method,

Euler's I m p r o v e d n
1.
y (0)
=

dy
method.

&UsingEn Euler
Improved

dx
= I using

y'=* y (0)
y'= +y,p r o b l e m s
p r o b l e m s
(1 0 - 1 1 ) :
(

given
given
the
d do
o )
(0-1)

Find
y Euler's
m e t h o d .

given
05
h =
1-1.
y (0)
=
Using
taking
(15) =y-1,
IaFindy

(0-4). h = 01, and


find y taking
1,
h=01,
y (0-5),
Ify'=1+yy
(0)= method to
calculate

I. improved
Euler's
Use h=01.
12 =y+siny (0)=2.
(1)= 1 if
logy-y logx,
y O-5.
05.
if y (1)
=

(16)ify=x dydx ify


1Find y given-=-
(1-2), y (1-4)
Euler to get y
14. Find by Improved
Euler method,
to get y (1-6) if
Modified
Euler and
15. Use Improved

i
dx f X
y(0)= 1.
0-25 to obtain y
(0-25), y (0-5).
given y (0) = 4, if h =

Solve y'=3r+y
16. 0:125.
'-;ry:y(1)=find y 2) if h =

17.
Given 2
y=-y,y (0) =2 if
method, given
18. Find y (0-2) by Improved Euler
h 0-1.
11 12. Runge-Kutta Method
differential equation
use of the previous methods to solve the
1abour
or due to
nerically is restricted due
to either slow convergence
Runge-Kutta
me,especially in Taylor-series method. But, in
S t h e derivatives of higher order are not required and we require
dy
AIM. To solve=fx, y) given y
dx (F%)= Yo .)
Proof. By Taylor series, we have,

yx+h)=y() +hy') +y)+0(h') .(2)


Differentiating the equation (1)
daton (1) w
w.r.t. x,
r
y +Y1,=f+f, 3
Using the values of
y' and y" got from (1) and (3), in (2), we get,
y+h)-y) =hf+ U. +f,+O)
Ay =hf+h G, +ff)+O(h')
Let
4)
Ay= k =fx, y). Ar=hf(x, y)
.(5)
Ay=k=hf(x+ mh, y+ mk)
and le Ay= akj + bk2 ..(6)
where a, b and m are ..(7)
of Ay.
constants to be determined to get the better
accuracy
Expand k, and Ay in powers of h.
Expanding k2, by Taylor series for two
k=hf(x+mh, y+mk;) variables, we have

=h S)+|mhm dx
2!

=h +mhf, +mhff, +"mhn


dx
2! ..(8)

since k, =hf
=hf+ mh (f, +f)+.
higher powers of h 9)
Substituting k, kz in (7),
Ay=ahf+bhft mk' (, +) + O(k*)
=
(a+b) hf+ bmh (f,
Equating Ay from (4) and
+)+O(h) ...(10)
(10), we get
EYI
381
DifereIl

Ordinary
NumericalSolution of
Colution Qf

higher powers of h
+5) + ...9)
hftmh (
in (7),
k, k2
+1)+o')
Substituting

G,
Ay=ahf+ bhf+mh' G, +fI)+ O(h) (10)
= (a +b) hf+bmh (10), we get
get
Ay from (4) and
Equating

..(11)
atb=l
and
bm2
bm =
two equations given by (1) to solve for three
we have only
Now

unknowns
a, b, m.

a+b=1,a=l-b
and also m= 2b using (7),
From

Ay= (1-b)k, +bk2


where
k =hflx. y)

4,h2y +2
Now Ay=y (x+ h) -y (x)
hf
y (+h)=y ()+(1-b) hf+bls x2 +25
i.e., Yn+1Y+ (1- b) hf yn)

From this general second order Runge-Kutta formula, setting


a=0,b=1, m=we get the second order Runge-Kutta algorithm as

k = hf x, y)

and
)|
Ay=K2 where h= Ar.
Second order R.K. algorithm

Since the derivations of third and fourth order Runge-Kutta


agorithms are tedious, we state them below for use.
ne third order Runge-Kutta method algorithm is given below:
k = hfx. y)

Third order

R.K. algorithm
kg=hf(x+h, y +2k2-k,)
and
Ay=k+4k +k)
382 algoritthm is m
mostly
ostl.

The fourth
order
Runge-Kutta
m e n t i o n e d . It
is
method
used n
otherwise
unless
problems

k =hf. )

Fourth order
k=hf R.K. algorithm
k =hfr +h, y +k)
and Ay=+24 +2kg +ka)

y(r+h)=y (x)+Ay
dy
Working Rule: To solve =f(% y),y ()=Yo
Calculate k =hflt% Yo
k=hf

k=hfl +h, yo tk)


and Ay=(k+2k+2kg +k)
6
where Ar =h.
Now y =Yo+ Ay.
Now starting from
2 ) etc.
(71, y1) and
repeating the process, we get
Note 1. In second order
Runge-Kutta method,

This is
exactly the
So, the Modified Euler method.
ModifiedRunge-Kutta method of second
Euler method. order is
Note 2. If
fr, y) nothing but the
=f), i.e.,
Runge-Kutta method only a
function x alone, then
reduces to the fourth
k =hfto) ordc
383
Solution of Ordinary Differential Equations
Numerical

yF4r h
= the area of y=f(®) between x=Xg and x
=x+h with 2

equal intervals of lengh by Simpson's one-third


,rule.
i.e., Ay reduces to the area by
Simpson's one-third rule.
afe 3, In all the three methods, (2nd order, 3rd order and 4th
order) the
values of ki, k2 are same. Therefore, one need not
repeat the work
while doing by all the three methods.
Example 1. Apply the fourth order Runge-Kutta method to find
that y =X+y. y (0) = I,.
y(0-2) given (Ap. 1992)
Solution. Since h 1s not mentioned in the question, we take
h 01
y=x+y:y (0)=1 f(&. y) =x+y, =0, yo=1
x =01,x2 02 =

By fourth order Runge-Kutta method, for the first interval,


k =hfl»Yo) (01)(%+ yo)= =
(0-1)(0+1)=01

;h Yo+k(0-1)f(005, 1405)
(01)(0-05+1-05) =0-11

= (01)f(0-05, 1-055) =(0-1)(0-05 + 1-055) =01105


k=hflto+h, yo+k) =0-12105
=
(01)f(0-1, 1-1105) =(0-1)(0-1+ 1-1105)
.
Ay k +2k +2k,+k)
0-110341667.
(0-1+0-22 +0.2210+ 0-12105)=
y(0-1)=y =yo+Ay=1-110341667 1-110342.
y). Again apply Runge-Kuta
from (x1, y) we get (r2.
vOW Starting
agorithm replacing (o Y) by (» Yi). 1-110342)=01210342

(0-1)0-1+
(0-1)%, +y)=
Yi) =
n = (0-1)f(0-15, 1-170859)

0-1320859

1-170859) =
(01)(0 15+
Numerical Method. OLD=-- 000
384 h +sk=(01)f015, 1-1763848)

+k) =
= (0-10 15 + 1-1763848)
(01)f(02, 1-24298048)
=
0-1326
1326384 -0-014
khfx+h, y
= 0:144298048
1-110342+ (0-7947RId
+2k, +K) 1008
=

y (0-2) =y (01) +k+2k


1-2428055
y (02) = O K 1)=-01
(0-2) = 1-2428.
Correct to four
decimal places, y
values of y at x 1 , 02 using R.K. method =

Example 2. Obtain the


third order and (it) fourth order for th
of (i) second order (ii)
differential equation y=-y, given y
(0) 1 (MKU 1971 =

Solution. Here, y)
f(x, *o=0, Yo= 1, x =01, x^ =02.
=-y,
(i) Second order:
pt(0)f(005
k =hflo» Yo) (0 1)-y,)=-01 =

-009525
k=hshSotk, =(01)/(005,095)
-0-1 x0-95 =-
0095 =Ay Hityl)=(01)f(01,0.98
yYo+Ay =1 0-095 -
= 0.905 -0090475
=y (0-1) =0-905
Again starting from (0-1, 0.905) replacing (xo. Yo) by (xj, y) we get
k= (01)ft1, y) = (01)(-0905) = - 00905

lat +,+k
=(0-1) f(0-15, 0-85975)] (01)(-0-85975) = =- 0085975
Ay=k ata })
Y y (02) =y, +Ay =0-819025 and
replaace
(ii) Third order:
k=hfo Yo)=-01 =-0490A
=- 0-095

k =hfo+h. yo+ 2k-k,)


=
(0-1)f(0-1,09) (0-1)(-09) =-0-09
=

Ay-k+ 4kg +k)


y
(0-1)=y =Yo+Ay = 1 -0.09 = 0-91
Again taking (x, y) as (xo. Yo) repeat the process
anary Differential
Numerical Solunon quations
k,hf(1, )1)=(01)-091) =-0-091 385

khf

(0-1)f(0-15,0-865)5)=(0-1)(-0-865) =-
00865
k=hfth, y +2k-k
(0-1)f (02,0828) = -0-0828

y=+Ay=091 +&1 +4k +k)


=091+-0-091-03460-00828)
y (0-2) = 0-823366
(i) Fourth order:
k=hflo Yo) =(0:1)f(0, 1) = -01

khf+h.Yotk|=01)f(005,095)=-0095
-hho*-01nso0s,09525) =- 0-09525

k=hfo+h, yo+ k)= (0-1)f(0-1,090475)


-0-090475
Ay=+2k,+2kg+k)
Yo+Ay=1+ (k+2k, +2k, +k)
=y (01) =09048375
Again start from this (x y) and replace (o, o) and repeat
khf , y) = (0-1)(-Y)=- 0-09048375

= (0-1)f(0 15, 0-8595956) = -0 cdot 08595956

-0 cdot 08618577
(01)f(0-15, 0 8618577)
=

ka= hfo, +h, y +k)


(01)f(02, 0-8186517)= -
008186517
4y -0-09048375-2x0-08595956
-2x0-08618577-00818651)
=- 0-0861066067

y ( 0 2 ) = y ,+ A y = 0 - 8 1 8 7 3 0 8 9

Tabular values are:

Third order
Fourth order
Exact vale
Second order y=e

0.91
0.90483775
0.904837413
0-905
0-1
0-823366
0-81873089
0-818730753
02 0-819025
closer to exact values.
more
values are
Fourth order

given
dy+y +xy=0, y (0)=1
Compute y(03) dx
Example 3.
order (corect to 4 deri mals
01 using RK
method of fourth
taking h =

=0, Yo=1, h=01,


Solution. y'=- (ry*+y) =flz, y)} , 0
= ?
0 2 , =03, y
For Ist interval:

(01) -(V6 + Yo)] 01


k =hfto Y) = = -

h
k=b otk(01)r(005,095)
=-0-1 [(0-05) (095)* +0:95]=-0-0995

= 9ot =(01s(005,095025
=(0-1) -(0-05 x 0-95025+ 1)
(0-95025) 1
=-0-09953987=- 0-0995
k4=hflo+h, yo+kz)
(0-1)f(0-1,0-9005) =-0-0982
=

=1+-0:1+2(-00995) +2 (-0-0995) -
0-0982]
y(0-1)=0-9006
Solution of Ordinary Differential Equations
Numerical Solution

387
ain taking ( Yi) in place of (o» yo) repeat the process.
(0-1)f(01,0.9006
=

k =hf(1 ))=-0-0982
h
k= =(0 1)f(015,08515
= - 0-0960

* 01so15,0852
= -0-0962

k=hf +h, y +k,) = (01)f(02,08044)


=- 0-0934

=++2+2k,+k)
=0-9006+-00982+2 x(-0-0960) +2 (-00962)

y (0-2) =0-8046
+(-0-0934)]
Again, starting from (x2 ) in place of (o Yo)

k,=-00934, k^=-0-0902, k^=--0-0904, k=-00867


=2+Ay=>tk1+2ka +2k, +k)
y (0:3) =0-7144
Example 4. Using R.K. method of fourth order, find y (0-8) correct
to 4 decimal places if y' =y -x, y (0-6) = 17379.
(April 1991
Solution. Here, xo=0-6, yo 1-7379, h = 0 1,x =07,x, =08
=

f% y) =y-x
By R.K. method of 4th order

Yo+, +2ka +2kg +k) ..(1)


where
khft Yo) =(0-1)f(06, 1-7379)
= (0-1) [1-7379-(06)1=01378

(0-1)f(0-65, 1-8068) =(01) [1:-8068-(0-65)1 =0-1384

=
(0-1)f(0-65, 1-8071)
(0-65)1=0-1385
Pinods-N
= (01) [1-8071
k= hfo +h, yo +ka)=(01)f(07, 1-8764)
=(0-1) [(1-8764)- (0-7)1=0-1386
Hence, using (1),
y (0-7)=Y=17379+ [0O1378+2 (01384) +2 (0-1385) +0130.
y (0-7)=18763.
1386
To find y2 =y (0-8), we again start from (x, Y1) (0-7, 18763)
=

Now,
+ k +2k2 +2k +kl
where
k =hf. y) =(0-1) [1-8763-(0-7)]=0-1386
+y+ =(01)f(075, 1-9456)
= (0-1) [1-9456-(0-75)j=01383

(0-1)f(0-75, 1-9455)
= (0-1) [1-9455 - (0-75)]=0-1383
k=hf* +h, y +ki)
=
(0-1)f (O-8, 2-0146)
= (0-1) [2-0146-(0-8)]=0-1375
Using (2),.
y2=y (0-8) =
1-8763 + [0-1386+2 (1-1383) +2 (1-1383) +01375
2-0145
2 y (08)=20145
Example 5. Using
Runge-Kutta method
dy-
dx42 8tven y(0) =l atx= 02, 0-4.
of fourth order, sove
(MS. April 92)
Solution. =f&)= (Anna Ap. 2005)
(Anna Nov. 2004)
Here
0 , h =02, x =0-2, 7
=04. yo=1
f t Yo)=f0, 1)
=1+0 =1
k= hf o» Yo) (0-2) x1 =0-2
=

ka=h5h.ok (0-2)f(0-1, 11)


of Ordinary
of
Ordin Diferential Equations
Solution

389
(1-1-01
Numerical

(0-2)L11+(0-1121+001
1-21+001
-001]|
= 0-1967213

'

(0-2)01, 1+(1967213
(0-2)f(01, 10983606)

= (0-210983606-(001 |-0
L(10983606 +(0-01)J 1967
01967
k=hfCo+ h, yotk)
= (0-2)f(02, 1-1967)
(0-2)967)*-(02?]

(1:1967+(02 189t

Ay=k+2k +2k,+4
= 6[0-2+2(0-19672)+2 (1-1967) +01891]
= 0-19598
119598.
y(0-2)=y=YotAy =

Again to find y (04), start from ( , y) = (02. 1-19598).

Now,
(1-19598)-(02 0-1891
k hfCa y) (02)
=

(1-19598)+ (0-27J
Ahyi* |=02/03,129059
=(02) 29055)-(03
L(1-29055)+(0-3317949

k= (02)f (03, 1-28572) = 01793

1-37528)
k= (0-2)f (0-4, y, +k,)= (0-2)f(04,
= 0-1687

Ay=+2k,+2k,+k)
(0-1793) +0-16871
101891 +2 (01795)
+2

= 0-1792
Numer

390
13751
Y, +Ay=
y (04) = simultaneous
first order differe
ren.
method for
1114. Runge-Kutta
tial equations
the
simuluneous ons dx
cquation / a.y,,
numerically
AIM. To solve

initial
conditions y(4%) =Yo» 2 (o) =z,
y, ) given the
a n d / (1.,
dx and z are dependent.
is independent
variable while y
Here, and Az in y and.
the increments Ay
Now. starting from (o» Yo» 2g)
respectively are given by formulae,
o)
k hf, (on o

ot)
k =hfi (o+h, yo +k
Ay=k+ 2 k +2k+k,) where h
=Ar

4=hf (o+h, yotkg, 20t l)

Az=,+ 21 +21 + l
y o + Ay and z =20 + Az.

Having got (. y1, Z1) we get (x7, y2, 3») by repeating the abo
algorithm once again starting from (1, y1, Z)
If we consider the second order
Runge-Kutta method, then
k= hf Mo Yo» o)
Ordinary Ditferential Equations 391
N u m e r i c aS
t olution
of

Ay=k

and

Az=l

=otn,
y +Ay,
=Jot z1=+ Az.
4,
y (01),2 (0-1) from the system of equations,
Then

E x a m p l e
6. Find
r - y given y (0) = 2, z (0) = I using Runge-Kutta method
d
dt
o ff o u r t h o r d e r .

dy =X+, =x-y?
Solution. Now
dx dx
2) =x-y
f y ,2)=X+2h&, y,
01,h=01
=0, o=2,
We use
0
k =hf; Fo»Yo =hf2 (o Yo o)
K

k2

k =hf o + h, yo t kg, Z + ) 4=hf o +h, yo +k, 2o+)


Ay=4+2k+2kg +k) a+2 +2,+
We will calculate k; and l; and then to k;+1

k =(0-1)f (0,2, 1) 4=(01)h 0,2, 1)


=(0-1) (0+ 1) (0-1) (0-2)
01
=-0-4
k=(0-1)f(0-05, 205,08) h= (01)/2 005, 2-05, 08)
(0-1) (0-05+08) =(0-1)(0-05-(205 1
0-085 :-0-41525

=(01)f(005, 2-0425,0-79238) =(0-1)f (0-05, 2-0425,0-79238)


=(0-1) (0-05+079238) = (0-1) [0-05-(20425) 1
0-084238 -0-4122
Numerical Methods-v

392
-(2-084238) )
2-084238,05878); | 4=(0:1) (0-1
k=(01)f(01, -042444
= (0-1) (0-1 +0-5878)
0-06878
2-0845
[0-1+2 (0-085
+0-084238) +0-06878]=
=2+
=1+-04-(0-41525 +0-4122) x2-04244]
6
0-5868

y (0-1)=20845
andz (0-1) =0-5868&
differential equation
method for second order
11-15. Runge-Kutta
AIM. To solve y, y ), given y (T)=yo» y o)=yo.
y" =f(x,
Now, set y'=z andy"=z
Hence, differential equation reduces to

dx
and
dx are simultaneous equations

dy where f (a, y, z) =z
dx , y , 2) =f(x, y, z) given.
and =f(x, y, 2) Also y (0) and z (0) are given.

Starting from these equations, we can use the previous article and
solve the problem.
1,y (0) 0, find the value
Example 7. Given y" +xy +y=0, y (0)
= =

of y (0-1) by using Runge-Kutta method of fourth order


Solution. y'=-y-y. y (0) =1,y (0) =0, h =0-1, yo=l,

=0,=y (0-1)
Setting ý=z
The equation becomes,

y'=d=-xz-y
dy 1)
f (,y, z)
- - y = f t, y, 2)
given oz1,%=o=0.
By algorithm.
=0
khh o o. 2o)= (0-1)f, (0, 1,0)= (0-1) 0)
h o Yo» 2g) =(0-1)s, (0, 1,0) = (-1) (0-1)=-0-1
S o l u t i o n
of O r d i n a .

Dyerental Equations
Dyjerenlial Equ
Numerical
393

(01)S (005, 1,--005)=


=
(01)(-005) - 0005
(0-1) (005, 1,-0-05) =
(0-1) 1+ (0-05) (0-05)- 11
-0-09975
h

=
(01), (0-05,09975,-00499)
=(0 1) (-0-0499)- 0-00499
hf2(0-05,09975, -00499)
= -

(0-1) [CO-05) (-0-04991) +09975]


= -0-09950
k =hfi (o+h, yotk3,otl)
(0-1)f, (01,099511,-0:0995)
= (0-1) -0-0995)=-000995
4=hf2 (0-1,0.99511,-0-0995)
=(0-1)- (0-1) (-00995)+099511) ]
= - 0-0985

y=Yo+Ay= 1+[0+2(-0-005)+2-000499) -000995


= 0.9950

y (0-1)=0-9950.

EXERCISE 11.4

Evaluate using Runge-Kuita methods. Unless otherwisee mentioned, use fourth


order R.K. method.

. Find y (0-2) given = y - x , y (0) = 2 taking h =01.


dx

2. Evaluate y (1.4) given dy=X+y, y (1-2) =2.


dx
3. Obtain the value of y at x= 02 if y satisfies

dy
d-*y=xy
dx
(0)= 1 taking h =01.

4.Solve =xy forx= 14, taking y (1) =2, h=02.


dx
5. Solve: y-= given y(0) = 1, to obtain y(02)

6, Solve the initial value problem


interval (0, 0-6) by sing fourt
using
394 =02 on
the
h
d-2u2,u (0) = 1 with
(Nov. 199
dt
order R.K. method.
(03) given
(0-2), y
for y (0.1), y
Evaluate

7.
y = 5 ( 1 + ) y y ) = 1 .

=005.
S o l v e : + = y ( 1 ) =
1 for y(1-1) taking h
8. (0)=1.
0:5 given y'= '
taking h
=
x+y
(1-5), y (2)
(0-5), y (1), y
9. Find y
2xy +
'y (1) =0.
'Y(1)=0. (MS. Ap. I198

10.
Evaluate y (1-2)
and y (1-4) given y'=
dy 1+y,y (0) =0.
(0-2) 0-6 given dx
11. Find y
for r= 0-2

02 by R.K. method of 4thh


1, taking h
=

-y, y (0)
=

12. Find y (0-2) given

order. (0) =
1 taking h
= 0-1 by (1) second
y=x-2y, y
13. Find y (0-1). y
(0-2) given
order R.K. method.
third order and fourth
order,
R.K method given= given
14. Determine y at x=0:2 (0-2) (0-6) by
y (0) =0.

15. Find y (02) given


of 4th order.
1 by using Runge-Kutta method
y=3x+y, y (0)
=

2, taking h=02.
x =02, 04, 0-6 given y (0)
=

16. Solve y'=xy+ 1 as

(12).
17. Given =r+5y.y() =2, find y (1-1),y
Solve 10y=x+y, given y (0)=
1 for x =0-1 (0-1) (0-3)
18.
Solve 8y =x+y given y (0) =0-5
for x =0-1 (0-1) (0-4).
19.
r=.
20. Solve the system: =x+1, = -y for x= 0:3 (O-3) (0-9) taking
(MKU 1979)
y=0, z = 1.
taking
21. Solve: = x + , = x - y , given y (0)=0,z (0) = 1 for x = 0-0 to

h= 01.
22. Solve dy dz given y (0) = 1, z (0) = 1 for r=0 (0-2) (04
dx
23. Evaluate y (1-1),z (1-1) given=zyz,=y (1)=1/3, z (1)=l

24. Using R.K, method determine r (0-1) v (0-1) oiven =ry +, X(

You might also like