Module 5 Numerical Methods 2
Module 5 Numerical Methods 2
MODULE-5
In this module we solve first order and first degree ordinary differential equations
of the form
dy
f ( x, y ) with y ( x0 ) y0
dx
2) MODIFIED EULER’SMETHOD
dy
f ( x, y ) with y ( x0 ) y0
dx
Let y y( x) be the solution of this problem.
Working Rule:
dy
Given x0 , y0 and y1 ( x) f ( x, y )
dx
Find y1 ( x0 ) by replacing x by x0 and y by y0
Differentiate y1 ( x) w.r.t. x , we get y2 ( x) .
Then replace x by x0 , y by y0 and y1 by y1 ( x0 ) we get y2 ( x0 )
Differentiate y2 ( x) w.r.t. x , we get y3 ( x) and etc.
Then replace x by x0 , y by y0 , y1 by y1 ( x0 ) and y2 by y2 ( x0 )
We get y3 ( x0 )
and etc.
Problems:
( x x0 ) ( x x0 ) 2 ( x x0 )3 ( x x0 )
4
y ( x) y ( x0 ) y ( x0 ) y2 ( x0 ) y3 ( x0 ) y4 ( x0 ) ...
1! 1
2! 3! 4!
But given x0 0 , then
4
y(0) 1
y1 ( x ) x 2 y 2 y1 (0) 02 12 1
x x
3 4
y x = 1+ x + x 2
+4 +7
3 6
Put x 0.1& x 0.2 we get
0.1 0.1
3 4
0.2 0.2
3 4
dy
2) Solve = e x - y with y 0 = 2 using Taylor’s series method up to 4th
dx
degree terms and find the value of y 1.1
( x x0 ) ( x x0 ) 2 ( x x0 )3 ( x x0 )
4
y ( x) y ( x0 ) y ( x0 ) y2 ( x0 ) y3 ( x0 ) y4 ( x0 ) ...
1! 1
2! 3! 4!
But given x0 0 , then
4
y(0) 2
y1 ( x) e x y y1 (0) e0 2 1 2 1
y2 ( x) e x y1 y2 (0) e0 1 2
y3 ( x) e x y2 y3 (0) e0 2 1
y4 ( x) e x y3 y4 (0) e0 1 2
4
( x) ( x) 2 ( x) 3 ( x)
(1) y ( x) 2 (1) (2) (1) (2)
1! 2! 3! 4!
x x
3 4
y x = 2 - x + x 2
+
6 12
Put x 1.1
1.1 1.1
3 4
dy
3) Using Taylor’s series method, solve the initial value problem = x2 y - 1
dx
with y(0) = 1 at the point x = 0.1
( x x0 ) ( x x0 ) 2 ( x x0 )3 ( x x0 )
4
y ( x) y ( x0 ) y ( x0 ) y2 ( x0 ) y3 ( x0 ) y4 ( x0 ) ...
1! 1
2! 3! 4!
But given x0 0 , then
4
y(0) 1
y1 ( x) x 2 y -1 y1 (0) 0(1) 1 1
y3 ( x) x 2 y2 2 xy1 2 xy1 y
y3 (0) 0 0 2 1 2
x 2 y2 4 xy1 2 y
y4 ( x) x 2 y3 2 xy2 4( xy2 y1 ) 2 y1
y4 (0) 0 0 6 1 6
x y3 6 xy2 6 y1
2
4
( x) ( x) 2 ( x)3 ( x)
(1) y ( x) 1 (1) (0) (2) (6)
1! 2! 3! 4!
x x
3 4
y x = 1- x +
3 4
Put x 0.1
0.1 0.1
3 4
y 0.1 = 1- 0.1 +
3 4
= 0.9003
Practices problems
1) Using Taylor’s series method, find y at x = 0.4 of the initial value problem
dy
= x 2 y + 1 with y 0 = 0 considering up to 4th degree terms
dx
2) Using Taylor’s series method, find y 0.1 considering up to 4th degree
dy
terms, given that = x - y 2 with y 0 = 1
dx
dy
3) Using Taylor’s series method, solve = x 2 + y in the range 0 ≤ x ≤ 0.2 by
dx
taking step size h = 0.1 , given that y = 10 at x = 0 initially, considering up to
4th degree terms.
dy 1
5) Use Taylor’s series method to find y 4.1 given that = 2 with
dx x + y
y 4 = 4
6) Employ Taylor’s series method to find y at x = 0.1 & x = 0.2 given that
dy
- 2y = 3e x with y 0 = 0 considering up to 4th degree terms
dx
MODIFIED EULER’SMETHOD
Consider the initial value problem
dy
f ( x, y ) with y ( x0 ) y0
dx
We determine the solution y at x1 x0 h by using Euler’s formula
y10 = y0 + hf x0 , y0
y11 = y0 +
h
2
f x0 , y0 + f x1 , y10
2nd approximation (2nd modification)
y1 2 = y0 +
h
2
f x0 , y0 + f x1 , y11
3rd approximation (3rd modification)
y1 3 = y0 +
h
2
f x0 , y0 + f x1 , y1 2
…etc
Note:1) First we decide to do the problem in one stage or in two stages depending
on the asking value of y at x1 x0 h or x2 x0 2h
3) To perform 2nd stage of the problem by taking x1 x0 and y1 y0 then use same
set of formula
Working Rule:
dy
Given x0 , y0 and f ( x, y )
dx
y1 2 y0
h
2
f x0 , y0 f x1 , y11
and etc.
Finally we get y1 x1
Problems:
dy
1) Use Modified Euler’s method to solve = x + y with y 0 = 1 at x = 0.1
dx
for three iterations, taking h = 0.1
Solution:
y11 y0
h
2
f x0 , y0 f x1 , y10
h
y1 2 y0
2
f x0 , y0 f x1 , y11
y13 y0
h
2
f x0 , y0 f x1 , y1 2
Hence
y 0.1 = 1.1105
dy y + x
2) Solve by Euler’s modified to obtain y 1.2 given that = with
dx y - x
y 1 = 2 carryout three modification
Solution:
yx
Given f x, y , x0 1, y0 2, x1 1.2 and h x1 x0 0.2
yx
h
y11 y0
2
f x0 , y0 f x1 , y1 0
h
y1 2 y0
2
f x0 , y0 f x1 , y11
h
y13 y0
2
f x0 , y0 f x1 , y1 2
Hence
y 1.2 = 2.5745
dy y
3) Given = 1+ , y = 2 at x = 1 . Find ‘y’ at x=1.4 by taking h=0.2.
dx x
Applying Modified Euler’s Method.
Solution: Given
y
f x, y 1 , x0 1, y0 2, h 0.2, x1 x0 h 1 0.2 1.2,
x
x2 x1 h 1.2 0.2 1.4
find both y1 and y2 in two stage
First stage:
y11 y0
h
2
f x0 , y0 f x1 , y1 0
y1 2 y0
h
2
f x0 , y0 f x1 , y11
0.2
2
2
f 1, 2 f 1.2, 2.6167 2.6181
y13 y0
h
2
f x0 , y0 f x1 , y1 2
0.2
2
2
f 1, 2 f 1.2, 2.6181 2.6182
y(1.2) 2.6182
y10 y0 hf x0 , y0
h
y11 y0
2
f x0 , y0 f x1 , y1 0
0.2 f 1.2, 2.6182 f 1.4,3.2546 3.2689
2.6182
2
h
y1 2 y0
2
f x0 , y0 f x1 , y11
0.2 f 1.2, 2.6182 f 1.4,3.2689 3.2699
2.6182
2
y13 y0
h
2
f x0 , y0 f x1 , y1 2
dy = x - y 2 , y 0 = 1
4) Solve at x = 0.2 correct to four decimal places,
dx
by taking h=0.1. Use Modified Euler’s Method.
Solution: Given
find y1 and y2
y11 y0
h
2
f x0 , y0 f x1 , y10
h
y1 2 y0
2
f x0 , y0 f x1 , y11
y13 y0
h
2
f x0 , y0 f x1 , y1 2
h
y11 y0
2
f x0 , y0 f x1 , y10
h
y1 2 y0
2
f x0 , y0 f x1 , y11
y13 y0
h
2
f x0 , y0 f x1 , y1 2
y(0.2) 0.8504
Solution: Given
First stage:
y11 y0
h
2
f x0 , y0 f x1 , y1 0
h
y1 2 y0
2
f x0 , y0 f x1 , y11
y13 y0
h
2
f x0 , y0 f x1 , y1 2
y(0.2) 1.2309
h
y11 y0
2
f x0 , y0 f x1 , y1 0
h
y1 2 y0
2
f x0 , y0 f
0.2 f 0.
1.2309
2
yy
1
3
0 2
h
0 0
f x ,y f x ,y
1 1
2
0.2
1.2309
2
f 0.2,1.2309 f 0.4,1.5253 1.5253
y (0.4) 1.5253
Practices Problems:
i.e. y(x1 ) = y0 +
1
6
k1 +2k2 +2k3 +k4
Where
k1 = hf(x0 , y0 )
h k
k2 = hf(x0 + , y0 + 1 )
2 2
h k
k3 = hf(x0 + , y0 + 2 )
2 2
k4 = hf(x0 + h , y0 + k3 )
Problems:
dy = x + y, x = 0, y = 1at x = 0.2
1) Solve . Using Runge-Kutta method,
dx
take h=0.2
Solution:
Given f ( x, y) x y, x 0, y 1, h 0.2
0 0
y( x h) y 1 (k 2k 2k k ) (1)
0 0 6 1 2 3 4
Dr.Dinesh A C, Associate Professor, Dept. of Mathematics, BIT
Bangalore Institute of Technology
h k1
k2 hf ( x0 , y0 ) 0.2 f (0.1,1.1) 0.24
2 2
h k2
k3 hf ( x0 , y0 ) (0.2) f (0.1,1.12) 0.244
2 2
1
(1) y (0.2) 1 0.2 2(0.24) 2(0.244) 0.2888
6
y(0.2) 1.2428
Solution:
yx
Given f ( x, y ) , x 0, y 1, h 0.2
yx 0 0
y( x h) y 1 (k 2k 2k k ) (1)
0 0 6 1 2 3 4
h k1
k2 hf ( x0 , y0 ) 0.2 f (0.1,1.1) 0.1667
2 2
h k2
k3 hf ( x0 , y0 ) (0.2) f (0.1,1.0835) 0.1662
2 2
1
(1) y (0.2) 1 0.2 2(0.1667) 2(0.1662) 0.1414
6
y(0.2) 1.1679
Solution:
y 2 x2
Given f ( x, y ) 2 , x 0, y 1, h 0.2
y x2 0 0
y( x h) y 1 (k 2k 2k k ) (1)
0 0 6 1 2 3 4
h k1
k2 hf ( x0 , y0 ) 0.2 f (0.1,1.1) 0.1967
2 2
h k2
k3 hf ( x0 , y0 ) (0.2) f (0.1,1.0984) 0.1967
2 2
1
(1) y (0.2) 1 0.2 2(0.1967) 2(0.1967) 0.1891
6
y(0.2) 1.1960
Solution:
Given f ( x, y ) x 2 y , x0 0, y0 1, h x1 x0 0.1 0 0.1
y( x1 ) y 1 (k 2k 2k k ) (1)
0 6 1 2 3 4
h k1
k2 hf ( x0 , y0 ) (0.1) f (0.05, 1.05) 0.1047
2 2
h k2
k3 hf ( x0 , y0 ) (0.1) f (0.05, 1.0523) 0.1049
2 2
1
(1) y (0.1) 1 0.1 2(0.1047) 2(0.1049) (0.1094)
6
y(0.1) 1.1047
y
Given f ( x, y ) 3x , x 0, y 1, h 0.2
2 0 0
y( x1 ) y 1 (k 2k 2k k ) (1)
0 6 1 2 3 4
h k1
k2 hf ( x0 , y0 ) (0.2) f (0.1,1.05) 0.165
2 2
h k2
k3 hf ( x0 , y0 ) (0.2) f (0.1,1.0825) 0.1682
2 2
1
(1) y (0.2) 1 0.1 2(0.165) 2(0.1682) (0.2368)
6
y(0.2) 1.1672
Practice Problems:
dy
1) Use Runge–Kutta method of fourth order, solve ( x y ) 1
dx
y(0.4) 1, h 0.1 . Find ' y ' at x 0.5 . Correct to four decimal
places.
dy
2) Use Runge–Kutta method of fourth order, solve x y 2 with
dx
y(0) 1. Find ' y ' at x 0.1 taking h 0.1
dy
3) Use Runge–Kutta method of fourth order, solve xy1/ 3 with
dx
y(1) 1 . Find y(1.1)
dy
4) Use Runge–Kutta method of fourth order, solve 3e x 2 y with
dx
y(0) 0 . Find y (0.1) taking step length h 0.1
dy
5) Use Runge–Kutta method of fourth order y 2 x at x 1.1 given
dx
that y 3 at x 1
6) Apply Runge–Kutta method of fourth order, to find y (0.1)
dy
y xy 2 0, y (0) 1 taking h 0.1
dx
dy
Consider the initial value problem f ( x, y ) with
dx
x x0 x1 x2 x3
y y0 y1 y2 y3
Predictor Formula:
4h
y4 (p) = y0 +2f1 - f 2 + 2f 3 where f 1 = f(x1 , y1 ), f 2 = f(x2 , y2 ), f 3 = f(x3 , y3 )
3
To improve this value, we use corrector formula.
Corrector Formula:
y4 (c) = y2 +
h
3
f 2 + 4f 3 + f 4 (p) where f 4 (p) = f(x4 , y4 (p) )
Note: 1) If x4 and y4 values are given in the table, then we have to find y5
at given x5 by using
4h
y5 (p) = y1 + 2f 2 - f 3 + 2f 4 where f 2 = f(x2 , y2 ), f 3 = f(x 3 , y3 ), f 4 = f(x4 , y4 )
3
y5 (c) = y3 +
h
3
f 3 + 4f 4 + f 5 (p) where f 5 (p) = f(x5 , y5 (p) )
(OR) If x4 and y4 values are given in the table, then ignore x0 and y0 from
the given data then we use same set of formulas and find y4( p ) & y4( c )
x y f ( x, y )
x0 y0 f0 f ( x0 , y0 )
x1 y1 f1 f ( x1 , y1 )
x2 y2 f 2 f ( x2 , y2 )
x3 y3 f3 f ( x3 , y3 )
x4 y4( p ) f 4( p ) f ( x4 , y4( p ) )
Problems:
1) Given
dy
xy y 2 , y (0) 1, y (0.1) 1.1169, y (0.2) 1.2773, y (0.3) 1.5049.
dx
Find y (0.4) using Milne’s Predictor-Corrector method.
Solution:
x y f ( x, y )
x0 0 y0 1 f0 1
x1 0.1 y1 1.1169 f1 1.3592
x2 0.2 y2 1.2773 f 2 1.8870
x3 0.3 y3 1.5049 f3 2.7162
x4 0.4 y4( p ) 1.8352 f 4( p ) 4.1020
4h
y4 (p) = y0 + 2f 1 - f 2 + 2f 3
3
4(0.1)
=1+ 2(1.3592) -1.8870 + 2(2.7162) = 1.8352
3
y4 (c) = y2 +
h
3
f 2 + 4f 3 + f 4 (p)
0.1
= 1.2773 + 1.887 + 4(2.7162)+ 4.102 = 1.8391
3
y(0.4) 1.8391
dy
2) Use Milne’s method find ' y ' at x 0.8 . Given x y 2 with
dx
X 0 0.2 0.4 0.6
Y 0 0.02 0.0795 0.1762
Solution:
x y f ( x, y )
x0 0 y0 0 f0 0
x1 0.2 y1 0.02 f1 0.1996
x2 0.4 y2 0.0795 f 2 0.3937
x3 0.6 y3 0.1762 f3 0.5690
x4 0.8 y4( p ) 0.3050 f 4( p ) 0.7070
4h 4(0.2)
y4 (p) = y0 + 2f1 - f 2 + 2f 3 = 0 + 2(0.1996) - 0.3937 + 2(0.569)
3 3
0.3050
y4 (c) = y2 +
h
3
f 2 + 4f 3 + f 4 (p)
0.2
= 0.0795 + 0.3937 + 4(0.569)+ 0.707 0.3046
3
y(0.8) = 0.3046
1
3) If y ' , y (0) 2, y (0.2) 2.0933, y (0.4) 2.1755, y (0.6) 2.2493.
x y
Find y 0.8 byMilne'smethod
Solution:
x y 1
f ( x, y )
x y
x0 0 y0 2 f0 0.5
x1 0.2 y1 2.0933 f1 0.4360
x2 0.4 y2 2.1755 f 2 0.3882
x3 0.6 y3 2.2493 f3 0.3509
x4 0.8 y4( p ) 2.3161 f 4( p ) 0.3209
4h
y4 (p) = y0 + 2f 1 - f 2 + 2f 3
3
4(0.2)
=2+ 2(0.436) - 0.3882 + 2(0.3509) 2.3161
3
y4 (c) = y2 +
h
3
f 2 + 4f 3 + f 4 (p)
0.2
= 2.1755 + 0.3882 + 4(0.3509)+ 0.3209 2.3163
3
y(0.8) = 2.3163
dy
4) If dx 2e x
y, y (0) 2, y (0.1) 2.01, y (0.2) 2.04, y (0.3) 2.09
Solution:
x y f ( x, y ) 2e x y
x0 0 y0 2 f0 0
x1 0.1 y1 2.01 f1 0.2003
x2 0.2 y2 2.04 f 2 0.4028
x3 0.3 y3 2.09 f3 0.6097
x4 0.4 y4( p ) 2.1622 f 4( p ) 0.8214
4h
y4 (p) = y0 + 2f 1 - f 2 + 2f 3
3
4(0.1)
=2+ 2(0.2003) - 0.4028 + 2(0.6097) 2.1622
3
y4 (c) = y2 +
h
3
f 2 + 4f 3 + f 4 (p)
0.1
= 2.04 + 0.4028 + 4(0.6097)+ 0.8214 2.1621
3
y(0.4) = 2.1621
5) The following table gives the solution of 5 xy' y 2 2 0 . Find the value
of 'y' at x = 4.5 using Milne’s Predictor – Corrector method
Solution:
2 y2
x y f ( x, y )
5x
x0 4.1 y0 1.0049 f0 0.0483
x1 4.2 y1 1.0097 f1 0.0466
x2 4.3 y2 1.0143 f 2 0.0452
x3 4.4 y3 1.0187 f3 0.0437
x4 4.5 y4( p ) 1.0229 f 4( p ) 0.0425
4h
y4 (p) = y0 + 2f 1 - f 2 + 2f 3
3
4(0.1)
=1.0049 + 2(0.0466) - 0.0452 + 2(0.0437) 1.0229
3
y4 (c) = y2 +
h
3
f 2 + 4f 3 + f 4 (p)
0.1
=1.0143 + 0.0452 + 4(0.0437)+ 0.0425 1.0230
3
y(0.4) = 1.0230
Practice Problems:
2) Given
dy x y
, y (0) 2, y (0.5) 2.636, y(1) 3.595, y(1.5) 4.968
dx 2
Then find the value of y at x 2 using Milne’s predictor and
corrector formula
3) Apply Milne’s method, find y (2) given that
dy y
2 , y (1) 2, y (1.25) 3.13, y (1.5) 4.5, y (1.75) 6.13
dx x
4) Use Milne’s method, find y (0.4) given that
dy
x y 2 , y (0) 1, y (0.1) 1.1, y (0.2) 1.231, y (0.3) 1.402
dx
ADAMS-BASHFORTH METHOD
dy
Consider the initial value problem f ( x, y ) with
dx
x x0 x1 x2 x3
y y0 y1 y2 y3
Predictor Formula
h
y4 (p) = y3 + 55f 3 - 59f 2 + 37f 1 - 9f0 where f0 = f(x0 , y0 ) f 1 = f(x1 , y1 ),
24
f 2 = f(x2 , y2 ), f 3 = f(x3 , y3 )
Corrector Formula:
y4 (c) = y3 +
h
24
f 1 - 5f 2 + 19f 3 + 9f 4(p) where f 4 (p) = f(x4 , y4 (p) )
Problems:
1) Given
dy
x 2 (1 y ) , y (1) 1, y (1.1) 1.233, y (1.2) 1.548, y (1.3) 1.979
dx
Then evaluate y (1.4) using Adams-Bashforth method
Solution:
x y f ( x, y ) x 2 (1 y )
x0 1 y0 1 f0 2
x1 1.1 y1 1.233 f1 2.7019
x2 1.2 y2 1.548 f 2 3.6691
x3 1.3 y3 1.979 f3 5.0345
x4 1.4 y4( p ) 2.5723 f 4( p ) 7.0017
h
y4 (p) = y3 + 55f 3 - 59f 2 + 37f 1 - 9f0
24
Dr.Dinesh A C, Associate Professor, Dept. of Mathematics, BIT
Bangalore Institute of Technology
(0.1)
=1.979 + 55(5.0345) - 59(3.6691) + 37(2.7019) - 9(2)
24
2.5723
y4 (c) = y3 +
h
24
f 1 - 5f 2 + 19f 3 + 9f 4(p)
(0.1)
=1.979 + (2.7019) - 5(3.6691) +19(5.0345) + 9(7.0017)
24
2.5749
∴ y(1.4 )
= 2.5749
Solution:
x y f ( x, y ) x 2 y
x0 0 y0 1 f 0 1
x1 0.1 y1 0.9051 f1 0.8951
x2 0.2 y2 0.8212 f 2 0.7812
x3 0.3 y3 0.7492 f3 0.6592
x4 0.4 y4( p ) 0.6897 f 4( p ) 0.5290
h
y4 (p) = y3 + 55f 3 - 59f 2 + 37f 1 - 9f0
24
(0.1)
= 0.7492 + 55(-0.6592) - 59(-0.7812) + 37(-0.8951) - 9(-1)
24
0.6897
y4 (c) = y3 +
h
24
f 1 - 5f 2 + 19f 3 + 9f 4(p)
(0.1)
= 0.7492 + (-0.8951) - 5(-0.7812) +19(-0.6592) + 9(-0.5290)
24
0.6897
∴ y(0.4 )
= 0.6897
Solution:
x y f ( x, y ) x 2 y
x0 0 y0 1 f 0 1
x1 0.1 y 0.9008 f1 0.9819
1
x2 0.2 y2 0.8066 f 2 0.9367
x3 0.3 y3 0.722 f 3 0.8784
x4 0.4 y4 0.6370 f 4 0.7993
h
y4 (p) = y3 + 55f 3 - 59f 2 + 37f 1 - 9f0
24
24
0.722
0.1 55(0.8784) 59(0.9367) 37(0.9819) 9(1)
0.6370
y4 (c) = y3 +
h
24
f 1 - 5f 2 + 19f 3 + 9f 4(p)
4 3 24 1
y(c) y h f 5 f 19 f 9 f 4(c)
2 3
0.6380
y(0.4) 0.6380
Practice Problems:
dy 1
2) Using Adams-Bashforth method, find y (0.4) from xy with
dx 2
y(0) 1, y(0.1) 1.0025, y(0.2) 1.0101, y(0.3) 1.0228 .
dy
2 yex with y(0) 2, y(0.1) 2.4, y(0.2) 2.473, y(0.3) 3.129
dx
4) Using Adams-Bashforth method, find y(4.4) given that
dy 2
5x y 2 with
dx
X 4 4.1 4.2 4.3
y 1 1.0049 1.0097 1.0143