0% found this document useful (0 votes)
12 views37 pages

NumericalMethods ODE 250316 111213

The document provides lecture notes on numerical solutions for ordinary differential equations, covering methods such as Euler’s, Taylor’s, Picard’s, and Runge-Kutta, along with predictor-corrector methods like Milne’s and Adams’. It emphasizes the importance of numerical methods in engineering for solving problems where analytical solutions are impractical or unavailable. Additionally, it discusses the need for understanding the concepts, methods, and applications of numerical analysis in order to effectively utilize these techniques.

Uploaded by

soumeshparida05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views37 pages

NumericalMethods ODE 250316 111213

The document provides lecture notes on numerical solutions for ordinary differential equations, covering methods such as Euler’s, Taylor’s, Picard’s, and Runge-Kutta, along with predictor-corrector methods like Milne’s and Adams’. It emphasizes the importance of numerical methods in engineering for solving problems where analytical solutions are impractical or unavailable. Additionally, it discusses the need for understanding the concepts, methods, and applications of numerical analysis in order to effectively utilize these techniques.

Uploaded by

soumeshparida05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

NATIONAL INSTITUTE OF TECHNOLOGY : TIRUCHIRAPPALLI

Dr. K. Murugesan
Professor(HAG)
Department of Mathematics
National Insitute of Technology
Tiruchirappalli - 620015
Tamil Nadu, India
Email : [email protected]

MAIR43 - Fourier Transforms and Numerical Techniques

LECTURE NOTES ON NUMERICAL SOLUTION’S FOR


ORDINARY DIFFERENTIAL EQUATIONS
[Numerical Solution of ODE’s – Euler’s, Taylor’s, Picard’s and Runge Kutta
methods – Milne’s and Adams’ predictor-corrector methods - Stability analysis.]

1
INTRODUCTION TO NUMERICAL METHODS

Numerical Methods:
Algorithms that are used to obtain numerical solutions of a mathematical problem.

Why do we need them?


1. No analytical solution exists,

2. An analytical solution is difficult to obtain or not practical.

What do we need?
Basic Needs in the Numerical Methods:

ˆ Practical:

– Can be computed in a reasonable amount of time.

ˆ Accurate:

– Good approximate to the true value,


– Information about the approximation error (Bounds, error order,. . . ).

Why are Numerical Methods so widely used in Engineering?


ˆ Engineers use mathematical modeling (equations and data) to describe and predict the be-
havior of systems.

ˆ Closed-form (analytical) solutions are only possible and complete for simple problems (geom-
etry, properties, etc.).

ˆ Computers are widely available, powerful, and (relatively) cheap.

ˆ Powerful software packages are available (special or general purpose).

2
A few applications of Numerical Methods in Engineering:
ˆ Structural/mechanical analysis, design, and behavior.

ˆ Communication/power

– Network simulation
– Train and traffic networks

ˆ Computational Fluid Dynamics (CFD):

– Weather prediction
– Groundwater & pollutant movement

Why study Numerical Methods?


Numerical Analysis is a Discipline:
ˆ Need to understand concepts and theory

– Know what problems can be solved.


– Know what problems cannot be solved, or when problems will be troublesome.

ˆ Need to understand methods and techniques

– Know why methods work, or judge when they are working.


– Be able to create or modify tools (software) as needed.
– Evaluate errors, convergence, and stability of arithmetic approximations.

ˆ Use of Numerical Methods is an Art:

– Numerical methods are approximate.


– The most appropriate method(s) is not always obvious.
– Evaluating precision and accuracy is an essential part of the process.

3
Numerical Solution for Ordinary Differential Equations

1 Initial Value Problem for Ordinary Differential Equa-


tions
We consider the problem of numerically solving a differential equation of the form
dy
= f (x, y), a ≤ x ≤ b, y(a) = α (given) .........(1)
dx
Such a problem is called the Initial Value Problem or in short IVP, because the initial value of
the solution y(a) = α is given.
Since there are infinitely many values between a and b, we will only be concerned here to find
approximations of the solution y(x) at several specified values of t in [a, b], rather than finding y(x)
at every value between a and b.
The following strategy will be used:

ˆ Divide [a, b] into N equal subintervals each of lengthh:

x0 = a < x1 < x2 < ... < xN = b

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 .

– y(xi ) = Exact value of y(x) at x = xi .


