Beruflich Dokumente
Kultur Dokumente
Numerical Methods – II 2
2.1 NUMERICAL SOLUTION OF SIMULTANEOUS
FIRST ORDER ORDINARY DIFFERENTIAL
EQUATIONS
2.1.1 Runge-Kutta Method of Fourth Order
dy dz
1. Let = f (x, y, z), = g(x, y, z) be the simultaneous first order ordi-
dx dx
nary differential equations with the initial values y(x0 ) = y0 , z(x0 ) = z0 .
The modified form of expression for computation are as follows.
k1 = h f (x0 , y0 , z0 ); l1 = hg(x0 , y0 , z0 )
h k1 l1 h k1 l1
k2 = h f x0 + , y0 + , z0 + ; l2 = hg x0 + , y0 + , z0 +
2 2 2 2 2 2
h k2 l2 h k2 l2
k3 = h f x0 + , y0 + , z0 + ; l3 = hg x0 + , y0 + , z0 +
2 2 2 2 2 2
k4 = h f x0 + h, y0 + k3 , z0 + l3 ; l4 = hg x0 + h, y0 + k3 , z0 + l3
y(x0 + h) = y0 + k2
z(x0 + h) = z0 + l2
l4 = hg t0 + h, x0 + k3 , y0 + l3
1
x(t0 + h) = x0 + k1 + 2k2 + 2k3 + k4
∴
6
1
=1+ [0.1 + 2 × 0.1 + 2 × 0.1005 + 0.101]
6
= 1.100333
and
1
y(t0 + h) = y0 + l1 + 2l2 + 2l3 + l4
6
1
=1+ [0.1 + 2(0.11) + 2(0.11) + 0.12005]
6
= 1.1100083
Thus,
dy dz
= 1 + xz; = – xy given y(0) = 0, z(0) = 1 at x = 0.3.
dx dx
dy dz
= 1 + xz, = – xy and y(0) = 0, z(0) = 1
dx dx
l1 = hg(x0 , y0 , z0 ) = 0.3 [ – 0 × 0] = 0
h k l
k2 = h f x0 + , y0 + 1 , z0 + 1
2 2 2
h k l
l2 = hg x0 + , y0 + 1 , z0 + 1
2 2 2
h k l
k3 = h f x0 + , y0 + 2 , z0 + 2
2 2 2
h k l
l3 = h f x0 + , y0 + 2 , z0 + 2
2 2 2
k4 = h f x0 + h, y0 + k3 , z0 + l3
l4 = h f x0 + h, y0 + k3 , z0 + l3
1
y(x0 + h) = y0 + k1 + 2k2 + 2k3 + k4
∴
6
1
∴ y(0.3) = 0 + [.3 + 2(.345) + 2(0.34485) + 0.3893]
6
= 0.34483
48 Engineering Mathematics-IV
and
1
z(x0 + h) = z0 + l1 + 2l2 + 2l3 + l4
6
1
=1+ [0 + 2( – 0.00675) + 2( – 0.0077625) + ( – 0.03104)]
6
∴ z(0.3) = 0.98999.
dy dz
= f (x, y, z) and = g(x, y, z)
dx dx
and so on.
dy dz 2
= f (x, y, z) = x + z and = g(x, y, z) = x – y
dx dx
x x
∴ y = y0 + f (x, y, z) dx and z = z0 + g(x, y, z) dx
x0 x0
Numerical Methods–II 49
First approximation
x x
x2
y1 = y0 + f (x, y0 , z0 ) dx = 2 + (x + 1) dx = 2 + x +
2
x0 0
x x
1
z1 = z0 + g(x, y0 , z0 ) dx = 1 + (x – 4) dx = 1 – 4x + x2
2
x0 0
Second approximation
x x
1
y2 = y0 + f (x, y1 , z1 )dx = 2 + x + 1 – 4x + x2 dx
2
x0 0
3 2 x3
=2+x– x +
2 6
x x
1 2 2
z2 = z0 + g(x, y1 , z1 )dx = 1 + x– 2+x+ x dx
2
x0 0
3 2 3 x4 x5
= 1 + 4x + x –x – –
2 4 20
Third approximation
x
y3 = y0 + f (x, y2 , z2 )dx
x0
3 2 1 3 1 4 1 5 1 6
=2+x– x – x – x – x – x
2 2 4 20 120
x
z3 = z0 + g(x, y2 , z2 )dx
0
3 2 5 3 7 4 31 5 1 6 1 7
= 1 – 4x – x – x + x – x + x – x
2 3 12 60 12 252
and so on.
50 Engineering Mathematics-IV
when x = 0.1
h2 h3
y1 = y0 + hy0 + y + y ... (3)
2! 0 3! 0
h2 h3
z1 = z0 + hz0 + z + z ... (4)
2! 0 3! 0
Differentiating (1) and (2) successively we get y , z , etc.
So the values y0 , y0 , y0 . . . and z0 , z0 , z0 . . . are known. Substituting these
in (3) and (4), we obtain y1 , z1 for the next step.
Similarly,
h2 h3
y2 = y1 + hy1 + y + y ... (5)
2! 1 3! 1
h2 h3
z2 = z1 + hz1 + z + z ... (6)
2! 1 3! 1
Since y1 and z1 are known, we calculate y1 , y1 . . . and z1 , z1 . . . substituting
these in (5) and (6) we get y2 and z2 .
Proceeding further, we can calculate the other values of y and z step by
step.
Numerical Methods–II 51
dy dz
Example 1: Given = z and = – xz – y with y(0) = 1, z(0) = 0, obtain
dx dx
y and z for x = 0.1, 0.2, 0.3 by Taylor’s series method.
Hint:
We have
y = z and z = – xz – y
d2y dy
= f x, y, (1)
dx2 dx
dy d 2 y dz
Now, let = z then = .
dx dx2 dx
Substituting in (1)
dz
= f (x, y, z) with y(x0 ) = y0 and z(x0 ) = z0
dx
The problem reduces to solving the simultaneous equations
dy
= z = f 1 (x, y, z)
dx
dz
= f (x, y, z) subject to y(x0 ) = y0 and z(x0 ) = z0 .
dx 2
By Picard’s method we have
x x
y1 = y0 + f1 (x, y0 , z0 ) dx, z1 = z0 + f2 (x, y0 , z0 ) dx
x0 x0
x x
y2 = y0 + f1 (x, y1 , z1 ) dx, z2 = z0 + f2 (x, y1 , z1 ) dx
x0 x0
Numerical Methods–II 53
x x
x2
.2 2
= 0.5 + .1 – 0.2 – 0.5x dx, z2 = 0.1 + – 2x 0.1 – x – .5x
2 2
0 0
– (0.5 + 0.1x) dx
x3 x2 x2 x4 x3
= 0.5 + 0.1x – 0.2 – 0.5 , = 0.1 – .2 + 0.2 +1
6 2 2 4 3
x2
– 0.5x – 0.1
2
and so on.
when x = 0.1
y1 = 0.51 y2 = 0.5074
∴ y(0.1) = 0.5074
y (0.1) = 0.0488
d 2 y 3 dy 3 1
=x +x y with y(0) = 1, y (0) =
dx2 dx 2
dy d 2 y dz
Let =z so that =
dx dx2 dx
dy dz 3 3 1
∴ =z and =x z+x y with y(0) = 1, z(0) = .
dx dx 2
= f (x, y, z) = f 1 (x, y, z)
By Picard’s methods,
54 Engineering Mathematics-IV
First approximation
x x
y1 = y0 + f (x y0 z0 )dx z1 = z0 + f2 (x, y0 z0 ) dx
x0 x0
x x
1 1 1 3 1 3 3
=1+ dx = + x + 1x3 dx = + x dx
2 2 2 2 2
0 0
x 1 3x4
=1+ = +
2 2 8
Second approximation
x x
y2 = y0 + f (x, y1 , z1 ) dx z 2 = z0 + f (x, y1 , z1 ) dx
x0
x0
x
1 3x4 4
x
1 1 3x x
=1+ + dx = + x3 +
3
+x 1+ dx
2 8 2 0 2 8 2
0
x
x 3x5 x3 3 7 3 x4
1
=1+ + = + + x +x + dx
2 x0 2 2 8 2
0
1 x4 3x8 x4 x5
= + + + +
2 8 64 4 10
1 3x4 x5 3x8
+ + + .=
2 8 10 64
Example 3: Using Picard’s method find the solution of the equation
y + xy + y = 0, with y(0) = 1 y (0) = 0 for x = 0.1 and 0.3.
Solution: Given equation is
y + xy + y = 0 with y(0) = 1, y (0) = 0.
dy d2y dz
Let = y = z so that
2
= y =
dx dx dx
dy dz
∴ =z and = – xz + y with y(0) = 1, z(0) = 0
dx dx
= f (x, y, z), = f 1 (x, y, z).
56 Engineering Mathematics-IV
when x = 0.1
when x = 0.3
d2y dy
= f x, y, . . . (1) with y(x0 ) = y0 , y (x0 ) = y0 .
dx2 dx
dy d 2 y dz
Now, let = z so that =
dx dx2 dx
dy dz
∴ =z and = f (x, y, z)
dx dx
dy dz
= z = f 1 (x, y, z) and = f (x, y, z) with y(x0 ) = y0 and z(x0 ) = z0 .
dx dx 2
K1 = h f1 (x0 , y0 , z0 ) l1 = h f2 (x0 , y0 , z0 )
1 k1 l1 h k1 l1
K2 = h f1 x0 + h, y0 + , z0 + l 2 = h f 2 x 0 + , y0 + , z 0 +
2 2 2 2 2 2
h k2 l2 h k2 l2
k3 = h f1 x0 + , y0 + , z0 + l 3 = h f 2 x 0 + , y0 + , z 0 +
2 2 2 2 2 2
k4 = h f1 x0 + h, y0 + k3 , z0 + l3 l4 = h f2 x0 + h, y0 + h3 , z0 + l3
1 h
y1 = y0 + k1 + 2k2 + 2k3 + k4 z 1 = z0 + l1 + 2l2 + 2l3 + l4
∴
6 6
y = xy 2 – y2 with x = 0, y = 1, y = 0
dy
Let = z = f 1 (x, y, z), then
dx
dz 2 2
= xz – y = f 2 (x, y, z) with x0 = 0, y0 = 1, z0 = 0
dx
we compute k1 , k2 , k3 , k4 for f1 (x, y, z) and l1 , l2 , l3 , l4 for f2 (x, y, z).
∴ by Runge-Kutta formulae, we have
k1 = h f1 (x0 , y0 , z0 ) l1 = h f2 (x0 , y0 , z0 )
h k l h k1 l1
k2 = h f 1 x0 + , y 0 + 1 , z 0 + 1 l 2 = h f 2 x0 + , y 0 + , z 0 +
2 2 2 2 2 2
h k l h k2 l2
k3 = h f1 x0 + , y 0 + 2 , z 0 + 2 l 3 = h f 2 x0 + , y 0 + , z 0 +
2 2 2 2 2 2
= 0.2( – 0.0999) = – 0.02 = 0.2( – 0.9791) = – 0.1958
Numerical Methods–II 59
dy d 2 y dz
Let = z then = .
dx dx2 dx
Substituting in (1)
dz
= f (x, y, z) with y(x0 ) = y0 and z(x0 ) = z0
dx
The problem reduces to solving the simultaneous equations.
dy
= z = f 1 (x, y, z)
dx
dz
= f (x, y, z) subject to y(x0 ) = y0 , and z(x0 ) = z0 .
dx 2
The predictor and corrector formulae can be written as
4h
y(P)
n+1
= yn – 3 + 2y n–2
–y
n–1
+ 2yn
3
4h
z(P)
n+1
= zn – 3 + 2z n–2
–z
n–1
+ 2zn
3
and
h
y(c) = yn – 1 + y + 4yn + y
n+1 3 n–1 n+1
h
zn(c)+ 1 = zn – 1 + zn – 1 + 4zn + zn + 1
3
In particular when n = 3
(P) 4h
y4 = y0 + 2y1 – y2 + 2y3
3
(2)
(P) 4h
z 4 = z0 + 2z1 – z2 + 2z3
3
and
(c) h
y4 = y2 + y + 4y3 + y4
3 2
(3)
(c) h
z 4 = z2 + z2 + 4z3 + z4
3
(2) is called Milne’s predictor formula and (3) is called Milne’s corrector for-
mula.
60 Engineering Mathematics-IV
d2y dy
Example 1: Given 2
+ x + y = 0, y(0) = 1, y (0) = 0 obtain y for
dx dx
x = 0, 0.1, 0.2, 0.3 by any method. Further compute y(0.4) by Milne’s method.
Solution: The given equation is
Let y = z then y = z
∴ z + xz + y = 0 and y = z
dy
= y = z = f 1 (x, y, z) with y(0) = 1
∴
dx
dz
= z = f 2 (x, y, z) = – xz – y with z(0) = 0
dx
We use Taylor’s series method to find y. Differentiating (1) n times we get
yn + 2 + xyn + 1 + nyn + yn = 0
At x = 0, yn + 2 = – (n + 1)yn
0
and
h
y(0.4) = y(0.2) + y (0.2) + 4y (0.3) + y (0.4)
3
0.1
= – 0.9802 + [ – 0.196 – 1.1452 – 0.3692]
3
= 0.9232
d2y dy
Example 2: Given 2
+ 2x + y = 0 and y(0) = 0.5, y (0) = 0.1 obtain y
dx dx
for x = 0, 0.1, 0.2, 0.3 by any suitable method. Hence, apply Milne’s method
to compute y(0.4).
2
Example 3: Given y = xy – y2 and y(0) = 1, y (0) = 0 obtain y for
x = 0, 0.1, 0.2, 0.3 by Taylor’s series method. Hence, apply Milne’s method
to compute y(0.4).
Ans: y(0.4) = 0.9232
y + xy + y = 0 (1)
Let y = z then y = z
∴ z + xz + y = 0; y = z (2)
yn + 2 + xyn + 1 + nyn + yn = 0
At x = 0,
(yn + 2 )0 = – (n + 1)yn