Professional Documents
Culture Documents
Numerical Solution of A Differential Equation: Module-4
Numerical Solution of A Differential Equation: Module-4
( x 0) / ( x 0) 2 // ( x 0) 3 /// ( x 0) 4 / V
y( x) y(0) y (0) y (0) y (0) y (0)
1! 2! 3! 4!
Problems:
1. Find by Taylor’s series method the value of y at x = 0.1 and 0.2 five places of decimals for the
dy
IVP x 2 y 1, y ( 0) 1 .
dx
Soln:
Given x0 0, y 0 1 and f ( x, y ) x y 1
2
y // ( x) 2 xy x 2 y / y // (0) 0
/ // /// iv
Putting the values of y (0), y (0), y (0), y (0), y (0) in (1), we get
x2 x3 x4
y( x) 1 x(1) (0) (2) (6)
2 6 24
x3 x4
y ( x) 1 x
3 4
Hence y(0.1) = 0.90033 and y(0.2) = 0.80227.
2. Employ Taylor’s series method to obtain approximate value of y at x = 0.1 and 0.2 for the
dy
differential equation 2 y 3e x , y (0) 0. Compare the numerical solution obtained with the
dx
exact solution.
Soln:
Given x 0 0, y 0 0 and f ( x, y ) 2 y 3e
x
/ // /// iv
Putting the values of y (0), y (0), y (0), y (0), y (0) in (2), we get
9 21 45 4
y ( x) 0 3x x 2 x 3 x
2 6 24
9 7 15
3x x 2 x 3 x 4
2 2 8
Hence,
y(0.1) = 3(0.1)+4.5(0.1)2+3.5(0.1)3+1.875(0.1)4
= 0.3486875
and
y(0.2) = 3(0.2)+4.5(0.2)2+3.5(0.2)3+1.875(0.2)4
= 0.8110.
dy
3. Using Taylor’s series method solve x 2 y, y (0) 1at 0.1 ≤ x ≤ 0.4.
dx
Soln:
Given x0 0, y 0 1 and f ( x, y ) x y
2
/ // /// iv
Putting the values of y (0), y (0), y (0), y (0), y (0) in (4), we get
x2 x3 x4
y ( x) 1 x
2 6 24
Hence,
dy
Consider the IVP f ( x, y ), y ( x0 ) y0 . The following two methods can be used to
dx
determine the solution at a point x xn x0 nh .
Euler’s Method :
y n 1 y n
h
2
f ( x n , y n ) f ( x n 1 , y nE1 ) , n 0,1,2,3, (2)
Remark:
1. The formulae (1) and (2) are also known as Euler’s Predictor – Corrector formula.
2. When Modified Euler’s method is applied to find the solution at a give point, we first find
the solution at that point by using Euler’s method and the same will be used in the
calculation of Modified Euler’s method. Also Modified Euler’s method has to be applied
repeatedly until the solution is stationary.
Problems:
dy y2
1. Solve , y(0) 1 by Euler’s method by choosing h = 0.1 and h = 0.05. Also solve
dx 1 x
the same problem by modified Euler’s method by choosing h = 0.05. Compare the numerical
solution with analytical solution.
Soln:
dy dx 1
log(1 x) c
y 2
1 x y
(1) 2
y1 y(0.05) 1.0 0.05 0.95
1 0
(0.95) 2
y 2 y(0.1) 0.95 0.05 0.90702
1 0.05
(0.90702) 2
y3 y(0.15) 0.90702 0.05 0.86963
1 0.1
(0.86963) 2
y 4 y(0.2) 0.86963 0.05 0.83675
1 0.15
(1) 2 (0.95) 2
y1(1) y(0.05) 1.0 0.025 0.95351
1 0 1 0.05
(1) 2 (0.95351) 2
y1( 2) y(0.05) 1.0 0.025 0.95335
1 0 1 0.05
(1) 2 (0.95335) 2
y( 3)
y(0.05) 1.0 0.025 0.95336
1 0 1 0.05
1
(1) 2 (0.95336) 2
y1( 4) y(0.05) 1.0 0.025 0.95336
1 0 1 0.05
Hence y1 y(0.05) 0.95336
(0.95336) 2
y 2E y(0.1) 0.95336 0.05 0.91008
1 0.05
From Modified Euler’s formula, we have
(0.95336) 2 (0.91008) 2
y 2(1) y(0.1) 0.95336 0.025 0.91286
1 0.05 1 0.1
(0.95336) 2 (0.91286) 2
y 2 y(0.1) 0.95336 0.025
( 2)
0.91278
1 0.05 1 0 .1
(0.95336) 2 (0.91278) 2
y 2( 2) y(0.1) 0.95336 0.025 0.91278
1 0.05 1 0.1
(0.91278) 2
y3E y(0.15) 0.91278 0.05 0.87491
1 0.1
From Modified Euler’s formula (for n = 2), we have
(0.91278) 2 (0.87491) 2
y3(1) y(0.15) 0.91278 0.025 0.87720
1 0.1 1 0.15
(0.91278) 2 (0.87720) 2
y3( 2) y(0.15) 0.91278 0.025 0.87712
1 0.1 1 0.15
(0.91278) 2 (0.87712) 2
y3(3) y(0.15) 0.91278 0.025 0.87712
1 0.1 1 0.15
Hence y3 y(0.15) 0.87712
(0.87712) 2 (0.84367) 2
y y(0.2) 0.87712 0.025
(1)
0.84557
1 0.15 1 0.2
4
(0.87712) 2 (0.84557) 2
y 4( 2) y(0.2) 0.87712 0.025 0.84550
1 0.15 1 0.2
(0.87712) 2 (0.84550) 2
y 4( 2) y(0.2) 0.87712 0.025 0.84550
1 0.15 1 0.2
2. Solve the following IVP by Euler’s modified method at 0.2 x 0.8 with h = 0.2:
dy
log 10 ( x y ), y ( 0) 2 .
dx
Soln:
Given Data is: x 0 0, y 0 2, h 0.2 and f ( x, y ) log 10 ( x y )
To Find: y1 y( x1 ) y(0.2), y 2 y( x 2 ) y(0.4), y 3 y( x 3 ) y(0.6)
& y 4 y( x 4 ) y(0.8)
Stage – I: Finding y1 = y(0.2)
y 2(1) y (0.4) 2.0656 0.1log 10 (0.2 2.0656) log 10 (0.4 2.1366 2.1415
y 2(3) y (0.4) 2.0656 0.1log 10 (0.2 2.0656) log 10 (0.4 2.1416 2.1416
y 3(1) y (0.6) 2.1416 0.1log 10 (0.4 2.1416) log 10 (0.6 2.2226 2.2272
y3( 2) y (0.6) 2.1416 0.1log 10 (0.4 2.1416) log 10 (0.6 2.2272 2.2272
y 4(1) y (0.8) 2.2272 0.1log 10 (0.6 2.2272) log 10 (0.8 2.3175 2.3217
dy
3. Using modified Euler’s method solve the IVP sin x cos y, y (2.5) 0 at
dx
x=3.5 in two steps, modifying the solution thrice at each stages. Here x is in radians.
Soln:
4. Using modified Euler’s method obtain the solution of the differential equation
dy
x y with the initial condition y = 1 at x = 0 for the range 0 < x 0.6 in steps of 0.2.
dx
Soln:
Given x0 0, y 0 1, h 0.2 and f ( x, y ) x y
To Find: y1 y ( x1 ) y(0.2), y 2 y( x2 ) y(0.4) and y3 y ( x3 ) y(0.6)
X Y1 f ( x n , y n ) y n hf ( xn , y n ) Y2 f ( xn1 , y n1 )
y n 1 y n
h
Y1 Y2
2
0.2 1 1.2 1.2954 1.2295
1.3088 1.2309
1.3094 1.2309
0.4 1.3094 1.4927 1.6218 1.5240
1.6345 1.5253
1.6350 1.5253
0.6 1.6350 1.8523 1.9610 1.8849
1.9729 1.8861
1.9734 1.8861
The solution is: y(0.2) 1.2309, y(0.4) 1.5253 and y(0.6) 1.8861
The Taylor’s series method to solve IVPs is restricted by the difficulty in finding the higher order
derivatives. However, Runge – Kutta method do not require the calculations of higher order
derivatives. Euler’s method and modified Euler’s method are Runge – Kutta methods of first and
second order respectively.
dy
Consider the IVP f ( x, y ), y ( x0 ) y0 . Let us find the approximate value of yat x x n 1 ,
dx
n = 0,1,2,3,…..of this numerically, using Runge – Kutta method, as follows:
First let us calculate the quantities k1 , k 2 , k 3 and k 4 using the following formulae.
k1 hf ( xn , y n )
h k
k 2 hf x n , y n 1
2 2
h k
k 3 hf x n , y n 2
2 2
k 4 hf xn h, y n k 3
y n 1 y n
1
k1 2k 2 2k 3 k 4
6
Problems:
1. Apply Runge – Kutta method, to find an approximate value of y when x = 0.2 given that
dy
x y, y ( 0) 1 .
dx
Soln:
1
0.2 0.24 0.244 0.2888 = 1.2468
y1 y (0.2) 1
6
Hence the required approximate value of y is 1.2468.
dy y 2 x 2
2.UsingRunge – Kutta method of fourth order, solve , y (0) 1 at
dx y 2 x 2
x = 0.2 & 0.4.
Soln:
y2 x2
Given: x0 0, y 0 1, h 0.2 and f ( x, y )
y2 x2
y1 y (0.2) 1
1
0.2 2(0.19672) 2(0.1967) 0.1891
6
= 1+0.19599
= 1.19599
Hence the required approximate value of y is 1.19599.
Stage – II: Finding y 2 y(0.4)
y 2 y (0.4) 1.19599
1
0.1891 2(0.1795) 2(0.1793) 0.1688
6
= 1.19599 + 0.1792
= 1.37519
3. Apply Runge – Kutta method to find an approximate value of y when x = 0.2 with h = 0.1
dy y
for the IVP 3x , y (0) 1 . Also find the Analytical solution and compare with the
dx 2
Numerical solution.
Soln:
y
Given: x 0 0, y 0 1, h 0.1 and f ( x, y ) 3 x
2
Stage – I: Finding y1 y(0.1)
= 1.0665242
y 2 y (0.2) 1.0665242
1
0.0833262 2(0.1004094) 2(0.1008364) 0.1006976
6
= 1.0665242 + 0.1006976
= 1.1672218
Hence the required approximate value of y is 1.1672218.
Milne’s Method:
dy
Given f ( x, y ), y ( x 0 ) y 0 . To find an approximate value of y at x=x0+nh by Milne’s
dx
method, we proceed as follows: Using the given value of y( x0 ) y 0 , we compute
y( x1 ) y( x0 h) y1 , y( x2 ) y( x0 2h) y 2 and y( x3 ) y( x0 3h) y3 using Taylor’s
series method.
4h
2 f1 f 2 2 f 3
y 4( P ) y 0
3
Then we compute f 4 f ( x 4 , y 4 )
( P)
y 4( C ) y 2
h
f2 4 f3 f4
3
Then, an improved value of f4 is computed and again, corrector formula is applied to find a
better value of y4. We repeat the step until y4 remains unchanged.
dy
Given f ( x, y ), y ( x 0 ) y 0 . Using the given value of y( x0 ) y 0 , we first compute
dx
y( x1 ) y( x0 h) y 1 , y( x2 ) y( x0 2h) y 2 and y( x3 ) y( x0 3h) y 3 using
Taylor’s series method.
y1( P ) y 0
h
55 f 0 59 f 1 37 f 2 9 f 3
24
formula is used.
y1(C ) y 0
h
9 f1 19 f 0 5 f 1 f 2
24
applied to find a better value of y1. This step is repeated until y1 remains unchanged and then
proceeds to calculate y2 as above.
Problems:
dy
1. Use Milne’s method to find y(0.3) for the IVP x2 y2 , y ( 0) 1
dx
Soln:
First, let us find the values of y at the points x = -0.1, x = 0.1 and x = 0.2 by using Taylor’s series
method for the given IVP.
x 2 // x 3 ///
y( x) y(0) xy / (0) y (0) y (0) -------- (1)
2 6
Given
y / ( x) x 2 y 2 y / (0) 0 1 1
y // ( x) 2 x 2 yy / y // (0) 2 1 1 2
y /// ( x) 2 2 yy // 2( y / ) 2 y /// (0) 2 4 2 8
Using the values of y(0), y/(0), y//(0) and y///(0) in (1), we get
4x 3
y ( x) 1 x x 2
3
Putting x = -0.1, x = 0.1 and x = 0.2 in the above expression, we get
Given:
x0 0.1, y 0 0.9087 and f 0 0.8357
x1 0, y1 1 and f1 1
x2 0.1, y 2 1.1113 and f 2 1.2449
x3 0.2, y3 1.2507 and f 3 1.6043
To Find: y 4 y( x4 ) y(0.3)
y 4( C ) y (0.3) y 2
h
f2 4 f3 f4
3
y 4( C ) y (0.3) 1.1113
0 .1
1.2449 (4 1.6043) 2.1555
3
= 1.4386
Now, we compute f 4 f (0.3,1.4386) 2.1596
dy
2. Given x y 2 , y (0) 0 , y(0.2) = 0.02, y(0.4) = 0.0795 and y(0.6) = 0.1762. Compute
dx
y(1) using Milne’s Method.
Soln:
Given:
x0 0, y 0 0 and f 0 f ( x0 , y 0 ) 0
x1 0.2, y1 0.02 and f1 f ( x1 , y1 ) 0.1996
x2 0.4, y 2 0.0795 and f 2 f ( x2 , y 2 ) 0.3937
x3 0.6, y3 0.1762 and f 3 f ( x3 , y3 ) 0.56895
To Find: y 4 y( x4 ) y(0.8)
y 4( P ) y (0.8) y 0
4h
2 f1 f 2 2 f 3
3
4 ( 0 .2 )
0 (2 0.1996) 0.3937 2 2 0.56895
3
= 0.30491
Now we compute f 4 f (0.8,0.30491) 0.7070
y 4( C ) y (0.8) y 2
h
f2 4 f3 f4
3
y 4( C ) y (0.8) 0.0795
0. 2
0.3937 4 0.56895 0.7070
3
= 0.3046
Now f 4 f (0.8,0.3046) 0.7072
y(0.8) = 0.3046
Stage - II: Finding y(1.0)
Given:
x1 0.2, y1 0.02 and f1 f ( x1 , y1 ) 0.1996
x2 0.4, y 2 0.0795 and f 2 f ( x2 , y 2 ) 0.3937
x3 0.6, y3 0.1762 and f 3 f ( x3 , y3 ) 0.56895
x4 0.8, y 4 0.3046 and f 4 f ( x4 , y 4 ) 0.7072
To Find: y5 y ( x5 ) y (1.0)
y 5( P ) y (1.0) y1
4h
2 f 2 f 3 2 f 4
3
4(0.2)
0.02 (2 0.3937) 0.56895 2 0.7072
3
= 0.45544
Now we compute f 5 f (1.0,0.45544) 0.7926
y 5( C ) y (1.0) y 3
h
f3 4 f4 f5
3
y 5( C ) y (1.0) 0.56895
0.2
0.56895 4 0.7072 0.7926
3
= 0.4556
Soln:
Given:
x3 1, y 3 1 and f 3 2
x2 1.1, y 2 1.233 and f 2 2.70193
x1 1.2, y 1 1.548 and f 1 3.66912
x0 1.3, y 0 1.979 and f 0 5.03451
To Find: y1 y( x1 ) y(1.4)
y1( P ) y (1.4) y 0
h
55 f 0 59 f 1 37 f 2 9 f 3
24
1.979
(0.1)
(55 5.03451) (59 3.66912) (37 2.70193) (9 2)
24
= 2.57229
Now we compute f1 f (1.4,2.57229) 7.0017
y1( C ) y (1.4) y 0
h
9 f1 19 f 0 5 f 1 f 2
24
1.979
0.1
(9 7.0017) (19 5.03451) (5 3.66912) 2.70193
24
y(1.4) = 2.57495
y1( C , 2 ) 1.979
0.1
(9 7.0073) (19 5.03451) (5 3.66912) 2.70193
24
y(1.4) = 2.57514
dy
4. Given x 2 y, y (0) 1. Find y(0.4) by Adam’s method.
dx
Soln:
First, let us find the values of y at the points x = 0.1, x = 0.2 and x = 0.3 by using Taylor’s series
method for the given IVP.
x 2 // x 3 ///
y( x) y(0) xy / (0) y (0) y (0) -------- (2)
2 6
Given
y / ( x) x 2 y y / (0) 0 1 1
y // ( x) 2 x y / y // (0) 0 (1) 1
y /// ( x) 2 2 y // y /// (0) 2 1 1
Using the values of y(0), y/(0), y//(0) and y///(0) in (2), we get
x2 x3
y ( x) 1 x
2 3
y1( C ) y (0.4) y 0
h
9 f1 19 f 0 5 f 1 f 2
24
0.7492
0.1
9 (0.5297) 19 (0.6592) 5 (0.7812) 0.895125
24
y(0.4)=0.689652