– yi = An approximation of y(xi ) at x = xi .

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.

1.1 Single step methods (or) pointwise methods


A series for y in terms of powers of x, form which the value of y can be obtained by direct
substitution. The methods of Taylor and Picard belong to this type. In these methods y is approx-
imated by a truncated series and each term of the series is a function of x. The information about
the curve at one point is used and the solution is not iterated. Hence, these methods are called
single step methods (or) pointwise methods.

1.2 Multistep methods (or) step by step methods


In a set of tabulated values of x and y, we obtain y by iterative process. The method Euler,
Runge-Kutta, Milne, Adam-Bashforth etc., belong to this type. Here, the value of y are computed
by short steps for equal intervals h of the independent variable. These values are iterated till we
get the desired accuracy. Hence, these methods are called step by step methods.

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 .

Substituting x = xi+1 in (2), we obtain

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:

Given y ′ = x2 y − 1 and x0 = 0, y0 = 1, h = 0.1 [ Hint: h = x1 − x0 = 0.1 − 0 = 0.1]

By using Taylor’s series formula,

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

y ′′ = 2xy + x2 y ′ y0′′ = 2x0 y0 + x20 y0′ = 0 + 0 = 0

y ′′′ = 2[xy ′ + y] + x2 y ′′ + 2xy ′ y0′′′ = 2y0 + 4x0 y0′ + x20 y0′′


= 2xy ′ + 2y + x2 y ′′ + 2xy ′ = 2(1) + 4(0)(−1) + (0)2 (0)
= 2y + 4xy ′ + x2 y ′′ =2

y iv = 2y ′ + 4[xy ′′ + y ′ ] + x2 y ′′′ + y ′′ 2x y0iv = 6y0′ + 6x0 y0′′ + x20 y0′′′


= 2y ′ + 4xy ′′ + 4y ′ + x2 y ′′′ + y ′′ 2x = 6(−1) + 6(0)(0) + (0)(2)
= 6y ′ + 6xy ′′ + x2 y ′′′ = −6

(0.1)2 (0.1)3 (0.1)4


∴ y1 = 1 + (0.1)(−1) + (0) + (2) + (−6) + ...
2! 3! 4!
(i.e., ) y(0.1) = 1 − 0.1 + 0.00033 − 0.000025 = 0.900305
y(0.1) = 0.900305

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:

Given y ′ = x + y and x0 = 0, y0 = 1, h = 0.1

We know that, the Taylor’s series formula for y1 is

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

y ′′′ = y ′′ y0′′′ = y0′′ = 2

y iv = y ′′′ y0iv = y0′′′ = 2

(0.1)2 (0.1)3 (0.1)4


∴ y1 = 1 + (0.1)(1) + (2) + (2) + (2) + ...
2! 3! 4!
y(0.1) = 1 + 0.1 + 0.01 + 0.00033
y(0.1) = 1.11033
To find y2 :
Now, take x1 = 0.1, y1 = 1.1103, h = 0.1
h2 ′′ h3 ′′′
∴ y2 = y1 + hy1′ + y + y1 + ...
2! 1 3!
Since,

y1′ = x1 + y1 = 0.1 + 1.1103 = 1.2103


y1′′ = 1 + y1′ = 1 + 1.2103 = 2.2103
y1′′′ = y1′′ = 2.2103
(0.1)2 (0.1)3
=⇒ y2 = 1.1103 + (0.1)(1.2103) + (2.2103) + (2.2103) + ...
2! 3!
y(0.2) = 1.1103 + 0.12103 + 0.0110515 + 0.00037
y(0.2) = 1.24275

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

dependent variables and x is independent.


Solution:

Given y ′ = z − x2 , z ′ = x + y, x0 = 0, y0 = 1, z0 = 1

y ′ = z − x2 y0′ = z0 − x20 = 1 − 0 = 1 z′ = x + y z0′ = x0 + y0 = 0 + 1 = 1

y ′′ = z ′ − 2x y0′′ = z0′ − 2x0 = 1 − 2(0) = 1 z ′′ = 1 + y ′ z0′′ = 1 + y0′ = 1 + 1 = 2

y ′′′ = z ′′ − 2 y0′′′ = z0′′ − 2 = 2 − 2 = 0 z ′′′ = y ′′ z0′′′ = y0′′ = 1

y iv = z ′′′ y iv = z0′′′ = 1 z iv = y ′′′ z0iv = y0′′′ = 0

