NumericalMethods ODE 250316 111213
NumericalMethods ODE 250316 111213
Dr. K. Murugesan
Professor(HAG)
Department of Mathematics
National Insitute of Technology
Tiruchirappalli - 620015
Tamil Nadu, India
Email : [email protected]
1
INTRODUCTION TO NUMERICAL METHODS
Numerical Methods:
Algorithms that are used to obtain numerical solutions of a mathematical problem.
What do we need?
Basic Needs in the Numerical Methods:
Practical:
Accurate:
Closed-form (analytical) solutions are only possible and complete for simple problems (geom-
etry, properties, etc.).
2
A few applications of Numerical Methods in Engineering:
Structural/mechanical analysis, design, and behavior.
Communication/power
– Network simulation
– Train and traffic networks
– Weather prediction
– Groundwater & pollutant movement
3
Numerical Solution for Ordinary Differential Equations
b−a
Set h = (step size)
N
Compute approximations yi to y(xi ) at x = xi ;that is, given y(0) = y0 , compute, recursively,
y1 , y2 , ..., yn .
This problem can be solved by any of the methods developed in this chapter, which will give
the solution in one of the two forms given below.
4
2 Taylor Series Method
Taylor series method is the fundamental numerical method for the solution of the initial value
problem given in (1).
Expanding y(x) in Taylor series about any point xi ,with the Lagrange form of remainder, we obtain
1 1
y(x) = y(xi ) + (x − xi )y ′ (xi ) + (x − xi )2 y ′′ (xi ) + ... + (x − xi )p y p (xi )
2! p!
1
+ (x − xi )p+1 y p+1 (xi + θh) ...........(2)
(p + 1)!
where 0 < θ < 1, x ∈ [x0 , b] and b is the point up to which the solution is required.
We denote the numerical solution and the exact solution at xi by yi and y(xi ) respectively.
Now, consider the interval [xi , xi+1 ]. The length of the interval is h = xi+1 − xi .
h2 ′′ hp hp+1 p+1
y(xi+1 ) = y(xi ) + hy ′ (xi ) + y (xi ) + ... + y p (xi ) + y (xi + θh)
2! p! (p + 1)!
Neglecting the error term, we obtain the Taylor series method (of order p) as
h2 ′′ hp
y(xi+1 ) = y(xi ) + hy ′ (xi ) + y (xi ) + ... + y p (xi )
2! p!
(or)
h2 ′′ hp
yi+1 = yi + hyi′ + yi + ... + yip
2! p!
Note that Taylor series method is an explicit single step method.
This method gives a straight forward adaptation of classic calculus to develop the solution as
an infinite series. It is a powerful single step method, if we are able to find the successive deriva-
tives easily. If f(x,y) involves some complicated algebraic structures, then the calculation of higher
derivatives becomes tedious and the method fails. This is the major drawback of this method.
However, the method will be very useful for finding the starting values for powerful methods like
Runge-Kutta method, Milne’s method etc.
5
2.1 Problems based on Taylor series
dy
1. Using Taylor’s series method find y at x = 0.1 if = x2 y − 1, y(0) = 1.
dx
Solution:
h2 ′′
yi+1 = yi + hyi′ + y + ...
2! i
For y1 take i = 0 we get,
h2 ′′ h3 ′′′
y1 = y0 + hy0′ + y + y0 + ...
2! 0 3!
y ′ = x2 y − 1 y0′ = x20 y0 − 1 = 0 − 1 = −1
2. Solve y ′ = x + y; y(0) = 1, by Taylor’s series method. Find the value y at x = 0.1 and x = 0.2
Solution:
h2 ′′ h3 ′′′
y1 = y0 + hy0′ + y + y0 + ...
2! 0 3!
6
y′ = x + y y0′ = x0 + y0 = 0 + 1 = 1
y ′′ = 1 + y ′ y0′′ = 1 + y0′ = 1 + 1 = 2
Exercise
1. Using Taylor’s series method, find y(1.1) and y(1.2), correct to four decimal places given
dy
= xy 1/3 and y(1)=1.
dx
dy
2. Using Taylor’s series method solve = 1 + xy with y(0) = 2. Find (i) y(0.1), (ii) y(0.2),
dx
(iii) y(0.3)
2.2 Taylor’s series method for simultaneous first order differential equa-
tions
dy dz
The equation of the type = f1 (x, y, z), = f2 (x, y, z) with initial conditions
dx dx
y(x0 ) = y0 , z(x0 ) = z0 can be solved by Taylor method.
7
Problems based on Taylor series for simultaneous equations
dy dz
1. Using Taylor’s series method, Solve the system of equations = z − x2 , = y + x with
dx dx
y(0) = 1, z(0) = 1 by taking h = 0.1, to get y(0.1) and z(0.1). Here y and z are
Given y ′ = z − x2 , z ′ = x + y, x0 = 0, y0 = 1, z0 = 1
h2 ′′ h3 ′′′
=⇒ y1 = y(0.1) = y0 + hy0′ + y + y0 + ...
2! 0 3!
(0.1)2 (0.1)3 (0.1)4
= 1 + (0.1)(1) + (1) + (0) + (1) + ...
2! 3! 4!
= 1 + 0.1 + 0.005 + 0 + 0.0000042
∴ y(0.1) = 1.1050
h2 ′′ h3 ′′′
=⇒ z1 = z(0.1) = z0 + hz0′ + z + z0 + ...
2! 0 3!
2 3
(0.1) (0.1) (0.1)4
= 1 + (0.1)(1) + (2) + (1) + (0) + ...
2! 3! 4!
= 1 + 0.1 + 0.01 + 0.000167
∴ z(0.1) = 1.110167 ≊ 1.1102
d2 y
dy
Suppose 2 = f x, y, i.e., y ′′ = f (x, y, y ′ ) (1)
dx dx
8
is the given differential equation together with the initial conditions
y(x0 ) = y0 (2)
z ′ = f (x, y, z) (5)
h2 ′′ h3 ′′′
z1 = z0 + hz0′ + z + z0 + ... (8)
2! 0 3!
where z1 = z(x = x1 ) where x1 − x0 = h
From (4),
h2 ′′ h3 ′′′
y1 = y0 + hy0′ +y + y0 + ... becomes
2! 0 3!
h2 h3
y1 = y0 + hz0 + z0′ + z0′′ + ... (9)
2! 3!
Equation (5) gives z ′ and differentiating it, we get z ′′ , z ′′′ , ... Hence z0′ , z0′′ , z0′′′ , ... can be got using (9)
and (8) we can get y1 and z1 . Since we know y1 , z1 we can get z1′ , z1′′ , z1′′′ , ... at (x1 , y1 ). Again using
h2 ′′ h3 ′′′
z2 = z1 + hz1′ + z + z1 + ... we get zb2 and using
2! 1 3!
h2 ′′ h3 ′′′
y2 = y1 + hy1′ + y + y1 + ... we get y2
2! 1 3!
Since we can calculate y1′ , y1′′ , ... from (4).
Thus we calculate y1 , y2 , ...
9
Problems based on Taylor series for 2nd order differential equation
1. Evaluate the values of y(0.1), given y ′′ − x(y ′ )2 + y 2 = 0; y(0) = 1, y ′ (0) = 0 by using Taylor
series method.
Solution:
Given y ′′ − x(y ′ )2 + y 2 = 0
P ut y ′ = z ........(1)
z ′′ = z 2 + 2xzz ′ − 2yy ′ z0′′ = z02 + 2x0 z0 z0′ − 2y0 y0′ = 0 y ′′ = z ′ y0′′ = z0′ = −1
z ′′′ = 2[xzz ′′ + 2zz ′ + x(y ′ )2 ] z0′′′ = 2[x0 z0 z0′′ + 2z0 z0′ + x0 (y0′ )2 ] y ′′′ = z ′′ y0′′′ = z0′′ = 0
− 2[yy ′′ + (y ′ )2 ] − 2[y0 y0′′ + (y0′ )2 ]
= 0 − 2[1 × (−1) + 0] = 2
Substituting in (4)
(0.1)2 (0.1)3
z1 = 0 + (0.1)(−1) + (0) + (2) + ...
2! 3!
= −0.1 + 0.000333 + ...
∴ z1 = −0.0997
By Taylor series for y1 ,
h2 ′′ h3 ′′′
y1 = y0 + hy0′ + y + y0 + ...
2! 0 3!
2
(0.1) (0.1)3
= 1 + (0.1)(0) + (−1) + (0) + ...
2! 3!
= 1 − 0.005 = 0.995
∴ y(0.1) = 0.995
10
Exercise
dy dz
1. Using Taylor’s series method, Solve the system of equations = z − x, = y + x with
dx dx
y(0) = 1, z(0) = 1 by taking h = 0.1, to get y(0.1) and z(0.1). Here y and z are
2. Solve y ′′ = y + xy ′ given y(0) = 1, y ′ (0) = 0 and calculate y(0.1). Using Taylor series method.
11
3 Picard’s method of successive approximations
We consider the general first order differential equation
dy
= f (x, y) (10)
dx
with the initial condtion,
y(x0 ) = y0
Integarting the differential equation (10), we obtain
Z x
y = y0 + f (x, y)dx. (11)
x0
Equation (11), in which the unknown function y apprears under the integarl sign, is called an
integral equation. Such an equation can be solved by the method of successive approximation in
which the first approximation to y is obtainefd by putting y0 for y on right side of (10), and we
write Z x
(1)
y = y0 + f (x, y0 )dx. (12)
x0
Teh integral on the right can now be solved and resulting y (1) is substituted for y in the integrand
of (10) to obtain the second approximation y (2) :
Z x
(2)
y = y0 + f (x, y (1) )dx. (13)
x0
processing in this way, we obtain y (3) , y (4) , . . . , y (n−1) and y (n) , where
Z x
(n)
y = y0 + f (x, y (n−1) )dx. (14)
x0
with y (0) = y0 Hence this method yields a sequence of approximations y (1) , y (2) , . . . , y (n) and it can
be proved that if the function f (x, y) is bounded in some region about the point (x0 , y0 ) and if
f (x, y) satisfies the Lipschitz condition, viz.,
K begin a constant.
then the sequence y (1) , y (2) , . . . converges to the solution of (10).
12
Problems based on Picard’s Method
dy
1. Solve = x + y given y(0) = 1. Obtain the values of y(0.1), y(0.2) using Picard’s method
dx
and check your answer with the exact solution.
Solution:
Here f (x, y) = x + y, x0 = 0, y0 = 1
Z x
y = y0 + f (x, y)dx.
x0
Z x
y =1+ f (x, y)dx. (16)
0
putting y = y0 on the R.H.S
x x
x2
Z Z
(1)
y = y0 + f (x, 1)dx = 1 + (x + 1)dx = 1 + x +
0 0 2
x3 x4
∴ y(x) =1 + x + x2 + + + ...
3 24
Setting x = 0.1,
1 1
y(0.1) = 1 + 0.1 + 0.01 + (0.001) + (0.0001)
3 24
= 1 + 0.1 + 0.01 + 0.0003333 + 0.00000041
= 1.1103374.
(0.2)3 (0.2)4
y(0.2) = 1 + 0.2 + (0.2)2 + +
3 24
= 1.242733.
dy
Integrating = x + y, we get y = 2ex − x − 1.
dx
∴ y(0.1) = 2e0.1 − 1 − 0.1 = 1.11034184 (actual value)
y(0.2) = 2e0.2 − 0.2 − 1 = 1.24280555
In both cases, y(0.1) are same (correct to 4 decimal places) and the values of y(0.2) differ only
by 0.0001.
13
′
2. Solve y + y = ex , y(0) = 0, by Picard’s method.
Solution:
By Picard’s method,
Z x
y = y0 + f (x, y)dx
x0
Z x
=0 + (ex − y)dx
0
Here , x0 =0, y0 = 0,
Z x
(1)
∴ y = (ex − 0)dx = ex − 1
Z0 x
y (2) = (ex − ex + 1)dx = x
Z0 x
x2
y (3) = (ex − x)dx = ex − −1
0 2
Z x
(4) x2 x3
y = [ex − (ex − − 1)]dx = +x
0 2 6
Z x
(5) x3 x2 x4
y = (ex − x − )dx = ex − − −1
0 6 2 24
x2 x4
Approximate y = ex − − − 1.
2 24
Exercise
′
1. Solve y = y − x2 , y(0) = 1, by Picard’s method upto the third approximation. Hence, find
the values of y(0.1), y(0.2).
dy
2. Solve = x2 + y 2 , y(0) = 1 by Picard’s method.
dx
14
4 Euler and Modified Euler Method
4.1 Euler’s Method
One of the simplest methods for solving the IVP is the classical Euler method.
The method is derived from the Taylor Series expansion of the function y(x).
Recall that the function y(x) has the following Taylor series expansion of order n at x = xi+1
and h = xi+1 − xi
h2 ′′ hn hn+1 (n+1)
y(xi+1 ) = y(xi ) + hy ′ (xi ) + y (xi ) + ... + y n (xi ) + y (ζi )
2! n! (n + 1)!
For n = 1, this formula reduces to
h2 ′′
y(xi+1 ) = y(xi ) + hy ′ (xi ) + y (ζi )
2!
h2 ′′
The term y (ζi ) is called the remainder term.
2!
Neglecting the remainder term, we can write the above equation as:
By Euler’s formula,
yn+1 = yn + hf (xn , yn )
Put n =0,
y1 = y0 + hf (x0 , y0 )
= 1 + (0.2)[x0 + y0 ]
= 1 + (0.2)[0 + 1]
∴ y(0.2) = 1.2
Put n =1,
y2 = y1 + hf (x1 , y1 )
= 1.2 + (0.2)[x1 + y1 ]
= 1.2 + (0.2)[0.2 + 1.2]
∴ y(0.4) = 1.48
Put n =2,
y3 = y2 + hf (x2 , y2 )
= 1.48 + (0.2)[x2 + y2 ]
= 1.48 + (0.2)[0.4 + 1.48]
∴ y(0.6) = 1.856
Exact solution is y = 2ex − x − 1. Hence the tabular values are:
16
x 0 0.2 0.4 0.6
The value of y deviates from the exact values as x increases. Hence we require to use Modified
Euler or Improved Euler method for the above problem.
By Euler’s formula,
yn+1 = yn + hf (xn , yn )
Put n =0,
y1 = y0 + hf (x0 , y0 )
= 1 + (0.05)[x0 + y0 + x0 y0 ]
= 1 + (0.05)[0 + 1 + (0)(1)]
y(0.05) = 1.05
∴ x1 = 0.05, y1 = 1.05
Put n =1,
y2 = y1 + hf (x1 , y1 )
= 1.05 + (0.05)[x1 + y1 + x1 y1 ]
= 1.05 + (0.05)[0.05 + 1.05 + (0.05)(1.05)]
y(0.1) = 1.107625
Put n=0,
1 1
y1 = y0 + h f x0 + h, y0 + hf (x0 , y0 )
2 2
17
0.25 0.25
= 1 + (0.25) f 0 + ,1 + (2x0 y0 )
2 2
0.25
= 1 + (0.25) f 0.125, 1 + (2)(0)(1)
2
= 1 + 0.25[(2)(0.125)(1)]
= 1 + 0.0625 = 1.0625
∴ y(0.25) = 1.0625
dy 2
By solving = 2xy, we get y = ex using y(0)=1.
dx 2
=⇒ y(0.25) = e(0.25) = 1.0645
Exact value of y(0.25)= 1.0645. Error is only 0.002.
4. Given y ′ = x2 − y, y(0) = 1, find correct to four decimal places the values of y(0.1), by using
Improved Euler method.
Exercise
1. Solve the initial value problem yy ′ = x, y(0) = 1, using the Euler method in 0 ≤ x ≤ 0.8, with
h = 0.2 and h = 0.1.
2. Solve f (x, y) = 1 − y, y(0) = 0 by Euler and modified Euler method. Calculate y(0.1), y(0.2)
and y(0.3). Compare your results with the exact solutions. Also, get the solution by Improved
Euler method.
18
5 Runge-Kutta Method
The use of the previous methods to solve the differential equation numerically is restricted due
to either slow convergence or due to labour involved, especially in Taylor-series method. But, in
Runge-Kutta methods, the derivatives of higher order are not required and we require only the
given function values at different points.
dy
Aim: To solve = f (x, y) given y(x0 ) = y0 , h = xn+1 − xn
dx
19
Problems based on Runge-Kutta Method
1. Apply the fourth order Runge-Kutta method to find y(0.1) and y(0.2)
given that y ′ = x + y, y(0) = 1.
Solution: Given y ′ = x + y; y(0) = 1
∴ f (x, y) = x + y, x0 = 0, y0 = 1, h = 0.1
We have to find the value of y at x = 0.1 and x=0.2
By Fourth order Runge-Kutta Method, for the first interval,(put n=0 in general formula)
k1 = hf (x0 , y0 )
h k1
k2 = hf x0 + , y0 +
2 2
h k2
k3 = hf x0 + , y0 +
2 2
k4 = hf (x0 + h, y0 + k3 )
1
and △ y = (k1 + 2k2 + 2k3 + k4 )
6
Substitute the given values we get,
k1 = (0.1)f (0, 1)
= (0.1)(0 + 1) = 0.1
(0.1) (0.1)
k2 = (0.1)f 0 + ,1 +
2 2
= (0.1)f (0.05, 1.05) = (0.1)(0.05 + 1.05) = 0.11
(0.1) (0.11)
k3 = (0.1)f 0 + ,1 +
2 2
= (0.1)f (0.05, 1.055) = (0.1)(0.05 + 1.055) = 0.1105
k4 = (0.1)f (0 + 0.1, 1 + 0.1105)
= (0.1)f (0.1, 1.1105) = (0.1)(0.1 + 1.1105) = 0.12105
1
∴ △y = (k1 + 2k2 + 2k3 + k4 )
6
1
= [0.1 + 2(0.11) + 2(0.1105) + 0.12105] = 0.110341667
6
∴ y(0.1) = y1 = y0 + △y
= 1 + 0.110341667 = 1.110341667 ≈ 1.110342
20
Now starting from (x1 , y1 ) we get (x2 , y2 ). Again apply Runge-Kutta algorithm replacing
(x0 , y0 ) by (x1 , y1 )
k1 = hf (x1 , y1 )
= (0.1)(x1 + y1 ) = (0.1)(0.1 + 1.110342) = 0.1210342
h k1
k2 = hf x1 + , y1 +
2 2
= (0.1)f (0.15, 1.170859) = (0.1)(0.15 + 1.170859) = 0.1320859
h k2
k3 = hf x1 + , y1 +
2 2
= (0.1)f (0.15, 1.1763848) = (0.1)(0.15 + 1.1763848) = 0.13263848
k4 = hf (x1 + h, y1 + k3 )
= (0.1)f (0.2, 1.24298048) = (0.1)(0.2 + 1.24298048) = 0.144298048
1
and △ y = (k1 + 2k2 + 2k3 + k4 )
6
1
= [0.1210342 + 2(0.1320859) + 2(0.13263848) + 0.144298048] = 0.13246350
6
∴ y(0.2) = y2 = y1 + △y
= 1.110342 + 0.13246350 = 1.2428055 ≈ 1.2428
2. Obtain the values of y at x = 0.1 and 0.2 using R.K. method of (i) Second order (ii) Third
order and (iii) Fourth order for the differential equation y ′ = −y given y(0) = 1.
k1 = hf (x0 , y0 )
= (0.1)(−y0 ) = (0.1)(−1) = −0.1
h k1
k2 = hf x0 + , y0 +
2 2
(0.1) (−0.1)
= (0.1)f 0 + ,1 +
2 2
= (0.1)f (0.05, 0.95) = −0.1 × 0.95 = −0.095
and △ y = k2 = −0.095
∴ y(0.1) = y1 = y0 + △y
= 1 − 0.095 = 0.905
y1 = y(0.1) = 0.905
21
Again starting form (0.1,0.905) replacing (x0 , y0 ) by (x1 , y1 ) we get
k1 = hf (x1 , y1 )
= (0.1)(−y1 ) = (0.1)(−0.905) = −0.0905
h k1
k2 = hf x1 + , y1 +
2 2
= (0.1)f (0.15, 0.85975) = −0.1 × 0.85975 = −0.085975
and △ y = k2 = −0.085975
∴ y(0.2) = y2 = y1 + △y
= 1 − 0.085975 = 0.819025
y2 = y(0.2) = 0.819025
k1 = hf (x0 , y0 )
= (0.1)(−y0 ) = (0.1)(−1) = −0.1
h k1
k2 = hf x0 + , y0 +
2 2
(0.1) (−0.1)
= (0.1)f 0 + ,1 +
2 2
= (0.1)f (0.05, 0.95) = −0.1 × 0.95 = −0.095
k3 = hf (x0 + h, y0 + 2k2 − k1 )
= (0.1)f (0.1, 0.9) = −0.09
1
and △ y = (k1 + 4k2 + k3 )
6
1
= [−0.1 + 4(−0.095) − 0.09] = −0.095
6
∴ y(0.1) = y1 = y0 + △y
= 1 − 0.095 = 0.905 ≈ 0.91
y1 = y(0.1) = 0.91
k1 = hf (x1 , y1 )
= (0.1)(−y1 ) = (0.1)(−0.91) = −0.091
h k1
k2 = hf x1 + , y1 +
2 2
= (0.1)f (0.15, 0.865) = −0.1 × 0.865 = −0.0865
k3 = hf (x1 + h, y1 + 2k2 − k1 )
= (0.1)f (0.2, 0.828) = −0.0828
22
1
and △ y = (k1 + 4k2 + k3 )
6
1
= [−0.091 + 4(−0.0865) − 0.0828] = −0.08663
6
∴ y(0.2) = y2 = y1 + △y
= 0.91 − 0.08663 = 0.823366
y(0.2) = 0.823366
k1 = hf (x0 , y0 )
= (0.1)(−y0 ) = (0.1)(−1) = −0.1
h k1
k2 = hf x0 + , y0 +
2 2
= (0.1)f (0.05, 0.95) = −0.095
h k2
k3 = hf x0 + , y0 +
2 2
= (0.1)f (0.05, 0.9525) = −0.09525
k4 = hf (x0 + h, y0 + k3 )
= (0.1)f (0.1, 0.90475) = −0.090475
1
and △ y = (k1 + 2k2 + 2k3 + k4 )
6
∴ y(0.1) = y1 = y0 + △y
1
= y0 + (k1 + 2k2 + 2k3 + k4 )
6
y1 = y(0.1) = 0.9048375
Again starting from this (x1 , y1 ) and replace (x0 , y0 ) and repeat the process.
k1 = hf (x1 , y1 )
= (0.1)(−y1 ) = −0.09048375
h k1
k2 = hf x1 + , y1 +
2 2
= (0.1)f (0.15, 0.8595956) = −0.08595956
h k2
k3 = hf x1 + , y1 +
2 2
= (0.1)f (0.15, 0.8618577) = −0.08618577
k4 = hf (x1 + h, y1 + k3 )
= (0.1)f (0.2, 0.8186517) = −0.08186517
23
1
and △ y = (k1 + 2k2 + 2k3 + k4 )
6
∴ y(0.2) = y2 = y1 + △y
1
= y0 + (k1 + 2k2 + 2k3 + k4 )
6
y2 = y(0.2) = 0.81873089
Exercise
dy
1. Compute y(0.3) given + y + xy 2 = 0, y(0) = 1 by taking h =0.1 using R.K. method of
dx
fourth order (correct to 4 decimals).
dy y 2 − x2
2. Using R.K. method of fourth order, solve = 2 given y(0)=1 at x = 0.2, 0.4
dx y + x2
24
5.4 Runge-Kutta method for simultaneous first order differential equa-
tions
dy dz
AIM: To solve numerically the simultaneous equation = f1 (x, y, z) and = f2 (x, y, z) given
dx dx
the initial conditions y(x0 ) = y0 , z(x0 ) = z0
Now, starting from (x0 , y0 , z0 ) the increment △y and △z in y and z respectively are given by
formula.
k1 = hf1 (x0 , y0 , z0 )
h k1 l1
k2 = hf1 x0 + , y0 + , z0 +
2 2 2
h k2 l2
k3 = hf1 x0 + , y0 + , z0 +
2 2 2
k4 = hf1 (x0 + h, y0 + k3 , z0 + l3 )
1
and △ y = (k1 + 2k2 + 2k3 + k4 )
6
l1 = hf2 (x0 , y0 , z0 )
h k1 l1
l2 = hf2 x0 + , y0 + , z0 +
2 2 2
h k2 l2
l3 = hf2 x0 + , y0 + , z0 +
2 2 2
l4 = hf2 (x0 + h, y0 + k3 , z0 + l3 )
1
and △ z = (l1 + 2l2 + 2l3 + l4 )
6
y1 = y0 + △y and z1 = z0 + △z
Having got (x1 , y1 , z1 ) we get (x2 , y2 , z2 ) by repeating the above algorithm once again starting from
(x1 , y1 , z1 ).
25
Problems based on R.K. Method for simultaneous 1st order differential equations
dy dz
1. Find y(0.1), z(0.1) from the system of equations, = x + z, = x − y 2 given y(0)=2,
dx dx
z(0)=1 using R.K. method of fourth order.
dy dz
Solution: Now = x + z, = x − y 2 =⇒ f1 (x, y, z) = x + y; f2 (x, y, z) = x − y 2
dx dx
x0 = 0, y0 = 2, z0 = 1, h = 0.1
we use R.K.method of fourth order formula,
k1 = hf1 (x0 , y0 , z0 ) l1 = hf2 (x0 , y0 , z0 )
= (0.1)f1 (0, 2, 1) = (0.1)f2 (0, 2, 1)
= (0.1)(0 + 1) = (0.1)(0 − (2)2 )
= 0.1 = −0.4
h k1 l1 h k1 l1
k2 = hf1 x0 + , y0 + , z0 + l2 = hf2 x0 + , y0 + , z0 +
2 2 2 2 2 2
= (0.1)f1 (0.05, 2.05, 0.8) = (0.1)f2 (0.05, 2.05, 0.8)
= (0.1)(0.05 + 0.8) = (0.1)(0.05 − (2.05)2 )
= 0.085 = −0.41525
h k2 l2 h k2 l2
k3 = hf1 x0 + , y0 + , z0 + l3 = hf2 x0 + , y0 + , z0 +
2 2 2 2 2 2
= (0.1)f1 (0.05, 2.0425, 0.79238) = (0.1)f2 (0.05, 2.0425, 0.79238)
= (0.1)(0.05 + 0.79238) = (0.1)(0.05 − (2.0425)2 )
= 0.084238 = −0.4122
1 1
△y = (k1 + 2k2 + 2k3 + k4 ) △z = (l1 + 2l2 + 2l3 + l4 )
6 6
y1 = y0 + △y
1
= 2 + (0.1 + 2(0.085) + 2(0.084238) + 0.06878)
6
= 2.0845
z1 = z0 + △z
1
= 1 + ((−0.4) + 2(−0.41525) + 2(−0.4122) + (−0.4244))
6
= 0.5868
∴ y(0.1) = 2.0845 and z(0.1) = 0.5868
26
5.5 Runge-Kutta method for second order differential equation
AIM: To solve y ′′ = f (x, y, y ′ ), given y(x0 ) = y0 , y ′ (x0 ) = y0′
dy
= y′ = z
dx
and
dz
= z ′ = y ′′ = f (x, y, y ′ ) = f (x, y, z)
dx
dy dz
∴ = z and = f (x, y, z)
dx dx
are simultaneous equations where
1. Given y ′′ + xy ′ + y = 0, y(0) = 1, y ′ (0) = 0, find the value of y(0.1) by using R.K. method of
fourth order.
setting y ′ = z
dy
∴ = z = f1 (x, y, z)
dx
dz
= −xz − y = f2 (x, y, z)
dx
given x0 = 0, y0 = 1, z0 = y0′ = 0
27
By algorithm,
1 1
△y = (k1 + 2k2 + 2k3 + k4 ) △z = (l1 + 2l2 + 2l3 + l4 )
6 6
y1 = y0 + △y
1
= 1 + (0 + 2(−0.005) + 2(−0.00499) + (−0.00995))
6
= 0.9950
y(0.1) = 0.9950
Exercise
1. Solve y ′ = −xz, z ′ = y 2 given y(0)=1, z(0)=1 for x=0 (0.2) 0.4 Using R.K. method
2. Using R.K. method, find y(0.1) given y ′′ + 2xy ′ − 4y = 0, y(0) = 0.2, y ′ (0) = 0.5
dy dz xy 1
3. Using R.K. method, Evaluate y(1.1), z(1.1) given = xyz, = , y(1) = , z(1) = 1
dx dx z 3
28
6 Predictor-Corrector methods
‘
The method which we have discussed so far are called single-step methods because they are
use only the information from the last step computed. The method of Milne’s predictor-corrector,
Adams-Bashforth predictor-corrector formulae are multi-step methods.
dy
In solving the equation = f (x, y), y(x0 ) = y0 we used Euler’s formula
dx
yi+1 = yi + hf ′ (xi , yi ), i = 0, 1, 2, ... .......(1)
29
Problems based on Milne’s and Adam’s Methods
dy 1
1. Solve and get y(2) given = (x + y) , y(0)=2, y(0.5)=2.636, y(1)=3.595 and y(1.5)=4.968
dx 2
by (i) Milne’s method (ii) Adam’s method
4(0.5)
y4,p = 2 + [2(1.5680) − (2.2975) + 2(3.2340)]
3
= 6.8710
1 1
y4′ = (x4 + y4 ) = (2 + 6.8710) = 4.4355
2 2
30
Using (3), we get
0.5
y4,c = 3.595 + [2.2975 + 4(3.2340) + 4.4355]
3
= 6.8732
0.5
y4,p = 4.968 + [55(3.2340) − 59(2.2975) + 37(1.5680) − 9(1)]
24
= 6.8708
1 1
y4′ = (x4 + y4 ) = (2 + 6.8708) = 4.4354
2 2
Using (5), we get
0.5
y4,c = 4.968 + [9(4.4354) + 19(3.234) − 5(2.2975) + 1.5680]
24
= 6.8731
31
2. Using Milne’s method find y(4.4) given 5xy ′ + y 2 − 2 = 0 given y(4) =1, y(4.1) = 1.0049,
y(4.2)=1.0097, and y(4.3) = 1.0143.
32
Exercise
1. Determine the value of y(0.4) using Milne’s method given y ′ = xy + y 2 , y(0)=1; using Taylor’s
series to get the value of y(0.1), y(0.2) and y(0.3).
2. Given y ′ = 3ex + 2y, y(0)=0, find y(0.1) by Euler method ; y(0.2) by Taylor’s method; y(0.3)
by R.K. method and y(0.4) by both Adam’s and Milne’s method.
We now study the stability of the single step methods when applied to the test equation , u′ =
λu, u(t0 ) = u0 where λ may be a real or complex number. The exact solution of the initial value
problem is u(t) = η0 eλ(t−t0 ) . Substitute t = tj+1 and t = tj in above solution and dividing , we get
u(tj+1 ) eλ(tj+1 −t0 )
= λ(tj −t0 ) = eλ(tj+1 −tj )
u(tj ) e
(i.e) u(tj+1 ) = eλh u(tj )
If we apply any single step method to solve the test equation u′ = λu, then we get a first order
difference equation of the form
uj+1 = E(λh)uj , j = 0, 1, 2, ... (2)
let ϵj = uj − u(tj ), Then we have
ϵj+1 = uj+1 − u(tj+1 )
= E(λh)uj − u(tj+1 )
= E(λh)[ϵj + u(tj )] − u(tj+1 )
= E(λh)[ϵj + u(tj )] − eλh u(tj )
= [E(λh) − eλh ]u(tj ) + E(λh)ϵj
33
The first term on the right hand side is the local truncation error and the second term on the
right hand side is the error propagated from the step tj to tj+1 . The error on the next step tj+2
satisfies the equation
ϵj+2 = [E 2 (λh) − e2λh ]u(tj ) + E 2 (λh) ϵj
where again the first term on the right hand side is the local truncation error and the second term
is the propagated error. The errors in computations do not grow, if the propagated error tends to
zero or is atleast bounded.
4. asymptotically stable (A-stable) if uj → 0 as j → ∞.. This implies that the stability interval
is hλ ∈ (−∞, 0), that is the entire left half hλ plane.
When λ < 0, the exact solution decreases as t increases and the necessary condition is absolute
stability, since the numerical solution must also decrease with t. When λ > 0. the exact solution
increases with t and we do not need the condition |E(λh)| ≤ 1, so that the relative stability is
the necessary condition to be satisfied. When λ is pure imaginary and |E(λh)| = 1, the absolute
stability is called periodic stability (P-stability).
uj+1 = uj + hfj
= uj + h(λuj )
= (1 + λh)uj
= E(λh)uj
When λ is real and λ < 0 , the condition |E(λh)| < 1 ⇒ |1 + λh| < 1 ⇒ −1 < 1 + λh < 1 ⇒
−2 < hλ < 0 ,which is the interval of stability.
When λ is complex with Re(λ) < 0. let h = λh = x + iy then |1 + λh| = |(1 + x) + iy| =
p
(1 + x)2 + y 2 . Hence, |1 + λh| < 1 gives (x + 1)2 + y 2 < 1, which is the region inside the circle
with centre at (-1,0) and radius 1.
34
Figure 1: Stability region for Euler’s method, h = hλ
K1 = hf (tj , uj )
K2 = hf (tj + c2 h, uj + c2 K1 )
h2 λ2
where E(λh) = 1 + hλ + .
2
Hence the propagation factor E(λh) is independent of the parameter c2 . Therefore, the stability
intervals or regions of all the second order methods is same.
35
Now, for λ real and λ < 0, the condition
h2 λ2
|E(λh)| = |1 + hλ + |<1
2
h2 λ2
⇒ −1 < 1 + hλ + <1
2
1 1 2 h2 λ2
⇒ −1 < + + hλ + <1
2 2 2 2
1 1
⇒ −1 < + [1 + 2hλ + h2 λ2 ] < 1
2 2
1
⇒ −1 < [1 + (1 + hλ)2 ] < 1
2
⇒ −2 < [1 + (1 + hλ)2 ] < 2
⇒ −2 < [1 + (1 + hλ)2 ] < 2
The left inequality is always satisfied. The right inequality gives (1 + hλ)2 < 1 ⇒ |1 + λh| < 1
giving hλ ∈ (−2, 0). Hence the interval of stability is (-2,0).
36