P 21 Numerical Method 2
P 21 Numerical Method 2
NUMERICAL METHODS-2
(NUMERICAL SOLUTION OF ORDINARY
DIFFERENTIAL EQUATIONS)
Dr. A. K. Malik
Associate Professor, Department of ASH (Mathematics)
B K Birla Institute of Engineering & Technology, Pilani (Rajasthan)
Email: [email protected]
NUMERICAL SOLUTION OF ORDINARY
DIFFERNTIAL EQUATIONS
1.09324
y (0.1) 1.09324
( x4 x0 4h 0 4 0.025 0.1)
SOLVED PROBLEMS
dy 2 2
Pr.2. Use Euler’s method to compute y(0.5) for y x
dx
with y=1 when x=0.
0.5
Sol. Here f ( x, y ) y 2 x 2 , x0 0, y0 1, h 0.1.
5
We know that the Euler’s method is y n1 y n hf ( xn , y n )
By Putting n=0, 1, 2, 3, ………..; we get
y1 y0 h f ( x0 , y0 )
y0 h( y0 x0 ) 1 (0.1)(12 0 2 ) 1.1
2 2
y2 y1 hf ( x1 , y1 )
y1 h( y1 x1 ) ( x1 x0 h 0 0.1 0.1)
2 2
y3 y2 hf ( x2 , y2 )
y 2 h ( y 2 x2 ) ( x2 x0 2h 0 2 0.1 0.2)
2 2
1.36484
y4 y3 hf ( x3 , y3 )
y3 h( y3 x3 ) ( x3 x0 3h 0 3 0.1 0.3)
2 2
1.54212
y5 y4 hf ( x4 , y4 )
y 4 h ( y 4 x4 ) ( x4 x0 4h 0 4 0.1 0.4)
2 2
1.7639
Hence the value of y at x=0.5 is
y (0.5) 1.763933
UNSOLVED PROBLEMS
dy
Assign.1. Use Euler’s method to compute y(0.04), y
dx
for with y(0)=1.
Sol.
y1 0.99
y2 0.9801
y3 0.970299
y4 0.960596
EULER’S MODIFIED METHOD
y0 hf ( x0 , y0 )
(0)
y1
SOLVED PROBLEMS
Pr.1. Use Euler’s modified method to find y(0.1) correct to
dy 2
six decimal figures where x y with y(0)=0.94.
dx
Sol. Here f ( x, y ) x 2 y, x0 0, y0 0.94, h 0.1.
h
y (1)
1 y0 [ f ( x0 , y0 ) f ( x1 , y1( 0) )]
2
h
y0 [( x0 y0 ) ( x1 y1( 0) )]
2 2
2
0.1
0.94 [(0 0.94) ((0.1) 2 1.034)]
2
1.0392
Put n=1 in equation (1), we get
h
y( 2)
1 y0 [ f ( x0 , y0 ) f ( x1 , y1(1) )]
2
h
y0 [( x0 y0 ) ( x1 y1(1) )]
2 2
0.1
0.94 [(0 0.94) ((0.1) 2 (1.0392))]
2
1.03946
Put n=2 in equation (1), we get
h
y1( 3) y0 [ f ( x0 , y0 ) f ( x1 , y1( 2 ) )]
2
h
y0 [( x0 y0 ) ( x1 y1( 2) )]
2 2
2
0.1
0.94 [(0 0.94) ((0.1) 2 (1.03946))]
2
1.039473
Put n=3 in equation (1), we get
h
y y0 [ f ( x0 , y0 ) f ( x1 , y1(3) )]
( 4)
1
2
h
y0 [( x0 y0 ) ( x1 y1(3) )]
2 2
2
0.1
0.94 [(0 0.94) ((0.1) 2 (1.039473))]
2
1.039473
y 1 y y0 2
y ( x) y0 x x0 y x x0
2
y
x x0
3
y
x x0
4
y ........
0 0 0 0
2! 3! 4!
Putting the value of x0, y0, y0 , y0 , y0, y0, ........
we get
y ( x) 1 x 0.(1)
x 0
2
2 x 0
3
2 x 0
4
2 ........
2! 3! 4!
2 x 2 2 x3 2 x 4
1 x ........
2! 3! 4!
Now put x=0.1 and taking up to fourth terms, we get
2
y (0.1) 1 0.1 0.1
2
0.13 2 0.14
6 24
1 1
1 0.1 0.1 0.1 0.1
2 3 4
3 12
1 1
1 0.1 0.01 0.001 0.0001
3 12
1.1103383
SOLVED PROBLEMS
Pr.2. Using Taylor’s series method to compute y(2.1)
dy
correct to 5 decimal places, where x x y with y(2)=2.
dx
y
Sol. Here y 1 , x0 2, y0 2.
x
Here we find some derivatives and their values at x=2, y=2, are
y
y 1 y0 0
x
y y 1
y 2 y0
x x 2
y 2 y 2 y 3
y 2 3 y0
x x x 4
y 3 y 6 y 6 y 3
y 2 3 4 y0
x x x x 2
The Taylor’s series method is
y ( x) y0 x x0 y x x0
2
y
x x0
3
y
x x0
4
y ........
0 0 0 0
2! 3! 4!
Putting the value of x0, y0, y0 , y0 , y0, y0, ........
we get
y ( x) 2 x 2.0
x 2 1 x 2 3 x 2 3
2
3
4
........
2! 2 3! 4 4! 2
1 1 1
2 x 2 x 2 x 2 ........
2 3 4
4 8 16
Now put x=2.1 and taking up to fourth terms, we get
1
y (2.1) 2 2.1 22 1 2.1 23 1 2.1 24
4 8 16
1 1 1
2 0.1 0.1 0.1
2 3 4
4 8 16
1 1 1
2 0.01 0.001 0.0001
4 8 16
2.00238125
UNSOLVED PROBLEMS
Assign.3. Find the solution of the differential equation
dy
x y 2 with y (0) 1
dx
y ( n ) y0 x f ( x, y ( n 1) )dx
x
0
x
y0 x ( x y ( 0) )dx
0
x
1 0 ( x 1)dx
x
x 2
1 x
2 0
x2
1 x
2
The second approximations is
x x
y ( 2)
y0 x f ( x, y )dx y0 x ( x y (1) )dx
(1)
0 0
x2
1 0 x x 1 dx
x
2
x x2
1 0 2 x 1 dx
2
x
2 x 3
x3
1 x x 1 x x 2
6 0 6
x3
1 x x 2
6
The third approximations is
x x
y ( 3)
y0 x f ( x, y )dx y0 x ( x y ( 2) )dx
( 2)
0 0
x 3
1 0 x 1 x x dx
x 2
6
x x3
1 0 2 x x 2 1 dx
6
x
2 x 4
x 3
1 x x
24 3 0
3 4
x x
1 x x2
3 24
The fourth approximations is
x x
y ( 4)
y0 x f ( x, y )dx y0 x ( x y (3) )dx
( 3)
0 0
x 3
x 4
1 0 x 1 x x dx
x 2
3 24
x
3 4
x x
1 0 2 x 1 x 2 dx
3 24
x
2 x x 3
x 4 5
1 x x
3 12 120 0
x3 x 4 x5
1 x x 2
3 12 120
The fifth approximations is
x x
y ( 5)
y0 x f ( x, y )dx y0 x ( x y ( 4) )dx
( 4)
0 0
x3 x 4 x 5
1 0 x 1 x x dx
x 2
3 12 120
x x3 x 4 x5
1 0 2 x 1 x
2
dx
3 12 120
x
2 x3
x 4
x 5
x
6
1 x x
3 12 60 720 0
3 4 5 6
x x x x
1 x x2
3 12 60 720
Here we construct a table for y at x=0.1, x=0.2 and y0=1.
y(2)=0.9098 y(2)=0.83867
y(3)=0.90967 y(3)=0.83740
y(4)=0.90967 y(4)=0.83746
y(5)=0.83746
Sol. Here f ( x, y ) x y 2 , x0 0, y0 0.
y0 x f ( x, y ( n 1) )dx
(n) x
y
0
x
y (1)
y0 x f ( x, y ( 0) )dx
0
x
y0 x ( x y0 )dx
2
0
x
0 0 ( x 0)dx
x
x 2
2 0
x2
2
The second approximations is
x
f ( x, y )dx y0 x [ x ( y ) ]dx
x
y0 x
( 2) (1) (1) 2
y
0 0
2 2
x
0 0 x dx
x
2
x x4
0 x dx
4
x
x x
2 5
2 20 0
x 2 x5
2 20
The third approximations is
x
f ( x, y )dx y0 x0 [ x ( y ) ]dx
x
y0 x
( 3) ( 2) ( 2) 2
y
0
x 2 5 2
x
0 0 x dx
x
2 20
x x 4 x10 x 7
0 x dx
4 400 20
x
x 2
x x x
5 8 11
2 20 160 4400 0
x 2 x 5 x8 x11
2 20 160 4400
UNSOLVED PROBLEMS
Assign.4. Using Picard’s method to compute up-to second
approximations to y(0.25), y(0.5) and y(1) correct to 3
dy x2
decimals, where 2 with y (0) 0.
dx y 1
Sol.
x3
y (1) .
3
3
1 x 1 x
3 3 3
x
y ( 2)
tan ....
3 3 3 3
RUNGE-KUTTA METHOD OF
FOURTH ORDER
dy
Consider the differential equation f ( x, y ) with y(x0)=y0.
dx
Runge-Kutta method of fourth order is yn+1 = yn+k for x1=x0+h
h
k [k1 2(k 2 k3 ) k 4 ]
6
where k1 f ( x0 , y0 )
h h h h
k 2 f x0 , y0 k1 , k3 f x0 , y0 k 2
2 2 2 2
k 4 f x0 h, y0 k3h
SOLVED PROBLEMS
Pr.1. Using Runge-Kutta method, obtain a solution of the
dy
equation xy, y (1) 2 for x=1.4 using h=0.2.
dx
Sol. Here f ( x, y ) xy, x0 1, y0 2, h 0.2.
f ( x0 , y0 ) x0 y0 1 2 2.
h
Runge-Kutta method of 4th order is k [k1 2(k 2 k3 ) k 4 ]
6
for y1=y0+k for x1=x0+h=1+0.2 =1.2
where
k1 f ( x0 , y0 ) x0 y0 1 2 2.
h h h h
k 2 f x0 , y0 k1 x0 y0 k1
2 2 2 2
0.2 0.2
1 2 2 (1.1)(2.2) 2.42
2 2
h h h h
k3 f x0 , y0 k 2 x0 y0 k 2
2 2 2 2
0.2 0.2
1 2 2.42 (1.1)(2.242) 2.4662
2 2
k 4 f ( x0 h, y0 k3h) ( x0 h)( y0 k3h)
Therefore
y(1.2) 2.4921
Now for the second interval
x1 1.2, y1 2.4921, h 0.2.
f ( x1 , y1 ) x1 y1 1.2 2.4921 2.99052.
Now to find the value of y2=y1+k for x2=x1+h=1.2+0.2 =1.4;
first we find k, so we have
k1 f ( x1 , y1 ) x1 y1 1.2 2.4921 2.99052.
h h h h
k 2 f x1 , y1 k1 x1 y1 k1
2 2 2 2
0.2 0.2
1.2 2.4921 2.9905 (1.3)(2.79105)
2 2
3.6283.
h h h h
k3 f x1 , y1 k 2 x1 y1 k 2
2 2 2 2
0.2 0.2
1.2 2.4921 3.6283 (1.3)(2.8548)
2 2
3.71143.
4.5281.
h
Now we have k [k1 2(k 2 k3 ) k 4 ]
6
0.2
[2.9905 2(3.6283 3.7112) 4.5281]
6
0.73992.
This show that
x2 x1 h 1.2 0.2 1.4
and
y2 y1 k 2.4921 0.73992 3.2330.
Therefore
y (1.4) 3.2321.
SOLVED PROBLEMS
Pr.2. Using Runge-Kutta method of fourth order to find
dy
y(1.2), given that x 2 y 2 , y (1) 0.
dx
Sol. Here f ( x , y ) x 2
y 2
, x0 1, y0 0, h 0.2.
f ( x0 , y0 ) x0 y0 12 0 1.
2 2
h
Runge-Kutta method of 4th order is k [k1 2(k 2 k3 ) k 4 ]
6
for y1=y0+k for x1=x0+h=1+0.2 =1.2
where
k1 f ( x0 , y0 ) x0 y0 12 0 1.
2 2
2 2
h h h h
k 2 f x0 , y0 k1 x0 y0 k1
2 2 2 2
2 2
0.2 0.2
1 0 1 (1.1) (0.1) 1.22.
2 2
2 2
2 2
h h h h
k3 f x0 , y0 k 2 x0 y0 k 2
2 2 2 2
2
0.2 0.2
1 0 1.22 (1.1) (0.122) 1.224884.
2
2 2
k 4 f ( x0 h, y0 k3h) ( x0 h) 2 ( y0 k3h) 2
Therefore
y (1.2) 0.246326.
UNSOLVED PROBLEMS
Assign.5. Use Runge-Kutta method of fourth order to find
the approximate value of y for x=0.4 if
dy
x y2
dx
given that y=1 when x=0, taking h=0.2.
MILNE’S AND ADAM’S PREDICTOR -
CORRECTOR METHODS
dy
Consider the differential equation f ( x, y ) with y(x0)=y0.
dx
4h
The predictor formula is y n1 y n3 (2 y n 2 y n 1 2 y n )
3
h
The corrector formula is y
(1)
n 1 yn 1 ( yn 1 4 yn yn 1 )
3
In Milne’s and Adam’s predictor- corrector method, first we
obtain the value of yn+1 by predictor formula and then improve
this value by corrector formula until we get two values of yn+1
become same to the desired degree of accuracy.
SOLVED PROBLEMS
Pr.1. Use Milne’ s predictor - corrector method to find y(0.8),
dy
given that x y 2 ; y(0) 0, y(0.2) 0.02, y(0.4) 0.0795,
dx
y(0.6) 0.1762.
Sol. Here y x y 2 , then we have
0.3046
Hence y(0.8)=0.3046.
SOLVED PROBLEMS
Pr.2. Use Milne’ s predictor - corrector method to find y(0.4),
dy
given that 1 xy 2 ; y(0) 1, y(0.1) 1.105, y(0.2) 1.223,
dx
y(0.3) 1.355.
Sol. Here y 1 xy 2 , then we have
1.5380
Hence y(0.4)=1.5380.
SOLVED PROBLEMS
dy 1
Assign.6. Given that (1 x 2 ) y 2 and y(0) 1,
dx 2
y(0.1) 1.06, y(0.2) 1.12, y(0.3) 1.21. Evaluate
y(0.4) by Milne’ s predictor method.
Thank You