By Taylor’s series for y1 and z1 , we have

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

2.3 Taylor’s series method for Second order differential equation


Any differential equation of the second or higher order can be solved by reducing it to a lower
order differential equation. A second order differential equation can be reduced to a first order
differential equation by transforming y ′ = z and then the later one can be solved as usual.

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)

and y ′ (x0 ) = y0′ (3)


where y0 , y0′ are known values.
setting y ′ = z (4)
We gety ′′ = z ′ and the equation (1) becomes

z ′ = f (x, y, z) (5)

with initial conditions,


y(x0 ) = y0 (6)
and z(x0 ) = z0 = y0′ (7)
Now, we resort to solve (5) together with (6) and (7) using Taylor series method.

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)

hence the equation reduce to


z ′ − xz 2 + y 2 = 0
∴ z ′ = xz 2 − y 2 ........(2)
By initial condition, y0 = y(0) = 1, z0 = y0′ = 0 ........(3)
Now we solve (2) given z0 = z(0) = 0, and x0 = 0 Here,
h2 ′′ h3 ′′′
z1 = z0 + hz0′ + z + z0 + ... ........(4)
2! 0 3!
From (2), we get the derivative of z

z ′ = xz 2 − y 2 z0′ = x0 z02 − y02 = −1 y′ = z y0′ = z0 = 0

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

dependent variables and x is independent.

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.,

|f (x, y) − f (x, y)| ≤ K|y − y| (15)

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

Again using y = y (1) on the R.H.S of (16), we get


Z x
(2) x2 x3
y =1+ (x + 1 + x + )dx = 1 + x + x2 +
0 2 6
agian using on the R.H.S.
Z x
(3) x3 x3 x4
y =1+ (x + 1 + x + x2 + )dx = 1 + x + x2 + +
0 6 3 24

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:

y(xi+1 ) = y(xi ) + hy ′ (xi )


Using our notations, established earlier, we then have
yi+1 = yi + hf (xi , yi )
Since y ′ = f (xi , yi )
We can then recursively generate the successive approximations y1 , y2 , ..., yn to y(x1 ), y(x2 ), ...y(xn )
as follows:
y0 = α (given)
y1 = y0 + hf (x0 , y0 )
y2 = y1 + hf (x1 , y1 )
...
yn = yn−1 + hf (xn−1 , yn−1 )
These iterations are known as Euler’s iterations and the method is the historical Euler’s method.
In other words,
yn+1 = yn + hf (xn , yn )

4.2 Improved Euler Method


The difference between Euler’s method and improved Euler’s method is that in the latter We take
(1)
the average of the slopes at (x0 , y0 ) and (x1 , y1 ) instead of the slope at (x0 , y0 ) in the former
method.
The formula for Improved Euler’s method is
1
yn+1 = yn + h [f (xn , yn ) + f (xn + h, yn + hf (xn , yn ))]
2
15
4.3 Modified Euler Method
In previous improved Euler method , we average the slopes, whereas in modified Euler method , we
will average the points.
The formula for Modified Euler’s method is
  
1 1
yn+1 = yn + h f xn + h, yn + hf (xn , yn )
2 2
Note:
Hence the Euler predictor is
yn+1 = yn + hyn′
and the corrector is
h
yn+1 = yn + (yn′ + yn+1

)
2
in the Improved Euler method
Problems based on Euler, Improved and Modified Euler Method
1. Using Euler’s method find y(0.2), y(0.4) and y(0.6) from y ′ = x + y, y(0) = 1 with h=0.2
Check your answer with exact solution.
Solution:

Given f (x, y) = x + y, x0 = 0, y0 = 1, x1 = 0.2, x2 = 0.4, x3 = 0.6, h = 0.2

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

Euler y 1 1.2 1.48 1.856

Exact y 1 1.2428 1.5836 2.0442

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.

2. Using Euler’s method, solve y ′ = x + y + xy, y(0) = 1 compute y at x =0.1, by taking h =


0.05.
Solution:

Given f (x, y) = x + y + xy, x0 = 0, y0 = 1, h = 0.05

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

3. Compute y at x = 0.25 by modified Euler’s method given y ′ = 2xy, y(0) = 1

Solution: Given f (x, y) = 2xy, x0 = 0, y0 = 1, h = 0.25, x1 = 0.25

By Modified Euler’s formula,


  
1 1
yn+1 = yn + h f xn + h, yn + hf (xn , yn )
2 2

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.

Solution: Given y ′ = x2 − y, x0 = 0, y0 = 1, x1 = 0.1, h = 0.1

By Improved Euler method,


1
yn+1 = yn + h [f (xn , yn ) + f (xn + h, yn + hf (xn , yn ))]
2
put n=0,
1
y1 = y0 + h [f (x0 , y0 ) + f (x0 + h, y0 + hf (x0 , y0 ))]
2
(0.1)
y1 = 1 + [f (0, 1) + f (x1 , 1 + (0.1)f (0, 1))]
2
(0.1)
=1+ [(0 − 1) + f (x1 , 1 + (0.1)(0 − 1))]
2
(0.1)
=1+ [−1 + f (0.1, 0.9)]
2
(0.1) 
−1 + ((0.1)2 − 0.9))

=1+
2
(0.1)
=1+ [−1.89]
2
∴ y1 = y(0.1) = 0.9055

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

5.1 Second order Runge-Kutta Method (for 1st order O.D.E.)


Second order R-K Algorithm is
k1 = hf (xn , yn )
 
h k1
k2 = hf xn + , yn +
2 2
and △ y = k2
∴ y(xn + h) = y(xn ) + △y
Note: Since Runge-Kutta method of second order is nothing but the modified Euler method.

5.2 Third order Runge-Kutta Method (for 1st order O.D.E.)


Third order R-K Algorithm is
k1 = hf (xn , yn )
 
h k1
k2 = hf xn + , yn +
2 2
k3 = hf (xn + h, yn + 2k2 − k1 )
1
and △ y = (k1 + 4k2 + k3 )
6
∴ y(xn + h) = y(xn ) + △y

5.3 Fourth order Runge-Kutta Method (for 1st order O.D.E.)


Fourth order R-K Algorithm is
k1 = hf (xn , yn )
 
h k1
k2 = hf xn + , yn +
2 2
 
h k2
k3 = hf xn + , yn +
2 2
k4 = hf (xn + h, yn + k3 )
1
and △ y = (k1 + 2k2 + 2k3 + k4 )
6
∴ y(xn + h) = y(xn ) + △y (or) yn+1 = yn + △y

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.

Solution: Here f (x, y) = −y, x0 = 0, y0 = 1, x1 = 0.1, x2 = 0.2

(i) Second order:

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

(ii) Third order:

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

Again taking (x1 , y1 ) as (x0 , y0 ) repeat the process.

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

(ii) Fourth order:

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

Tabular values are:

x Second order Third order Fourth order Exact Value


y = e−x

0.1 0.905 0.91 0.9048375 0.904837418

0.2 0.819025 0.823366 0.81873089 0.818730753

Fourth order values are more closer to exact values.

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

Here, x is independent variable while y and z are dependent

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

k4 = hf1 (x0 + h, y0 + k3 , z0 + l3 ) l4 = hf2 (x0 + h, y0 + k3 , z0 + l3 )


= (0.1)f1 (0.1, 2.084238, 0.5878) = (0.1)f2 (0.1, 2.084238, 0.5878)
= (0.1)(0.1 + 0.5878) = (0.1)(0.1 − (2.084238)2 )
= 0.06878 = −0.4244

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′

Now set y ′ = z and y ′′ = z ′ ,

Hence the differential equation reduce to

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

f1 (x, y, z) = z and f2 (x, y, z) = f (x, y, z)

Also y(0) and z(0) are given.


starting from these equations, we can use the previous algorithm and solve the problem.

Problems based on R.K. Method for 2nd order differential equations

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.

Solution: Given y ′′ + xy ′ + y = 0, y(0) = 1, y ′ (0) = 0, h = 0.1

setting y ′ = z

The equation becomes,


y ′′ = −xz − 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,

k1 = hf1 (x0 , y0 , z0 ) l1 = hf2 (x0 , y0 , z0 )


= (0.1)f1 (0, 1, 0) = (0.1)f2 (0, 1, 0)
= (0.1)(0) = (0.1)(0 − 1)
=0 = −0.1
   
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, 1, −0.05) = (0.1)f2 (0.05, 1, −0.05)
= (0.1)(−0.05) = (0.1)(−(0.05)(−0.05) − (1))
= −0.005 = −0.09975
   
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, 0.9975, −0.0499) = (0.1)f2 (0.05, 0.9975, −0.0499)
= (0.1)(−0.0499) = (0.1)(−(−0.04991)(0.05) − (0.9975))
= −0.00499 = −0.09950

k4 = hf1 (x0 + h, y0 + k3 , z0 + l3 ) l4 = hf2 (x0 + h, y0 + k3 , z0 + l3 )


= (0.1)f1 (0.1, 0.99511, −0.0995) = (0.1)f2 (0.1, 0.99511, −0.0995)
= (0.1)(−0.0995) = (0.1)(−(0.1)(−0.0995) − (0.99511))
= −0.00995 = −0.0985

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)

We improved this value by Improved Euler method


1
yi+1 = yi + h [f (xi , yi ) + f (xi+1 , yi+1 )] .......(2)
2
In the equation (2), to get the value of yi+1 we require yi+1 on the R.H.S. To overcome this
difficulty, we calculate yi+1 using Euler’s formula (1) and then we use it on the R.H.S. of (2), to get
the L.H.S. of (2). This yi+1 can be used further to get refined yi+1 on the L.H.S. Here, we predict a
value of yi+1 from the rough formula (1) and use in (2) to correct the value. Every time, we improve
using (2). Hence equation (1) Euler’s formula is a predictor and (2) is a corrector. A predictor
formula is used to predict the value of y at xi+1 and a corrector formula is used to correct the error
and to improve that value of yi+1 .

6.1 Milne’s Predictor corrector Formulae


We state below that a Predictor-Corrector method, called Milne’s method. We give below predictor
and corrector formula without proof. Here we require four continuous values of y to find the value
of y at the fifth point.
4h  ′ ′
+ 2yn′

P redictor : yn+1,p = yn−3 + 2yn−2 − yn−1
3
h ′
yn−1 + 4yn′ + yn+1


Corrector : yn+1,c = yn−1 +
3

6.2 Adam-Bashforth (or Adam’s) Predictor corrector Formulae


We state below another Predictor-Corrector method, called Adam’s method or Adam-Bashforth
method . We give below predictor and corrector formula without proof. Here also, we require four
continuous values of y to find the value of y at the fifth point similar to Milne’s method.
h  ′ ′ ′ ′

P redictor : yn+1,p = yn + 55yn − 59yn−1 + 37yn−2 − 9yn−3
24
h  ′ ′
9yn+1 + 19yn′ − 5yn−1 ′

Corrector : yn+1,c = yn + + yn−2
24

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

Solution: Given x0 = 0, x1 = 0.5, x2 = 1, x3 = 1.5, x4 = 2, h = 0.5

y0 = 2, y1 = 2.636, y2 = 3.595, y3 = 4.968


1
f (x, y) = (x + y) = y ′ (1)
2
To find y4 at x = 2

(i) Milne’s Method

By Milne’s predictor formula,


4h  ′ ′
+ 2yn′

yn+1,p = yn−3 + 2yn−2 − yn−1
3
4h
∴ y4,p = y0 + [2y1′ − y2′ + 2y3′ ] (2)
3
From (1),
1 1
y1′ = (x1 + y1 ) = (0.5 + 2.636) = 1.5680
2 2
1 1
y2′ = (x2 + y2 ) = (1 + 3.595) = 2.2975
2 2
1 1
y3′ = (x3 + y3 ) = (1.5 + 4.968) = 3.2340
2 2
By (2),

4(0.5)
y4,p = 2 + [2(1.5680) − (2.2975) + 2(3.2340)]
3
= 6.8710

Using Milne’s corrector formula,


h ′
yn−1 + 4yn′ + yn+1


yn+1,c = yn−1 +
3
h ′
y4,c = y2 + [y + 4y3′ + y4′ ] (3)
3 2

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

∴ Corrected value of y at x=2 is 6.8732

(ii) Adam’s Method


1
From (i) under Milne’s method, We have y0′ = (0 + 2) = 1
2
y1′ = 1.5680, y2′ = 2.2975, y3′ = 3.2340
By Adam’s predictor formula,
h  ′ ′ ′ ′

yn+1,p = yn + 55yn − 59yn−1 + 37yn−2 − 9yn−3
24
h
∴ y4,p = y3 + [55y3′ − 59y2′ + 37y1′ − 9y0′ ] (4)
24

0.5
y4,p = 4.968 + [55(3.2340) − 59(2.2975) + 37(1.5680) − 9(1)]
24
= 6.8708

Using Adam’s corrector formula,


h  ′
9yn+1 + 19yn′ − 5yn−1
′ ′

yn+1,c = yn + + yn−2
24
h
∴ y4,c = y3 + [9y4′ + 19y3′ − 5y2′ + y1′ ] (5)
24

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

∴ Corrected value of y at x=2 is 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.

Solution:Given x0 = 4, x1 = 4.1, x2 = 4.2, x3 = 4.3, x4 = 4.4, h = 0.1


y0 = 1, y1 = 1.0049, y2 = 1.0097, y3 = 1.0143
2 − y2
f (x, y) = = y′ (1)
5x
To find y4 at x = 4.4

By Milne’s predictor formula,


4h  ′ ′
+ 2yn′

yn+1,p = yn−3 + 2yn−2 − yn−1
3
4h
∴ y4,p = y0 + [2y1′ − y2′ + 2y3′ ] (2)
3
From (1),
2 − y12 2 − (1.0049)2
y1′ = = = 0.0493
5x1 5(4.1)
2 − y22 2 − (1.0097)2
y2′ = = = 0.0467
5x2 5(4.2)
2 − y32 2 − (1.0143)2
y3′ = = = 0.0452
5x3 5(4.3)
By (2),
4(0.1)
y4,p = 1 + [2(0.0493) − (0.0467) + 2(0.0452)]
3
= 1.01897
Using Milne’s corrector formula,
h ′
yn−1 + 4yn′ + yn+1 ′

yn+1,c = yn−1 +
3
h
y4,c = y2 + [y2′ + 4y3′ + y4′ ] (3)
3
2 − y42 2 − (1.01897)2
y4′ = = = 0.0437
5x4 5(4.4)
Using (3), we get
0.1
y4,c = 1.0097 + [0.0467 + 4(0.0452) + 0.0437]
3
= 1.01874
∴ Corrected value of y at x=2 is 1.01874

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.

7 Stability Analysis of Single step Methods


The analytical solution u(tj ) of the differential equation, the difference solution uj of the difference
equation and the numerical solution uj , can be related by a relation of the form

|u(tj ) − uj | ≤ |u(tj ) − uj | + |uj − uj ] (1)


In practice, we would like the difference between the analytical and numerical solution to be
small. From (1), we find that this difference depends on the values |u(tj ) − uj |, and |uj − uj |. The
value |u(tj ) − uj |, is the truncation error which arises because the differential equation is replaced
by the difference equation. A method, is said to be consistent if it is atleast of order 1. For a
consistent method, the truncation error tends to zero as h approaches zero. The numerical error
|uj − uj |, arises because in actual computation, we cannot compute the difference solution exactly
as we are faced with the round-off errors. In fact, in some cases the numerical solution may differ
considerably from the difference solution. If the effect of the total error including the roundoff error
remains bounded as j → ∞ with fixed step size, then the difference method is said to be stable,
otherwise unstable.

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.

We call a singlestep method, when applied to the test equation u′ = λu

1. absolutely stable if |E(λh)| ≤ 1, λ < 0.

2. relatively stable if |E(λh)| ≤ eλh , λ > 0.

3. periodically stable if |E(λh)| = 1, λ pure imaginary.

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).

7.1 Euler Method


Applying the Euler method to the test equation u′ = λu , we obtain

uj+1 = uj + hfj
= uj + h(λuj )
= (1 + λh)uj
= E(λh)uj

where E(λh) = 1 + λh.

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λ

7.2 Runge-Kutta Second order method


Applying the Runge-Kutta Second order method ,
1 1
uj+1 = uj + (1 − )K1 + K2
2c2 2c2
where ,

K1 = hf (tj , uj )
K2 = hf (tj + c2 h, uj + c2 K1 )

to the test equation u′ = λu, we get

K1 = hλ uj , K2 = hλ(uj + c2 K1 ) = hλ(1 + c2 hλ)uj


1 1
uj+1 = uj + (1 − )hλ uj + hλ(1 + c2 hλ)uj
2c2 2c2
1 hλ
= [1 + (1 − )hλ + (1 + c2 hλ)]uj
2c2 2c2
h2 λ2
= [1 + hλ + ]uj
2
= E(λh)uj

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

You might also like