Numerical Methods by Jain & Iyengar
Numerical Methods by Jain & Iyengar
Numerical Methods by Jain & Iyengar
intentionally left
blank
Copyright 2009, New Age International (P) Ltd., Publishers
Published by New Age International (P) Ltd., Publishers
All rights reserved.
No part of this ebook may be reproduced in any form, by photostat, microfilm,
xerography, or any other means, or incorporated into any information retrieval
system, electronic or mechanical, without the written permission of the publisher.
All inquiries should be emailed to rights@newagepublishers.com
PUBLISHING FOR ONE WORLD
NEW AGE INTERNATIONAL (P) LIMITED, PUBLISHERS
4835/24, Ansari Road, Daryaganj, New Delhi - 110002
Visit us at www.newagepublishers.com
ISBN (13) : 978-81-224-2707-3
2HAB=?A
This book is based on the experience and the lecture notes of the authors while teaching
Numerical Analysis for almost four decades at the Indian Institute of Technology, New Delhi.
This comprehensive textbook covers material for one semester course on Numerical
Methods of Anna University. The emphasis in the book is on the presentation of fundamentals
and theoretical concepts in an intelligible and easy to understand manner. The book is written
as a textbook rather than as a problem/guide book. The textbook offers a logical presentation
of both the theory and techniques for problem solving to motivate the students for the study
and application of Numerical Methods. Examples and Problems in Exercises are used to explain
each theoretical concept and application of these concepts in problem solving. Answers for
every problem and hints for difficult problems are provided to encourage the students for self-
learning.
The authors are highly grateful to Prof. M.K. Jain, who was their teacher, colleague
and co-author of their earlier books on Numerical Analysis. With his approval, we have freely
used the material from our book, Numerical Methods for Scientific and Engineering
Computation, published by the same publishers.
This book is the outcome of the request of Mr. Saumya Gupta, Managing Director,
New Age International Publishers, for writing a good book on Numerical Methods for Anna
University. The authors are thankful to him for following it up until the book is complete.
The first author is thankful to Dr. Gokaraju Gangaraju, President of the college,
Prof. P.S. Raju, Director and Prof. Jandhyala N. Murthy, Principal, Gokaraju Rangaraju
Institute of Engineering and Technology, Hyderabad for their encouragement during the
preparation of the manuscript.
The second author is thankful to the entire management of Manav Rachna Educational
Institutions, Faridabad and the Director-Principal of Manav Rachna College of Engineering,
Faridabad for providing a congenial environment during the writing of this book.
S.R.K. Iyengar
R.K. Jain
This page
intentionally left
blank
Cont ent s
Preface (v)
1. SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 162
1.1 Solution of Algebraic and Transcendental Equations, 1
1.1.1 Introduction, 1
1.1.2 Initial Approximation for an Iterative Procedure, 4
1.1.3 Method of False Position, 6
1.1.4 Newton-Raphson Method, 11
1.1.5 General Iteration Method, 15
1.1.6 Convergence of Iteration Methods, 19
1.2 Linear System of Algebraic Equations, 25
1.2.1 Introduction, 25
1.2.2 Direct Methods, 26
1.2.2.1 Gauss Elimination Method, 28
1.2.2.2 Gauss-Jordan Method, 33
1.2.2.3 Inverse of a Matrix by Gauss-Jordan Method, 35
1.2.3 Iterative Methods, 41
1.2.3.1 Gauss-Jacobi Iteration Method, 41
1.2.3.2 Gauss-Seidel Iteration Method, 46
1.3 Eigen Value Problems, 52
1.3.1 Introduction, 52
1.3.2 Power Method, 53
1.4 Answers and Hints, 59
2. INTERPOLATION AND APPROXIMATION 63108
2.1 Introduction, 63
2.2 Interpolation with Unevenly Spaced Points, 64
2.2.1 Lagrange Interpolation, 64
2.2.2 Newtons Divided Difference Interpolation, 72
2.3 Interpolation with Evenly Spaced Points, 80
2.3.1 Newtons Forward Difference Interpolation Formula, 89
2.3.2 Newtons Backward Difference Interpolation Formula, 92
2.4 Spline Interpolation and Cubic Splines, 99
2.5 Answers and Hints, 108
3. NUMERICAL DIFFERENTIATION AND INTEGRATION 109179
3.1 Introduction, 109
3.2 Numerical Differentiation, 109
3.2.1 Methods Based on Finite Differences, 109
3.2.1.1 Derivatives Using Newtons Forward Difference Formula, 109
3.2.1.2 Derivatives Using Newtons Backward Difference Formula, 117
3.2.1.3 Derivatives Using Newtons Divided Difference Formula, 122
3.3 Numerical Integration, 128
3.3.1 Introduction, 128
3.3.2 Integration Rules Based on Uniform Mesh Spacing, 129
3.3.2.1 Trapezium Rule, 129
3.3.2.2 Simpsons 1/3 Rule, 136
3.3.2.3 Simpsons 3/8 Rule, 144
3.3.2.4 Romberg Method, 147
3.3.3 Integration Rules Based on Non-uniform Mesh Spacing, 159
3.3.3.1 Gauss-Legendre Integration Rules, 160
3.3.4 Evaluation of Double Integrals, 169
3.3.4.1 Evaluation of Double Integrals Using Trapezium Rule, 169
3.3.4.2 Evaluation of Double Integrals by Simpsons Rule, 173
3.4 Answers and Hints, 177
4. INITIAL VALUE PROBLEMS FOR ORDINARY
DIFFERENTIAL EQUATIONS 180240
4.1 Introduction, 180
4.2 Single Step and Multi Step Methods, 182
4.3 Taylor Series Method, 184
4.3.1 Modified Euler and Heuns Methods, 192
4.4 Runge-Kutta Methods, 200
4.5 System of First Order Initial Value Problems, 207
4.5.1 Taylor Series Method, 208
4.5.2 Runge-Kutta Fourth Order Method, 208
4.6 Multi Step Methods and Predictor-Corrector Methods, 216
4.6.1 Predictor Methods (Adams-Bashforth Methods), 217
4.6.2 Corrector Methods, 221
4.6.2.1 Adams-Moulton Methods, 221
4.6.2.2 Milne-Simpson Methods, 224
4.6.2.3 Predictor-Corrector Methods, 225
4.7 Stability of Numerical Methods, 237
4.8 Answers and Hints, 238
5. BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL
EQUATIONS AND INITIAL & BOUNDARY VALUE PROBLEMS IN
PARTIAL DIFFERENTIAL EQUATIONS 241309
5.1 Introduction, 241
5.2 Boundary Value Problems Governed by Second Order Ordinary Differential Equations,
241
5.3 Classification of Linear Second Order Partial Differential Equations, 250
5.4 Finite Difference Methods for Laplace and Poisson Equations, 252
5.5 Finite Difference Method for Heat Conduction Equation, 274
5.6 Finite Difference Method for Wave Equation, 291
5.7 Answers and Hints, 308
Bibliography 311312
Index 313315
This page
intentionally left
blank
1
.
For this method, we can give the count of the total number of operations.
There are direct methods for finding all the roots of cubic and fourth degree polynomi-
als. However, these methods are difficult to use.
Direct methods for finding the roots of polynomial equations of degree greater than 4 or
transcendental equations are not available in literature.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 3
Iterative methods These methods are based on the idea of successive approximations. We
start with one or two initial approximations to the root and obtain a sequence of approxima-
tions x
0
, x
1
, ..., x
k
, ..., which in the limit as k , converge to the exact root . An iterative
method for finding a root of the equation f(x) = 0 can be obtained as
x
k + 1
= (x
k
), k = 0, 1, 2, ..... (1.5)
This method uses one initial approximation to the root .
0
x The sequence of approxima-
tions is given by
x
1
= (x
0
), x
2
= (x
1
), x
3
= (x
2
), .....
The function is called an iteration function and x
0
is called an initial approximation.
If a method uses two initial approximations x
0
, x
1
, to the root, then we can write the
method as
x
k + 1
= (x
k 1
, x
k
), k = 1, 2, ..... (1.6)
Convergence of iterative methods The sequence of iterates, {x
k
}, is said to converge to the
exact root , if
lim
k
x
k
= , or lim
k
| x
k
| = 0. (1.7)
The error of approximation at the kth iterate is defined as
k
= x
k
. Then, we can
write (1.7) as
lim
k
| error of approximation | = lim
k
| x
k
| = lim
k
|
k
| = 0.
Remark 2 Given one or two initial approximations to the root, we require a suitable iteration
function for a given function f(x), such that the sequence of iterates, {x
k
}, converge to the
exact root . Further, we also require a suitable criterion to terminate the iteration.
Criterion to terminate iteration procedure Since, we cannot perform infinite number of
iterations, we need a criterion to stop the iterations. We use one or both of the following
criterion:
(i) The equation f(x) = 0 is satisfied to a given accuracy or f(x
k
) is bounded by an error
tolerance .
| f (x
k
) | . (1.8)
(ii) The magnitude of the difference between two successive iterates is smaller than a given
accuracy or an error bound .
| x
k + 1
x
k
| . (1.9)
Generally, we use the second criterion. In some very special problems, we require to use
both the criteria.
For example, if we require two decimal place accuracy, then we iterate until | x
k+1
x
k
|
< 0.005. If we require three decimal place accuracy, then we iterate until | x
k+1
x
k
| < 0.0005.
As we have seen earlier, we require a suitable iteration function and suitable initial
approximation(s) to start the iteration procedure. In the next section, we give a method to find
initial approximation(s).
4 NUMERICAL METHODS
1.1.2 Initial Approximation for an Iterative Procedure
For polynomial equations, Descartes rule of signs gives the bound for the number of positive
and negative real roots.
(i) We count the number of changes of signs in the coefficients of P
n
(x) for the equation f(x) =
P
n
(x) = 0. The number of positive roots cannot exceed the number of changes of signs. For
example, if there are four changes in signs, then the equation may have four positive roots or
two positive roots or no positive root. If there are three changes in signs, then the equation
may have three positive roots or definitely one positive root. (For polynomial equations with
real coefficients, complex roots occur in conjugate pairs.)
(ii) We write the equation f( x) = P
n
( x) = 0, and count the number of changes of signs in the
coefficients of P
n
( x). The number of negative roots cannot exceed the number of changes of
signs. Again, if there are four changes in signs, then the equation may have four negative
roots or two negative roots or no negative root. If there are three changes in signs, then the
equation may have three negative roots or definitely one negative root.
We use the following theorem of calculus to determine an initial approximation. It is
also called the intermediate value theorem.
Theorem 1.1 If f(x) is continuous on some interval [a, b] and f(a)f(b) < 0, then the equation
f(x) = 0 has at least one real root or an odd number of real roots in the interval (a, b).
This result is very simple to use. We set up a table of values of f (x) for various values
of x. Studying the changes in signs in the values of f (x), we determine the intervals in which
the roots lie. For example, if f (1) and f (2) are of opposite signs, then there is a root in the
interval (1, 2).
Let us illustrate through the following examples.
Example 1.1 Determine the maximum number of positive and negative roots and intervals of
length one unit in which the real roots lie for the following equations.
(i) 8x
3
12x
2
2x + 3 = 0 (ii) 3x
3
2x
2
x 5 = 0.
Solution
(i) Let f(x) = 8x
3
12x
2
2x + 3 = 0.
The number of changes in the signs of the coefficients (8, 12, 2, 3) is 2. Therefore, the
equation has 2 or no positive roots. Now, f( x) = 8x
3
12x
2
+ 2x + 3. The number of changes
in signs in the coefficients ( 8, 12, 2, 3) is 1. Therefore, the equation has one negative root.
We have the following table of values for f(x), (Table 1.1).
Table 1.1. Values of f (x), Example 1.1(i ).
x 2 1 0 1 2 3
f(x) 105 15 3 3 15 105
Since
f( 1) f(0) < 0, there is a root in the interval ( 1, 0),
f(0) f(1) < 0, there is a root in the interval (0, 1),
f(1) f(2) < 0, there is a root in the interval (1, 2).
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 5
Therefore, there are three real roots and the roots lie in the intervals ( 1, 0), (0, 1), (1, 2).
(ii) Let f(x) = 3x
2
2x
2
x 5 = 0.
The number of changes in the signs of the coefficients (3, 2, 1, 5) is 1. Therefore,
the equation has one positive root. Now, f(
x) = 3x
2
2x
2
+ x 5.
The number of changes in
signs in the coefficients ( 3, 2, 1, 5) is 2. Therefore, the equation has two negative or no
negative roots.
We have the table of values for f (x), (Table 1.2).
Table 1.2. Values of f (x ), Example 1.1(ii ).
x 3 2 1 0 1 2 3
f(x) 101 35 9 5 5 9 55
From the table, we find that there is one real positive root in the interval (1, 2). The
equation has no negative real root.
Example 1.2 Determine an interval of length one unit in which the negative real root, which is
smallest in magnitude lies for the equation 9x
3
+ 18x
2
37x 70 = 0.
Solution Let f(x) = 9x
3
+ 18x
2
37x 70 = 0. Since, the smallest negative real root in magni-
tude is required, we form a table of values for x < 0, (Table 1.3).
Table 1.3. Values of f (x ), Example 1.2.
x 5 4 3 2 1 0
f(x) 560 210 40 4 24 70
Since, f( 2)f( 1) < 0, the negative root of smallest magnitude lies in the interval
( 2, 1).
Example 1.3 Locate the smallest positive root of the equations
(i) xe
x
= cos x. (ii) tan x = 2x.
Solution
(i) Let f(x) = xe
x
cos x = 0. We have f(0) = 1, f(1) = e cos 1 = 2.718 0.540 = 2.178. Since,
f(0) f(1) < 0, there is a root in the interval (0, 1).
(ii) Let f(x) = tan x 2x = 0. We have the following function values.
f(0) = 0, f(0.1) = 0.0997, f(0.5) =
0.4537,
f(1) = 0.4426, f(1, 1) = 0.2352, f(1.2) = 0.1722.
Since, f(1.1) f(1.2) < 0, the root lies in the interval (1.1, 1.2).
Now, we present some iterative methods for finding a root of the given algebraic or
transcendental equation.
We know from calculus, that in the neighborhood of a point on a curve, the curve can be
approximated by a straight line. For deriving numerical methods to find a root of an equation
6 NUMERICAL METHODS
f(x) = 0, we approximate the curve in a sufficiently small interval which contains the root, by
a straight line. That is, in the neighborhood of a root, we approximate
f(x) ax + b, a 0
where a and b are arbitrary parameters to be determined by prescribing two appropriate
conditions on f(x) and/or its derivatives. Setting ax + b = 0, we get the next approximation to
the root as x = b/a. Different ways of approximating the curve by a straight line give different
methods. These methods are also called chord methods. Method of false position (also called
regula-falsi method) and Newton-Raphson method fall in this category of chord methods.
1.1.3 Method of False Position
The method is also called linear interpolation method or chord method or regula-falsi method.
At the start of all iterations of the method, we require the interval in which the root
lies. Let the root of the equation f(x) = 0, lie in the interval (x
k1
, x
k
), that is, f
k1
f
k
< 0,
where
f(x
k1
) = f
k1
, and f(x
k
) = f
k
. Then, P(x
k1,
f
k1
), Q(x
k,
f
k
) are points on the curve f(x) = 0. Draw a
straight line joining the points P and Q (Figs. 1.2a, b). The line PQ is taken as an approxima-
tion of the curve in the interval [x
k1
, x
k
]. The equation of the line PQ is given by
y f
f f
x x
x x
k
k k
k
k k
1 1
.
The point of intersection of this line PQ with the x-axis is taken as the next approxima-
tion to the root. Setting y = 0, and solving for x, we get
x = x
k
x x
f f
k k
k k
1
1
f
k
= x
k
x x
f f
k k
k k
1
1
f
k
.
The next approximation to the root is taken as
x
k+1
= x
k
x x
f f
k k
k k
1
1
f
k
. (1.10)
Simplifying, we can also write the approximation as
x
k+1
=
x f f x x f
f f
k k k k k k
k k
( ) ( )
1 1
1
=
x f x f
f f
k k k k
k k
1 1
1
, k = 1, 2, ... (1.11)
Therefore, starting with the initial interval (x
0
, x
1
), in which the root lies, we compute
x
2
=
x f x f
f f
0 1 1 0
1 0
.
Now, if f(x
0
) f(x
2
) < 0, then the root lies in the interval (x
0
, x
2
). Otherwise, the root lies in
the interval (x
2
, x
1
). The iteration is continued using the interval in which the root lies, until
the required accuracy criterion given in Eq.(1.8) or Eq.(1.9) is satisfied.
Alternate derivation of the method
Let the root of the equation f(x) = 0, lie in the interval (x
k1
, x
k
). Then, P(x
k1
, f
k1
), Q(x
k
, f
k
)
are points on the curve f(x) = 0. Draw the chord joining the points P and Q (Figs. 1.2a, b). We
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 7
approximate the curve in this interval by the chord, that is, f(x) ax + b. The next approximation
to the root is given by x = b/a. Since the chord passes through the points P and Q, we get
f
k1
= ax
k1
+ b, and f
k
= ax
k
+ b.
Subtracting the two equations, we get
f
k
f
k1
= a(x
k
x
k 1
), or a =
f f
x x
k k
k k
1
1
.
The second equation gives b = f
k
ax
k
.
Hence, the next approximation is given by
x
k+1
=
b
a
f ax
a
k k
=
= x
k
f
a
k
= x
k
x x
f f
k k
k k
1
1
f
k
which is same as the method given in Eq.(1.10).
y
O
x
P
x
3
x
2
x
1
x
0
Q
y
O
x
P
x
3
x
2
x
1
x
0
Q
Fig. 1.2a Method of false position Fig. 1.2b Method of false position
Remark 3 At the start of each iteration, the required root lies in an interval, whose length is
decreasing. Hence, the method always converges.
Remark 4 The method of false position has a disadvantage. If the root lies initially in the
interval (x
0
, x
1
), then one of the end points is fixed for all iterations. For example, in Fig.1.2a,
the left end point x
0
is fixed and the right end point moves towards the required root. There-
fore, in actual computations, the method behaves like
x
k+1
=
x f x f
f f
k k
k
0 0
0
, k = 1, 2, (1.12)
In Fig.1.2b, the right end point x
1
is fixed and the left end point moves towards the
required root. Therefore, in this case, in actual computations, the method behaves like
x
k+1
=
x f x f
f f
k k
k
1 1
1
, k = 1, 2, (1.13)
Remark 5 The computational cost of the method is one evaluation of the function f(x), for
each iteration.
Remark 6 We would like to know why the method is also called a linear interpolation method.
Graphically, a linear interpolation polynomial describes a straight line or a chord. The linear
interpolation polynomial that fits the data (x
k1
, f
k1
), (x
k
, f
k
) is given by
8 NUMERICAL METHODS
f(x) =
x x
x x
k
k k
1
f
k1
+
x x
x x
k
k k
1
1
f
k
.
(We shall be discussing the concept of interpolation polynomials in Chapter 2).
Setting f(x) = 0, we get
( ) ( ) x x f x x f
x x
k k k k
k k
1 1
1
= 0, or x(f
k
f
k1
) = x
k1
f
k
x
k
f
k 1
or x = x
k+1
=
x f x f
f f
k k k k
k k
1 1
1
.
This gives the next approximation as given in Eq. (1.11).
Example 1.4 Locate the intervals which contain the positive real roots of the equation x
3
3x
+ 1 = 0. Obtain these roots correct to three decimal places, using the method of false position.
Solution We form the following table of values for the function f(x).
x 0 1 2 3
f (x) 1 1 3 19
There is one positive real root in the interval (0, 1) and another in the interval (1, 2).
There is no real root for x > 2 as f(x) > 0, for all x > 2.
First, we find the root in (0, 1). We have
x
0
= 0, x
1
= 1, f
0
= f(x
0
) = f(0) = 1, f
1
= f(x
1
) = f(1) = 1.
x
2
=
x f x f
f f
0 1 1 0
1 0
0 1
1 1
=
= 0.5, f(x
2
) = f(0.5) = 0.375.
Since, f(0) f(0.5) < 0, the root lies in the interval (0, 0.5).
x
3
=
x f x f
f f
0 2 2 0
2 0
0 0 5 1
0 375 1
=
. ( )
.
= 0.36364, f(x
3
) = f(0.36364) = 0.04283.
Since, f(0) f(0.36364) < 0, the root lies in the interval (0, 0.36364).
x
4
=
x f x f
f f
0 3 3 0
3 0
0 036364 1
004283 1
=
. ( )
.
= 0.34870, f(x
4
) = f(0.34870) = 0.00370.
Since, f(0) f(0.3487) < 0, the root lies in the interval (0, 0.34870).
x
5
=
x f x f
f f
0 4 4 0
4 0
0 03487 1
000370 1
=
. ( )
.
= 0.34741, f(x
5
) = f(0.34741) = 0.00030.
Since, f(0) f(0.34741) < 0, the root lies in the interval (0, 0.34741).
x
6
=
x f x f
f f
0 5 5 0
5 0
0 034741 1
00003 1
=
. ( )
.
= 0.347306.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 9
Now, | x
6
x
5
| = | 0.347306 0.34741 | 0.0001 < 0.0005.
The root has been computed correct to three decimal places. The required root can be
taken as x x
6
= 0.347306. We may also give the result as 0.347, even though x
6
is more
accurate. Note that the left end point x = 0 is fixed for all iterations.
Now, we compute the root in (1, 2). We have
x
0
= 1, x
1
= 2, f
0
= f(x
0
) = f(1) = 1, f
1
= f(x
1
) = f(2) = 3.
x
2
=
x f x f
f f
0 1 1 0
1 0
3 2 1
3 1
=
( )
( )
= 1.25, f(x
2
) = f(1.25) = 0.796875.
Since, f(1.25) f(2) < 0, the root lies in the interval (1.25, 2). We use the formula given in Eq.(1.13).
x
3
=
x f x f
f f
2 1 1 2
1 2
=
1.25(3) 2( 0.796875)
3 ( 0.796875)
= 1.407407,
f(x
3
) = f(1.407407) = 0.434437.
Since, f(1.407407) f(2) < 0, the root lies in the interval (1.407407, 2).
x
4
=
x f x f
f f
3 1 1 3
1 3
=
1.407407(3) 2( 0.434437)
3 ( 0.434437)
= 1.482367,
f(x
4
) = f(1.482367) = 0.189730.
Since f(1.482367) f(2) < 0, the root lies in the interval (1.482367, 2).
x
5
=
x f x f
f f
4 1 1 4
1 4
=
1.482367(3) 2( 0.18973)
3 ( 0.18973)
= 1.513156,
f(x
5
) = f(1.513156) = 0.074884.
Since, f(1.513156) f(2) < 0, the root lies in the interval (1.513156, 2).
x
6
=
x f x f
f f
5 1 1 5
1 5
=
1.513156(3) 2( 0.074884)
3 ( 0.74884)
= 1.525012,
f(x
6
) = f(1.525012) = 0.028374.
Since, f(1.525012) f(2) < 0, the root lies in the interval (1.525012, 2).
x
7
=
x f x f
f f
6 1 1 6
1 6
=
1.525012(3) 2( 0.028374)
3 ( 0.028374)
= 1.529462.
f(x
7
) = f(1.529462) = 0.010586.
Since, f(1.529462) f(2) < 0, the root lies in the interval (1.529462, 2).
x
8
=
x f x f
f f
7 1 1 7
1 7
=
1.529462(3) 2( 0.010586)
3 ( 0.010586)
= 1.531116,
f(x
8
) = f(1.531116) = 0.003928.
Since, f(1.531116) f(2) < 0, the root lies in the interval (1.531116, 2).
10 NUMERICAL METHODS
x
9
=
x f x f
f f
8 1 1 8
1 8
=
1.531116(3) 2( 0.003928)
3 ( 0.003928)
= 1.531729,
f(x
9
) = f(1.531729) = 0.001454.
Since, f(1.531729) f(2) < 0, the root lies in the interval (1.531729, 2).
x
10
=
x f x f
f f
9 1 1 9
1 9
=
1.531729(3) 2( 0.001454)
3 ( 0.001454)
= 1.531956.
Now, |x
10
x
9
| = | 1.531956 1.53179 | 0.000227 < 0.0005.
The root has been computed correct to three decimal places. The required root can be
taken as x x
10
= 1.531956. Note that the right end point x = 2 is fixed for all iterations.
Example 1.5 Find the root correct to two decimal places of the equation xe
x
= cos x, using the
method of false position.
Solution Define f(x) = cos x
xe
x
= 0. There is no negative root for the equation. We have
f(0) = 1, f(1) = cos 1 e = 2.17798.
A root of the equation lies in the interval (0, 1). Let x
0
= 0, x
1
= 1. Using the method of
false position, we obtain the following results.
x
2
=
x f x f
f f
0 1 1 0
1 0
=
0 1(1)
2.17798 1
= 0.31467, f(x
2
) = f(0.31467) = 0.51986.
Since, f(0.31467) f(1) < 0, the root lies in the interval (0.31467, 1). We use the formula given in
Eq.(1.13).
x
3
=
x f x f
f f
2 1 1 2
1 2
=
0.31467( 2.17798) 1(0.51986)
2.17798 0.51986
= 0.44673,
f(x
3
) = f(0.44673) = 0.20354.
Since, f (0.44673) f(1) < 0, the root lies in the interval (0.44673, 1).
x
4
=
x f x f
f f
3 1 1 3
1 3
=
0.44673( 2.17798) 1(0.20354)
2.17798 0.20354
= 0.49402,
f(x
4
) = f(0.49402) = 0.07079.
Since, f (0.49402) f(1) < 0, the root lies in the interval (0.49402, 1).
x
5
=
x f x f
f f
4 1 1 4
1 4
=
0 . 49402( 2.17798) 1(0.07079)
2.17798 0.07079
= 0.50995,
f(x
5
) = f(0.50995) = 0.02360.
Since, f(0.50995) f(1) < 0, the root lies in the interval (0.50995, 1).
x
6
=
x f x f
f f
5 1 1 5
1 5
=
0.50995( 2.17798) 1(0.0236)
2.17798 0.0236
= 0.51520,
f(x
6
) = f(0.51520) = 0.00776.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 11
Since, f(0.51520) f(1) < 0, the root lies in the interval (0.51520, 1).
x
7
=
x f x f
f f
6 1 1 6
1 6
=
0.5152( 2.17798) 1(0.00776)
2.17798 0.00776
= 0.51692.
Now, | x
7
x
6
| = | 0.51692 0.51520 | 0.00172 < 0.005.
The root has been computed correct to two decimal places. The required root can be
taken as x x
7
= 0.51692.
Note that the right end point x = 2 is fixed for all iterations.
1.1.4 Newton-Raphson Method
This method is also called Newtons method. This method is also a chord method in which we
approximate the curve near a root, by a straight line.
Let
0
x be an initial approximation to the root
of f(x) = 0. Then, P(x
0
, f
0
), where f
0
= f(x
0
), is a point on
the curve. Draw the tangent to the curve at P, (Fig.
1.3). We approximate the curve in the neighborhood of
the root by the tangent to the curve at the point P. The
point of intersection of the tangent with the x-axis is
taken as the next approximation to the root. The
process is repeated until the required accuracy is
obtained. The equation of the tangent to the curve
y = f(x) at the point P(x
0
, f
0
) is given by
y f(x
0
) = (x x
0
) f (x
0
)
where f (x
0
) is the slope of the tangent to the curve at P. Setting y = 0 and solving for x, we get
x = x
0
f x
f x
( )
( )
0
0
, f (x
0
) 0.
The next approximation to the root is given by
x
1
= x
0
f x
f x
( )
( )
0
0
, f (x
0
) 0.
We repeat the procedure. The iteration method is defined as
x
k+1
= x
k
f x
f x
k
k
( )
( )
, f (x
k
) 0. (1.14)
This method is called the Newton-Raphson method or simply the Newtons method.
The method is also called the tangent method.
Alternate derivation of the method
Let x
k
be an approximation to the root of the equation f(x) = 0. Let x be an increment in
x such that x
k
+ x is the exact root, that is f(x
k
+ x) 0.
y
O
x
P
a
x
1
x
0
Fig. 1.3 Newton-Raphson method
12 NUMERICAL METHODS
Expanding in Taylors series about the point x
k
, we get
f(x
k
) + x f (x
k
) +
( )
!
x
2
2
f (x
k
) + ... = 0. (1.15)
Neglecting the second and higher powers of x, we obtain
f(x
k
) + x f (x
k
) 0, or x =
f x
f x
k
k
( )
( )
.
Hence, we obtain the iteration method
x
k+1
= x
k
+ x = x
k
f x
f x
k
k
( )
( )
, f (x
k
) 0, k = 0, 1, 2, ...
which is same as the method derived earlier.
Remark 7 Convergence of the Newtons method depends on the initial approximation to the
root. If the approximation is far away from the exact root, the method diverges (see Example
1.6). However, if a root lies in a small interval (a, b) and x
0
(a, b), then the method converges.
Remark 8 From Eq.(1.14), we observe that the method may fail when f (x) is close to zero in
the neighborhood of the root. Later, in this section, we shall give the condition for convergence
of the method.
Remark 9 The computational cost of the method is one evaluation of the function f(x) and one
evaluation of the derivative f (x), for each iteration.
Example 1.6 Derive the Newtons method for finding 1/N, where N > 0. Hence, find 1/17,
using the initial approximation as (i) 0.05, (ii) 0.15. Do the iterations converge ?
Solution Let x =
1
N
, or
1
x
= N. Define f(x) =
1
x
N. Then, f (x) =
1
2
x
.
Newtons method gives
x
k+1
= x
k
f x
f x
k
k
( )
( )
= x
k
[( / ) ]
[ / ]
1
1
2
x N
x
k
k
= x
k
+ [x
k
Nx
k
2
] = 2x
k
Nx
k
2
.
(i) With N = 17, and x
0
= 0.05, we obtain the sequence of approximations
x
1
= 2x
0
Nx
0
2
= 2(0.05) 17(0.05)
2
= 0.0575.
x
2
= 2x
1
Nx
1
2
= 2(0.0575) 17(0.0575)
2
= 0.058794.
x
3
= 2x
2
Nx
2
2
= 2(0.058794) 17(0.058794)
2
= 0.058823.
x
4
= 2x
3
Nx
3
2
= 2(0.058823) 17(0.058823)
2
= 0.058823.
Since, | x
4
x
3
| = 0, the iterations converge to the root. The required root is 0.058823.
(ii) With N = 17, and x
0
= 0.15, we obtain the sequence of approximations
x
1
= 2x
0
Nx
0
2
= 2(0.15) 17(0.15)
2
= 0.0825.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 13
x
2
= 2x
1
Nx
1
2
= 2( 0.0825) 17( 0.8025)
2
= 0.280706.
x
3
= 2x
2
Nx
2
2
= 2( 0.280706) 17( 0.280706)
2
= 1.900942.
x
4
= 2x
3
Nx
3
2
= 2( 1.900942) 17( 1.900942)
2
= 65.23275.
We find that x
k
as k increases. Therefore, the iterations diverge very fast. This
shows the importance of choosing a proper initial approximation.
Example 1.7 Derive the Newtons method for finding the qth root of a positive number N, N
1/q
,
where N > 0, q > 0. Hence, compute 17
1/3
correct to four decimal places, assuming the initial
approximation as x
0
= 2.
Solution Let x = N
1/q
, or x
q
= N. Define f(x) = x
q
N. Then, f (x) = qx
q 1
.
Newtons method gives the iteration
x
k+1
= x
k
x N
qx
qx x N
qx
q x N
qx
k
q
k
q
k
q
k
q
k
q
k
q
k
q
=
+
=
+
1 1 1
1 ( )
.
For computing 17
1/3
, we have q = 3 and N = 17. Hence, the method becomes
x
k+1
=
2 17
3
3
2
x
x
k
k
+
, k = 0, 1, 2, ...
With x
0
= 2, we obtain the following results.
x
1
=
2 17
3
2 8 17
3 4
0
3
0
2
x
x
+
=
+ ( )
( )
= 2.75,
x
2
=
2 17
3
1
3
1
2
x
x
+
=
+ 2(2.75) 17
3(2.75)
3
2
= 2.582645,
x
3
=
2 17
3
2
3
2
2
x
x
+
=
+ 2(2.582645) 17
3(2.582645)
3
2
= 2.571332,
x
4
=
2 17
3
3
3
3
2
x
x
+
=
+ 2(2.571332) 17
3(2.571332)
3
2
= 2.571282.
Now, | x
4
x
3
| = | 2.571282 2.571332 | = 0.00005.
We may take x 2.571282 as the required root correct to four decimal places.
Example 1.8 Perform four iterations of the Newtons method to find the smallest positive root
of the equation f(x) = x
3
5x + 1 = 0.
Solution We have f(0) = 1, f(1) = 3. Since, f(0) f(1) < 0, the smallest positive root lies in the
interval (0, 1). Applying the Newtons method, we obtain
x
k+1
= x
k
x x
x
x
x
k k
k
k
k
3
2
3
2
5 1
3 5
2 1
3 5
+
, k = 0, 1, 2, ...
14 NUMERICAL METHODS
Let x
0
= 0.5. We have the following results.
x
1
=
2 1
3 5
2 0 5 1
3 0 5 5
0
3
0
2
3
2
x
x
( . )
( . )
= 0.176471,
x
2
=
2 1
3 5
2 0 176471 1
3 0 176471 5
1
3
1
2
3
2
x
x
( . )
( . )
= 0.201568,
x
3
=
2 1
3 5
2 0 201568 1
3 0 201568 5
2
3
2
2
3
2
x
x
( . )
( . )
= 0.201640,
x
4
=
2 1
3 5
2 0 201640 1
3 0 201640 5
3
3
3
2
3
2
x
x
( . )
( . )
= 0.201640.
Therefore, the root correct to six decimal places is x 0.201640.
Example 1.9 Using Newton-Raphson method solve x log
10
x = 12.34 with x
0
= 10.
(A.U. Apr/May 2004)
Solution Define f(x) = x log
10
x 12.34.
Then f (x) = log
10
x +
1
10 log
e
= log
10
x + 0.434294.
Using the Newton-Raphson method, we obtain
x
k+1
= x
k
x x
x
k k
k
log .
log .
10
10
1234
0 434294
+
, k = 0, 1, 2, ...
With x
0
= 10, we obtain the following results.
x
1
= x
0
x x
x
0 10 0
10 0
log 12.34
log 0.434294
+
= 10
10 10
10
10
10
log
log
+
12.34
0.434294
= 11.631465.
x
2
= x
1
x x
x
1 10 1
10 1
log
log
+
12.34
0.434294
= 11.631465
11.631465 11.631465
11.631465
10
10
log
log
+
12.34
0.434294
= 11.594870.
x
3
= x
2
x x
x
2 10 2
10 2
log
log
+
12.34
0.434294
= 11.59487
11.59487 11.59487 12.34
11.59487 0.434294
log
log
10
10
+
= 11.594854.
We have | x
3
x
2
| = | 11.594854 11.594870 | = 0.000016.
We may take x 11.594854 as the root correct to four decimal places.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 15
1.1.5 General Iteration Method
The method is also called iteration method or method of successive approximations or fixed
point iteration method.
The first step in this method is to rewrite the given equation f(x) = 0 in an equivalent
form as
x = (x). (1.16)
There are many ways of rewriting f(x) = 0 in this form.
For example, f(x) = x
3
5x + 1 = 0, can be rewritten in the following forms.
x =
x
3
1
5
+
, x = (5x 1)
1/3
, x =
5 1 x
x
, etc. (1.17)
Now, finding a root of f(x) = 0 is same as finding a number such that = (), that is,
a fixed point of (x). A fixed point of a function is a point such that = (). This result is
also called the fixed point theorem.
Using Eq.(1.16), the iteration method is written as
x
k+1
= (x
k
), k = 0, 1, 2, ... (1.18)
The function (x) is called the iteration function. Starting with the initial approxima-
tion x
0
, we compute the next approximations as
x
1
= (x
0
), x
2
= (x
1
), x
3
= (x
2
),...
The stopping criterion is same as used earlier. Since, there are many ways of writing
f(x) = 0 as x = (x), it is important to know whether all or at least one of these iteration
methods converges.
Remark 10 Convergence of an iteration method x
k+1
= (x
k
), k = 0, 1, 2,..., depends on the
choice of the iteration function (x), and a suitable initial approximation x
0
, to the root.
Consider again, the iteration methods given in Eq.(1.17), for finding a root of the equation
f(x) = x
3
5x + 1 = 0. The positive root lies in the interval (0, 1).
(i) x
k+1
=
x
k
3
1
5
+
, k = 0, 1, 2, ... (1.19)
With x
0
= 1, we get the sequence of approximations as
x
1
= 0.4, x
2
= 0.2128, x
3
= 0.20193, x
4
= 0.20165, x
5
= 0.20164.
The method converges and x x
5
= 0.20164 is taken as the required approximation to
the root.
(ii) x
k+1
= (5x
k
1)
1/3
, k = 0, 1, 2, ... (1.20)
With x
0
= 1, we get the sequence of approximations as
x
1
= 1.5874, x
2
= 1.9072, x
3
= 2.0437, x
4
= 2.0968,...
which does not converge to the root in (0, 1).
(iii) x
k+1
=
5 1 x
x
k
k
, k = 0, 1, 2, ... (1.21)
16 NUMERICAL METHODS
With x
0
= 1, we get the sequence of approximations as
x
1
= 2.0, x
2
= 2.1213, x
3
= 2.1280, x
4
= 2.1284,...
which does not converge to the root in (0, 1).
Now, we derive the condition that the iteration function (x) should satisfy in order that
the method converges.
Condition of convergence
The iteration method for finding a root of f(x) = 0, is written as
x
k+1
= (x
k
), k = 0, 1, 2,... (1.22)
Let be the exact root. That is,
= (). (1.23)
We define the error of approximation at the kth iterate as
k
= x
k
, k = 0, 1, 2,...
Subtracting (1.23) from (1.22), we obtain
x
k+1
= (x
k
) ()
= (x
k
)(t
k
) (using the mean value theorem) (1.24)
or
k+1
= (t
k
)
k
, x
k
< t
k
< .
Setting k = k 1, we get
k
= (t
k1
)
k1
, x
k1
< t
k1
< .
Hence,
k+1
= (t
k
)(t
k1
)
k1
.
Using (1.24) recursively, we get
k+1
= (t
k
)(t
k1
) ... (t
0
)
0
.
The initial error
0
is known and is a constant. We have
|
k+1
| = | (t
k
) | | (t
k1
) | ... | (t
0
) | |
0
|.
Let | (t
k
) | c, k = 0, 1, 2,
Then, |
k+1
| c
k+1
|
0
|. (1.25)
For convergence, we require that |
k+1
| 0 as k . This result is possible, if and only
if c < 1. Therefore, the iteration method (1.22) converges, if and only if
| (x
k
) | c < 1, k = 0, 1, 2, ...
or | (x) | c < 1, for all x in the interval (a, b). (1.26)
We can test this condition using x
0
, the initial approximation, before the computations
are done.
Let us now check whether the methods (1.19), (1.20), (1.21) converge to a root in (0, 1) of
the equation f(x) = x
3
5x + 1 = 0.
(i) We have (x) =
x
3
1
5
+
, (x) =
3
5
2
x
, and | (x) | =
3
5
2
x
1 for all x in
. 1 0 < < x
Hence,
the method converges to a root in (0, 1).
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 17
(ii) We have (x) = (5x 1)
1/3
, (x) =
5
3 5 1
2 3
( )
/
x
. Now | (x) | < 1, when x is close to 1 and
| (x) | > 1 in the other part of the interval. Convergence is not guaranteed.
(iii) We have (x) =
5 1 x
x
, (x) =
1
2 5 1
3 2 1 2
x x
/ /
( )
. Again, | (x) | < 1, when x is close to
1 and | (x) | > 1 in the other part of the interval. Convergence is not guaranteed.
Remark 11 Sometimes, it may not be possible to find a suitable iteration function (x) by
manipulating the given function f(x). Then, we may use the following procedure. Write
f(x) = 0 as x = x + f(x) = (x), where is a constant to be determined. Let x
0
be an initial
approximation contained in the interval in which the root lies. For convergence, we require
| (x
0
) | = | 1 + f(x
0
) | < 1. (1.27)
Simplifying, we find the interval in which lies. We choose a value for from this
interval and compute the approximations. A judicious choice of a value in this interval may
give faster convergence.
Example 1.10 Find the smallest positive root of the equation x
3
x 10 = 0, using the general
iteration method.
Solution We have
f(x) = x
3
x 10, f(0) = 10, f(1) = 10,
f(2) = 8 2 10 = 4, f(3) = 27 3 10 = 14.
Since, f(2) f(3) < 0, the smallest positive root lies in the interval (2, 3).
Write x
3
= x + 10, and x = (x + 10)
1/3
= (x). We define the iteration method as
x
k+1
= (x
k
+ 10)
1/3
.
We obtain (x) =
1
3 10
2 3
( )
/
x +
.
We find | (x) | < 1 for all x in the interval (2, 3). Hence, the iteration converges.
Let x
0
= 2.5. We obtain the following results.
x
1
= (12.5)
1/3
= 2.3208, x
2
= (12.3208)
1/3
= 2.3097,
x
3
= (12.3097)
1/3
= 2.3090, x
4
= (12.3090)
1/3
= 2.3089.
Since, | x
4
x
3
| = 2.3089 2.3090 | = 0.0001, we take the required root as x 2.3089.
Example 1.11 Find the smallest negative root in magnitude of the equation
3x
4
+ x
3
+ 12x + 4 = 0, using the method of successive approximations.
Solution We have
f(x) = 3x
4
+ x
3
+ 12x + 4 = 0, f(0) = 4, f( 1) = 3 1 12 + 4 = 6.
Since, f( 1) f(0) < 0, the smallest negative root in magnitude lies in the interval ( 1, 0).
18 NUMERICAL METHODS
Write the given equation as
x(3x
3
+ x
2
+ 12) + 4 = 0, and x =
4
3 12
3 2
x x + +
= (x).
The iteration method is written as
x
k+1
=
4
3 12
3 2
x x
k k
+ +
.
We obtain (x) =
4 9 2
3 12
2
3 2 2
( )
( )
x x
x x
+
+ +
.
We find | (x) | < 1 for all x in the interval ( 1, 0). Hence, the iteration converges.
Let x
0
= 0.25. We obtain the following results.
x
1
=
4
3 0 25 0 25 12
3 2
( . ) ( . ) + +
= 0.33290,
x
2
=
4
3 0 3329 0 3329 12
3 2
( . ) ( . ) + +
= 0.33333,
x
3
=
4
3 0 33333 0 33333 12
3 2
( . ) ( . ) + +
= 0.33333.
The required approximation to the root is x 0.33333.
Example 1.12 The equation f(x) = 3x
3
+ 4x
2
+ 4x + 1 = 0 has a root in the interval ( 1, 0).
Determine an iteration function (x), such that the sequence of iterations obtained from
x
k+1
= (x
k
), x
0
= 0.5, k = 0, 1,..., converges to the root.
Solution We illustrate the method given in Remark 10. We write the given equation as
x = x + (3x
3
+ 4x
2
+ 4x + 1) = (x)
where is a constant to be determined such that
| (x) | = | 1 + f (x) |
= | 1 + (9x
2
+ 8x + 4) | < 1
for all x ( 1, 0). This condition is also to be satisfied at the initial approximation. Setting x
0
= 0.5, we get
| (x
0
) | = | 1 + f (x
0
) | = 1
9
4
+
< 1
or 1 < 1 +
9
4
< 1 or
8
9
< < 0.
Hence, takes negative values. The interval for depends on the initial approximation
x
0
. Let us choose the value = 0.5. We obtain the iteration method as
x
k+1
= x
k
0.5 (3x
k
3
+ 4x
k
2
+ 4x
k
+ 1)
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 19
= 0.5 (3x
k
3
+ 4x
k
2
+ 2x
k
+ 1) = (x
k
).
Starting with x
0
= 0.5, we obtain the following results.
x
1
= (x
0
) = 0.5 (3x
0
3
+ 4x
0
2
+ 2x
0
+ 1)
= 0.5 [3( 0.5)
3
+ 4( 0.5)
2
+ 2( 0.5) + 1] = 0.3125.
x
2
= (x
1
) = 0.5(3x
1
3
+ 4x
1
2
+ 2x
1
+ 1)
= 0.5[3( 0.3125)
3
+ 4( 0.3125)
2
+ 2( 0.3125) + 1] = 0.337036.
x
3
= (x
2
) = 0.5(3x
2
3
+ 4x
2
2
+ 2x
2
+ 1)
= 0.5[3 ( 0.337036)
3
+ 4( 0.337036)
2
+ 2( 0.337036) + 1] = 0.332723.
x
4
= (x
3
) = 0.5(3x
3
3
+ 4x
3
2
+ 2x
3
+ 1)
= 0.5[3( 0.332723)
3
+ 4( 0.332723)
2
+ 2( 0.332723) + 1] = 0.333435.
x
5
= (x
4
) = 0.5(3x
4
3
+ 4x
4
2
+ 2x
4
+ 1)
= 0.5[3( 0.333435)
3
+ 4( 0.333435)
2
+ 2( 0.333435) + 1] = 0.333316.
Since | x
5
x
4
| = | 0.333316 + 0.333435 | = 0.000119 < 0.0005, the result is correct to
three decimal places.
We can take the approximation as x x
5
= 0.333316. The exact root is x = 1/3.
We can verify that | (x
j
) | < 1 for all j.
1.1.6 Convergence of the Iteration Methods
We now study the rate at which the iteration methods converge to the exact root, if the initial
approximation is sufficiently close to the desired root.
Define the error of approximation at the kth iterate as
k
= x
k
, k = 0, 1, 2,...
Definition An iterative method is said to be of order p or has the rate of convergence p, if p is
the largest positive real number for which there exists a finite constant 0 C , such that
|
k+1
| C |
k
|
p
. (1.28)
The constant C, which is independent of k, is called the asymptotic error constant and it
depends on the derivatives of f(x) at x = .
Let us now obtain the orders of the methods that were derived earlier.
Method of false position We have noted earlier (see Remark 4) that if the root lies initially
in the interval (x
0
, x
1
), then one of the end points is fixed for all iterations. If the left end point
x
0
is fixed and the right end point moves towards the required root, the method behaves like
(see Fig.1.2a)
x
k+1
=
x f x f
f f
k k
k
0 0
0
.
Substituting x
k
=
k
+ , x
k+1
=
k+1
+ , x
0
=
0
+ , we expand each term in Taylors
series and simplify using the fact that f() = 0. We obtain the error equation as
k+1
= C
0
k
, where C =
f
f
( )
( )
2
.
20 NUMERICAL METHODS
Since
0
is finite and fixed, the error equation becomes
|
k+1
| = | C* | |
k
|, where C* = C
0
. (1.29)
Hence, the method of false position has order 1 or has linear rate of convergence.
Method of successive approximations or fixed point iteration method
We have x
k+1
= (x
k
), and = ()
Subtracting, we get
x
k+1
= (x
k
) () = ( + x
k
) ()
= [() + (x
k
) () + ...] ()
or
k+1
=
k
() + O(
k
2
).
Therefore, |
k+1
| = C |
k
|, x
k
< t
k
< , and C = | () |. (1.30)
Hence, the fixed point iteration method has order 1 or has linear rate of convergence.
Newton-Raphson method
The method is given by
x
k+1
= x
k
f x
f x
k
k
( )
( )
, f (x
k
) 0.
Substituting x
k
=
k
+ , x
k+1
=
k+1
+ , we obtain
k+1
+ =
k
+
f
f
k
k
( )
( )
+
+
.
Expand the terms in Taylors series. Using the fact that f() = 0, and canceling f (), we
obtain
k+1
=
k
k k
k
f f
f f
+ +
3
2
+
( ) ( ) ...
( ) ( )
1
2
2
=
k
k k k
f
f
f
f
+
3
2
+
3
2
( )
( )
...
( )
( )
...
2
1
2
1
=
k
k k k
f
f
f
f
+
3
2
3
2
( )
( )
...
( )
( )
...
2
1
2
=
k
k k
f
f
f
f
3
2
=
( )
( )
...
( )
( ) 2 2
2
k
2
+ ...
Neglecting the terms containing
k
3
and higher powers of
k
, we get
k+1
= C
k
2
, where C =
f
f
( )
( )
2
,
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 21
and |
k+1
| = | C | |
k
|
2
. (1.31)
Therefore, Newtons method is of order 2 or has quadratic rate of convergence.
Remark 12 What is the importance of defining the order or rate of convergence of a method?
Suppose that we are using Newtons method for computing a root of f(x) = 0. Let us assume
that at a particular stage of iteration, the error in magnitude in computing the root is 10
1
=
0.1. We observe from (1.31), that in the next iteration, the error behaves like C(0.1)
2
= C(10
2
).
That is, we may possibly get an accuracy of two decimal places. Because of the quadratic
convergence of the method, we may possibly get an accuracy of four decimal places in the next
iteration. However, it also depends on the value of C. From this discussion, we conclude that
both fixed point iteration and regula-falsi methods converge slowly as they have only linear
rate of convergence. Further, Newtons method converges at least twice as fast as the fixed
point iteration and regula-falsi methods.
Remark 13 When does the Newton-Raphson method fail?
(i) The method may fail when the initial approximation x
0
is far away from the exact root
(see Example 1.6). However, if the root lies in a small interval (a, b) and x
0
(a, b), then the
method converges.
(ii) From Eq.(1.31), we note that if f () 0, and f(x) is finite then C and the method
may fail. That is, in this case, the graph of y = f(x) is almost parallel to x-axis at the root .
Remark 14 Let us have a re-look at the error equation. We have defined the error of approxi-
mation at the kth iterate as
k
= x
k
, k = 0, 1, 2,... From x
k+1
= (x
k
), k = 0, 1, 2,... and = (),
we obtain (see Eq.(1.24))
x
k+1
= (x
k
) () = ( +
k
) ()
= ( ) ( ) ( ) ... + + +
3
2
k k
1
2
2
()
or
k+1
= a
1
k
+ a
2
k
2
+ ... (1.32)
where a
1
= (), a
2
= (1/2)(), etc.
The exact root satisfies the equation = ().
If a
1
0 that is, () 0, then the method is of order 1 or has linear convergence. For the
general iteration method, which is of first order, we have derived that the condition of conver-
gence is | (x) | < 1 for all x in the interval (a, b) in which the root lies. Note that in this method,
| (x) | 0 for all x in the neighborhood of the root .
If a
1
= () = 0, and a
2
= (1/2)() 0, then from Eq. (1.32), the method is of order 2 or
has quadratic convergence.
Let us verify this result for the Newton-Raphson method. For the Newton-Raphson
method
x
k+1
= x
k
f x
f x
k
k
( )
( )
, we have (x) = x
f x
f x
( )
( )
.
Then, (x) = 1
[ ( )] ( ) ( )
[ ( )]
( ) ( )
[ ( )]
f x f x f x
f x
f x f x
f x
2
2 2
22 NUMERICAL METHODS
and () =
f f
f
( ) ( )
[ ( )]
2
= 0
since f() = 0 and f () 0 ( is a simple root).
When, x
k
, f (x
k
) 0, we have | (x
k
) | < 1, k = 1, 2,... and 0 as n .
Now, (x) =
1
3
[ ( )] f x
[f (x) {f (x) f (x) + f(x) f (x)} 2 f(x) {f (x)}
2
]
and () =
f
f
( )
( )
0.
Therefore, a
2
0 and the second order convergence of the Newtons method is verified.
REVIEW QUESTIONS
1. Define a (i) root, (ii) simple root and (iii) multiple root of an algebraic equation f(x) = 0.
Solution
(i) A number , such that f() 0 is called a root of f(x) = 0.
(ii) Let be a root of f(x) = 0. If f() 0 and f () 0, then is said to be a simple root.
Then, we can write f(x) as
f (x) = (x ) g(x), g() 0.
(iii) Let be a root of f(x) = 0. If
f() = 0, f () = 0,..., f
(m1)
() = 0, and f
(m)
() 0,
then, is said to be a multiple root of multiplicity m. Then, we can write f (x) as
f(x) = (x )
m
g(x), g() 0.
2. State the intermediate value theorem.
Solution If f(x) is continuous on some interval [a, b] and f (a)f (b) < 0, then the equation
f(x) = 0 has at least one real root or an odd number of real roots in the interval (a, b).
3. How can we find an initial approximation to the root of f (x) = 0 ?
Solution Using intermediate value theorem, we find an interval (a, b) which contains
the root of the equation f (x) = 0. This implies that f (a)f(b) < 0. Any point in this interval
(including the end points) can be taken as an initial approximation to the root of f(x) = 0.
4. What is the Descartes rule of signs?
Solution Let f (x) = 0 be a polynomial equation P
n
(x) = 0. We count the number of
changes of signs in the coefficients of f (x) = P
n
(x) = 0. The number of positive roots
cannot exceed the number of changes of signs in the coefficients of P
n
(x). Now, we write
the equation f( x) = P
n
( x) = 0, and count the number of changes of signs in the coeffi-
cients of P
n
( x). The number of negative roots cannot exceed the number of changes of
signs in the coefficients of this equation.
5. Define convergence of an iterative method.
Solution Using any iteration method, we obtain a sequence of iterates (approxima-
tions to the root of f(x) = 0), x
1
, x
2
,..., x
k
,... If
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 23
lim
k
x
k
= , or lim
k
| x
k
| = 0
where is the exact root, then the method is said to be convergent.
6. What are the criteria used to terminate an iterative procedure?
Solution Let be the prescribed error tolerance. We terminate the iterations when
either of the following criteria is satisfied.
(i) | f(x
k
) | . (ii) | x
k+1
x
k
| .
Sometimes, we may use both the criteria.
7. Define the fixed point iteration method to obtain a root of f(x) = 0. When does the method
converge?
Solution Let a root of f(x) = 0 lie in the interval (a, b). Let x
0
be an initial approximation
to the root. We write f(x) = 0 in an equivalent form as x = (x), and define the fixed point
iteration method as x
k+1
= (x
k
), k = 0, 1, 2, Starting with x
0
, we obtain a sequence of
approximations x
1
, x
2
,..., x
k
,... such that in the limit as k , x
k
. The method
converges when | (x) | < 1, for all x in the interval (a, b). We normally check this
condition at x
0
.
8. Write the method of false position to obtain a root of f(x) = 0. What is the computational
cost of the method?
Solution Let a root of f(x) = 0 lie in the interval (a, b). Let x
0
, x
1
be two initial approxi-
mations to the root in this interval. The method of false position is defined by
x
k+1
=
x f x f
f f
k k k k
k k
1 1
1
, k = 1, 2,...
The computational cost of the method is one evaluation of f(x) per iteration.
9. What is the disadvantage of the method of false position?
Solution If the root lies initially in the interval (x
0
, x
1
), then one of the end points is
fixed for all iterations. For example, in Fig.1.2a, the left end point x
0
is fixed and the
right end point moves towards the required root. Therefore, in actual computations, the
method behaves like
x
k+1
=
x f x f
f f
k k
k
0 0
0
.
In Fig.1.2b, the right end point x
1
is fixed and the left end point moves towards the
required root. Therefore, in this case, in actual computations, the method behaves like
x
k+1
=
x f x f
f f
k k
k
1 1
1
.
10. Write the Newton-Raphson method to obtain a root of f(x) = 0. What is the computa-
tional cost of the method?
Solution Let a root of f(x) = 0 lie in the interval (a, b). Let x
0
be an initial approximation
to the root in this interval. The Newton-Raphson method to find this root is defined by
24 NUMERICAL METHODS
x
k+1
= x
k
f x
f x
k
k
( )
( )
, f (x
k
) 0, k = 0, 1, 2,...,
The computational cost of the method is one evaluation of f(x) and one evaluation of the
derivative f (x) per iteration.
11. Define the order (rate) of convergence of an iterative method for finding the root of an
equation f(x) = 0.
Solution Let be the exact root of f (x) = 0. Define the error of approximation at the kth
iterate as
k
= x
k
, k = 0, 1, 2,... An iterative method is said to be of order p or has the
rate of convergence p, if p is the largest positive real number for which there exists a
finite constant C 0, such that
|
k+1
| C |
k
|
p
.
The constant C, which is independent of k, is called the asymptotic error constant and it
depends on the derivatives of f(x) at x = .
12. What is the rate of convergence of the following methods: (i) Method of false position,
(ii) Newton-Raphson method, (iii) Fixed point iteration method?
Solution (i) One. (ii) Two. (iii) One.
EXERCISE 1.1
In the following problems, find the root as specified using the regula-falsi method (method of
false position).
1. Find the positive root of x
3
= 2x + 5. (Do only four iterations). (A.U. Nov./Dec. 2006)
2. Find an approximate root of x log
10
x 1.2 = 0.
3. Solve the equation x tan x = 1, starting with a = 2.5 and b = 3, correct to three decimal
places.
4. Find the root of xe
x
= 3, correct to two decimal places.
5. Find the smallest positive root of x e
x
= 0, correct to three decimal places.
6. Find the smallest positive root of x
4
x 10 = 0, correct to three decimal places.
In the following problems, find the root as specified using the Newton-Raphson method.
7. Find the smallest positive root of x
4
x = 10, correct to three decimal places.
8. Find the root between 0 and 1 of x
3
= 6x 4, correct to two decimal places.
9. Find the real root of the equation 3x = cos x + 1. (A.U. Nov./Dec. 2006)
10. Find a root of x log
10
x 1.2 = 0, correct to three decimal places.
(A.U. Nov./Dec. 2004)
11. Find the root of x = 2 sin x, near 1.9, correct to three decimal places.
12. (i) Write an iteration formula for finding N where N is a real number.
(A.U. Nov./Dec. 2006, A.U. Nov./Dec. 2003)
(ii) Hence, evaluate 142 , correct to three decimal places.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 25
13. (i) Write an iteration formula for finding the value of 1/N, where N is a real number.
(ii) Hence, evaluate 1/26, correct to four decimal places.
14. Find the root of the equation sin x = 1 + x
3
, which lies in the interval ( 2, 1), correct to
three decimal places.
15. Find the approximate root of xe
x
= 3, correct to three decimal places.
In the following problems, find the root as specified using the iteration method/method of
successive approximations/fixed point iteration method.
16. Find the smallest positive root of x
2
5x + 1 = 0, correct to four decimal places.
17. Find the smallest positive root of x
5
64x + 30 = 0, correct to four decimal places.
18. Find the smallest negative root in magnitude of 3x
3
x + 1 = 0, correct to four decimal
places.
19. Find the smallest positive root of x = e
x
, correct to two decimal places.
20. Find the real root of the equation cos x = 3x 1. (A.U. Nov./Dec. 2006)
21. The equation x
2
+ ax + b = 0, has two real roots and . Show that the iteration method
(i) x
k+1
= (ax
k
+ b)/x
k
, is convergent near x = , if | | > | |,
(ii) x
k+1
= b/(x
k
+ a), is convergent near x = , if | | < | |.
1.2 LNEAR 8Y8TEM OF ALGEBRAC EQUATON8
1.2.1 Introduction
Consider a system of n linear algebraic equations in n unknowns
a
11
x
1
+ a
12
x
2
+ ... + a
1n
x
n
= b
1
a
21
x
1
+ a
22
x
2
+ ... + a
2n
x
n
= b
2
... ... ... ...
a
n1
x
1
+ a
n2
x
2
+ ... + a
nn
x
n
= b
n
where a
ij
, i = 1, 2, ..., n, j = 1, 2, , n, are the known coefficients, b
i
, i = 1, 2, , n, are the known
right hand side values and x
i
, i = 1, 2, , n are the unknowns to be determined.
In matrix notation we write the system as
Ax = b (1.33)
where A =
a a a
a a a
a a a
n
n
n n nn
11 12 1
21 22 2
1 2
, x =
x
x
x
n
1
2
, and b =
b
b
b
n
1
2
.
The matrix [A | b], obtained by appending the column b to the matrix A is called the
augmented matrix. That is
26 NUMERICAL METHODS
[A|b] =
a a a b
a a a b
a a a b
n
n
n n nn n
11 12 1 1
21 22 2 2
1 2
=
,
=
b a x a
j
n
j j 1
2
1 11
=
,
(1.37)
The unknowns are obtained by back substitution and this procedure is called the back
substitution method.
Therefore, when the given system of equations is one of the above two forms, the solution
is obtained directly.
Before we derive some direct methods, we define elementary row operations that can be
performed on the rows of a matrix.
Elementary row transformations (operations) The following operations on the rows of a
matrix A are called the elementary row transformations (operations).
(i) Interchange of any two rows. If we interchange the ith row with the jth row, then we
usually denote the operation as R
i
R
j
.
(ii) Division/multiplication of any row by a non-zero number p. If the ith row is multiplied by
p, then we usually denote this operation as pR
i
.
(iii) Adding/subtracting a scalar multiple of any row to any other row. If all the elements of
the jth row are multiplied by a scalar p and added to the corresponding elements of the ith
row, then, we usually denote this operation as R
i
R
i
+ pR
j
. Note the order in which the
operation R
i
+ pR
j
is written. The elements of the jth row remain unchanged and the elements
of the ith row get changed.
These row operations change the form of A, but do not change the row-rank of A. The
matrix B obtained after the elementary row operations is said to be row equivalent with A. In
the context of the solution of the system of algebraic equations, the solution of the new system
is identical with the solution of the original system.
The above elementary operations performed on the columns of A (column C in place of
row R) are called elementary column transformations (operations). However, we shall be using
only the elementary row operations.
28 NUMERICAL METHODS
In this section, we derive two direct methods for the solution of the given system of
equations, namely, Gauss elimination method and Gauss-Jordan method.
1.2.2.1 Gauss Elimination Method
The method is based on the idea of reducing the given system of equations Ax = b, to an
upper triangular system of equations Ux = z, using elementary row operations. We know that
these two systems are equivalent. That is, the solutions of both the systems are identical. This
reduced system Ux = z, is then solved by the back substitution method to obtain the solution
vector x.
We illustrate the method using the 3 3 system
a
11
x
1
+ a
12
x
2
+ a
13
x
3
= b
1
a
21
x
1
+ a
22
x
2
+ a
23
x
3
= b
2
(1.38)
a
31
x
1
+ a
32
x
2
+ a
33
x
3
= b
3
We write the augmented matrix [A | b] and reduce it to the following form
[A|b]
Gauss elimination
[U|z]
The augmented matrix of the system (1.38) is
a a a b
a a a b
a a a b
11 12 13 1
21 22 23 2
31 32 33 3
(1.39)
First stage of elimination
We assume a
11
0. This element
11
a in the 1 1 position is called the first pivot. We use
this pivot to reduce all the elements below this pivot in the first column as zeros. Multiply the
first row in (1.39) by a
21
/a
11
and a
31
/a
11
respectively and subtract from the second and third
rows. That is, we are performing the elementary row operations R
2
(a
21
/a
11
)R
1
and
R
3
(a
31
/a
11
)R
1
respectively. We obtain the new augmented matrix as
a a a b
a a b
a a b
11 12 13 1
22 23 2
32 33 3
0
0
(1) (1) (1)
(1) (1) (1)
(1.40)
where a
22
(1)
= a
22
a
a
21
11
a
12
, a
23
(1)
= a
23
a
a
21
11
a
13
, b
2
(1)
= b
2
a
a
21
11
b
1
,
a
32
(1)
= a
32
a
a
31
11
a
12
, a
33
(1)
= a
33
a
a
31
11
a
13
, b
3
(1)
= b
3
a
a
31
11
b
1
.
Second stage of elimination
We assume a
22
(1)
0 . This element a
22
(1)
in the 2 2 position is called the second pivot.
We use this pivot to reduce the element below this pivot in the second column as zero. Multi-
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 29
ply the second row in (1.40) by a
32
(1)
/ a
22
(1)
and subtract from the third row. That is, we are
performing the elementary row operation R
3
( a
32
(1)
/ a
22
(1)
)R
2
. We obtain the new augmented
matrix as
a a a b
a a b
a b
11 12 13 1
22 23 2
33
2
3
2
0
0 0
(1) (1) (1)
( ) ( )
(1.41)
where a a
a
a
a
33
2
33
32
22
23
( ) (1)
(1)
(1)
(1)
=
, b b
a
a
b
3
2
3
32
22
2
( ) (1)
(1)
(1)
(1)
=
.
The element a
33
2 ( )
0 is called the third pivot. This system is in the required upper
triangular form [U|z]. The solution vector x is now obtained by back substitution.
From the third row, we get x
3
= b a
3
2
33
2 ( ) ( )
/ .
From the second row, we get x
2
= ( )/
(1) (1) (1)
b a x a
2 23 3 22
.
From the first row, we get x
1
= (b
1
a
12
x
2
a
13
x
3
)/a
11
.
In general, using a pivot, all the elements below that pivot in that column are made zeros.
Alternately, at each stage of elimination, we may also make the pivot as 1, by dividing
that particular row by the pivot.
Remark 15 When does the Gauss elimination method as described above fail? It fails when
any one of the pivots is zero or it is a very small number, as the elimination progresses. If a
pivot is zero, then division by it gives over flow error, since division by zero is not defined. If a
pivot is a very small number, then division by it introduces large round-off errors and the
solution may contain large errors.
For example, we may have the system
2x
2
+ 5x
3
= 7
7x
1
+ x
2
2x
3
= 6
2x
1
+ 3x
2
+ 8x
3
= 13
in which the first pivot is zero.
Pivoting Procedures How do we avoid computational errors in Gauss elimination? To avoid
computational errors, we follow the procedure of partial pivoting. In the first stage of
elimination, the first column of the augmented matrix is searched for the largest element in
magnitude and brought as the first pivot by interchanging the first row of the augmented
matrix (first equation) with the row (equation) having the largest element in magnitude. In
the second stage of elimination, the second column is searched for the largest element in
magnitude among the n 1 elements leaving the first element, and this element is brought as
the second pivot by interchanging the second row of the augmented matrix with the later row
having the largest element in magnitude. This procedure is continued until the upper triangular
system is obtained. Therefore, partial pivoting is done after every stage of elimination. There
is another procedure called complete pivoting. In this procedure, we search the entire matrix
A in the augmented matrix for the largest element in magnitude and bring it as the first pivot.
30 NUMERICAL METHODS
This requires not only an interchange of the rows, but also an interchange of the positions of
the variables. It is possible that the position of a variable is changed a number of times during
this pivoting. We need to keep track of the positions of all the variables. Hence, the procedure
is computationally expensive and is not used in any software.
Remark 16 Gauss elimination method is a direct method. Therefore, it is possible to count
the total number of operations, that is, additions, subtractions, divisions and multiplications.
Without going into details, we mention that the total number of divisions and multiplications
(division and multiplication take the same amount of computer time) is n (n
2
+ 3n 1)/3. The
total number of additions and subtractions (addition and subtraction take the same amount of
computer time) is n (n 1)(2n + 5)/6.
Remark 17 When the system of algebraic equations is large, how do we conclude that it is
consistent or not, using the Gauss elimination method? A way of determining the consistency
is from the form of the reduced system (1.41). We know that if the system is inconsistent then
rank (A) rank [A|b]. By checking the elements of the last rows, conclusion can be drawn
about the consistency or inconsistency.
Suppose that in (1.41), a
33
2 ( )
0 and b
3
2 ( )
0. Then, rank (A) = rank [A|b] = 3. The
system is consistent and has a unique solution.
Suppose that we obtain the reduced system as
a a a b
a a b
b
11 12 13 1
22
1
23
1
2
1
3
2
0
0 0 0
( ) ( ) ( )
( )
.
Then, rank (A) = 2, rank [A|b] = 3 and rank (A) rank [A|b]. Therefore, the system is
inconsistent and has no solution.
Suppose that we obtain the reduced system as
a a a b
a a b
11 12 13 1
22
1
23
1
2
1
0
0 0 0 0
( ) ( ) ( )
.
Then, rank (A) = rank [A|b] = 2 < 3. Therefore, the system has 3 2 = 1 parameter
family of infinite number of solutions.
Example 1.13 Solve the system of equations
x
1
+ 10x
2
x
3
= 3
2x
1
+ 3x
2
+ 20x
3
= 7
10x
1
x
2
+ 2x
3
= 4
using the Gauss elimination with partial pivoting.
Solution We have the augmented matrix as
1 10 1 3
2 3 20 7
10 1 2 4
. R
2
(R
1
/5), R
3
(R
1
/10) :
10 1 2 4
0 32 196 62
0 101 12 26
. . .
. . .
. R
2
R
3
:
10 1 2 4
0 101 12 26
0 32 196 62
. . .
. . .
.
R
3
(3.2/10.1)R
2
:
10 1 2 4
0 101 12 26
0 0 1998020 537624
. . .
. .
.
Back substitution gives the solution.
Third equation gives x
3
=
5.37624
19.98020
= 0.26908.
Second equation gives x
2
=
1
10.1
(2.6 + 1.2x
3
) =
1
10.1
(2.6 + 1.2(0.26908)) = 0.28940.
First equation gives x
1
=
1
10
(4 + x
2
2x
3
) =
1
10
(4 + 0.2894 2(0.26908)) = 0.37512.
Example 1.14 Solve the system of equations
2x
1
+ x
2
+ x
3
2x
4
= 10
4x
1
+ 2x
3
+ x
4
= 8
3x
1
+ 2x
2
+ 2x
3
= 7
x
1
+ 3x
2
+ 2x
3
x
4
= 5
using the Gauss elimination with partial pivoting.
Solution The augmented matrix is given by
2 1 1 2 10
4 0 2 1 8
3 2 2 0 7
1 3 2 1 5
.
We perform the following elementary row transformations and do the eliminations.
R
1
R
2
:
4 0 2 1 8
2 1 1 2 10
3 2 2 0 7
1 3 2 1 5
. R
2
(1/2) R
1
, R
3
(3/4) R
1
, R
4
(1/4) R
1
:
32 NUMERICAL METHODS
4 0 2 1 8
0 1 0 5 2 14
0 2 1 2 3 4 1
0 3 3 2 5 4 7
/
/ /
/ /
. R
2
R
4
:
4 0 2 1 8
0 3 3 2 5 4 7
0 2 1 2 3 4 1
0 1 0 5 2 14
/ /
/ /
/
.
R
3
(2/3) R
2
, R
4
(1/3)R
2
:
4 0 2 1 8
0 3 3 2 5 4 7
0 0 1 2 1 12 17 3
0 0 1 2 25 12 35 3
/ /
/ / /
/ / /
. R
4
R
3
:
4 0 2 1 8
0 3 3 2 5 4 7
0 0 1 2 1 12 17 3
0 0 0 13 6 52 3
/ /
/ / /
/ /
.
Using back substitution, we obtain
x
4
=
52
3
6
13
= 8, x
3
= 2
17
3
1
12
3
x
= 2
17
3
1
12
8
( ) = 10,
x
2
=
1
3
7
3
2
5
4
1
3
7
3
2
10
5
4
8
3 4
x x ( ) ( ) = 6,
x
1
=
1
4
[8 2x
3
x
4
] =
1
4
[8 2( 10) 8] = 5.
Example 1.15 Solve the system of equations
3x
1
+ 3x
2
+ 4x
3
= 20
2x
1
+ x
2
+ 3x
3
= 13
x
1
+ x
2
+ 3x
3
= 6
using the Gauss elimination method.
Solution Let us solve this problem by making the pivots as 1. The augmented matrix is given
by
3 3 4 20
2 1 3 13
1 1 3 6
.
We perform the following elementary row transformations and do the eliminations.
R
1
/3:
1 1 4 3 20 3
2 1 3 13
1 1 3 6
/ /
. R
2
2R
1
, R
3
R
1
:
1 1 4 3 20 3
0 1 1 3 1 3
0 0 5 3 2 3
/ /
/ /
/ /
.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 33
Back substitution gives the solution as
x
3
=
2
3
3
5
=
2
5
, x
2
=
1
3 3
1
3
1
3
2
5
1
5
3
+ = +
=
x
,
x
1
=
20
3
x
2
4
3
x
3
=
20
3
1
5
4
3
2
5
35
5
= = 7.
Example 1.16 Test the consistency of the following system of equations
x
1
+ 10x
2
x
3
= 3
2x
1
+ 3x
2
+ 20x
3
= 7
9x
1
+ 22x
2
+ 79x
3
= 45
using the Gauss elimination method.
Solution We have the augmented matrix as
1 10 1 3
2 3 20 7
9 22 79 45
.
We perform the following elementary row transformations and do the eliminations.
R
2
2R
1
, R
3
9R
1
:
1 10 1 3
0 17 22 1
0 68 88 18
. R
3
4R
2
:
1 10 1 3
0 17 22 1
0 0 0 14
.
Now, rank [A] = 2, and rank [A|b] = 3. Therefore, the system is inconsistent and has no
solution.
1.2.2.2 Gauss-Jordan Method
The method is based on the idea of reducing the given system of equations Ax = b, to a
diagonal system of equations Ix = d, where I is the identity matrix, using elementary row
operations. We know that the solutions of both the systems are identical. This reduced system
gives the solution vector x. This reduction is equivalent to finding the solution as x = A
1
b.
[A|b]
Gauss Jordan method -
[I | X]
In this case, after the eliminations are completed, we obtain the augmented matrix for
a 3 3 system as
1 0 0
0 1 0
0 0 1
1
2
3
d
d
d
(1.42)
and the solution is x
i
= d
i
, i = 1, 2, 3.
34 NUMERICAL METHODS
Elimination procedure The first step is same as in Gauss elimination method, that is, we
make the elements below the first pivot as zeros, using the elementary row transformations.
From the second step onwards, we make the elements below and above the pivots as zeros
using the elementary row transformations. Lastly, we divide each row by its pivot so that the
final augmented matrix is of the form (1.42). Partial pivoting can also be used in the solution.
We may also make the pivots as 1 before performing the elimination.
Let us illustrate the method.
Example 1.17 Solve the following system of equations
x
1
+ x
2
+ x
3
= 1
4x
1
+ 3x
2
x
3
= 6
3x
1
+ 5x
2
+ 3x
3
= 4
using the Gauss-Jordan method (i) without partial pivoting, (ii) with partial pivoting.
Solution We have the augmented matrix as
1 1 1 1
4 3 1 6
3 5 3 4
3
2
2
(i) We perform the following elementary row transformations and do the eliminations.
R
2
4R
1
, R
3
3R
1
:
1 1 1 1
0 1 5 2
0 2 0 1
3
2
2
.
R
1
+ R
2
, R
3
+ 2R
2
:
1 0 4 3
0 1 5 2
0 0 10 5
3
2
2
.
R
1
(4/10)R
3
, R
2
(5/10) R
3
:
1 0 0 1
0 1 0 12
0 0 10 5
3
2
2
/ .
Now, making the pivots as 1, (( R
2
), (R
3
/( 10))) we get
1 0 0 1
0 1 0 12
0 0 1 12
/
/
3
2
2
.
Therefore, the solution of the system is x
1
= 1, x
2
= 1/2, x
3
= 1/2.
(ii) We perform the following elementary row transformations and do the elimination.
R
1
R
2
:
4 3 1 6
1 1 1 1
3 5 3 4
3
2
2
. R
1
/4 :
1 34 14 32
1 1 1 1
3 5 3 4
/ / /
3
2
2
.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 35
R
2
R
1
, R
3
3R
1
:
1 3 4 14 3 2
0 14 5 4 12
0 11 4 15 4 12
/ / /
/ / /
/ / /
3
2
2
.
R
2
R
3
:
1 3 4 14 3 2
0 11 4 15 4 12
0 14 5 4 12
/ / /
/ / /
/ / /
3
2
2
. R
2
/(11/4) :
1 3 4 1 4 3 2
0 1 15 11 2 11
0 14 5 4 12
/ / /
/ /
/ / /
3
2
2
.
R
1
(3/4) R
2
, R
3
(1/4)R
2
:
1 0 14 11 18 11
0 1 15 11 2 11
0 0 10 11 5 11
3
2
2
/ /
/ /
/ /
.
R
3
/(10/11) :
1 0 14 11 18 11
0 1 15 11 2 11
0 0 1 12
3
2
2
/ /
/ /
/
.
R
1
+ (14/11) R
3
, R
2
(15/11)R
3
:
1 0 0 1
0 1 0 12
0 0 1 12
/
/
3
2
2
.
Therefore, the solution of the system is x
1
= 1, x
2
= 1/2, x
3
= 1/2.
Remark 18 The Gauss-Jordan method looks very elegant as the solution is obtained directly.
However, it is computationally more expensive than Gauss elimination. For large n, the total
number of divisions and multiplications for Gauss-Jordan method is almost 1.5 times the
total number of divisions and multiplications required for Gauss elimination. Hence, we do
not normally use this method for the solution of the system of equations. The most important
application of this method is to find the inverse of a non-singular matrix. We present this
method in the following section.
1.2.2.3 Inverse of a Matrix by Gauss-Jordan Method
As given in Remark 18, the important application of the Gauss-Jordan method is to
find the inverse of a non-singular matrix A. We start with the augmented matrix of A with the
identity matrix I of the same order. When the Gauss-Jordan procedure is completed, we ob-
tain
[A | I]
Gauss Jordan method -
[I | A
1
]
since, AA
1
= I.
Remark 19 Partial pivoting can also be done using the augmented matrix [A|I]. However,
we cannot first interchange the rows of A and then find the inverse. Then, we would be finding
the inverse of a different matrix.
Example 1.18 Find the inverse of the matrix
1 1 1
4 3 1
3 5 3
3
2
2
36 NUMERICAL METHODS
using the Gauss-Jordan method (i) without partial pivoting, and (ii) with partial pivoting.
Solution Consider the augmented matrix
1 1 1 1 0 0
4 3 1 0 1 0
3 5 3 0 0 1
3
2
2
.
(i) We perform the following elementary row transformations and do the eliminations.
R
2
4R
1
, R
3
3R
1
:
1 1 1 1 0 0
0 1 5 4 1 0
0 2 0 3 0 1
3
2
2
.
R
2
:
1 1 1 1 0 0
0 1 5 4 1 0
0 2 0 3 0 1
3
2
2
R
1
R
2
, R
3
2R
2
:
1 0 4 3 1 0
0 1 5 4 1 0
0 0 10 11 2 1
3
2
2
.
R
3
/( 10) :
1 0 4 3 1 0
0 1 5 4 1 0
0 0 1 1110 2 10 110
3
2
2
/ / /
.
R
1
+ 4R
3
, R
2
5R
3
:
1 0 0 14 10 2 10 4 10
0 1 0 15 10 0 5 10
0 0 1 1110 2 10 110
/ / /
/ /
/ / /
3
2
2
.
Therefore, the inverse of the given matrix is given by
7 5 15 2 5
3 2 0 12
1110 15 110
/ / /
/ /
/ / /
3
2
2
.
(ii) We perform the following elementary row transformations and do the eliminations.
R
1
R
2
:
4 3 1 0 1 0
1 1 1 1 0 0
3 5 3 0 0 1
3
2
2
. R
1
/ 4 :
1 3 4 14 0 14 0
1 1 1 1 0 0
3 5 3 0 0 1
/ / /
3
2
2
.
R
2
R
1
, R
3
3R
1
:
1 3 4 14 0 14 0
0 14 5 4 1 14 0
0 114 15 4 0 3 4 1
/ / /
/ / /
/ / /
3
2
2
.
R
2
R
3
:
1 34 14 0 14 0
0 114 154 0 34 1
0 14 54 1 14 0
/ / /
/ / /
/ / /
3
2
2
.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 37
R
2
/(11/4) :
1 34 14 0 14 0
0 1 1511 0 311 411
0 14 54 1 14 0
/ / /
/ / /
/ / /
3
2
2
.
R
1
(3/4) R
2
, R
3
(1/4)R
2
:
1 0 1411 0 511 311
0 1 1511 0 311 411
0 0 1011 1 211 111
3
2
2
/ / /
/ / /
/ / /
.
R
3
/(10/11) :
1 0 1411 0 511 311
0 1 1511 0 311 411
0 0 1 1110 15 110
3
2
2
/ / /
/ / /
/ / /
.
R
1
+ (14/11) R
3
, R
2
(15/11)R
3
:
1 0 0 75 15 25
0 1 0 32 0 12
0 0 1 1110 15 110
/ / /
/ /
/ / /
3
2
2
.
Therefore, the inverse of the matrix is given by
75 15 25
32 0 12
1110 15 110
/ / /
/ /
/ / /
3
2
2
Example 1.19 Using the Gauss-Jordan method, find the inverse of
2 2 3
2 1 1
1 3 5
3
2
2
. (A.U. Apr./May 2004)
Solution We have the following augmented matrix.
2 2 3 1 0 0
2 1 1 0 1 0
1 3 5 0 0 1
3
2
2
.
We perform the following elementary row transformations and do the eliminations.
R
1
/ 2 :
1 1 3 2 12 0 0
2 1 1 0 1 0
1 3 5 0 0 1
/ /
3
2
2
. R
2
2R
1
, R
3
R
1
:
1 1 32 12 0 0
0 1 2 1 1 0
0 2 72 12 0 1
/ /
/ /
3
2
2
.
R
2
R
3
. Then, R
2
/2 :
1 1 32 12 0 0
0 1 74 14 0 12
0 1 2 1 1 0
/ /
/ / /
3
2
2
.
R
1
R
2
, R
3
+ R
2
:
1 0 14 34 0 12
0 1 74 14 0 12
0 0 14 54 1 12
3
2
2
/ / /
/ / /
/ / /
.
38 NUMERICAL METHODS
R
3
/( 1/4) :
1 0 14 34 0 12
0 1 74 14 0 12
0 0 1 5 4 2
3
2
2
/ / /
/ / / .
R
1
+ (1/4)R
3
, R
2
(7/4)R
3
:
1 0 0 2 1 1
0 1 0 9 7 4
0 0 1 5 4 2
3
2
2
.
Therefore, the inverse of the given matrix is given by
2 1 1
9 7 4
5 4 2
3
2
2
.
REVIEW QUESTIONS
1. What is a direct method for solving a linear system of algebraic equations Ax = b ?
Solution Direct methods produce the solutions in a finite number of steps. The number
of operations, called the operational count, can be calculated.
2. What is an augmented matrix of the system of algebraic equations Ax = b ?
Solution The augmented matrix is denoted by [A | b], where A and b are the coeffi-
cient matrix and right hand side vector respectively. If A is an n n matrix and b is an
n 1 vector, then the augmented matrix is of order n (n + 1).
3. Define the rank of a matrix.
Solution The number of linearly independent rows/columns of a matrix define the row-
rank/column-rank of that matrix. We note that row-rank = column-rank = rank.
4. Define consistency and inconsistency of a system of linear system of algebraic equa-
tions Ax = b.
Solution Let the augmented matrix of the system be [A | b].
(i) The system of equations Ax = b is consistent (has at least one solution), if
rank (A) = rank [A | b] = r.
If r = n, then the system has unique solution.
If r < n, then the system has (n r) parameter family of infinite number of solutions.
(ii) The system of equations Ax = b is inconsistent (has no solution) if
rank (A) rank [A | b].
5. Define elementary row transformations.
Solution We define the following operations as elementary row transformations.
(i) Interchange of any two rows. If we interchange the ith row with the jth row, then we
usually denote the operation as R
i
R
j
.
(ii) Division/multiplication of any row by a non-zero number p. If the ith row is multi-
plied by p, then we usually denote this operation as pR
i
.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 39
(iii) Adding/subtracting a scalar multiple of any row to any other row. If all the elements
of the jth row are multiplied by a scalar p and added to the corresponding elements
of the ith row, then, we usually denote this operation as R
i
R
i
+ pR
j
. Note the
order in which the operation R
i
+ pR
j
is written. The elements of the jth row remain
unchanged and the elements of the ith row get changed.
6. Which direct methods do we use for (i) solving the system of equations Ax = b, and (ii)
finding the inverse of a square matrix A?
Solution (i) Gauss elimination method and Gauss-Jordan method. (ii) Gauss-Jordan
method.
7. Describe the principle involved in the Gauss elimination method.
Solution The method is based on the idea of reducing the given system of equations Ax
= b, to an upper triangular system of equations Ux = z, using elementary row opera-
tions. We know that these two systems are equivalent. That is, the solutions of both the
systems are identical. This reduced system Ux = z, is then solved by the back substitu-
tion method to obtain the solution vector x.
8. When does the Gauss elimination method fail?
Solution Gauss elimination method fails when any one of the pivots is zero or it is a
very small number, as the elimination progresses. If a pivot is zero, then division by it
gives over flow error, since division by zero is not defined. If a pivot is a very small
number, then division by it introduces large round off errors and the solution may con-
tain large errors.
9. How do we avoid computational errors in Gauss elimination?
Solution To avoid computational errors, we follow the procedure of partial pivoting. In
the first stage of elimination, the first column of the augmented matrix is searched for
the largest element in magnitude and brought as the first pivot by interchanging the
first row of the augmented matrix (first equation) with the row (equation) having the
largest element in magnitude. In the second stage of elimination, the second column is
searched for the largest element in magnitude among the n 1 elements leaving the
first element, and this element is brought as the second pivot by interchanging the
second row of the augmented matrix with the later row having the largest element in
magnitude. This procedure is continued until the upper triangular system is obtained.
Therefore, partial pivoting is done after every stage of elimination.
10. Define complete pivoting in Gauss elimination.
Solution In this procedure, we search the entire matrix A in the augmented matrix for
the largest element in magnitude and bring it as the first pivot. This requires not only
an interchange of the equations, but also an interchange of the positions of the vari-
ables. It is possible that the position of a variable is changed a number of times during
this pivoting. We need to keep track of the positions of all the variables. Hence, the
procedure is computationally expensive and is not used in any software.
11. Describe the principle involved in the Gauss-Jordan method for finding the inverse of a
square matrix A.
40 NUMERICAL METHODS
Solution We start with the augmented matrix of A with the identity matrix I of the
same order. When the Gauss-Jordan elimination procedure using elementary row trans-
formations is completed, we obtain
[A | I]
Gauss Jordan method -
[I | A
1
]
since, AA
1
= I.
12. Can we use partial pivoting in Gauss-Jordan method?
Solution Yes. Partial pivoting can also be done using the augmented matrix [A | I].
However, we cannot first interchange the rows of A and then find the inverse. Then, we
would be finding the inverse of a different matrix.
EXERCISE 1.2
Solve the following system of equations by Gauss elimination method.
1. 10x 2y + 3z = 23 2. 3.15x 1.96y + 3.85z = 12.95
2x + 10y 5z = 53 2.13x + 5.12y 2.89z = 8.61
3x 4y + 10z = 33. 5.92x + 3.05y + 2.15z = 6.88.
3.
2 2 1
4 3 3
1 1 1
1
2
3
3
2
2
3
2
2
=
3
2
2
x
y
z
. 4.
2 1 1 2
4 0 2 1
3 2 2 0
1 3 2 6
2
3
1
2
1
2
3
4
3
2
2
2
3
2
2
2
=
3
2
2
2
x
x
x
x
.
Solve the following system of equations by Gauss-Jordan method.
5. 10x + y + z = 12
2x + 10y + z = 13 (A.U. Nov/Dec 2004)
x + y + 5z = 7.
6. x + 3y + 3z = 16
x + 4y + 3z = 18 (A.U. Apr/May 2005)
x + 3y + 4z = 19.
7. 10x 2y + 3z = 23 8. x
1
+ x
2
+ x
3
= 1
2x + 10y 5z = 53 4x
1
+ 3x
2
x
3
= 6
3x 4y + 10z = 33. 3x
1
+ 5x
2
+ 3x
3
= 4.
Find the inverses of the following matrices by Gauss-Jordan method.
9.
2 1 1
3 2 3
1 4 9
3
2
2
. (A.U. Nov/Dec 2006) 10.
1 1 3
1 3 3
2 4 4
3
2
2
. (A.U. Nov/Dec 2006)
11.
2 2 6
2 6 6
4 8 8
3
2
2
. 12.
2 0 1
3 2 5
1 1 0
3
2
2
. (A.U. Nov/Dec 2005)
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 41
Show that the following systems of equations are inconsistent using the Gauss elimination
method.
13. 2x
1
+ x
2
3x
3
= 0 14. x
1
3x
2
+ 4x
3
= 2
5x
1
+ 8x
2
+ x
3
= 14, x
1
+ x
2
x
3
= 0
4x
1
+ 13x
2
+ 11x
3
= 25. 3x
1
x
2
+ 2x
3
= 4.
Show that the following systems of equations have infinite number of solutions using the Gauss
elimination.
15. 2x
1
+ x
2
3x
3
= 0, 16. x
1
+ 5x
2
x
3
= 0,
5x
1
+ 8x
2
+ x
3
= 14, 2x
1
+ 3x
2
+ x
3
= 11,
4x
1
+ 13x
2
+ 11x
3
= 28. 5x
1
+ 11x
2
+ x
3
= 22.
1.2.3 Iterative Methods
As discussed earlier, iterative methods are based on the idea of successive approximations.
We start with an initial approximation to the solution vector x = x
0
, to solve the system of
equations Ax = b, and obtain a sequence of approximate vectors x
0
, x
1
, ..., x
k
, ..., which in the
limit as k , converges to the exact solution vector x = A
1
b. A general linear iterative
method for the solution of the system of equations Ax = b, can be written in matrix form as
x
(k+1)
= Hx
(k)
+ c, k = 0, 1, 2, (1.43)
where x
(k+1)
and x
(k)
are the approximations for x at the (k + 1)th and kth iterations respec-
tively. H is called the iteration matrix, which depends on A and c is a column vector, which
depends on A and b.
When to stop the iteration We stop the iteration procedure when the magnitudes of the
differences between the two successive iterates of all the variables are smaller than a given
accuracy or error tolerance or an error bound , that is,
x x i
i
k
i
k ( ) ( )
, .
+
1
for all (1.44)
For example, if we require two decimal places of accuracy, then we iterate until
x x
i
k
i
k ( ) ( )
. ,
+
<
1
0 005 for all i. If we require three decimal places of accuracy, then we iterate
until x x
i
k
i
k ( ) ( )
. ,
+
<
1
0 0005 for all i.
Convergence property of an iterative method depends on the iteration matrix H.
Now, we derive two iterative methods for the solution of the system of algebraic equations
a
11
x
1
+ a
12
x
2
+ a
13
x
3
= b
1
a
21
x
1
+ a
22
x
2
+ a
23
x
3
= b
2
(1.45)
a
31
x
1
+ a
32
x
2
+ a
33
x
3
= b
3
1.2.3.1 Gauss-Jacobi Iteration Method
Sometimes, the method is called Jacobi method. We assume that the pivots a
ii
0, for
all i. Write the equations as
42 NUMERICAL METHODS
a
11
x
1
= b
1
(a
12
x
2
+ a
13
x
3
)
a
22
x
2
= b
2
(a
21
x
1
+ a
23
x
3
)
a
33
x
3
= b
3
(a
31
x
1
+ a
32
x
2
)
The Jacobi iteration method is defined as
x
a
b a x a x
k k k
1
1
11
1 12 2 13 3
1
( ) ( ) ( )
[ ( )]
+
= +
x
a
b a x a x
k k k
2
1
22
2 21 1 23 3
1
( ) ( ) ( )
[ ( )]
+
= +
x
a
b a x a x
k k k
3
1
33
3 31 1 32 2
1
( ) ( ) ( )
[ ( )]
+
= +
, k = 0, 1, 2, ... (1.46)
Since, we replace the complete vector x
(k)
in the right hand side of (1.46) at the end of
each iteration, this method is also called the method of simultaneous displacement.
Remark 20 A sufficient condition for convergence of the Jacobi method is that the system of
equations is diagonally dominant, that is, the coefficient matrix A is diagonally dominant. We
can verify that | a
ii
|
=
j i j
n
ij
a
1,
| |. This implies that convergence may be obtained even if the
system is not diagonally dominant. If the system is not diagonally dominant, we may exchange
the equations, if possible, such that the new system is diagonally dominant and convergence
is guaranteed. However, such manual verification or exchange of equations may not be possible
for large systems that we obtain in application problems. The necessary and sufficient condition
for convergence is that the spectral radius of the iteration matrix H is less than one unit, that
is, (H) < 1, where (H) is the largest eigen value in magnitude of H. Testing of this condition
is beyond the scope of the syllabus.
Remark 21 How do we find the initial approximations to start the iteration? If the system is
diagonally dominant, then the iteration converges for any initial solution vector. If no suitable
approximation is available, we can choose x = 0, that is x
i
= 0 for all i. Then, the initial
approximation becomes x
i
= b
i
/a
ii
, for all i.
Example 1.20 Solve the system of equations
4x
1
+ x
2
+ x
3
= 2
x
1
+ 5x
2
+ 2x
3
= 6
x
1
+ 2x
2
+ 3x
3
= 4
using the Jacobi iteration method. Use the initial approximations as
(i) x
i
= 0, i = 1, 2, 3, (ii) x
1
= 0.5, x
2
= 0.5, x
3
= 0.5.
Perform five iterations in each case.
Solution Note that the given system is diagonally dominant. Jacobi method gives the iterations
as
x
1
(k+1)
= 0.25 [2 (x
2
(k)
+ x
3
(k)
)]
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 43
x
2
(k+1)
= 0.2 [ 6 (x
1
(k)
+ 2x
3
(k)
)]
x
3
(k+1)
= 0.33333 [ 4 (x
1
(k)
+ 2x
2
(k)
)], k = 0, 1, ...
We have the following results.
(i) x
1
(0)
= 0, x
2
(0)
= 0, x
3
(0)
= 0.
First iteration
x
1
(1)
= 0.25 [2 (x
2
(0)
+ x
3
(0)
)] = 0.5,
x
2
(1)
= 0.2 [ 6 (x
1
(0)
+ 2x
3
(0)
)] = 1.2,
x
3
(1)
= 0.33333 [ 4 (x
1
(0)
+ 2x
2
(0)
)] = 1.33333.
Second iteration
x
1
(2)
= 0.25 [2 (x
2
(1)
+ x
3
(1)
)] = 0.25 [2 ( 1.2 1.33333)] = 1.13333,
x
2
(2)
= 0.2 [ 6 (x
1
(1)
+ 2x
3
(1)
)] = 0.2 [ 6 (0.5 + 2( 1.33333))] = 0.76668,
x
3
(2)
= 0.33333 [ 4 (x
1
(1)
+ 2x
2
(1)
)] = 0.33333 [ 4 (0.5 + 2( 1.2))] = 0.7.
Third iteration
x
1
(3)
= 0.25 [2 (x
2
(2)
+ x
3
(2)
)] = 0.25 [2 ( 0.76668 0.7)] = 0.86667,
x
2
(3)
= 0.2 [ 6 (x
1
(2)
+ 2x
3
(2)
)] = 0.2 [ 6 (1.13333 + 2( 0.7))] = 1.14667,
x
3
(3)
= 0.33333 [ 4 (x
1
(2)
+ 2x
2
(2)
)]
= 0.33333 [ 4 (1.13333 + 2( 0.76668))] = 1.19998.
Fourth iteration
x
1
(4)
= 0.25 [2 (x
2
(3)
+ x
3
(3)
)] = 0.25 [2 ( 1.14667 1.19999)] = 1.08666,
x
2
(4)
= 0.2 [ 6 (x
1
(3)
+ 2x
3
(3)
)] = 0.2 [ 6 (0.86667 + 2( 1.19998))] = 0.89334,
x
3
(4)
= 0.33333 [ 4 (x
1
(3)
+ 2x
2
(3)
)]
= 0.33333 [ 4 (0.86667 + 2( 1.14667))] = 0.85777.
Fifth iteration
x
1
(5)
= 0.25 [2 (x
2
(4)
+ x
3
(4)
)] = 0.25 [2 ( 0.89334 0.85777)] = 0.93778,
x
2
(5)
= 0.2 [ 6 (x
1
(4)
+ 2x
3
(4)
)] = 0.2 [ 6 (1.08666 + 2( 0.85777))] = 1.07422,
x
3
(5)
= 0.33333 [ 4 (x
1
(4)
+ 2x
2
(4)
)]
= 0.33333 [ 4 (1.08666 + 2( 0.89334))] = 1.09998.
It is interesting to note that the iterations oscillate and converge to the exact solution
x
1
= 1.0, x
2
= 1, x
3
= 1.0.
(ii) x
1
(0)
= 0.5, x
2
(0)
= 0.5, x
3
(0)
= 0.5.
First iteration
x
1
(1)
= 0.25 [2 (x
2
(0)
+ x
3
(0)
)] = 0.25 [2 ( 0.5 0.5)] = 0.75,
x
2
(1)
= 0.2 [ 6 (x
1
(0)
+ 2x
3
(0)
)] = 0.2 [ 6 (0.5 + 2( 0.5))] = 1.1,
x
3
(1)
= 0.33333 [ 4 (x
1
(0)
+ 2x
2
(0)
)] = 0.33333 [ 4 (0.5 + 2( 0.5))] = 1.16667.
44 NUMERICAL METHODS
Second iteration
x
1
(2)
= 0.25 [2 (x
2
(1)
+ x
3
(1)
)] = 0.25 [2 ( 1.1 1.16667)] = 1.06667,
x
2
(2)
= 0.2 [ 6 (x
1
(1)
+ 2x
3
(1)
)] = 0.2 [ 6 (0.75 + 2( 1.16667))] = 0.88333,
x
3
(2)
= 0.33333 [ 4 (x
1
(1)
+ 2x
2
(1)
)] = 0.33333 [ 4 (0.75 + 2( 1.1))] = 0.84999.
Third iteration
x
1
(3)
= 0.25 [2 (x
2
(2)
+ x
3
(2)
)] = 0.25 [2 ( 0.88333 0.84999)] = 0.93333,
x
2
(3)
= 0.2 [ 6 (x
1
(2)
+ 2x
3
(2)
)] = 0.2 [ 6 (1.06667 + 2( 0.84999))] = 1.07334,
x
3
(3)
= 0.33333 [ 4 (x
1
(2)
+ 2x
2
(2)
)]
= 0.33333 [ 4 (1.06667 + 2( 0.88333))] = 1.09999.
Fourth iteration
x
1
(4)
= 0.25 [2 (x
2
(3)
+ x
3
(3)
)] = 0.25 [2 ( 1.07334 1.09999)] = 1.04333,
x
2
(4)
= 0.2 [ 6 (x
1
(3)
+ 2x
3
(3)
)] = 0.2 [ 6 (0.93333 + 2( 1.09999))] = 0.94667,
x
3
(4)
= 0.33333 [ 4 (x
1
(3)
+ 2x
2
(3)
)]
= 0.33333 [ 4 (0.93333 + 2( 1.07334))] = 0.92887.
Fifth iteration
x
1
(5)
= 0.25 [2 (x
2
(4)
+ x
3
(4)
)] = 0.25 [2 ( 0.94667 0.92887)] = 0.96889,
x
2
(5)
= 0.2 [ 6 (x
1
(4)
+ 2x
3
(4)
)] = 0.2 [ 6 (1.04333 + 2( 0.92887))] = 1.03712,
x
3
(5)
= 0.33333 [ 4 (x
1
(4)
+ 2x
2
(4)
)]
= 0.33333 [ 4 (1.04333 + 2( 0.94667))] = 1.04999.
Example 1.21 Solve the system of equations
26x
1
+ 2x
2
+ 2x
3
= 12.6
3x
1
+ 27x
2
+ x
3
= 14.3
2x
1
+ 3x
2
+ 17x
3
= 6.0
using the Jacobi iteration method. Obtain the result correct to three decimal places.
Solution The given system of equations is strongly diagonally dominant. Hence, we can ex-
pect faster convergence. Jacobi method gives the iterations as
x
1
(k+1)
= [12.6 (2x
2
(k)
+ 2x
3
(k)
)]/26
x
2
(k+1)
= [ 14.3 (3x
1
(k)
+ x
3
(k)
)]/27
x
3
(k+1)
= [6.0 (2x
1
(k)
+ 3x
2
(k)
)]/17 k = 0, 1, ...
Choose the initial approximation as x
1
(0)
= 0, x
2
(0)
= 0, x
3
(0)
= 0. We obtain the following
results.
First iteration
x
1
(1)
=
1
26
[12.6 (2x
2
(0)
+ 2x
3
(0)
)] =
1
26
[12.6] = 0.48462,
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 45
x
2
(1)
=
1
27
[ 14.3 (3x
1
(0)
+ x
3
(0)
)] =
1
27
[ 14.3] = 0.52963,
x
3
(1)
=
1
17
[6.0 (2x
1
(0)
+ 3x
2
(0)
)] =
1
17
[6.0] = 0.35294.
Second iteration
x
1
(2)
=
1
26
[12.6 (2x
2
(1)
+ 2x
3
(1)
)] =
1
26
[12.6 2 ( 0.52963 + 0.35294)] = 0.49821,
x
2
(2)
=
1
27
[ 14.3 (3x
1
(1)
+ x
3
(1)
)] =
1
27
[ 14.3 (3(0.48462) + 0.35294)] = 0.59655,
x
3
(2)
=
1
17
[ 6.0 (2x
1
(1)
+ 3x
2
(1)
)] =
1
17
[6.0 (2(0.48462) + 3( 0.52963))] = 0.38939.
Third iteration
x
1
(3)
=
1
26
[12.6 (2x
2
(2)
+ 2x
3
(2)
)] =
1
26
[12.6 2( 0.59655 + 0.38939)] = 0.50006,
x
2
(3)
=
1
27
[ 14.3 (3x
1
(2)
+ x
3
(2)
)] =
1
27
[ 14.3 (3(0.49821) + 0.38939)] = 0.59941,
x
3
(3)
=
1
17
[ 6.0 (2x
1
(2)
+ 3x
2
(2)
)] =
1
17
[6.0 (2(0.49821) + 3( 0.59655))] = 0.39960.
Fourth iteration
x
1
(4)
=
1
26
[12.6 (2x
2
(3)
+ 2x
3
(3)
)] =
1
26
[12.6 2( 0.59941 + 0.39960)] = 0.50000,
x
2
(4)
=
1
27
[ 14.3 (3x
1
(3)
+ x
3
(3)
)] =
1
27
[ 14.3 (3(0.50006) + 0.39960)] = 0.59999,
x
3
(4)
=
1
17
[ 6.0 (2x
1
(3)
+ 3x
2
(3)
)] =
1
17
[6.0 (2(0.50006) + 3( 0.59941))] = 0.39989.
We find x x
1
4
1
3 ( ) ( )
= | 0.5 0.50006 | = 0.00006,
x x
2
4
2
3 ( ) ( )
= | 0.59999 + 0.59941 | = 0.00058,
x x
3
4
3
3 ( ) ( )
= | 0.39989 0.39960 | = 0.00029.
Three decimal places of accuracy have not been obtained at this iteration.
Fifth iteration
x
1
(5)
=
1
26
[12.6 (2x
2
(4)
+ 2x
3
(4)
)] =
1
26
[12.6 2( 0.59999 + 0.39989)] = 0.50001,
x
2
(5)
=
1
27
[ 14.3 (3x
1
(4)
+ x
3
(4)
)] =
1
27
[ 14.3 (3(0.50000) + 0.39989)] = 0.60000,
46 NUMERICAL METHODS
x
3
(5)
=
1
17
[ 6.0 (2x
1
(4)
+ 3x
2
(4)
)] =
1
17
[6.0 (2(0.50000) + 3( 0.59999))] = 0.40000.
We find x x
1
4
1
3 ( ) ( )
= | 0.50001 0.5 | = 0.00001,
x x
2
4
2
3 ( ) ( )
= | 0.6 + 0.59999 | = 0.00001,
x x
3
4
3
3 ( ) ( )
= | 0.4 0.39989 | = 0.00011.
Since, all the errors in magnitude are less than 0.0005, the required solution is
x
1
= 0.5, x
2
= 0.6, x
3
= 0.4.
Remark 22 What is the disadvantage of the Gauss-Jacobi method? At any iteration step, the
value of the first variable x
1
is obtained using the values of the previous iteration. The value of
the second variable x
2
is also obtained using the values of the previous iteration, even though
the updated value of x
1
is available. In general, at every stage in the iteration, values of the
previous iteration are used even though the updated values of the previous variables are
available. If we use the updated values of x
1
, x
2
,..., x
i1
in computing the value of the variable
x
i
, then we obtain a new method called Gauss-Seidel iteration method.
1.2.3.2 Gauss-Seidel Iteration Method
As pointed out in Remark 22, we use the updated values of x
1
, x
2
,..., x
i1
in computing
the value of the variable x
i
. We assume that the pivots a
ii
0, for all i. We write the equations
as
a
11
x
1
= b
1
(a
12
x
2
+ a
13
x
3
)
a
22
x
2
= b
2
(a
21
x
1
+ a
23
x
3
)
a
33
x
3
= b
3
(a
31
x
1
+ a
32
x
2
)
The Gauss-Seidel iteration method is defined as
x
1
(k+1)
=
1
11
a
[b
1
(a
12
x
2
(k)
+ a
13
x
3
(k)
)]
x
2
(k+1)
=
1
22
a
[b
2
(a
21
x
1
(k+1)
+ a
23
x
3
(k)
)]
x
3
(k+1)
=
1
33
a
[b
3
(a
31
x
1
(k+1)
+ a
32
x
2
(k+1)
)] (1.47)
k = 0, 1, 2,...
This method is also called the method of successive displacement.
We observe that (1.47) is same as writing the given system as
a
11
x
1
(k+1)
= b
1
(a
12
x
2
(k)
+ a
13
x
3
(k)
)
a
21
x
1
(k+1)
+ a
22
x
2
(k+1)
= b
2
a
23
x
3
(k)
(1.48)
a
31
x
1
(k+1)
+ a
32
x
2
(k+1)
+ a
33
x
3
(k+1)
= b
3
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 47
Remark 23 A sufficient condition for convergence of the Gauss-Seidel method is that the sys-
tem of equations is diagonally dominant, that is, the coefficient matrix A is diagonally domi-
nant. This implies that convergence may be obtained even if the system is not diagonally
dominant. If the system is not diagonally dominant, we may exchange the equations, if possi-
ble, such that the new system is diagonally dominant and convergence is guaranteed. The
necessary and sufficient condition for convergence is that the spectral radius of the iteration
matrix H is less than one unit, that is, (H) < 1, where (H) is the largest eigen value in
magnitude of H. Testing of this condition is beyond the scope of the syllabus.
If both the Gauss-Jacobi and Gauss-Seidel methods converge, then Gauss-Seidel method
converges at least two times faster than the Gauss-Jacobi method.
Example 1.22 Find the solution of the system of equations
45x
1
+ 2x
2
+ 3x
3
= 58
3x
1
+ 22x
2
+ 2x
3
= 47
5x
1
+ x
2
+ 20x
3
= 67
correct to three decimal places, using the Gauss-Seidel iteration method.
Solution The given system of equations is strongly diagonally dominant. Hence, we can expect
fast convergence. Gauss-Seidel method gives the iteration
x
1
(k+1)
=
1
45
(58 2x
2
(k)
3x
3
(k)
),
x
2
(k+1)
=
1
22
(47 + 3x
1
(k+1)
2x
3
(k)
),
x
3
(k+1)
=
1
20
(67 5x
1
(k+1)
x
2
(k+1)
).
Starting with x
1
(0)
= 0, x
2
(0)
= 0, x
3
(0)
= 0, we get the following results.
First iteration
x
1
(1)
=
1
45
(58 2x
2
(0)
3x
3
(0)
) =
1
45
(58) = 1.28889,
x
2
(1)
=
1
22
(47 + 3x
1
(1)
2x
3
(0)
) =
1
22
(47 + 3(1.28889) 2(0)) = 2.31212,
x
3
(1)
=
1
20
(67 5x
1
(1)
x
2
(1)
) =
1
20
(67 5(1.28889) (2.31212)) = 2.91217.
Second iteration
x
1
(2)
=
1
45
(58 2x
2
(1)
3x
3
(1)
) =
1
45
(58 2(2.31212) 3(2.91217)) = 0.99198,
x
2
(2)
=
1
22
(47 + 3x
1
(2)
2x
3
(1)
) =
1
22
(47 + 3(0.99198) 2(2.91217)) = 2.00689,
48 NUMERICAL METHODS
x
3
(2)
=
1
20
(67 5x
1
(2)
x
2
(2)
) =
1
20
(67 5(0.99198) (2.00689)) = 3.00166.
Third iteration
x
1
(3)
=
1
45
(58 2x
2
(2)
3x
3
(2)
) =
1
45
(58 2(2.00689) 3(3.00166) = 0.99958,
x
2
(3)
=
1
22
(47 + 3x
1
(3)
2x
3
(2)
) =
1
22
(47 + 3(0.99958) 2(3.00166)) = 1.99979,
x
3
(3)
=
1
20
(67 5x
1
(3)
x
2
(3)
) =
1
20
(67 5(0.99958) (1.99979)) = 3.00012.
Fourth iteration
x
1
(4)
=
1
45
(58 2x
2
(3)
3x
3
(3)
) =
1
45
(58 2(1.99979) 3(3.00012)) = 1.00000,
x
2
(4)
=
1
22
(47 + 3x
1
(4)
2x
3
(3)
) =
1
22
(47 + 3(1.00000) 2(3.00012)) = 1.99999,
x
3
(4)
=
1
20
(67 5x
1
(4)
x
2
(4)
) =
1
20
(67 5(1.00000) (1.99999)) = 3.00000.
We find x x
1
4
1
3 ( ) ( )
= 1.00000 0.99958 = 0.00042,
x x
2
4
2
3 ( ) ( )
= 1.99999 1.99979 = 0.00020,
x x
3
4
3
3 ( ) ( )
= 3.00000 3.00012 = 0.00012.
Since, all the errors in magnitude are less than 0.0005, the required solution is
x
1
= 1.0, x
2
= 1.99999, x
3
= 3.0.
Rounding to three decimal places, we get x
1
= 1.0, x
2
= 2.0, x
3
= 3.0.
Example 1.23 Computationally show that Gauss-Seidel method applied to the system of
equations
3x
1
6x
2
+ 2x
3
= 23
4x
1
+ x
2
x
3
= 8
x
1
3x
2
+ 7x
3
= 17
diverges. Take the initial approximations as x
1
= 0.9, x
2
= 3.1, x
3
= 0.9. Interchange the first
and second equations and solve the resulting system by the Gauss-Seidel method. Again take
the initial approximations as x
1
= 0.9, x
2
= 3.1, x
3
= 0.9, and obtain the result correct to two
decimal places. The exact solution is x
1
= 1.0, x
2
= 3.0, x
3
= 1.0.
Solution Note that the system of equations is not diagonally dominant. Gauss-Seidel method
gives the iteration
x
1
(k+1)
= [23 + 6x
2
(k)
2x
3
(k)
)]/3
x
2
(k+1)
= [ 8 + 4x
1
(k+1)
+ x
3
(k)
]
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 49
x
3
(k+1)
= [17 x
1
(k+1)
+ 3x
2
(k+1)
]/7.
Starting with the initial approximations x
1
= 0.9, x
2
= 3.1, x
3
= 0.9, we obtain the
following results.
First iteration
x
1
(1)
=
1
3
[23 + 6x
2
(0)
2x
3
(0)
] =
1
3
[23 + 6( 3.1) 2(0.9)] = 0.8667,
x
2
(1)
= [ 8 + 4x
1
(1)
+ x
3
(0)
] = [ 8 + 4(0.8667) + 0.9] = 3.6332,
x
3
(1)
=
1
7
[17 x
1
(1)
+ 3x
2
(1)
] =
1
7
[17 (0.8667) + 3( 3.6332)] = 0.7477.
Second iteration
x
1
(2)
=
1
3
[23 + 6x
2
(1)
2x
3
(1)
] =
1
3
[23 + 6 ( 3.6332) 2(0.7477)] = 0.0982,
x
2
(2)
= [ 8 + 4x
1
(2)
+ x
3
(1)
] = [ 8 + 4( 0.0982) + 0.7477] = 7.6451,
x
3
(2)
=
1
7
[17 x
1
(2)
+ 3x
2
(2)
] =
1
7
[17 + 0.0982 + 3( 7.6451)] = 0.8339.
Third iteration
x
1
(3)
=
1
3
[23 + 6x
2
(2)
2x
3
(2)
] =
1
3
[23 + 6 ( 7.6451) 2( 0.8339)] = 7.0676,
x
2
(3)
= [ 8 + 4x
1
(3)
+ x
3
(2)
] = [ 8 + 4( 7.0676) 0.8339] = 37.1043,
x
3
(3)
=
1
7
[17 x
1
(3)
+ 3x
2
(3)
] =
1
7
[17 + 7.0676 + 3( 37.1043)] = 12.4636.
It can be observed that the iterations are diverging very fast.
Now, we exchange the first and second equations to obtain the system
4x
1
+ x
2
x
3
= 8
3x
1
6x
2
+ 2x
3
= 23
x
1
3x
2
+ 7x
3
= 17.
The system of equations is now diagonally dominant. Gauss-Seidel method gives iteration
x
1
(k+1)
= [8 + x
2
(k)
x
3
(k)
]/4
x
2
(k+1)
= [23 3x
1
(k+1)
2x
3
(k)
]/6
x
3
(k+1)
= [17 x
1
(k+1)
+ 3x
2
(k+1)
]/7.
Starting with the initial approximations x
1
= 0.9, x
2
= 3.1, x
3
= 0.9, we obtain the
following results.
First iteration
x
1
(1)
=
1
4
[8 + x
2
(0)
x
3
(0)
] =
1
4
[8 3.1 0.9] = 1.0,
50 NUMERICAL METHODS
x
2
(1)
=
1
6
[23 3x
1
(1)
2x
3
(0)
] =
1
6
[23 3(1.0) 2(0.9)] = 3.0333,
x
3
(1)
=
1
7
[17 x
1
(1)
+ 3x
2
(1)
] =
1
7
[17 1.0 + 3( 3.0333)] = 0.9857.
Second iteration
x
1
(2)
=
1
4
[8 + x
2
(1)
x
3
(1)
] =
1
4
[8 3.0333 0.9857] = 0.9953,
x
2
(2)
=
1
6
[23 3x
1
(2)
2x
3
(1)
] =
1
6
[23 3(0.9953) 2(0.9857)] = 3.0071,
x
3
(2)
=
1
7
[17 x
1
(2)
+ 3x
2
(2)
] =
1
7
[17 0.9953 + 3( 3.0071)] = 0.9976.
Third iteration
x
1
(3)
=
1
4
[8 + x
2
(2)
x
3
(2)
] =
1
4
[8 3.0071 0.9976] = 0.9988,
x
2
(3)
=
1
6
[23 3x
1
(3)
2x
3
(2)
] =
1
6
[23 3(0.9988) 2(0.9976)] = 3.0014,
x
3
(3)
=
1
7
[17 x
1
(3)
+ 3x
2
(3)
] =
1
7
[17 0.9988 + 3( 3.0014)] = 0.9996.
Fourth iteration
x
1
(4)
=
1
4
[8 + x
2
(3)
x
3
(3)
] =
1
4
[8 3.0014 0.9996] = 0.9998,
x
2
(4)
=
1
6
[23 3x
1
(4)
2x
3
(3)
] =
1
6
[23 3(0.9998) 2(0.9996)] = 3.0002,
x
3
(4)
=
1
7
[17 x
1
(4)
+ 3x
2
(4)
] =
1
7
[17 0.9998 + 3( 3.0002)] = 0.9999.
We find x x
1
4
1
3 ( ) ( )
= 0.9998 0.9988 = 0.0010,
x x
2
4
2
3 ( ) ( )
= 3.0002 + 3.0014 = 0.0012,
x x
3
4
3
3 ( ) ( )
= 0.9999 0.9996 = 0.0003.
Since, all the errors in magnitude are less than 0.005, the required solution is
x
1
= 0.9998, x
2
= 3.0002, x
3
= 0.9999.
Rounding to two decimal places, we get x
1
= 1.0, x
2
= 3.0, x
3
= 1.0.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 51
REVIEW QUESTIONS
1. Define an iterative procedure for solving a system of algebraic equations Ax = b. What
do we mean by convergence of an iterative procedure?
Solution A general linear iterative method for the solution of the system of equations
Ax = b can be written in matrix form as
x
(k+1)
= Hx
(k)
+ c, k = 0, 1, 2, ...
where x
(k+1)
and x
(k)
are the approximations for x at the (k + 1)th and kth iterations
respectively. H is called the iteration matrix depending on A and c, which is a column
vector depends on A and b. We start with an initial approximation to the solution vec-
tor x = x
0
, and obtain a sequence of approximate vectors x
0
, x
1
,..., x
k
, ... We say that the
iteration converges if in the limit as k , the sequence of approximate vectors x
0
,
x
1
,..., x
k
,... converge to the exact solution vector x = A
1
b.
2. How do we terminate an iterative procedure for the solution of a system of algebraic
equations Ax = b ?
Solution We terminate an iteration procedure when the magnitudes of the differences
between the two successive iterates of all the variables are smaller than a given accu-
racy or an error bound , that is,
x x
i
k
i
k ( ) ( ) +
1
, for all i.
For example, if we require two decimal places of accuracy, then we iterate until
x x
i
k
i
k ( ) ( ) +
1
< 0.005, for all i. If we require three decimal places of accuracy, then we
iterate until x x
i
k
i
k ( ) ( ) +
1
< 0.0005, for all i.
3. What is the condition of convergence of an iterative procedure for the solution of a
system of linear algebraic equations Ax = b ?
Solution A sufficient condition for convergence of an iterative method is that the sys-
tem of equations is diagonally dominant, that is, the coefficient matrix A is diagonally
dominant. We can verify that | a
ii
|
=
j i j
n
ij
a
1,
| |. This implies that convergence may be
obtained even if the system is not diagonally dominant. If the system is not diagonally
dominant, we may exchange the equations, if possible, such that the new system is
diagonally dominant and convergence is guaranteed. The necessary and sufficient con-
dition for convergence is that the spectral radius of the iteration matrix H is less than
one unit, that is, (H) < 1, where (H) is the largest eigen value in magnitude of H.
4. Which method, Gauss-Jacobi method or Gauss-Seidel method converges faster, for the
solution of a system of algebraic equations Ax = b ?
Solution If both the Gauss-Jacobi and Gauss-Seidel methods converge, then Gauss-
Seidel method converges at least two times faster than the Gauss-Jacobi method.
52 NUMERICAL METHODS
EXERCISE 1.3
Solve the following system of equations using the Gauss-Jacobi iteration method.
1. 20x + y 2z = 17, 2. 27x + 6y z = 85,
3x + 20y z = 18, x + y + 54z = 110,
2x 3y + 20z = 25. (A.U. Nov/Dec 2006) 6x + 15y + 2z = 72. (A.U. May/June 2006)
3. x + 20y + z = 18, 4. 10x + 4y 2z = 20,
25x + y 5z = 19, 3x + 12y z = 28,
3x + 4y + 8z = 7. x + 4y + 7z = 2.
Solve the following system of equations using the Gauss-Seidel iteration method.
5. 27x + 6y z = 85, 6. 4x + 2y + z = 14,
x + y + 54z = 110, x + 5y z = 10,
6x + 15y + 2z = 72. x + y + 8z = 20.
(A.U. May/June 2006) (A.U. Apr/May 2005)
7. x + 3y + 52z = 173.61,
x 27y + 2z = 71.31,
41x 2y + 3z = 65.46. Start with x = 1, y = 1, z = 3. (A.U. Apr/May 2004)
8. 20x y 2z = 17,
3x + 20y z = 18,
2x 3y + 20z = 25. (A.U. Nov/Dec 2003)
9. x + 20y + z = 18, 10. 10x + 4y 2z = 20,
25x + y 5z = 19, 3x + 12y z = 28,
3x + 4y + 8z = 7. x + 4y + 7z = 2.
1.3 EGEN VALUE PROBLEM8
1.3.1 Introduction
The concept of eigen values and finding eigen values and eigen vectors of a given matrix are
very important for engineers and scientists.
Consider the eigen value problem
Ax = x. (1.49)
The eigen values of a matrix A are given by the roots of the characteristic equation
A I = 0. (1.50)
If the matrix A is of order n, then expanding the determinant, we obtain the character-
istic equation as
p() = ( 1)
n
n
+ a
1
n1
+ ... + a
n1
+ a
n
= 0. (1.51)
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 53
For any given matrix we write the characteristic equation (1.50), expand it and find the
roots
1
,
2
,...,
n
, which are the eigen values. The roots may be real, repeated or complex. Let
x
i
be the solution of the system of the homogeneous equations (1.49), corresponding to the
eigen value
i
. These vectors x
i
, i = 1, 2, , n are called the eigen vectors of the system.
There are several methods for finding the eigen values of a general matrix or a symmet-
ric matrix. In the syllabus, only the power method for finding the largest eigen value in mag-
nitude of a matrix and the corresponding eigen vector, is included.
1.3.2 Power Method
The method for finding the largest eigen value in magnitude and the corresponding eigen
vector of the eigen value problem Ax = x, is called the power method.
What is the importance of this method? Let us re-look at the Remarks 20 and 23. The
necessary and sufficient condition for convergence of the Gauss-Jacobi and Gauss-Seidel
iteration methods is that the spectral radius of the iteration matrix H is less than one unit,
that is, (H) < 1, where (H) is the largest eigen value in magnitude of H. If we write the
matrix formulations of the methods, then we know H. We can now find the largest eigen value
in magnitude of H, which determines whether the methods converge or not.
We assume that
1
,
2
,...,
n
are distinct eigen values such that
1
| >
2
> ... >
n
. (1.52)
Let v
1
, v
2
,..., v
n
be the eigen vectors corresponding to the eigen values
1
,
2
,...,
n
,
respectively. The method is applicable if a complete system of n linearly independent eigen
vectors exist, even though some of the eigen values
2
,
3
,...,
n
, may not be distinct. The n
linearly independent eigen vectors form an n-dimensional vector space. Any vector v in this
space of eigen vectors v
1
, v
2
,..., v
n
can be written as a linear combination of these vectors. That
is,
v = c
1
v
1
+ c
2
v
2
+ ... + c
n
v
n
. (1.53)
Premultiplying by A and substituting Av
1
=
1
v
1
, Av
2
=
2
v
2
,..., Av
n
=
n
v
n
, we get
Av = c
1
1
v
1
+ c
2
2
v
2
+ ... + c
n
n
v
n
=
1
c c c
n
n
n 1 1 2
2
1
2
1
v v v +
+ +
... .
Premultiplying repeatedly by A and simplifying, we get
A
2
v =
1
2
1 1 2
2
1
2
2
1
2
c c c
n
n
n
v v v +
+ +
...
... ... ... ...
A
k
v =
1 1 1 2
2
1
2
1
k
k
n
n
k
n
c c c v v v +
+ +
... . (1.54)
54 NUMERICAL METHODS
A
k+1
v =
1
1
1 1 2
2
1
1
2
1
1
k
k
n
n
k
n
c c c
+
+ +
+
+ +
v v v ... . (1.55)
As k , the right hand sides of (1.54) and (1.55) tend to
1
k
c
1
v
1
and
1
1 k+
c
1
v
1
, since
i
/
1
< 1, i = 2, 3, , n. Both the right hand side vectors in (1.54), (1.55)
[c
1
v
1
+ c
2
(
2
/
1
)
k
v
2
+ ... + c
n
(
n
/
1
)
k
v
n
],
and [c
1
v
1
+ c
2
(
2
/
1
)
k+1
v
2
+ ... + c
n
(
n
/
1
)
k+1
v
n
]
tend to c
1
v
1
, which is the eigen vector corresponding to
1
. The eigen value
1
is obtained as
the ratio of the corresponding components of A
k+1
v and A
k
v. That is,
1
=
lim
( )
( )
k
k
r
k
r
+
A v
A v
1
, r = 1, 2, 3, ..., n (1.56)
where the suffix r denotes the rth component of the vector. Therefore, we obtain n ratios, all of
them tending to the same value, which is the largest eigen value in magnitude,
1
.
When do we stop the iteration The iterations are stopped when all the magnitudes of the
differences of the ratios are less than the given error tolerance.
Remark 24 The choice of the initial approximation vector v
0
is important. If no suitable
approximation is available, we can choose v
0
with all its components as one unit, that is,
v
0
= [1, 1, 1,..., 1]
T
. However, this initial approximation to the vector should be non-orthogonal
to v
1
.
Remark 25 Faster convergence is obtained when
2
<<
1
.
As k , premultiplication each time by A, may introduce round-off errors. In order to
keep the round-off errors under control, we normalize the vector before premultiplying by A.
The normalization that we use is to make the largest element in magnitude as unity. If we use
this normalization, a simple algorithm for the power method can be written as follows.
y
k+1
= Av
k
, (1.57)
v
k+1
= y
k+1
/m
k+1
(1.58)
where m
k+1
is the largest element in magnitude of y
k+1
. Now, the largest element in magni-
tude of v
k+1
is one unit. Then (1.56) can be written as
1
= lim
( )
( ) k
k r
k r
+
y
v
1
, r = 1, 2, 3, ...., n (1.59)
and v
k+1
is the required eigen vector.
Remark 26 It may be noted that as k , m
k+1
also gives
1
.
Remark 27 Power method gives the largest eigen value in magnitude. If the sign of the eigen
value is required, then we substitute this value in the determinant A
1
I and find its
value. If this value is approximately zero, then the eigen value is of positive sign. Otherwise,
it is of negative sign.
Example 1.24 Determine the dominant eigen value of A =
1 2
3 4
by power method.
(A.U. Nov/Dec 2004)
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 55
Solution Let the initial approximation to the eigen vector be v
0
. Then, the power method is
given by
y
k+1
= Av
k
,
v
k+1
= y
k+1
/m
k+1
where m
k+1
is the largest element in magnitude of y
k+1
. The dominant eigen value in magni-
tude is given by
1
= lim
( )
( ) k
k r
k r
+
y
v
1
, r = 1, 2, 3, ..., n
and v
k+1
is the required eigen vector.
Let v
0
= [1 1]
T
. We have the following results.
y
1
= Av
0
=
1 2
3 4
1
1
3
7
, m
1
= 7, v
1
=
y
1
1
1
7
3
7
0 42857
1
m
=
.
.
y
2
= Av
1
=
1 2
3 4
0 42857
1
2 42857
5 28571
. .
.
, m
2
= 5.28571,
v
2
=
y
2
2
1
5 28571
242857
528571
0 45946
1
m
=
.
.
.
.
.
y
3
= Av
2
=
1 2
3 4
0 45946
1
2 45946
537838
. .
.
, m
3
= 5.37838,
v
3
=
y
3
3
1
537838
2 45946
537838
0 45729
1
m
=
.
.
.
.
.
y
4
= Av
3
=
1 2
3 4
0 45729
1
2 45729
537187
. .
.
, m
4
= 5.37187,
v
4
=
y
4
4
1
537187
2 45729
537187
0 45744
1
m
=
.
.
.
.
y
5
= Av
4
=
1 2
3 4
0 45744
1
2 45744
537232
. .
.
, m
4
= 5.37232,
v
5
=
y
5
5
1
537232
2 45744
537232
0 45743
1
m
=
.
.
.
.
.
y
6
= Av
5
=
1 2
3 4
0 45743
1
245743
537229
. .
.
.
Now, we find the ratios
1
= lim
( )
( ) k
k r
k r
+
y
v
1
r = 1, 2.
56 NUMERICAL METHODS
We obtain the ratios as
245743
045743
.
.
= 5.37225, 5.37229.
The magnitude of the error between the ratios is | 5.37225 5.37229 | = 0.00004
< 0.00005. Hence, the dominant eigen value, correct to four decimal places is 5.3722.
Example 1.25 Determine the numerically largest eigen value and the corresponding eigen
vector of the following matrix, using the power method.
25 1 2
1 3 0
2 0 4
3
2
2
(A.U. May/June 2006)
Solution Let the initial approximation to the eigen vector be v
0
. Then, the power method is
given by
y
k+1
= Av
k
,
v
k+1
= y
k+1
/ m
k+1
where m
k+1
is the largest element in magnitude of y
k+1
. The dominant eigen value in magni-
tude is given by
1
= lim
( )
( ) k
k r
k r
+
y
v
1
, r = 1, 2, 3, , n
and v
k+1
is the required eigen vector.
Let the initial approximation to the eigen vector be v
0
= [1, 1, 1]
T
. We have the following
results.
y
1
= Av
0
=
25 1 2
1 3 0
2 0 4
1
1
1
28
4
2
3
2
2
3
2
2
=
3
2
2
, m
1
= 28,
v
1
=
1
1
m
y
1
=
1
28
28
4
2
1
0.14286
0.07143
3
2
2
=
3
2
2
.
y
2
= Av
1
=
25 1 2
1 3 0
2 0 4
1
0.14286
0.07143
25.0000
1.42858
2.28572
3
2
2
3
2
2
=
3
2
2
, m
2
= 25.0,
v
2
=
1
2
m
y
2
=
1
25.0
25.00000
1.14286
2.28572
1
0.05714
0.09143
3
2
2
=
3
2
2
,
y
3
= Av
2
=
25 1 2
1 3 0
2 0 4
1
0.05714
0.09143
25.24000
1.17142
1.63428
3
2
2
3
2
2
=
3
2
2
, m
3
= 25.24,
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 57
v
3
=
1
3
m
y
3
=
1
25.24
25.24000
1.17142
1.63428
1
0.04641
0.06475
3
2
2
=
3
2
2
,
y
4
= Av
3
=
25 1 2
1 3 0
2 0 4
1
0.04641
0.06475
25.17591
1.13923
1.74100
3
2
2
3
2
2
=
3
2
2
, m
4
= 25.17591,
v
4
=
1
4
m
y
4
=
1
25.17591
25.17591
1.13923
1.74100
1
0.04525
0.06915
3
2
2
=
3
2
2
,
y
5
= Av
4
=
25 1 2
1 3 0
2 0 4
3
2
2
3
2
2
=
3
2
2
1
0.04525
0.06915
25.18355
1.13575
1.72340
, m
5
= 25.18355,
v
5
=
1
5
m
y
5
=
1
25.18355
25.18355
1.13575
1.72340
1
0.04510
0.06843
3
2
2
=
3
2
2
,
y
6
= Av
5
=
25 1 2
1 3 0
2 0 4
1
0.04510
0.06843
25.18196
1.13530
1.72628
3
2
2
3
2
2
=
3
2
2
, m
6
= 25.18196,
v
6
=
1
6
m
y
6
=
1
25.18196
25.18196
1.13530
1.72628
1
0.04508
0.06855
3
2
2
=
3
2
2
,
y
7
= Av
6
=
25 1 2
1 3 0
2 0 4
1
0.04508
0.06855
25.18218
1.13524
1.72580
3
2
2
3
2
2
=
3
2
2
, m
7
= 25.18218,
v
7
=
1
7
m
y
7
=
1
25.18218
25.18218
1.13524
1.72580
1
0.04508
0.06853
3
2
2
=
3
2
2
,
y
8
= Av
7
=
25 1 2
1 3 0
2 0 4
1
0.04508
0.06853
25.18214
1.13524
1.72588
3
2
2
3
2
2
=
3
2
2
, m
8
= 25.18214.
Now, we find the ratios
1
= lim
( )
( ) k
k r
k r
+
y
v
1
, r = 1, 2, 3.
58 NUMERICAL METHODS
We obtain the ratios as
25.18214,
1.13524
0.04508
= 25.18279,
1.72588
0.06853
= 25.18430.
The magnitudes of the errors of the differences of these ratios are 0.00065, 0.00216,
0.00151, which are less than 0.005. Hence, the results are correct to two decimal places. There-
fore, the largest eigen value in magnitude is |
1
| = 25.18.
The corresponding eigen vector is v
8
,
v
8
=
1
8
m
y
8
=
1
25.18214
25.18214
1.13524
1.72588
1
0.04508
0.06854
3
2
2
=
3
2
2
.
In Remark 26, we have noted that as k , m
k+1
also gives |
1
|. We find that this
statement is true since | m
8
m
7
| = | 25.18214 25.18220 | = 0.00006.
If we require the sign of the eigen value, we substitute
1
in the characteristic equation.
In the present problem, we find that | A 25.18 I | = 1.4018, while | A + 25.18 I | is very
large. Therefore, the required eigen value is 25.18.
REVIEW QUESTIONS
1. When do we use the power method?
Solution We use the power method to find the largest eigen value in magnitude and
the corresponding eigen vector of a matrix A.
2. Describe the power method.
Solution Power method can be written as follows.
y
k+1
= Av
k
,
v
k+1
= y
k+1
/m
k+1
where m
k+1
is the largest element in magnitude of y
k+1
. Now, the largest element in
magnitude of v
k+1
is one unit. The largest eigen value in magnitude is given by
1
= lim
( )
( ) k
k r
k r
+
y
v
1
, r = 1, 2, 3, , n
and v
k+1
is the required eigen vector. All the ratios in the above equation tend to the
same number.
3. When do we stop the iterations in power method?
Solution Power method can be written as follows.
y
k+1
= Av
k
,
v
k+1
= y
k+1
/ m
k+1
where
1 + k
m is the largest element in magnitude of y
k+1
. Now, the largest element in
magnitude of v
k+1
is one unit. The largest eigen value is given by
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 59
1
= lim
( )
( ) k
k r
k r
+
y
v
1
, r = 1, 2, 3, , n
and v
k+1
is the required eigen vector. All the ratios in the above equation tend to the
same number. The iterations are stopped when all the magnitudes of the differences of
the ratios are less than the given error tolerance.
4. When can we expect faster convergence in power method?
Solution To apply power method, we assume |
1
| > |
2
| > ... > |
n
|. Faster
convergence is obtained when |
2
| << |
1
|. That is, the leading eigen value in
magnitude is much larger than the remaining eigen values in magnitudes.
5. Does the power method give the sign of the largest eigen value?
Solution No. Power method gives the largest eigen value in magnitude. If the sign of
the eigen value is required, then we substitute this value in the characteristic determi-
nant | A
1
I | and determine the sign of the eigen value. If | A
1
I | = 0 is satisfied
approximately, then it is of positive sign. Otherwise, it is of negative sign.
EXERCISE 1.4
Determine the largest eigen value in magnitude and the corresponding eigen vector of
the following matrices by power method. Use suitable initial approximation to the eigen
vector.
1.
1 3 1
3 2 4
1 4 10
3
2
2
. (A.U. Nov/Dec 2003) 2.
1 3 2
4 4 1
6 3 5
3
2
2
(A.U. Apr/May 2005)
3.
35 2 1
2 3 0
1 0 1
3
2
2
. 4.
20 1 1
1 3 0
1 0 1
3
2
2
. 5.
6 1 0
1 40 1
0 1 6
3
2
2
.
6.
15 2 1
0 3 2
0 0 1
3
2
2
. 7.
3 1 5
1 0 2
5 2 1
3
2
2
. 8.
65 0 1
0 5 0
1 0 2
3
2
2
.
1.4 AN8WER8 AND HNT8
Exercise 1.1
1. (2, 3); x
0
= 2, x
1
= 3, x
2
= 2.058824, x
3
= 2.081264, x
4
= 2.089639, x
5
= 2.092740.
2. (2, 3); x
0
= 2, x
1
= 3, x
2
= 2.721014, x
3
= 2.740205, x
4
= 2.740637, | x
4
x
3
| = 0.000432.
Root correct up to 4 decimal places is x
4
.
3. x
0
= 2.5, x
1
= 3, x
2
= 2.801252, x
3
= 2.798493, x
4
= 2.798390, | x
4
x
3
| = 0.000103. Root
correct up to 3 decimal places is x
4
.
60 NUMERICAL METHODS
4. (1, 2); x
0
= 1, x
1
= 2, x
2
= 1.023360, x
3
= 1.035841, x
4
= 1.042470, x
5
= 1.045980, | x
5
x
4
|
= 0.00351. Root correct up to 2 decimal places is x
5
.
5. (0, 1); x
0
= 0, x
1
= 1, x
2
= 0.612700, x
3
= 0.572182, x
4
= 0.567703, x
5
= 0.567206, |x
5
x
4
| = 0.000497. Root correct up to 3 decimal places is x
5
.
6. (1, 2); x
0
= 1, x
1
= 2, x
2
= 1.636364, x
3
= 1.828197, x
4
= 1.852441, x
5
= 1.855228, x
6
= 1.855544, | x
6
x
5
| = 0.000316. Root correct up to 3 decimal places is x
6
.
7. (1, 2); x
0
= 2, x
1
= 1.870968, x
2
= 1.855781, x
3
= 1.855585, | x
3
x
2
| = 0.000196. Root
correct up to 3 decimal places is x
3
.
8. (0, 1); x
0
= 1, x
1
= 0.666667, x
2
= 0.730159, x
3
= 0.732049, | x
3
x
2
| = 0.00189. Root
correct up to 2 decimal places is x
3
.
9. (0, 1); x
0
= 1, x
1
= 0.620016, x
2
= 0.607121, x
3
= 0.607102, | x
3
x
2
| = 0.000019. Root
correct up to 4 decimal places is x
3
.
10. (2, 3); x
0
= 3, x
1
= 2.746149, x
2
= 2.740649, x
3
= 2.740646, | x
3
x
2
| = 0.000003. Root
correct up to 3 decimal places is x
3
.
11. x
0
= 1.9, x
1
= 1.895506, x
2
= 1.895494, | x
2
x
1
| = 0.000012. Root correct up to 3 decimal
places is x
2
.
12. (i) x
k +1
=
x N
x
k
k
2
2
+
, k = 0, 1, ....
(ii) N = 142; x
0
= 12, x
1
= 11.916667, x
2
= 11.916375, | x
2
x
1
| = 0.000292. Root correct
up to 3 decimal places is x
2
.
13. (i) x
k+1
= 2x
k
Nx
k
2
, k = 0, 1, ...
(ii) N = 26; x
0
= 0.04, x
1
= 0.0384, x
2
= 0.038461, x
3
= 0.038462, | x
3
x
2
| = 0.000001. The
required root is x
3
.
14. x
0
= 1.5, x
1
= 1.293764, x
2
= 1.250869, x
3
= 1.249055, x
4
= 1.249052, | x
4
x
3
|
= 0.000003. Root correct up to 3 decimal places is x
4
.
15. (0, 1); x
0
= 1, x
1
= 1.051819, x
2
= 1.049912, x
3
= 1.049909, | x
3
x
2
| = 0.000003. Root
correct up to 3 decimal places is x
3
.
16. (0, 1); x
k+1
= [(x
k
3
+ 1)/5] = (x
k
), k = 0,1,2,... x
0
= 0, x
1
= 0.2, x
2
= 0.2016,
x
3
= 0.201639, | x
3
x
2
| = 0.000039. Root correct up to 4 decimal places is x
3
.
17. (0, 1); x
k+1
= [(x
k
5
+ 30)/64] = (x
k
), k = 0, 1, 2,... x
0
= 0, x
1
= 0.46875, x
2
= 0.469104,
x
3
= 0.469105, | x
3
x
2
| = 0.000001. Root correct up to 4 decimal places is x
3
.
18. ( 1, 0); x
k+1
= [(x
k
1)/3]
1/3
= (x
k
), k = 0, 1, 2,... x
0
= 1, x
1
= 0.87358,
x
2
= 0.854772, x
3
= 0.851902, x
4
= 0.851463, x
5
= 0.851395, x
6
= 0.851385,
| x
6
x
5
| = 0.00001. Root correct up to 4 decimal places is x
6
.
19. (0, 1); x
0
= 0, x
1
= 1, x
2
= 0.367879, x
3
= 0.692201, x
4
= 0.500473,..., x
12
= 0.566415,
x
13
= 0.567557, | x
13
x
12
| = 0.001142. Root correct up to 2 decimal places is x
13
.
SOLUTION OF EQUATIONS AND EIGEN VALUE PROBLEMS 61
20. (0, 1); x
k+1
= [(1 + cos x
k
)/3] = (x
k
), k = 0, 1, 2,... x
0
= 0, x
1
= 0.666667,
x
2
= 0.595296, x
3
= 0.609328, x
4
= 0.606678, x
5
= 0.607182, x
6
= 0.607086,
| x
6
x
5
| = 0.000096. Root correct up to 3 decimal places is x
6
.
21. We have + = a, = b.
(i) (x) =
ax b
x
+
, (x) =
b
x x
2
=
2
. For convergence to , we have
| () | = | ()/
2
| < 1, or | | > | |.
(ii) (x) =
b
x a +
, (x) =
b
x a x ( ) ( ) +
=
2 2
. For convergence to , we have
| () | = | ()/
2
| < 1, or | | < | |.
Exercise 1.2
1. x = 1.70869, y = 1.80032, z = 1.04909. 2. x = 4.5, y = 2.5, z = 5.
3. x = 1, y = 5, z = 1. 4. x
1
= 1, x
2
= 1, x
3
= 1, x
4
= 1.
5. x = 1, y = 1, z = 1. 6. x = 1, y = 2, z = 3.
7. x = 1, y = 5, z = 1. 8. x = 1, y = 1/2, z = 1/2.
9.
1
2
6 5 1
24 17 3
10 7 1
3
2
2
. 10.
1
8
24 8 12
10 2 6
2 2 2
3
2
2
.
11.
1
56
12 4 6
1 5 3
5 3 1
3
2
2
. 12.
1
5
5 1 2
5 1 7
5 2 4
3
2
2
.
In Problems 13-16, Gauss elimination gives the following results.
13.
2 1 3
0 11 2 17 2
0 0 0
0
14
3
3
2
2
/ / ; rank (A) = 2; rank (A|b) = 3. The system is inconsistent.
14.
1 3 4
0 4 5
0 0 0
2
2
2
3
2
2
; rank (A) = 2; rank (A|b) = 3. The system is inconsistent.
15.
2 1 3
0 11 2 17 2
0 0 0
2
14
0
3
2
2
/ /
; rank (A) = 2; rank (A|b) = 2. The system is consistent and has
one parameter family of solutions.
16.
1 5 1
0 7 3
0 0 0
0
11
0
3
2
2
; rank (A) = 2; rank (A|b) = 2. The system is consistent and has one
parameter family of solutions.
62 NUMERICAL METHODS
Exercise 1.3
In all the Problems, values for four iterations have been given. Solutions are the transposes of
the given vectors.
1. [0, 0, 0], [0.85, 0.9, 1.25], [1.02, 0.965, 1.03], [1.00125, 1.0015, 1.00325],
[1.00040, 0.99990, 0.99965]. Exact: [1, 1, 1].
2. [0, 0, 0], [3.14815, 4.8, 2.03704], [2.15693, 3.26913, 1.88985], [2.49167, 3.68525, 1.93655],
[2.40093, 3.54513, 1.92265].
3. Exchange the first and second rows. [0, 0, 0], [0.76, 0.9, 0.875], [0.971, 0.98175,
1.04], [1.00727, 1.00055, 1.00175], [1.00037, 1.00045, 0.99755]. Exact: [1, 1, 1].
4. [0, 0, 0], [2.0, 2.33333, 0.28571], [1.12381, 1.85714, 1.33333], [0.99048, 1.94127,
0.93605], [1.03628, 2.00771, 0.96508]. Exact: [1, 2, 1].
5. [0, 0, 0], [3.14815, 3.54074, 1.91317], [2.43218, 3.57204, 1.92585], [2.42569, 3.57294,
1.92595], [2.42549, 3.57301, 1.92595].
6. [0, 0, 0], [3.5, 1.3, 1.9], [2.375, 1.905, 1.965], [2.05625, 1.98175, 1.99525], [2.01031,
1.99700, 1.99909]. Exact: [2, 2, 2].
7. Interchange first and third rows. [1, 1, 3], [1.32829, 2.36969, 3.44982], [1.22856,
2.34007, 3.45003], [1.22999, 2.34000, 3.45000], [1.23000, 2.34000, 3.45000].
8. [0, 0, 0], [0.85, 1.0275, 1.01088], [0.89971, 0.98441, 1.01237], [0.90202, 0.98468,
1.01210], [0.90200, 0.98469, 1.01210].
9. Interchange first and second rows. [0, 0, 0], [0.76, 0.938, 1.059], [1.00932, 1.00342,
0.99821], [0.99978, 0.99990, 1.00003], [1.0, 1.0, 1.0].
10. [0, 0, 0], [2.0, 1.83333, 1.04762], [1.05714, 1.98175, 0.99773], [1.00775, 1.99825,
1.00011], [1.00068, 1.99982, 0.99989]. Exact: [1, 2, 1].
Exercise 1.4
In all problems, we have taken v
(0)
= [1, 1, 1]. The results obtained after 8 iterations are given.
Solutions are the transposes of the given vectors.
1. | | = 11.66, v = [0.02496, 0.42180, 1.0]. 2. | | = 6.98, v = [0.29737, 0.06690, 1.0].
3. | | = 35.15, v = [1.0, 0.06220, 0.02766]. 4. | | = 20.11, v = [1.0, 0.05316, 0.04759].
5. | | = 40.06, v = [0.02936, 1.0, 0.02936]. 6. | | = 15, v = [1.0, 0.00002, 0.0].
7. | | = 6.92, v = [1.0, 0.35080, 0.72091]. 8. | | = 65.02, v = [1.0, 0.0, 0.01587].
2.1 NTRODUCTON
In this chapter, we discuss the problem of approximating a given function by polynomials.
There are two main uses of these approximating polynomials. The first use is to reconstruct
the function f(x) when it is not given explicitly and only values of f(x) and/ or its certain order
derivatives are given at a set of distinct points called nodes or tabular points. The second use
is to perform the required operations which were intended for f(x), like determination of roots,
differentiation and integration etc. can be carried out using the approximating polynomial
P(x). The approximating polynomial P(x) can be used to predict the value of f(x) at a non-
tabular point. The deviation of P(x) from f(x), that is f(x) P(x), is called the error of approxi-
mation.
Let f(x) be a continuous function defined on some interval [a, b], and be prescribed
at n + 1 distinct tabular points x
0
, x
1
,..., x
n
such that a = x
0
< x
1
< x
2
< ... < x
n
= b. The distinct
tabular points x
0
, x
1
,..., x
n
may be non-equispaced or equispaced, that is x
k+1
x
k
= h, k = 0, 1,
2,, n 1. The problem of polynomial approximation is to find a polynomial P
n
(x), of degree
n, which fits the given data exactly, that is,
P
n
(x
i
) = f(x
i
), i = 0, 1, 2,, n. (2.1)
The polynomial P
n
(x) is called the interpolating polynomial. The conditions given in
(2.1) are called the interpolating conditions.
Remark 1 Through two distinct points, we can construct a unique polynomial of degree 1
(straight line). Through three distinct points, we can construct a unique polynomial of degree
2 (parabola) or a unique polynomial of degree1 (straight line). That is, through three distinct
points, we can construct a unique polynomial of degree 2. In general, through n + 1 distinct
points, we can construct a unique polynomial of degree n. The interpolation polynomial
fitting a given data is unique. We may express it in various forms but are otherwise the same
polynomial. For example, f(x) = x
2
2x 1 can be written as
x
2
2x 1 = 2 + (x 1) + (x 1) (x 2).
63
. (2.3)
Since, l
i
(x) = 0 at x = x
0
, x
1
,..., x
i1
, x
i + 1
, ..., x
n
, we know that
(x x
0
), (x x
1
),..., (x x
i1
), (x x
i+1
),..., (x x
n
)
are factors of l
i
(x). The product of these factors is a polynomial of degree n. Therefore, we can
write
l
i
(x) = C(x x
0
) (x x
1
)...(x x
i1
) (x x
i+1
)...(x x
n
)
where C is a constant.
Now, since l
i
(x
i
) = 1, we get
l
i
(x
i
) = 1 = C(x
i
x
0
) (x
i
x
1
)...(x
i
x
i1
) (x
i
x
i+1
)...(x
i
x
n
).
INTERPOLATION AND APPROXIMATION 65
Hence, C =
1
0 1 1 1
( ) ( )...( ) ( )...( ) x x x x x x x x x x
i i i i i i i n
+
.
Therefore, l
i
(x) =
( ) ( )...( )( )...( )
( ) ( )...( ) ( )...( )
x x x x x x x x x x
x x x x x x x x x x
i i n
i i i i i i i n
+
+
0 1 1 1
0 1 1 1
(2.4)
Note that the denominator on the right hand side of l
i
(x) is obtained by setting x = x
i
in
the numerator.
The polynomial given in (2.2) where l
i
(x) are defined by (2.4) is called the Lagrange
interpolating polynomial and l
i
(x) are called the Lagrange fundamental polynomials.
We can write the Lagrange fundamental polynomials l
i
(x) in a simple notation.
Denote w(x) = (x x
0
) (x x
1
)...(x x
n
)
which is the product of all factors. Differentiating w(x) with respect to x and substituting x = x
i
we get
w(x
i
) = (x
i
x
0
) (x
i
x
1
)...(x
i
x
i1
) (x
i
x
i+1
)...(x
i
x
n
)
since all other terms vanish. Therefore, we can also write l
i
(x) as
l
i
(x) =
w x
x x w x
i i
( )
( ) ( )
. (2.5)
Let us derive the linear and quadratic interpolating polynomials.
Linear interpolation
For n = 1, we have the data
x x
0
x
1
f(x) f(x
0
) f(x
1
)
The Lagrange fundamental polynomials are given by
l
0
(x) =
( )
( )
x x
x x
1
0 1
, l
1
(x) =
( )
( )
x x
x x
0
1 0
. (2.6)
The Lagrange linear interpolation polynomial is given by
P
1
(x) = l
0
(x) f(x
0
) + l
1
(x) f(x
1
). (2.7)
Quadratic interpolation
For n = 2, we have the data
x x
0
x
1
x
2
f(x) f(x
0
) f(x
1
) f(x
2
)
The Lagrange fundamental polynomials are given by
l
0
(x) =
( ) ( )
( ) ( )
x x x x
x x x x
1 2
0 1 0 2
, l
1
(x) =
( ) ( )
( ) ( )
x x x x
x x x x
0 2
1 0 1 2
, l
2
(x) =
( ) ( )
( ) ( )
x x x x
x x x x
0 1
2 0 2 1
.
66 NUMERICAL METHODS
The Lagrange quadratic interpolation polynomial is given by
P
1
(x) = l
0
(x) f(x
0
) + l
1
(x) f(x
1
) + l
2
(x) f(x
2
). (2.8)
Error of interpolation
We assume that f(x) has continuous derivatives of order up to n + 1 for all x (a, b).
Since, f(x) is approximated by P
n
(x), the results contain errors. We define the error of interpo-
lation or truncation error as
E(f, x) = f(x) P
n
(x). (2.9)
Without giving the derivation, we write the expression for the error of interpolation as
E(f, x) = f(x) P
n
(x)
=
( ) ( )...( )
( ) !
x x x x x x
n
n
+
0 1
1
f
(n+1)
() =
w x
n
( )
( ) ! +1
f
(n+1)
() (2.10)
where min(x
0
, x
1
,..., x
n
, x) < < max(x
0
, x
1
,..., x
n
, x).
Since, is an unknown, it is difficult to find the value of the error. However, we can find
a bound of the error. The bound of the error is obtained as
| E(f, x) | =
1
1 ( ) ! n +
| (x x
0
) (x x
1
)...(x x
n
) | | f
(n+1)
() |
1
1
0 1
1
( ) !
max ( ) ( ) ...( ) max ( )
( )
n
x x x x x x f x
a x b
n
a x b
n
+
| |
| |
+
(2.11)
Note that in (2.11), we compute the maximum absolute value of
w(x) = (x x
0
)(x x
1
)...(x x
n
), that is max | w(x) | and not the maximum of w(x).
Since the interpolating polynomial is unique, the error of interpolation is also unique,
that is, the error is same whichever form of the polynomial is used.
Example 2.1 Using the data sin(0.1) = 0.09983 and sin (0.2) = 0.19867, find an approximate
value of sin (0.15) by Lagrange interpolation. Obtain a bound on the error at x = 0.15.
Solution We have two data values. The Lagrange linear polynomial is given by
P
1
(x) =
( )
( )
x x
x x
1
0 1
f(x
0
) +
( )
( )
x x
x x
0
1 0
f(x
1
)
=
( . )
( . )
x
02
0 02 .1
(0.09983) +
( )
)
x
0
02 0
.1
( . .1
(0.19867).
Hence, f(0.15) = P
1
(0.15) =
( . )
( . )
0 0 2
0 0 2
.15
.1
(0.09983) +
( )
( . )
0 0
0 2 0
.15 .1
.1
(0.19867)
= (0.5) (0.09983) + (0.5) (0.19867) = 0.14925.
INTERPOLATION AND APPROXIMATION 67
The truncation error is given by
T.E =
( ) ( ) x x x x
0 1
2
f () =
( ) ( . ) x x 0 02
2
.1
( sin ), 0.1 < < 0.2.
since f(x) = sin x. At x = 0.15, we obtain the bound as
T.E =
( ) ( . ) 0 0 0 2
2
.15 0.1 .15
( sin ) = 0.00125 sin
and | T.E | = 0.00125 | sin | 0.00125 max
. . 0 1 0 2 x
| sin x |
= 0.00125 sin (0.2) = 0.00125(0.19867) = 0.00025.
Example 2.2 Use Lagranges formula, to find the quadratic polynomial that takes the values
x 0 1 3
y 0 1 0 (A.U Nov/Dec. 2005)
Solution Since f
0
= 0 and f
2
= 0, we need to compute l
1
(x) only. We have
l
1
(x) =
( ) ( )
( ) ( )
( )
( ) ( )
x x x x
x x x x
x x
=
=
0 2
1 0 1 2
3
1 2
1
2
(3x x
2
).
The Lagrange quadratic polynomial is given by
f(x) = l
1
(x) f(x
1
) =
1
2
(3x x
2
) (1) =
1
2
(3x x
2
).
Example 2.3 Given that f(0) = 1, f(1) = 3, f(3) = 55, find the unique polynomial of degree 2 or
less, which fits the given data.
Solution We have x
0
= 0, f
0
= 1, x
1
= 1, f
1
= 3, x
2
= 3, f
2
= 55. The Lagrange fundamental
polynomials are given by
l
0
(x) =
( ) ( )
( ) ( )
( ) ( )
( ) ( )
x x x x
x x x x
x x
=
=
1 2
0 1 0 2
1 3
1 3
1
3
(x
2
4x + 3).
l
1
(x) =
( ) ( )
( ) ( )
( )
( ) ( )
x x x x
x x x x
x x
=
=
0 2
1 0 1 2
3
1 2
1
2
(3x x
2
).
l
2
(x) =
( ) ( )
( ) ( )
( )
( ) ( )
x x x x
x x x x
x x
=
=
0 1
2 0 2 1
1
3 2
1
6
(x
2
x).
Hence, the Lagrange quadratic polynomial is given by
P
2
(x) = l
0
(x) f(x
0
) + l
1
(x) f(x
1
) + l
2
(x) f(x
2
)
=
1
3
(x
2
4x + 3) +
1
2
(3x x
2
) (3) +
55
6
(x
2
x) = 8x
2
6x + 1.
68 NUMERICAL METHODS
Example 2.4 The following values of the function f(x) = sin x + cos x, are given
x 10 20 30
f(x) 1.1585 1.2817 1.3660
Construct the quadratic Lagrange interpolating polynomial that fits the data. Hence, find
f (/12). Compare with the exact value.
Solution Since the value of f at /12 radians is required, we convert the data into radian
measure. We have
x
0
= 10 =
18
= 0.1745, x
1
= 20 =
9
= 0.3491, x
2
= 30 =
6
= 0.5236.
The Lagrange fundamental polynomials are given by
l
0
(x) =
( ) ( )
( ) ( )
( . ) ( . )
( . ) ( . )
x x x x
x x x x
x x
=
1 2
0 1 0 2
03491 05236
01746 03491
= 16.4061 (x
2
0.8727x + 0.1828).
l
1
(x) =
( ) ( )
( ) ( )
( ) ( . )
( ) ( )
x x x x
x x x x
x x
=
0 2
1 0 1 2
0 05236
0 0
.1745
.1746 .1745
= 32.8216(x
2
0.6981x + 0.0914).
l
2
(x) =
( ) ( )
( ) ( )
( ) ( . )
( ) ( )
x x x x
x x x x
x x
=
0 1
2 0 2 1
0 03491
03491 0
.1745
. .1745
= 16.4155(x
2
0.5236x + 0.0609).
The Lagrange quadratic polynomial is given by
P
2
(x) = l
0
(x) f(x
0
) + l
1
(x) f(x
1
) + l
2
(x) f(x
2
)
= 16.4061(x
2
0.8727x + 0.1828) (1.1585) 32.8616 (x
2
0.6981x
+ 0.0914) (1.2817) + 16.4155(x
2
0.5236x + 0.0609) (1.3660)
= 0.6374x
2
+ 1.0394x + 0.9950.
f(/12) = f(0.2618) = 1.2234.
The exact value is f(0.2618) = sin(0.2618) + cos(0.2618) = 1.2247.
Example 2.5 Construct the Lagrange interpolation polynomial for the data
x 1 1 4 7
f (x) 2 0 63 342
Hence, interpolate at x = 5.
Solution The Lagrange fundamental polynomials are given by
l
0
(x) =
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
x x x x x x
x x x x x x
x x x
=
1 2 3
0 1 0 2 0 3
1 4 7
1 1 1 4 1 7
INTERPOLATION AND APPROXIMATION 69
=
1
80
(x
3
12x
2
+ 39x 28).
l
1
(x) =
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
x x x x x x
x x x x x x
x x x
=
+
+
0 2 3
1 0 1 2 1 3
1 4 7
1 1 1 4 1 7
=
1
36
(x
3
10x
2
+ 17x + 28).
l
2
(x) =
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
x x x x x x
x x x x x x
x x x
=
+
+
0 1 3
2 0 2 1 2 3
1 1 7
4 1 4 1 4 7
=
1
45
(x
3
7x
2
x + 7).
l
3
(x) =
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
x x x x x x
x x x x x x
x x x
=
+
+
0 1 2
3 0 3 1 3 2
1 1 4
7 1 7 1 7 4
=
1
144
(x
3
4x
2
x + 4).
Note that we need not compute l
1
(x) since f(x
1
) = 0.
The Lagrange interpolation polynomial is given by
P
3
(x) = l
0
(x) f(x
0
) + l
1
(x) f(x
1
) + l
2
(x) f(x
2
) + l
3
(x) f(x
3
)
=
1
80
(x
3
12x
2
+ 39x 28) ( 2)
1
45
(x
3
7x
2
x + 7) (63)
+
1
144
(x
3
4x
2
x + 4) (342)
=
1
40
7
5
171
72
+
x
3
+
+
3
10
49
5
171
18
x
2
+
39
40
7
5
171
72
+
x +
+
7
10
49
5
171
8
= x
3
1.
Hence, f(5) = P
3
(5) = 5
3
1 = 124.
Remark 2 For a given data, it is possible to construct the Lagrange interpolation polynomial.
However, it is very difficult and time consuming to collect and simplify the coefficients of x
i
, i
= 0, 1, 2,, n. Now, assume that we have determined the Lagrange interpolation polynomial
of degree n based on the data values (x
i
, f(x
i
)), i = 0, 1, 2,, n at the (n + 1) distinct points.
Suppose that to this given data, a new value (x
n+1
, f(x
n+1
)) at the distinct point x
n+1
is added at
the end of the table. If we require the Lagrange interpolating polynomial for this new data,
then we need to compute all the Lagrange fundamental polynomials again. The nth degree
Lagrange polynomial obtained earlier is of no use. This is the disadvantage of the Lagrange
interpolation. However, Lagrange interpolation is a fundamental result and is used in prov-
ing many theoretical results of interpolation.
70 NUMERICAL METHODS
Remark 3 Suppose that the data (x
i
, f(x
i
)), i = 0, 1, 2,, n, is given. Assume that a new value
(x
n+1
, f(x
n+1
)) at the distinct point x
n+1
is added at the end of the table. The data, (x
i
, f(x
i
)),
i = 0, 1, 2,, n + 1, represents a polynomial of degree
1
1
, i = 0, 1, 2,, n 1. (2.12)
Therefore, f [x
0
, x
1
] =
f x f x
x x
( ) ( )
1 0
1 0
, f[x
1
, x
2
] =
f x f x
x x
( ) ( )
2 1
2 1
etc.
Note that f [x
i
, x
i+1
] = f [x
i+1
, x
i
] =
f x
x x
f x
x x
i
i i
i
i i
( ) ( )
+
+
+ 1
1
1
.
We say that the divided differences are symmetrical about their arguments.
Second divided difference Consider any three consecutive data values (x
i
, f(x
i
)), (x
i+1
, f(x
i+1
)),
(x
i+2
, f(x
i+2
)). Then, we define the second divided difference as
f [x
i
x
i+1
, x
i+2
] =
f x x f x x
x x
i i i i
i i
[ , ] [ , ]
+ + +
+
1 2 1
2
i = 0, 1, 2,, n 2 (2.13)
Therefore, f [x
0
, x
1
, x
2
] =
f x x f x x
x x
[ , ] [ , ]
1 2 0 1
2 0
etc.
We can express the divided differences in terms of the ordinates. We have
f [x
0
, x
1
, x
2
] =
1
2 0
2 1
2 0
1 0
1 0
x x
f f
x x
f f
x x
=
f
x x x x
f
x x x x x x
f
x x x x
0
0 1 0 2
1
2 0 2 1 1 0
2
2 0 2 1
1 1
( )( ) ( ) ( )( )
+
+
=
f
x x x x
f
x x x x
f
x x x x
0
0 1 0 2
1
1 0 1 2
2
2 0 2 1
( )( ) ( )( ) ( )( )
+
+
Notice that the denominators are same as the denominators of the Lagrange funda-
mental polynomials. In general, we have the second divided difference as
f [x
i
x
i+1
, x
i+2
] =
f x x f x x
x x
i i i i
i i
[ , ] [ , ]
+ + +
+
1 2 1
2
INTERPOLATION AND APPROXIMATION 71
=
f
x x x x
f
x x x x
f
x x x x
i
i i i i
i
i i i i
i
i i i i
( )( ) ( )( ) ( )( )
+
+
+ +
+
+ + +
+
+ + + 1 2
1
1 1 2
2
2 2 1
The nth divided difference using all the data values in the table, is defined as
f [x
0
,
x
1
, ..., x
n
] =
f x x x f x x x
x x
n n
n
[ , ,..., ] [ , ,...,
] 1 2 0 1 1
0
(2.14)
The nth divided difference can also be expressed in terms of the ordinates f
i
. The de-
nominators of the terms are same as the denominators of the Lagrange fundamental polyno-
mials.
The divided differences can be written in a tabular form as in Table 2.1.
Table 2.1. Divided differences (d.d).
x f(x) First d.d Second d.d Third d.d
x
0
f
0
f [x
0
, x
1
]
x
1
f
1
f [x
0
, x
1
, x
2
]
f [x
1
, x
2
] f [x
0
, x
1
, x
2
, x
3
]
x
2
f
2
f [x
1
, x
2
, x
3
]
f [x
2
, x
3
]
x
3
f
3
Example 2.6 Find the second divided difference of f(x) = 1/x, using the points a, b, c.
Solution We have
f[a, b] =
f b f a
b a b a b a
a b
b a ab ab
( ) ( )
( )
=
1 1 1 1
,
f [b, c] =
f c f b
c b c b c b
b c
c b bc bc
( ) ( )
( )
=
1 1 1 1
,
f [a, b, c] =
f b c f a b
c a c a bc ab
c a
c a abc abc
[ , ] [ , ]
( )
=
1 1 1 1
.
Example 2.7 Obtain the divided difference table for the data
x 1 0 2 3
) (x f 8 3 1 12 (A.U Nov/Dec 2006)
72 NUMERICAL METHODS
Solution We have the following divided difference table for the data.
Divided difference table. Example 2.7.
x f(x) First d.d Second d.d Third d.d
1 8
3 8
0 1
+
+
= 11
0 3
+
1 11
2 1
= 4
1 3
2 0
1
=
4 4
3 1
+
+
= 2
2 1
11 1
3 0
4
+
=
12 1
3 2
= 11
3 12
2.2.2 Newtons Divided Difference Interpolation
We mentioned earlier that the interpolating polynomial representing a given data values is
unique, but the polynomial can be represented in various forms.
We write the interpolating polynomial as
f(x) = P
n
(x)
= c
0
+ (x
x
0
) c
1
+ (x x
0
)(x x
1
) c
2
+ ... + (x x
0
)(x x
1
)...(x x
n1
) c
n
. (2.15)
The polynomial fits the data P
n
(x
i
) = f(x
i
) = f
i
.
Setting P
n
(x
0
) = f
0
, we obtain
P
n
(x
0
) = f
0
= c
0
since all the remaining terms vanish.
Setting P
n
(x
1
) = f
1
, we obtain
f
1
= c
0
+ (x
1
x
0
) c
1
, or c
1
=
f c
x x
f f
x x
1 0
1 0
1 0
1 0
= f [x
0
, x
1
].
Setting P
n
(x
2
) = f
2
, we obtain
f
2
= c
0
+ (x
2
x
0
) c
1
+ (x
2
x
0
)(x
2
x
1
) c
2
,
or c
2
=
f f x x f x x
x x x x
2 0 2 0 0 1
2 0 2 1
( ) [ , ]
( )( )
=
1
2 0 2 1
2 0 2 0
1 0
1 0
( )( )
( )
x x x x
f f x x
f f
x x
0 1
1
4. What is the disadvantage of Lagrange interpolation?
Solution Assume that we have determined the Lagrange interpolation polynomial of degree
n based on the data values (x
i
, f(x
i
)), i = 0, 1, 2,, n given at the (n + 1) distinct points.
INTERPOLATION AND APPROXIMATION 77
Suppose that to this given data, a new value (x
n+1
, f(x
n+1
)) at the distinct point x
n+1
is
added at the end of the table. If we require the Lagrange interpolating polynomial of
degree (n + 1) for this new data, then we need to compute all the Lagrange fundamental
polynomials again. The nth degree Lagrange polynomial obtained earlier is of no use.
This is the disadvantage of the Lagrange interpolation.
5. Define the permanence property of interpolating polynomials.
Solution Suppose that a data (x
i
, f(x
i
)), i = 0, 1, 2,, n, is given. Assume that a new
value (x
n+1
, f(x
n+1
)) at the distinct point x
n+1
is added at the end of the table. The data,
(x
i
, f(x
i
)), i = 0, 1, 2,, n + 1, represents a polynomial of degree (n + 1). If this polynomial
of degree (n + 1) can be obtained by adding an extra term to the previously obtained nth
degree interpolating polynomial, then the interpolating polynomial is said to have the
permanence property.
6. Does the Lagrange interpolating polynomial have the permanence property?
Solution Lagrange interpolating polynomial does not have the permanence property.
Suppose that to the given data (x
i
, f(x
i
)), i = 0, 1, 2,, n, a new value (x
n+1
, f(x
n+1
)) at the
distinct point x
n+1
is added at the end of the table. If we require the Lagrange interpolat-
ing polynomial for this new data, then we need to compute all the Lagrange fundamen-
tal polynomials again. The nth degree Lagrange polynomial obtained earlier is of no
use.
7. Does the Newtons divided difference interpolating polynomial have the permanence
property?
Solution Newtons divided difference interpolating polynomial has the permanence
property. Suppose that to the given data (x
i
, f(x
i
)), i = 0, 1, 2,, n, a new data value (x
n+1
,
f(x
n+1
)) at the distinct point x
n+1
is added at the end of the table. Then, the (n + 1) th
column of the divided difference table has the (n + 1)th divided difference. Hence, the
data represents a polynomial of degree (n + 1). We need to add only one extra term
(x x
0
)(x x
1
)...(x x
n
) f[x
0
, x
1
, ... x
n+1
] to the previously obtained nth degree divided
difference polynomial.
8. Define inverse interpolation.
Solution Suppose that a data (x
i
, f(x
i
)), i = 0, 1, 2,, n, is given. In interpolation, we
predict the value of the ordinate f(x) at a non-tabular point x = x. In many applications,
we require the value of the abscissa x for a given value of the ordinate f(x). For this
problem, we consider the given data as ( f (x
i
), x
i
), i = 0, 1, 2,, n and construct the
interpolation polynomial. That is, we consider f(x) as the independent variable and x as
the dependent variable. This procedure is called inverse interpolation
EXERCISE 2.1
1. Use the Lagranges formula to find the quadratic polynomial that takes these values
x 0 1 3
y 0 1 0
Then, find f(2). (A.U Nov/Dec. 2005)
78 NUMERICAL METHODS
2. Using Lagrange interpolation, find the unique polynomial P(x) of degree 2 or less such
that P(1) = 1, P(3) = 27, P(4) = 64.
3. A third degree polynomial passes through the points (0, 1), (1, 1), (2, 1), and (3, 2).
Determine this polynomial using Lagranges interpolation. Hence, find the value at 1.5.
4. Using Lagrange interpolation, find y(10) given that
y(5) = 12, y(6) = 13, y(9) = 14, y(11) = 16.
5. Find the polynomial f(x) by using Lagranges formula and hence find f(3) for
x 0 1 2 5
f(x) 2 3 12 147
(A.U Apr/May 2005)
6. Using Lagranges method, fit a polynomial to the data
x 0 1 2 4
y 12 0 6 12
Also find y at x = 2. (A.U Nov/Dec. 2006)
7. Using Lagrange interpolation, calculate the profit in the year 2000 from the following
data.
Year 1997 1999 2001 2002
Profit in lakhs of Rs. 43 65 159 248
(A.U Nov/Dec. 2004)
8. Given the values
x 14 17 31 35
f(x) 68.7 64.0 44.0 39.1
find f(27) by using Lagranges interpolation formula.
(A.U May/Jun 2006, Nov/Dec. 2006)
9. From the given values, evaluate f(9) using Lagranges formula.
x 5 7 11 13 17
f(x) 150 392 1452 2366 5202
(A.U Nov/Dec. 2003)
10. From the given values, evaluate f(3) using Lagranges formula.
x 1 2 4 5
f(x) 5 13 255 625
INTERPOLATION AND APPROXIMATION 79
11. Find the missing term in the table using Lagranges interpolation
x 0 1 2 3 4
y 1 3 9 81
12. Obtain the root of f(x) = 0 by Lagranges interpolation given that
f(30) = 30, f(34) = 13, f(38) = 3, f(42) = 18. (A.U Nov/Dec. 2004)
13. Using the Lagrange interpolation with the truncation error, show that the Lagrange
interpolation polynomial for f(x) = x
n+1
at the points x
0
, x
1
, , x
n
is given by x
n+1
(x
x
0
)(x x
1
)...(x x
n
).
14. Show that
abcd
a abcd
3
1 1
=
+ .
Forward difference operator When the operator is applied on f(x
i
), we obtain
f(x
i
) = f(x
i
+ h) f(x
i
) = f
i+1
f
i
. (2.19)
That is, f(x
0
) = f(x
0
+ h) f(x
0
) = f(x
1
) f(x
0
),
f(x
1
) = f(x
1
+ h) f(x
1
) = f(x
2
) f(x
1
), etc.
These differences are called the first forward differences.
The second forward difference is defined by
2
f(x
i
) = [ f(x
i
)] = [f(x
i
+ h) f(x
i
)] = f(x
i
+ h) f(x
i
)
= [f(x
i
+ 2h) f(x
i
+ h)] [f(x
i
+ h) f(x
i
)]
= f(x
i
+ 2h) 2f(x
i
+ h) + f(x
i
) = f
i+2
2f
i+1
+ f
i
.
The third forward difference is defined by
3
f(x
i
) = [
2
f(x
i
)] = f(x
i
+ 2h) 2 f(x
i
+ h) + f(x
i
)
= f
i+3
3f
i+2
+ 3f
i+1
f
i
.
Now, from (2.18) and (2.19), we get
f(x
i
) = f(x
i
+ h) f(x
i
) = E f
i
f
i
= (E 1) f
i
.
INTERPOLATION AND APPROXIMATION 81
Comparing, we obtain the operator relation
= E 1, or E = 1 + . (2.20)
Using this relation, we can write the nth forward difference of f(x
i
) as
n
f(x
i
) = (E 1)
n
f(x
i
) =
k
n
k
i n k
n
k n k
f
=
+
0
1 ( )
!
! ( ) !
.
(2.21)
The forward differences can be written in a tabular form as in Table 2.2.
Table 2.2. Forward differences.
x f(x) f
2
f
3
f
x
0
f(x
0
)
f
0
= f
1
f
0
x
1
f(x
1
)
2
f
0
= f
1
f
0
f
1
= f
2
f
1
3
f
0
=
2
f
1
2
f
0
x
2
f(x
2
)
2
f
1
= f
2
f
1
f
2
= f
3
f
2
x
3
f(x
3
)
Backward difference operator When the operator is applied on f(x
i
), we obtain
f(x
i
) = f(x
i
) f(x
i
h) = f
i
f
i1
. (2.22)
That is, f(x
1
) = f(x
1
) f(x
0
),
f(x
2
) = f(x
2
) f(x
1
), etc.
These differences are called the first backward differences.
The second backward difference is defined by
2
f(x
i
) = [ f(x
i
)] = [f(x
i
) f(x
i
h)] = f(x
i
) f(x
i
h)
= f(x
i
) f(x
i
h)] [f(x
i
h) f(x
i
2h)]
= f(x
i
) 2f(x
i
h) + f(x
i
2h) = f
i
2f
i1
+ f
i2
The third backward difference is defined by
3
f(x
i
) = [
2
f(x
i
)] = f(x
i
) 2 f(x
i
h) + f(x
i
2h)
= f
i
3f
i1
+ 3f
i2
f
i3
.
Now, from (2.18) and (2.22), we get
f(x
i
) = f(x
i
) f(x
i
h) = f
i
E
1
f
i
= (1 E
1
)f
i
.
Comparing, we obtain the operator relation
= 1 E
1
, or E
1
= 1 , or E = (1 )
1
. (2.23)
82 NUMERICAL METHODS
Using this relation, we can write the nth backward difference of f(x
i
) as
n
f(x
i
) = (1 E
1
)
n
f(x
i
) =
k
n
k
i k
n
k n k
f
=
0
1 ( )
!
! ( ) !
(2.24)
The backward differences can be written in a tabular form as in Table 2.3.
Table 2.3. Backward differences.
x f(x) f
2
f
3
f
x
0
f(x
0
)
f
1
= f
1
f
0
x
1
f(x
1
)
2
f
2
= f
2
f
1
f
2
= f
2
f
1
3
f
3
=
2
f
3
2
f
2
x
2
f(x
2
)
2
f
3
= f
3
f
2
f
3
= f
3
f
2
x
3
f(x
3
)
Remark 6 From the difference tables 2.2, 2.3, we note that the numbers (values of differ-
ences) in all the columns in the two tables are same. We identify these numbers as the re-
quired forward or backward difference. For example, from the columns of the table, we have
f
0
= f
1
, f
1
= f
2
, f
2
= f
3
, ...,
3
f
0
=
3
f
3
.
Example 2.11 Construct the forward difference table for the data
x 1 0 1 2
f(x) 8 3 1 12
Solution We have the following difference table.
Forward difference table. Example 2.11
x f(x) f
2
f
3
f
1 8
3 + 8 = 11
0 3 2 11 = 13
1 3 = 2 13 + 13 = 26
1 1 11 + 2 = 13
12 1 = 11
2 12
INTERPOLATION AND APPROXIMATION 83
Example 2.12 Construct the backward difference table for the data
x 1 0 1 2
f(x) 8 3 1 12
Solution We have the following difference table.
Backward difference table. Example 2.12.
x f(x) f
2
f
3
f
1 8
3 + 8 = 11
0 3 2 11 = 13
1 3 = 2 13 + 13 = 26
1 1 11 + 2 = 13
12 1 = 11
2 12
Central difference operator When the operator is applied on f(x
i
), we obtain
f(x
i
) = x
h
f x
h
f f
i i i i
+
=
+
2 2
1/ 2 1/ 2
. (2.25)
We note that the ordinates on the right hand side of (2.25) are not the data values. These
differences are called the first central differences. Alternately, we can define the first central
differences as
f
x
h
f f x h f x f f
i i i i i i
+
= = + =
+ +
2
1/ 2 1
( ) ( )
. (2.26)
That is, f
1/2
= f
1
f
0
, f
3/2
= f
2
f
1
, etc. The ordinates on the right hand side of (2.26) are the
data values.
The second central difference is defined by
2
f(x
i
) = [ f(x
i
)] = [f
i+1/2
f
i1/2
] = f
i+1/2
f
i1/2
= [f
i+1
f
i
] [f
i
f
i1
] = f
i+1
2f
i
+ f
i1
.
The third central difference is defined by
3
f(x
i
) = [
2
f(x
i
)] = f
i+1
2 f
i
+ f
i1
= (f
i+3/2
f
i+1/2
) 2(f
i+1/2
f
i1/2
) + (f
i1/2
f
i3/2
)
= f
i+3/2
3f
i+1/2
+ 3f
i1/2
f
i3/2
.
All the odd central differences contain non-nodal values and the even central differences contain
nodal values.
84 NUMERICAL METHODS
Now, from (2.18) and (2.25), we get
f(x
i
) = f
i+1/2
f
i1/2
= E
1/2
f
i
E
1/2
f
i
= (E
1/2
E
1/2
) f
i
.
Comparing, we obtain the operator relation
= (E
1/2
E
1/2
). (2.27)
Using this relation, we can write the nth central difference of f(x
i
) as
n
f(x
i
) = (E
1/2
E
1/2
)
n
f(x
i
) =
k
n
k
n
k n k
=
0
1 ( )
!
! ( ) !
f
i + (n/2) k
. (2.28)
The central differences can be written in a tabular form as in Table 2.4.
Table 2.4. Central differences.
x f(x) f
2
f
3
f
x
0
f(x
0
)
f
1/2
= f
1
f
0
x
1
f(x
1
)
2
f
1
= f
3/2
f
1/2
f
3/2
= f
2
f
1
3
f
3/2
=
2
f
2
2
f
1
x
2
f(x
2
)
2
f
2
= f
5/2
f
3/2
f
5/2
= f
3
f
2
x
3
f(x
3
)
Very often, we may denote the reference point as x
0
and the previous points as x
1
, x
2
,
... and the later points as x
1
, x
2
, .... Then, the central difference table can be written as in
Table 2.5. Note that all the differences of even order lie on the same line as the abscissa and
the ordinate.
Remark 7 We show that
n
f
i
=
n
f
i+n
=
n
f
i+(n/2)
.
We have = 1 E
1
= (E 1) E
1
= E
1
.
n
f
i+n
=
n
E
n
f
i+n
=
n
f
i
.
= (E
1/2
E
1/2
) = (E 1)E
1/2
= E
1/2.
n
f
i+(n/2)
=
n
E
n/2
f
i+(n/2)
=
n
f
i
.
Remark 8 Let P
n
(x) = a
0
x
n
+ a
1
x
n1
+ a
2
x
n2
+ ... + a
n
be a polynomial of degree n. Then,
k
P
n
(x) = 0, for k > n, and
k
P
n
(x) = 0, for k > n,
= a
0
(n !), for k = n = a
0
(n !), for k = n.
INTERPOLATION AND APPROXIMATION 85
Table 2.5. Central differences.
x f(x) f
2
f
3
f
4
f
x
2
f
2
f
3/2
x
1
f
1
2
f
1
f
1/2
3
f
1/2
x
0
f
0
2
f
0
4
f
0
f
1/2
3
f
1/2
x
1
f
1
2
f
1
f
3/2
x
2
f
2
Remark 9 For well behaved functions, the forward differences, backward differences and
central differences decrease in magnitude along each column. That is, the second difference is
smaller in magnitude than the first difference, the third difference is smaller in magnitude
than second difference etc.
Mean operator When the operator is applied on f(x
i
), we obtain
f(x
i
) =
1
2 2 2
1
2
1
2
1 2 1 2
1 2 1 2
f x
h
f x
h
f f E E f
i i i i i
+
= + = +
+
/ /
/ /
Comparing, we have the operator relation
= +
1
2
1/ 2 1/ 2
E E . (2.29)
Example 2.13 Compute
3
(1 2x)(1 3x)(1 4x).
Solution We have
3
(1 2x)(1 3x)(1 4x) =
3
( 24x
3
+ lower order terms)
= 24 (3 !) = 144
since
3
(polynomial of degree 2 and less) = 0.
Example 2.14 Construct the forward difference table for the sequence of values
f(0, 0, 0, , 0, 0, 0)
where is the magnitude of the error in one ordinate value and all other ordinates are exact.
Show that the errors propagate and increase in magnitude and that the errors in each column
are binomial coefficients.
Solution We have the following difference table. From the table, it can be observed that the
errors propagate and increase in magnitude and that the errors in each column are binomial
coefficients.
86 NUMERICAL METHODS
Forward difference table. Example 2.15.
f(x) f
2
f
3
f
4
f
5
f
6
f
0
0
0 0
0
0 4
3 10
2 6 20
3 10
0 4
0
0 0
0
0
Example 2.15 Prove the following.
(i) = (1 )
1/2
(ii) = 1
4
2
1/2
+
(iii) (f
i
2
) = (f
i
+ f
i+1
) f
i
(iv)
f(x)
g(x)
f(x) f(x) f(x) g(x)
g(x) g(x h)
=
+
.
Solution
(i) (1 )
1/2
= (1 E
1
) [1 (1 E
1
)]
1/2
= (1 E
1
)E
1/2
= E
1/2
E
1/2
= .
(ii)
2
= (E
1/2
E
1/2
)
2
= E + E
1
2.
1
4
1
1
4
2
2
1/ 2
1
1/ 2
+
= + +
( ) E E
=
1
2
2
1
2
1 1/ 2
[ ] E E + + =
[E
1/2
+ E
1/2
] = .
(iii) (f
i
2
) = f f f f f f f f f
i i i i i i i i i + + + +
= + = +
1
2 2
1 1 1
( )( ) ( ) .
(iv)
f x
g x
f x h
g x h
f x
g x
f x h g x f x g x h
g x g x h
( )
( )
( )
( )
( )
( )
( ) ( ) ( ) ( )
( ) ( )
=
+
+
=
+ +
+
INTERPOLATION AND APPROXIMATION 87
=
g x f x h f x f x g x h g x
g x g x h
( )[ ( ) ( )] ( )[ ( ) ( )]
( ) ( )
+ +
+
=
g x f x f x g x
g x g x h
( ) ( ) ( ) ( )
( ) ( )
+
.
Relations between differences and derivatives
We write Ef(x) as
Ef(x) = f(x + h) = f(x) + hf (x) +
h
2
2
f (x) + ...
= 1
2
2 2
+ + +
hD
h D
!
... f(x) = e
hD
f(x).
where D
r
f(x) = d
r
f / dx
r
, r = 1, 2, ...
Hence, we obtain the operator relation
E = e
hD
or hD = ln(E). (2.30)
In terms of the forward, backward and central differences, we obtain
hD E = = + = + ln( ) ln( ) ... 1
1
2
1
3
2 3
(2.31)
hD E = = = = + + +
= +
2 2
2 2
+ ...
Neglecting the higher order terms, we get the approximation
f(x) hf (x), or f (x)
1
h
f(x). (2.35)
The error term is given by
= + f x
h
f x
h
f x ( ) ( ) ( ) ...
1
2
Hence, we call the approximation given in (2.35) as a first order approximation or of order
O(h).
88 NUMERICAL METHODS
We have
2
f(x) = f(x + 2h) 2f(x + h) + f(x)
=
f x hf x
h
f x
h
f x ( ) ( ) ( ) ( ) ... + + + +
2
4
2
8
6
2 3
2 f x hf x
h
f x
h
f x ( ) ( ) ( ) ( ) ... + + + +
2 3
2 6
+ f(x)
= h
2
f (x) + h
3
f (x) + ...
Neglecting the higher order terms, we get the approximation
2
f(x) h
2
f (x), or f (x)
1
2
h
2
f(x). (2.36)
The error term is given by
= + f x
h
f x h f x ( ) ( ) ( ) ...
1
2
2
2
f(x) h
2
f (x), or
f x
h
f x ( ) ( )
1
2
2
. [O(h) approximation] (2.38)
For the central differences, we obtain
f x f x
h
f x
h
( ) = +
2 2
= f x
h
f x
h
f x
h
f x ( ) ( ) ( ) ( ) ... + + + +
2 8 48
2 3
f x
h
f x
h
f x
h
f x ( ) ( ) ( ) ( ) ... + +
2 8 48
2 3
= hf (x) +
h
f x
3
24
+ ( ) ...
Neglecting the higher order terms, we get the approximation
f(x) h f (x), or f (x)
1
h
f(x). (2.39)
The error term is given by
= + f x
h
f x
h
f x ( ) ( ) ( ) ...
1
24
2
2
2
2 f(x) +
f x hf x
h
f x ( ) ( ) ( ) ... +
2
2
Neglecting the higher order terms, we get the approximation
2
f(x) h
2
f (x), or f (x)
1
2
h
2
f(x). (2.40)
The error term is given by
f (x)
1
2
h
2
f(x) =
h
f x
iv
2
12
( )
( ) + ...
Hence, we call the approximation given in (2.35) as a second order approximation or of
order O(h
2
).
Note that the central differences give approximations of higher order because of sym-
metry of the arguments.
The divided differences are also related to forward differences and backward differences.
In the uniform mesh case, the divided differences can be written as
f x x
f x f x
x x h
f
h
f
i i
i i
i i
i i
[ , ]
( ) ( )
+
+
+
+
=
= =
1
1
1
1
1 1
.
f x x x
f x x f x x
x x
h f h f
h
i i i
i i i i
i i
i i
[ , , ]
[ , ] [ , ] ( / ) ( / )
+ +
+ + +
+
+
=
=
1 2
1 2 1
2
1
1 1
2
=
1
2
1
2
2
2
2
2
2
! ! h
f
h
f
i i
=
+
.
By induction we can prove that the nth divided difference can be written as
f x x x
n h
f
n h
f
n
n
n
n
n
n
[ , , ..., ]
! !
0 1 0
1 1
= =
. (2.41)
2.3.1 Newtons Forward Difference Interpolation Formula
Let h be the step length in the given data.
In terms of the divided differences, we have the interpolation formula as
f(x) = f (x
0
) + (x x
0
) f [x
0
, x
1
] + (x x
0
)(x x
1
) f [x
0
, x
1
, x
2
] + ...
Using the relations for the divided differences given in (2.36)
f x x x
n h
f
n
n
n
[ , , ..., ]
!
0 1 0
1
=
90 NUMERICAL METHODS
we get f(x) = f(x
0
) + (x x
0
)
f
h
0
1!
(x x
0
)(x x
1
)
2
0
2
2
f
h !
+ ...
+ (x x
0
)(x x
1
)...(x x
n1
)
n
n
f
h
0
1!
(2.42)
This relation is called the Newtons forward difference interpolation formula.
Suppose that we want to interpolate near the point
0
x . Set x = x
0
+ sh. Then,
x x
i
= x
0
+ sh (x
0
+ ih) = (s i)h.
Therefore, x
x
0
= sh, x x
1
= (s 1)h, x x
2
= (s 2)h, etc.
Substituting in (2.42), we obtain
f(x) = f(x
0
+ sh)
= f(x
0
) + sf
0
+
s s
f
s s s s n
n
f
n
( )
!
...
( )( ) ... ( )
!
+ +
+ 1
2
1 2 1
2
0 0
(2.43)
We note that the coefficients are the binomial coefficients
n
sC sC sC ,..., ,
1 0
.
Hence, we can write the formula (2.43) as
f(x) = f(x
0
+ sh)
= sC
0
f(x
0
) + sC
1
f
0
+ sC
2
2
f
0
+ ... + sC
n
n
f
0
Note that s = [(x x
0
)/h] > 0.
This is an alternate form of the Newtons forward difference interpolation formula.
Error of interpolation The error of interpolation is same as in the Lagrange interpolation.
Therefore, error of interpolation is given by
E
n
(f, x) =
( )( )... ( )
( ) !
( )
( )
x x x x x x
n
f
n n
+
+ 0 1 1
1
=
s s s s n
n
h f sC h f
n n
n
n n
( )( )..( )
( ) !
( ) ( )
( ) ( )
+
=
+ +
+
+ +
1 2
1
1 1
1
1 1
(2.44)
where 0 < < n. The coefficient in the error expression is the next binomial coefficient sC
n+1
.
Remark 10 The Newtons forward difference formula has the permanence property. Suppose
we add a new data value (x
n+1
, f(x
n+1
)) at the end of the given table of values. Then, the
(n + 1)th column of the forward difference table has the (n + 1)th forward difference. Then, the
Newtons forward difference formula becomes
f(x) = f(x
0
) + (x x
0
)
f
h
x x x x
f
h
0
0 1
2
0
2
1 2 !
( )( )
!
+ + ...
+ (x x
0
)(x x
1
)...(x x
n
)
n
n
f
n h
+
+
+
1
0
1
1 ( ) !
INTERPOLATION AND APPROXIMATION 91
Example 2.16 Derive the Newtons forward difference formula using the operator relations.
Solution We have
f(x
0
+ sh) = E
s
f(x
0
) = (1 + )
s
f(x
0
).
Symbolically, expanding the right hand side, we obtain
f(x
0
+ sh) = (sC
0
+ sC
1
+ sC
2
2
+ ...) f(x
0
)
= sC
0
f(x
0
) + sC
1
f(x
0
) + sC
2
2
f(x
0
) + ... + sC
n
n
f(x
0
) + ...
We neglect the (n + 1)th and higher order differences to obtain the Newtons forward
difference formula as
f(x
0
+ sh) = (sC
0
+ sC
1
+ sC
2
2
+ ...) f(x
0
)
= sC
0
f(x
0
) + sC
1
f(x
0
) + sC
2
2
f(x
0
) + ... + sC
n
n
f(x
0
).
Example 2.17 For the data
x 2 1 0 1 2 3
f (x) 15 5 1 3 11 25
construct the forward difference formula. Hence, find f (0.5).
Solution We have the following forward difference table.
Forward difference table. Example 2.17.
x f(x) f
2
f
3
f
2 15
10
1 5 6
4 0
0 1 6
2 0
1 3 6
8 0
2 11 6
14
3 25
From the table, we conclude that the data represents a quadratic polynomial. We have
h = 1. The Newtons forward difference formula is given by
f(x) = f(x
0
) + (x x
0
)
f
h
x x x x
f
h
0
0 1
2
0
2
2
( )( )
92 NUMERICAL METHODS
= 15 + (x + 2)( 10) + (x + 2) (x + 1)
6
2
= 15 10x 20 + 3x
2
+ 9x + 6 = 3x
2
x + 1.
We obtain f(0.5) = 3(0.5)
2
0.5 + 1 = 0.75 0.5 + 1 = 1.25.
2.3.2 Newtons Backward Difference Interpolation Formula
Again, we use the Newtons divided difference interpolation polynomial to derive the Newtons
backward difference interpolation formula. Since, the divided differences are symmetric with
respect to their arguments, we write the arguments of the divided differences in the order
x
n
, x
n1
,..., x
1
, x
0
. The Newtons divided difference interpolation polynomial can be written as
f(x) = f(x
n
) + (x x
n
) f [x
n
, x
n1
] + (x x
n
)(x x
n1
) f [x
n
, x
n1
, x
n2
] + ...
+ (x x
n
)(x x
n1
) ... (x x
1
) f [x
n
, x
n1
,..., x
0
] (2.45)
Since, the divided differences are symmetric with respect to their arguments, we have
f [x
n
, x
n1
] = f [x
n1
, x
n
] =
1
h
f
n
,
f[x
n
, x
n1
, x
n2
] = f [x
n2
, x
n1
, x
n
] =
1
2
2
2
! h
f
n
, ....,
f [x
n
, x
n1
, ..., x
0
] = f [x
0
, x
1
,..., x
n
] =
1
n h
f
n
n
n
!
.
Substituting in (2.45), we obtain the Newtons backward difference interpolation formula as
f(x) = f(x
n
) + (x x
n
)
1
1
1
2
1
2
2
!
( ) ( )( )
!
( ) ...
h
f x x x x x
h
f x
n n n n
+ +
+ (x x
n
)(x x
n1
) ... (x x
1
)
1
n h
f x
n
n
n
!
( ) . (2.46)
Let x be any point near x
n
. Let x x
n
= sh. Then,
x x
i
= x x
n
+ x
n
x
i
= x x
n
+ (x
0
+ nh) (x
0
+ ih)
= sh + h(n i) = (s + n i)h, i = n 1, n 2, ..., 0.
Therefore, x x
n
= sh, x x
n1
= (s + 1)h, x x
n2
= (s + 2)h, ..., x x
1
= (s + n 1)h.
Substituting in (2.46), we obtain the formula as
f(x) = f(x
n
+ sh) = f(x
n
) + sf(x
n
) +
s s ( )
!
+ 1
2
2
f(x
n
) + ...
+
s s s s n
n
f x
n
n
( )( ) ... ( )
!
( )
+ + +
1 2 1
. (2.47)
INTERPOLATION AND APPROXIMATION 93
Note that s = [(x x
n
)/h] < 0. The magnitudes of the successive terms on the right hand
side become smaller and smaller. Note that the coefficients are the binomial coefficients
[( 1)
k
( s)C
k
].
Error of interpolation The expression for the error becomes
E
n
(f, x) =
( )( ) ... ( )
( ) !
( )
( )
x x x x x x
n
f
n n n
+
+ 1 0 1
1
=
s s s s n
n
h f
n n
( )( ) ... ( )
( ) !
( )
( )
+ + +
+
+ +
1 2
1
1 1
(2.48)
where 0 < < n.
Remark 11 As in divided differences, given a table of values, we can determine the degree of
the forward/ backward difference polynomial using the difference table. The kth column of the
difference table contains the kth forward/ backward differences. If the values of these differ-
ences are same, then the (k + 1)th and higher order differences are zero. Hence, the given data
represents a kth degree polynomial.
Remark 12 We use the forward difference interpolation when we want to interpolate near
the top of the table and backward difference interpolation when we want to interpolate near
the bottom of the table.
Example 2.18 Derive the Newtons backward difference formula using the operator relations.
Solution Let x = x
n
+ sh. Then, s = [(x x
n
)/h] < 0
We have f(x
n
+ sh) = E
s
f(x
n
) = (1 )
s
f(x
n
)
Symbolically, expanding the right hand side, we obtain
f(x
n
+ sh) = f(x
n
) + sf(x
n
) +
s s ( )
!
+1
2
2
f(x
n
) + ... +
s s s n
n
( ) ... ( )
!
+ + 1 1
n
f(x
n
) + ...
We neglect the (n + 1)th and higher order differences to obtain the Newtons backward
difference formula as
f(x
n
+ sh) = f(x
n
) + sf(x
n
) +
s s ( )
!
+1
2
2
f(x
n
) + ... +
s s s n
n
( ) ... ( )
!
+ + 1 1
n
f(x
n
).
Example 2.19 For the following data, calculate the differences and obtain the Newtons
forward and backward difference interpolation polynomials. Are these polynomials different?
Interpolate at x = 0.25 and x = 0.35.
x 0.1 0.2 0.3 0.4 0.5
f(x) 1.40 1.56 1.76 2.00 2.28
Solution The step length is h = 0.1. We have the following difference table.
Since, the third and higher order differences are zero, the data represents a quadratic
polynomial. The third column represents the first forward/ backward differences and the fourth
column represents the second forward/ backward differences.
94 NUMERICAL METHODS
The forward difference polynomial is given by
f(x) = f(x
0
) + (x x
0
)
f
h
0
+ (x x
0
) (x x
1
)
2
0
2
2
f
h !
= 1.4 + (x 0.1)
0 16
0 1
0 1 0 2
0 04
0 02
.
.
( . )( . )
.
.
x x
= 2x
2
+ x + 1.28.
The backward difference polynomial is given by
f(x) = f(x
n
) + (x x
n
)
f
h
x x x x
f
h
n
n n
n
( )( )
!
1
2
2
2
= 2.28 + (x 0.5)
0 28
0 1
0 5 0 4)
0 04
0 02
.
.
( . )( .
.
.
x x
= 2x
2
+ x + 1.28.
Both the polynomials are identical, since the interpolation polynomial is unique. We obtain
f(0.25) = 2(0.25)
2
+ 0.25 + 1.28 = 1.655
f(0.35) = 2(0.35)
2
+ (0.35) + 1.28 = 1.875.
Difference table. Example 2.19.
x f(x) f
2
f
3
f
4
f
0.1 1.40
0.16
0.2 1.56 0.04
0.20 0.0
0.3 1.76 0.04 0.0
0.24 0.0
0.4 2.00 0.04
0.28
0.5 2.28
Example 2.20 Using Newtons backward difference interpolation, interpolate at
0 . 1 = x
from
the following data.
x 0.1 0.3 0.5 0.7 0.9 1.1
f(x) 1.699 1.073 0.375 0.443 1.429 2.631
Solution The step length is h = 0.2. We have the difference table as given below.
INTERPOLATION AND APPROXIMATION 95
Since the fourth and higher order differences are zero, the data represents a third de-
gree polynomial. The Newtons backward difference interpolation polynomial is given by
f(x) = f(x
n
) + (x x
n
)
1
1! h
f(x
n
) + (x x
n
)(x x
n1
)
1
2
2
! h
2
f(x
n
)
+ (x x
n
)(x x
n1
)(x x
n2
)
1
3
3
3
!
( )
h
f x
n
= 2.631 + (x 1.1)
1202
0 2
.
.
+ (x 1.1)(x 0.9)
0 216
2 0 04)
.
( .
1
2
1
3
2 3
...
2. Write the expression for the derivative operator D in terms of the backward difference
operator .
Solution The required expression is
hD = ln(E) = ln(1 )
1
= ln(1 ) = +
1
2
2
+
1
3
3
+ ...
or D =
1
h
ln(E) =
1
h
ln (1 )
1
=
1
h
ln(1 ) =
1
h
+ + +
1
2
1
3
2 3
... .
3. What is the order of the approximation f (x)
1
h
f(x) ?
Solution The error term is given by f (x)
1
h
f(x) =
h
f x
2
+ ( ) ...
Hence, it is a first order approximation or of order O(h).
4. What is the order of the approximation
f x
h
f x ( ) ( )
1
2
2
?
Solution The error term is given by = + f x
h
f x h f x ( ) ( ) ( ) ...
1
2
2
?
Solution The error term is given by
= + f x
h
f x
h
f x
iv
( ) ( ) ( ) ...
( )
1
12
2
2
2
n
n
f
n h
+
+
+
1
0
1
1 ( ) !
8. For performing interpolation for a given data, when do we use the Newtons forward
and backward difference formulas?
Solution We use the forward difference interpolation when we want to interpolate
near the top of the table and backward difference interpolation when we want to
interpolate near the bottom of the table.
9. Can we decide the degree of the polynomial that a data represents by writing the forward
or backward difference tables?
Solution Given a table of values, we can determine the degree of the forward/ backward
difference polynomial using the difference table. The kth column of the difference table
contains the kth forward/ backward differences. If the values of these differences are
same, then the (k + 1)th and higher order differences are zero. Hence, the given data
represents a kth degree polynomial.
10. If x = x
0
+ sh, write the error expression in the Newtons forward difference formula.
Solution The error expression is given by
E
n
(f, x) =
s s s s n
n
h f sC h f n
n n
n
n n
( )( )..( )
( ) !
( ) ( ).
( ) ( )
+
= < <
+ +
+
+ +
1 2
1
0
1 1
1
1 1
.
11. If x = x
n
+ sh, write the error expression in the Newtons backward difference formula.
Solution The error expression is given by
E
n
(f, x) =
s s s s n
n
h f
n n
( )( )..( )
( ) !
( ).
( )
+ + +
+
+ +
1 2
1
1 1
0 < < n.
EXERCISE 2.2
1. Prove the following.
(i)
1
1
f
f
f f
i
i
i i
=
+
. (ii) + =
. (iii)
k
n
k n
f f f
=
+
=
0
2
1 0
.
(iv) = . (v) = ( + )/2.
(iv) (1 + )(1 ) = 1. (vii) = E
1/2
. (viii) 1
2 2
+ = 1 + (1/2)
2
.
2. Using the Newtons forward difference formula, find the polynomial f(x) satisfying the
following data. Hence, evaluate y at x = 5.
x 4 6 8 10
y 1 3 8 10 (A.U. May/Jun 2006)
98 NUMERICAL METHODS
3. A third degree polynomial passes through the points (0, 1), (1, 1), (2, 1) and (3, 2).
Determine this polynomial using Newtons forward interpolation formula. Hence, find
the value at 1.5.
4. Using the Newtons forward interpolation formula, find the cubic polynomial which
takes the following values.
x 0 1 2 3
y 1 2 1 10
Evaluate y(4) using Newtons backward interpolation formula. Is it the same as ob-
tained from the cubic polynomial found above?
5. Obtain the interpolating quadratic polynomial for the given data by using the Newtons
forward difference formula
x 0 2 4 6
y 3 5 21 45
(A.U. Nov/Dec 2003)
6. For the following data, estimate the number of persons earning weekly wages between
60 and 70 rupees.
Wage (in Rs.) below 40 4060 6080 80100 100120
No. of persons 250 120 100 70 50
(in thousands)
(A.U. Nov/Dec 2003)
7. Using the Newtons backward interpolation formula construct an interpolation polyno-
mial of degree 3 for the data
f( 0.75) = 0.07181250, f( 0.5) = 0.024750, f( 0.25) = 0.33493750, f(0) = 1.1010.
Hence, find f( 1/3). (A.U. Apr/May 2003)
8. Using the Newtons forward difference formula, find the polynomial f(x) satisfying the
following data. Hence, find f(2).
x 0 5 10 15
y 14 379 1444 3584
(A.U. Apr/May 2004)
9. The following data represents the function f(x) = e
x
.
x 1 1.5 2.0 2.5
y 2.7183 4.4817 7.3891 12.1825
INTERPOLATION AND APPROXIMATION 99
Estimate the value of f(2.25) using the (i) Newtons forward difference interpolation
and (ii) Newtons backward difference interpolation. Compare with the exact value.
10. The following data represents the function f(x) = cos (x + 1).
x 0.0 0.2 0.4 0.6
f(x) 0.5403 0.3624 0.1700 0.0292
Estimate the value of f(0.5) using the Newtons backward difference interpolation. Com-
pare with the exact value.
11. The following data are part of a table for x x x f / cos ) ( = , where x is in radians.
x 0.1 0.2 0.3 0.4
f(x) 9.9500 4.9003 3.1845 2.3027
Calculate f(0.12), (i) by interpolating directly from the table, (ii) by first tabulating x
f(x) and then interpolating from the table. Explain the difference between the results.
2.4 8PLNE NTERPOLATON AND CUBC 8PLNE8
In the earlier days of development of engineering devices, the draftsman used a device to
draw smooth curves through a given sets of points such that the slope and curvature are also
continuous along the curves, that is, f(x), f(x) and f(x) are continuous on the curves. Such a
device was called a spline and plotting of the curve was called spline fitting.
We now define a spline.
Let the given interval [a, b] be subdivided into n subintervals [x
0
, x
1
], [x
1
, x
2
], ...,
[x
n1
, x
n
] where a = x
0
< x
1
< x
2
< ... < x
n
= b. The points x
0
, x
1
, ..., x
n
are called nodes or knots and
x
1
, ..., x
n1
are called internal nodes.
Spline function A spline function of degree n with nodes x
0
, x
1
, ..., x
n
, is a function F(x)
satisfying the following properties.
(i) F(x
i
) = f(x
i
), i = 0, 1, ...., n. (Interpolation conditions).
(ii) On each subinterval [x
i1
, x
i
], 1 i n, F(x) is a polynomial of degree n.
(iii) F(x) and its first (n 1) derivatives are continuous on (a, b).
For our discussion, we shall consider cubic splines only. From the definition, a cubic spline
has the following properties.
(i) F(x
i
) = f(x
i
), i = 0, 1, ..., n. (Interpolation conditions).
(ii) On each subinterval [x
i1
, x
i
], 1 i n, F(x) is a third degree (cubic) polynomial.
(iii) F(x), F(x) and F (x) are continuous on (a, b).
Let F(x) = P
i
(x) = a
i
x
3
+ b
i
x
2
+ c
i
x + d
i
on [x
i1
, x
i
]
and F(x) = P
i+1
(x) = a
i+1
x
3
+ b
i+1
x
2
+ c
i+1
x + d
i+1
on [x
i
, x
i+1
].
100 NUMERICAL METHODS
On each interval, we have four unknowns a
i
, b
i
, c
i
and d
i
, i = 1, 2, ..., n. Therefore, the
total number of unknowns is 4n.
Continuity of F(x), F(x) and F(x) on (a, b) implies the following.
(i) Continuity of F(x) :
On [x
i1,
x
i
] : P
i
(x
i
) = f(x
i
) = a
i
x b x c x d
i i i i i i
3 2
+ + +
On [x
i
, x
i+1
] : P
i+1
(x
i
) = f(x
i
) = a
i+1
x b x c x d
i i i i i i
3
1
2
1 1
+ + +
+ + +
, i = 1, 2, ..., n 1. (2.49)
(ii) Continuity of F(x) :
3 2 3 2
2
1
2
1 1
a x b x c a x b x c
i i i i i i i i i i
+ + = + +
+ + +
, i = 1, 2, ..., n 1. (2.50)
(iii) Continuity of F (x) :
6a
i
x
i
+ 2b
i
= 6a
i+1
x
i
+ 2b
i+1
, i = 1, 2, ..., n 1. (2.51)
At the end points x
0
and x
n
, we have the interpolation conditions
f(x
0
) = a x b x c x d
1 0
3
1 0
2
1 0 1
+ + + ,
and f(x
n
) = a
n
x b x c x d
n n n n n n
3 2
+ + + . (2.52)
We have 2(n 1) equations from (2.49), (n 1) equations from (2.50), (n 1) equations
from (2.51) and 2 equations from (2.52). That is, we have a total of 4n 2 equations. We need
two more equations to obtain the polynomial uniquely. There are various types of conditions
that can be prescribed to obtain two more equations. We shall consider the case of a natural
spline, in which we set the two conditions as F(x
0
) = 0, F(x
n
) = 0.
The above procedure is a direct way of obtaining a cubic spline. However, we shall
derive a simple method to determine the cubic spline.
Example 2.21 Find whether the following functions are cubic splines ?
(i) f(x) = 5x
3
3x
2
, 1 x 0 (ii) f(x) = 2x
3
x
2
, 1 x 0
= 5x
3
3x
2
, 0 x 1. = 2x
3
+ x
2
, 0 x 1.
Solution In both the examples, f(x) is a cubic polynomial in both intervals ( 1, 0) and (0, 1).
(i) We have
lim ( ) lim ( )
x x
f x f x
+
= =
0 0
0 .
The given function f(x) is continuous on ( 1, 1).
f (x) = 15x
2
6x, 1 x 0
= 15x
2
6x, 0 x 1.
We have lim ( ) lim ( )
x x
f x f x
+
= =
0 0
0 .
The function f (x) is continuous on ( 1, 1).
f (x) = 30x 6, 1 x 0
= 30x 6, 0 x 1.
INTERPOLATION AND APPROXIMATION 101
We have
lim ( ) lim ( )
x x
f x f x
+
= =
0 0
6
.
The function f (x) is continuous on ( 1, 1).
We conclude that the given function f(x) is a cubic spline.
(ii) We have
lim ( ) lim ( )
x x
f x f x
+
= =
0 0
0
.
The given function f(x) is continuous on ( 1, 1).
f (x) = 6x
2
2x, 1 x 0
= 6x
2
+ 2x, 0 x 1.
We have
lim ( ) lim ( )
x x
f x f x
+
= =
0 0
0
The function f (x) is continuous on ( 1, 1).
f (x) = 12x 2, 1 x 0
= 12x + 2, 0 x 1.
We have
lim ( )
x
f x
+
=
0
2
, lim ( )
x
f x
0
= 2
The function f (x) is not continuous on ( 1, 1).
We conclude that the given function f(x) is not a cubic spline.
Cubic spline
From the definition, the spline is a piecewise continuous cubic polynomial. Hence,
F(x) is a linear function of x in all the intervals.
Consider the interval [x
i1
, x
i
]. Using Lagrange interpolation in this interval, F (x) can
be written as
F(x) =
x x
x x
F x
x x
x x
F x
i
i i
i
i
i i
i
1
1
1
1
( ) ( )
=
x x
x x
F x
x x
x x
F x
i
i i
i
i
i i
i
1
1
1
1
( ) ( ) (2.53)
Denote F(x
i1
) = M
i1
, and F(x
i
) = M
i
.
Integrating (2.53) with respect to x, we get
F (x) =
( )
( )
( )
( )
x x
x x
M
x x
x x
M a
i
i i
i
i
i i
i
2
1
1
1
2
1
2 2
. (2.54)
Integrating (2.54) again with respect to x, we get
F(x) =
( )
( )
( )
( )
x x
x x
M
x x
x x
M ax b
i
i i
i
i
i i
i
+ +
3
1
1
1
3
1
6 6
(2.55)
where a, b are arbitrary constants to be determined by using the conditions
102 NUMERICAL METHODS
F(x
i1
) = f(x
i1
) and F(x
i
) = f(x
i
). (2.56)
Denote x
i
x
i1
= h
i
, f(x
i1
) = f
i1
, and f(x
i
) = f
i
. Note that h
i
is the length of the interval
[x
i1
, x
i
].
To ease the computations, we write
ax + b = c(x
i
x) + d(x x
i1
) where a = d c, b = c x
i
d x
i1
.
That is, we write (2.55) as
F(x) =
( ) ( )
( ) ( )
x x
h
M
x x
h
M c x x d x x
i
i
i
i
i
i i i
+
+ +
3
1
1
3
1
6 6
.
Using the condition F(x
i1
) = f(x
i1
) = f
i1
, we get
f
i1
=
( )
( )
x x
h
M c x x
h
h
M ch
i i
i
i i i
i
i
i i
+ = +
1
3
1 1
3
1
6 6
or c =
1
6
1
2
1
h
f
h
M
i
i
i
i
.
Using the condition F(x
i
) = f(x
i
) = f
i
, we get
f
i
=
( )
( )
x x
h
M d x x
h
h
M dh
i i
i
i i i
i
i
i i
+ = +
1
3
1
3
6 6
or d =
1
6
2
h
f
h
M
i
i
i
i
.
Substituting the expressions for c and d in (2.55), we obtain the spline in the interval [x
i1
, x
i
]
as
F
i
(x) =
1
6 6
3
1 1
3
1
2
1
h
x x M x x M
x x
h
f
h
M
i
i i i i
i
i
i
i
i
[( ) ( ) ]
( )
+ +
+
( ) x x
h
f
h
M
i
i
i
i
i
1
2
6
(2.57)
Note that the spline second derivatives M
i1
, M
i
are unknowns and are to be determined.
Setting i = i + 1 in (2.57), we get the spline valid in the interval [x
i
, x
i+1
] as
F
i+1
(x) =
1
6 6
1
1
3 3
1
1
1
1
2
h
x x M x x M
x x
h
f
h
M
i
i i i i
i
i
i
i
i
+
+ +
+
+
+ +
[( ) ( ) ]
( )
+
( ) x x
h
f
h
M
i
i
i
i
i
+
+
+
+
1
1
1
2
1
6
(2.58)
where h
i+1
= x
i+1
x
i
. Differentiating (2.57) and (2.58), we get
INTERPOLATION AND APPROXIMATION 103
F
i
(x) =
1
6
3 3
2
1 1
2
h
x x M x x M
i
i i i i
[ ( ) ( ) ] +
1
6
1
6
1
2
1
2
h
f
h
M
h
f
h
M
i
i
i
i
i
i
i
i
(2.59)
valid in the interval [x
i1
, x
i
], and
F
i+1
(x) =
1
6
3 3
1
1
2 2
1
h
x x M x x M
i
i i i i
+
+ +
+ [ ( ) ( ) ]
+
+
1
6
1
1
2
h
f
h
M
i
i
i
i
+
1
6
1
1
1
2
1
h
f
h
M
i
i
i
i
+
+
+
+
(2.60)
valid in the interval [x
i
, x
i +1
].
Now, we require that the derivative F(x) be continuous at x = x
i
. Hence, the left hand
and right hand derivatives of F(x) at x = x
i
must be equal, that is,
lim ( ) lim ( )
+
= +
0 0
1
F x F x
i i i i .
Using (2.59) and (2.60), we obtain
h
M
h
f
h
M
h
f
h
M
i
i
i
i
i
i
i
i
i
i
2
1
6
1
6
1 1
+ +
=
h
M
h
f
h
M
h
f
h
M
i
i
i
i
i
i
i
i
i
i
+
+
+
+
+
+
+
+ +
1
1
1
1
1
1
1
2
1
6
1
6
or
h
M h h M
h
M
h
f f
h
f f
i
i i i i
i
i
i
i i
i
i i
6
1
3 6
1 1
1 1
1
1
1
1 1 +
+
+
+
+
+ + + = ( ) ( ) ( )
i = 1, 2, ..., n 1. (2.61)
This relation gives a system of n 1 linear equations in n + 1 unknowns M
0
, M
1
, ..., M
n
.
The two additional conditions required are the natural spline conditions M
0
= 0 = M
n
. These
equations are solved for M
1
, M
2
, ..., M
n1
. Substituting these values in (2.57), we obtain the
spline valid in the interval [x
i1
, x
i
]. If the derivative is required, we can find it from (2.59).
Equispaced data When the data is equispaced, we have h
i
= h
i+1
= h and x
i
= x
0
+ ih. Then, the
spline in the interval [x
i1
, x
i
], given in (2.57) and the relation between the second derivatives
given in (2.61) simplify as
F
i
(x) =
1
6
3
1 1
3
h
x x M x x M
i i i i
[( ) ( ) ] +
+
( ) x x
h
f
h
M
i
i i 1
2
1
6
+
( ) x x
h
f
h
M
i
i i
1
2
6
(2.62)
104 NUMERICAL METHODS
M
i1
+ 4M
i
+ M
i+1
=
6
2
2
1 1
h
f f f
i i i
( )
+
+ (2.63)
i = 1, 2, ..., n 1.
Remark 12 Splines provide better approximation to the behaviour of functions that have
abrupt local changes. Further, splines perform better than higher order polynomial approxi-
mations.
Example 2.22 Obtain the cubic spline approximation for the following data.
x 0 1 2
f(x) 1 3 29
with M
0
= 0, M
2
= 0. Hence, interpolate at x = 0.5, 1.5.
Solution We have equispaced data with h = 1. We obtain from (2.63),
M
i1
+ 4M
i
+ M
i+1
= 6(f
i+1
2f
i
+ f
i1
), i = 1.
For i = 1, we get
M
0
+ 4M
1
+ M
2
= 6(f
2
2f
1
+ f
0
).
Since, M
0
= 0, M
2
= 0, we get
4M
1
= 6[29 2(3) 1] = 132, or M
1
= 33.
The spline is given by
F
i
(x) =
1
6
1
6
3
1 1
3
1 1
[( ) ( ) ] ( ) x x M x x M x x f M
i i i i i i i
+ +
+ (x x
i1
) f M
i i
1
6
We have the following splines.
On [0, 1]:
F(x) =
1
6
[(x
1
x)
3
M
0
+ (x x
0
)
3
M
1
] + (x
1
x) f M x x f M
0 0 0 1 1
1
6
1
6
( )
=
1
6
(33)x
3
+ (1 x)( 1) + x 3
1
6
33
( )
=
1
2
(11x
3
3x 2).
On [1, 2]:
F(x) =
1
6
1
6
1
6
2
3
1 1
3
2 2 1 1 1 2 2
[( ) ( ) ] ( ) ( ) x x M x x M x x f M x x f M + +
=
1
6
2 33 2 3
1
6
33 1 29
3
[( ) ( )] ( ) ( ) ( ) [ ] +
+ x x x
INTERPOLATION AND APPROXIMATION 105
=
11
2
2
63
2
3
( ) + x x 34.
Since, 0.5 lies in the interval (0, 1), we obtain
F(0.5) =
1
2
11
8
3
2
2
17
16
,
= .
Since, 1.5 lies in the interval (1, 2), we obtain
F(1.5) =
1
2
11 2 15 63 15 68
223
16
3
[ ( . ) ( . ) ] + = .
Example 2.23 Obtain the cubic spline approximation for the following data.
x 0 1 2 3
f(x) 1 2 33 244
with M
0
= 0, M
3
= 0. Hence, interpolate at x = 2.5.
Solution We have equispaced data with h = 1. We obtain from (2.63),
M
i1
+ 4M
i
+ M
i+1
= 6(f
i+1
2f
i
+ f
i1
) i = 1, 2.
For i = 1, we get
M
0
+ 4M
1
+ M
2
= 6(f
2
2f
1
+ f
0
) = 6(33 4 + 1) = 180.
For i = 2, we get
M
1
+ 4M
2
+ M
3
= 6(f
3
2f
2
+ f
1
) = 6(244 66 + 2) = 1080.
Since, M
0
= 0, M
3
= 0, we get
4M
1
+ M
2
= 180, M
1
+ 4M
2
= 1080.
The solution is M
1
= 24, M
2
= 276.
The cubic splines in the corresponding intervals are as follows.
On [0, 1]:
F(x) =
1
6
1
6
1
3
0 0
3
1 1 0 0
[( ) ( ) ] ( ) x x M x x M x x f M + +
+ (x x
0
) f M
1 1
1
6
=
1
6
24 1 2
1
6
24 4 5 1
3 3
x x x x x ( ) ( ) ( ) + +
= + + .
On [1, 2]:
F(x) =
1
6
1
6
2
3
1 1
3
2 2 1 1
[( ) ( ) ] ( ) x x M x x M x x f M + +
+ (x x
1
) f M
2 2
1
6
=
1
6
[(2 x)
3
( 24) + (x 1)
3
(276)] + (2 x) 2
1
6
24 1 33
1
6
276
( ) ( ) ( ) x
106 NUMERICAL METHODS
=
1
6
[(8 12x + 6x
2
x
3
)( 24) + (x
3
3x
2
+ 3x 1)(276)] + 6(2 x) 13(x 1)
= 50x
3
162x
2
+ 167x 53.
On [2, 3]:
F(x) =
1
6
1
6
3
3
2 2
3
3 3 2 2
[( ) ( ) ] ( ) x x M x x M x x f M + +
+ (x x
2
) f M
3 3
1
6
=
1
6
3 276 3 33
1
6
276
3
[( ) ( )] ( ) ( ) +
x x + (x 2)(244)
=
1
6
[(27 27x + 9x
2
x
3
) (276)] 13(3 x) + 244(x 2)
= 46x
3
+ 414 x
2
985 x + 715.
The estimate at x = 2.5 is
F(2.5) = 46(2.5)
3
+ 414(2.5)
2
985(2.5) + 715 = 121.25.
REVIEW QUESTIONS
1. What are the advantages of cubic spline fitting?
Solution Splines provide better approximation to the behaviour of functions that have
abrupt local changes. Further, splines perform better than higher order polynomial
approximations.
2. Write the relation between the second derivatives ) (x M
i
in cubic splines with equal
mesh spacing.
Solution The required relation is
M
i1
+ 4M
i
+ M
i+1
=
6
2
h
( f
i+1
2f
i
+ f
i1
), i = 1, 2, ..., n 1.
3. Write the end conditions on M
i
(x) in natural cubic splines.
Solution The required conditions are M
0
(x) = 0, M
n
(x) = 0.
EXERCISE 2.3
Are the following functions cubic splines?
1. f(x) = x
3
2x + 3, 0 x 1,
= 2x
3
3x
2
+ x + 2, 1 x 2.
2. f(x) = 5x
3
3x
2
+ 1, 0 x 1,
= 2x
3
+ 6x
2
9x + 4, 1 x 2.
INTERPOLATION AND APPROXIMATION 107
3. f(x) = 3x
2
+ x + 1, 0 x 1,
= 3x
2
5x + 1, 1 < x 2.
4. f(x) = x
3
3x
2
+ 1, 0 x 1,
= x
3
2, 1 x 2.
5. Find the values of , such that the given function is a cubic spline.
f(x) = x
3
+ x
2
+ 2x, 1 x 0.
= 3x
3
+ x
2
+ 2x, 0 x 1.
6. Obtain the cubic spline approximation valid in the interval [3, 4], for the function given
in the tabular form, under the natural cubic spline conditions
f (1) = M(1) = 0, and f (4) = M(4) = 0.
x 1 2 3 4
f(x) 3 10 29 65
7. Obtain the cubic spline approximation valid in the interval [1, 2], for the function given
in the tabular form, under the natural cubic spline conditions f (0) = M(0) = 0, and f (3)
= M(3) = 0. Hence, interpolate at x = 1.5.
x 0 1 2 3
f(x) 1 4 10 8
8. Fit the following four points by the cubic spline using natural spline conditions
M(1) = 0, M(4) = 0.
x 1 2 3 4
f(x) 1 5 11 8
Hence, estimate f(1.5).
9. Fit the following four points by the cubic spline using natural spline conditions
M(1) = 0, M(4) = 0.
x 1 2 3 4
f(x) 0 1 0 0
10. The following values of x and y are given
x 1 2 3 4
f(x) 1 2 5 11
Find the cubic splines and evaluate y(1.5). (A.U. Nov/Dec 2004)
108 NUMERICAL METHODS
# )59-45 ), 0165
Exercise 2.1
1. (3x x
2
)/2; 1. 2. 8x
2
19x + 12.
3. (x
3
5x
2
+ 8x 2)/2. 4. (3x
3
70x
2
+ 557x 690)/60; 44/3.
5. x
3
+ x
2
x + 2; 35. 6. (x
3
9x
2
+ 32x 24)/2; 6.
7. Profit in the year 2000 = 100. 8. 49.2819.
9. x
3
+ x
2
; 810. 10. 10x
3
27x
2
+ 3x + 35; 71.
11. 2x
3
4x
2
+ 4x + 1; 31.
12. (x
2
200x + 6060)/32. Roots of f(x) = 0 are x = 162.7694 and x = 37.2306.
13. For f(x) = x
n+1
, f
n+1
() = (n + 1) !. 15. [x
2
x
3
(x
1
+ x
4
) + x
1
x
4
(x
2
+ x
3
)]/[x
1
2
x
2
2
x
3
2
x
4
2
].
16. ( 1)
n
/(x
0
x
1
... x
n
). 17. x
3
9x
2
+ 21x + 1; 10.
18. (3x
3
70x
2
+ 557x 690); 44/3. 19. 3x
3
+ 7x
2
4x 32; 99.
20. x
3
x
2
; 448. 21. 0.5118199.
22. 10x
3
27x
2
+ 3x + 35; 71.
Exercise 2.2
2. ( x
3
+ 21x
2
126x + 240)/8; 1.25. 3. ( x
3
3x
2
+ 16x 6)/6 ; 1.3125.
4. 2x
3
7x
2
+ 6x + 1; 41. 5. x
2
+ 2x 3.
6. P(70) 424. Number of persons with wages between 60 and 70 = (Persons with wages
70) (Persons with wages 60) = 424 370 = 54.
7. 0.31815664. 8. (x
3
+ 13x
2
+ 56x + 28)/2; 100.
9. 9.5037. 10. 0.0708.
11. (a) [cos (0.12)/0.12] = 8.5534, cos (0.12) = 1.0264. (b) 0.9912. Exact value = 0.9928.
Differences in (b) decrease very fast. Hence, results from (b) will be more accurate.
Exercise 2.3
1. Cubic spline. 2. Cubic spline.
3. f(x) is not continuous. Not a cubic spline.
4. f(x) is not continuous. Not a cubic spline.
5. f(x) is a cubic spline for = 1 and all values of .
6. M
2
= 112/5, M
1
= 62/5. Spline in [3, 4]: ( 112x
3
+ 1344x
2
4184x + 4350)/30.
7. M
2
= 14, M
1
= 8. Spline in [1, 2] : ( 22x
3
+ 90x
2
80x + 36)/6; 7.375.
8. M
2
= 76/5, M
1
= 34/5. Spline in [1, 2]: (17x
3
51x
2
+ 94x 45)/15; 2.575.
9. M
2
= 12/5, M
1
= 18/5. Spline in [1, 2]: ( 3x
3
+ 9x
2
x 5)/5. Spline in [2, 3]:
(30x
3
234x
2
+ 570x 414)/30. Spline in [3, 4]: 2( x
3
+ 12x
2
47x + 60)/5.
10. M
2
= 4, M
1
= 2. Spline in [1, 2]: (x
3
3x
2
+ 5x)/3; 1.375.
109
!
Numerical Differentiation
and ntegration
3.1 NTRODUCTON
We assume that a function f(x) is given in a tabular form at a set of n + 1 distinct points x
0
, x
1
,
..., x
n
. From the given tabular data, we require approximations to the derivatives f
(r)
(x), r 1,
where x may be a tabular or a non-tabular point. We consider the cases r = 1, 2.
In many applications of Science and engineering, we require to compute the value of the
definite integral
a
b
f x dx
2
0
2
2
f
h !
+ ...
+ (x x
0
)(x x
1
)...(x x
n1
)
n
n
f
n h
0
!
. (3.1)
Set x = x
0
+ sh. Now, (3.1) becomes
f(x) = f(x
0
+ sh)
= f(x
0
) + sf
0
+
1
2!
s(s 1)
2
f
0
+
1
3!
s(s 1)(s 2)
3
f
0
+
1
4 !
s(s 1)(s 2)(s 3)
4
f
0
+
1
5!
s(s 1)(s 2)(s 3)(s 4)
5
f
0
+ ...
+
s s s s n
n
( )( ) ... ( )
!
+ 1 2 1
n
f
0
. (3.2)
Note that s = [x x
0
]/h > 0.
The magnitudes of the successive terms on the right hand side become smaller and
smaller.
Differentiating (3.2) with respect to x, we get
df
dx
df
ds
ds
dx h
df
ds
= =
1
=
1 1
2
2 1
1
6
3 6 2
1
24
4 18 22 6
0
2
0
2 3
0
3 2 4
0
h
f s f s s f s s s f + + + + +
( ) ( ) ( )
+ + + +
1
120
5 40 105 100 24
4 3 2 5
0
( ) ... s s s s f
(3.3)
At x = x
0
, that is, at s = 0, we obtain the approximation to the derivative f (x) as
f (x
0
) =
1 1
2
1
3
1
4
1
5
0
2
0
3
0
4
0
5
0
h
f f f f f + +
...
(3.4)
Differentiating (3.3) with respect to x, we get
d f
dx h
d
ds
df
ds
ds
dx h
d
ds
df
ds
2
2 2
1 1
=
=
1 1
6
6 6
1
24
12 36 22
2
2
0
3
0
2 4
0
h
f s f s s f + + +
( ) ( )
+
1
120
20 120 210 100
3 2 5
0
( ) ... s s s f + +
(3.5)
NUMERICAL DIFFERENTIATION AND INTEGRATION 111
At x = x
0
, that is, at s = 0, we obtain the approximation to the derivative f (x) as
f (x
0
) =
1 11
12
5
6
137
180
2
2
0
3
0
4
0
5
0
6
0
h
f f f f f + +
... . (3.6)
We use formulas (3.3) and (3.5) when the entire data is to be used.
Very often, we may require only lower order approximations to the derivatives. Taking
a few terms in (3.4), we get the following approximations.
Taking one term in (3.4), we get
f (x
0
) =
1
h
f
0
=
1
h
[f(x
1
) f(x
0
)],
or, in general, f (x
k
) =
1
h
f
k
=
1
h
[f(x
k+1
) f(x
k
)]. (3.7)
Taking two terms in (3.4), we get
f (x
0
) =
1 1
2
1 1
2
2
0
2
0 1 0 2 1 0
h
f f
h
f x f x f x f x f x
= +
{ ( ) ( )} { ( ) ( ) ( )}
=
1
2
3 4
0 1 2
h
f x f x f x [ ( ) ( ) ( )] + (3.8)
or, in general, f (x
k
) =
1
2h
[ 3f(x
k
) + 4f(x
k+1
) f(x
k+2
)]. (3.9)
Similarly, we have the approximation for f (x
0
) as
f (x
0
) =
1 1
2
2
2
0
2
2 1 0
h
f
h
f x f x f x = + [ ( ) ( ) ( )]
or, in general, f (x
k
) =
1
2
2
2 1
h
f x f x f x
k k k
[ ( ) ( ) ( )]
+ +
+ . (3.10)
Errors of approximations. Using Taylor series approximations, we obtain the error in the
formula (3.7) for f (x) at x = x
k
as
E(f, x
k
) = f (x
k
)
1
h
f x h f x
k k
[ ( ) ( )] +
= f (x
k
)
1
2
2
h
f x hf x
h
f x f x
k k k k
{ ( ) ( ) ( ) ...} ( ) + + +
=
h
f x
k
2
( ) + ... (3.11)
The error is of order O(h), or the formula is of first order.
The error in the formula (3.8) for f (x) at x = x
k
is obtained as
E(f, x
k
) = f (x
k
)
1
2h
[ 3 f(x
k
) + 4f(x
k+1
) f(x
k+2
)]
112 NUMERICAL METHODS
= + + + + +
f x
h
f x f x hf x
h
f x
h
f x
k k k k k k
( ) ( ) ( ) ( ) ( ) ( ) ...
1
2
3 4
2 6
2 3
f x hf x
h
f x
h
f x
k k k k
( ) ( )
( )
( )
( )
( ) ... + + + +
2
2
2
2
6
2 3
=
h
f x
k
2
3
( ) + ... (3.12)
The error is of order O(h
2
), or the formula is of second order.
The error in the formula (3.9) for f (x) at x = x
k
is obtained as
E(f, x
k
) = f (x
k
)
1
2
h
[f(x
k
+ 2h) 2 f(x
k
+ h) + f(x
k
)]
= f (x
k
)
1
2
h
f x hf x
h
f x
h
f x
k k k k
( ) ( )
( )
( )
( )
( ) ... + + + +
2
2
2
2
6
2 3
2 f x hf x
h
f x
h
f x f x
k k k k k
( ) ( ) ( ) ( ) ... ( ) + + + +
2 3
2 6
= h f (x
k
) + ... (3.13)
The error is of order O(h), or the formula is of first order.
Remark 1 It can be noted that on the right hand side of the approximation to f (x), we have
the multiplying factor 1/h, and on the right hand side of the approximation to f (x), we have
the multiplying factor 1/h
2
. Since h is small, this implies that we may be multiplying by a
large number. For example, if h = 0.01, the multiplying factor on the right hand side of the
approximation to f (x) is 100, while the multiplying factor on the right hand side of the
approximation to f (x) is 10000. Therefore, the round-off errors in the values of f(x) and hence
in the forward differences, when multiplied by these multiplying factors may seriously effect
the solution and the numerical process may become unstable. This is one of the drawbacks of
numerical differentiation.
Remark 2 Numerical differentiation must be done with care. When a data is given, we do not
know whether it represents a continuous function or a piecewise continuous function. It is
possible that the function may not be differentiable at some points in its domain. What happens
if we try to find the derivatives at these points where the function is not differentiable? For
example, if f(x) = | x |, and a data is prepared in the interval [ 1, 1], what value do we get
when we try to find f (x) at x = 0, where the function is not differentiable?
Remark 3 We use the forward difference formulas for derivatives, when we need the values
of the derivatives at points near the top of the table of the values.
NUMERICAL DIFFERENTIATION AND INTEGRATION 113
Example 3.1 Find dy/dx at x = 1 from the following table of values
x 1 2 3 4
y 1 8 27 64
Solution We have the following forward difference table.
Forward difference table. Example 3.1.
x y y
2
y
3
y
1 1
7
2 8 12
19 6
3 27 18
37
4 64
We have h = 1, x
0
= 1, and x = x
0
+ sh = 1 + s. For x = 1, we get s = 0.
Therefore,
dy
dx h
f f f ( ) 1
1 1
2
1
3
0
2
0
3
0
= +
= 7
1
2
12
1
3
6 3 ( ) ( ) . + =
Example 3.2 Using the operator relations, derive the approximations to the derivatives f (x
0
)
and f (x
0
) in terms of forward differences.
Solution From the operator relation E = e
hD
, where D = d/dx, we obtain
hDf(x
0
) = log E[ f(x
0
)] = log (1 + ) f(x
0
)
=
+ +
2 3 4 5
2 3 4 5
...
f(x
0
)
or f (x
0
) =
1 1
2
1
3
1
4
1
5
0
2
0
3
0
4
0
5
0
h
f f f f f + +
...
h
2
D
2
f(x
0
) = [log (1 + )]
2
f(x
0
)
=
+ +
2 3 4 5
2
2 3 4 5
... f(x
0
)
114 NUMERICAL METHODS
=
2 3 4 5 6
0
11
12
5
6
137
180
+ + +
... ( ) f x
or f (x
0
) =
1 11
12
5
6
137
180
2
2
0
3
0
4
0
5
0
6
0
h
f f f f f + +
...
Example 3.3 Find f (3) and f (3) for the following data:
x 3.0 3.2 3.4 3.6 3.8 4.0
f(x) 14 10.032 5.296 0.256 6.672 14
[A.U. April/May 2005]
Solution We have h = 0.2 and x = x
0
+ sh = 3.0 + s(0.2). For x = 3, we get s = 0.
We have the following difference table.
Forward difference table. Example 3.3.
x f(x) f
2
f
3
f
4
f
5
f
3.0 14
3.968
3.2 10.032 0.768
4.736 0.464
3.4 5.296 0.304 2.048
5.040 1.584 5.120
3.6 0.256 1.888 3.072
6.928 1.488
3.8 6.672 0.400
7.328
4.0 14
We have the following results:
f (x
0
) =
1 1
2
1
3
1
4
1
5
0
2
0
3
0
4
0
5
0
h
f f f f f + +
f (3.0) =
1
0 2
3968
1
2
0768
1
3
0 464
1
4
2 048
1
5
5 120
.
. ( . ) ( . ) ( . ) ( . ) + +
= 9.4667.
f (x
0
) =
1 11
12
5
6
2
2
0
3
0
4
0
5
0
h
f f f f +
f (3.0) =
1
0 04
0 768 0 464
11
12
2 048
5
6
5 12
.
. . ( . ) ( . ) + +
= 184.4
NUMERICAL DIFFERENTIATION AND INTEGRATION 115
Example 3.4 The following data represents the function f(x) = e
2x
. Using the forward differ-
ences and the entire data, compute the approximation to f(0.3). Also, find the first order and
second order approximations to f(0.3). Compute the approximation to f(0.3) using the entire
data and the first order approximation. Compute the magnitudes of actual errors in each case.
x 0.0 0.3 0.6 0.9 1.2
f (x) 1.0000 1.8221 3.3201 6.0496 11.0232
Solution The step length is h = 0.3 and x = x
0
+ sh = 0.0 + s(0.3). For x = 0.3, we get
s = 1. We have the following forward difference table.
Forward difference table. Example 3.4.
x f(x) f
2
f
3
f
4
f
0.0 1.0000
0.8221
0.3 1.8221 0.6759
1.4980 0.5556
0.6 3.3201 1.2315 0.4570
2.7295 1.0126
0.9 6.0496 2.2441
4.9736
1.2 11.0232
From (3.3), we have the following approximation for s = 1.
f (x
0
+ sh) = f (x
0
+ h) =
1 1
2
1
6
1
12
0
2
0
3
0
4
0
h
f f f f + +
f (0.3) =
1
03
08221
1
2
06759
1
6
05556
1
12
04570
.
. ( . ) ( . ) ( . ) + +
= 3.6851.
The first order approximation gives
f (0.3) =
1
h
f(0.3) =
1
0 3 .
[f (0.6) f(0.3)]
=
1
0 3 .
[3.3201 1.8221] =
14980
0 3
.
.
= 4.9933.
From (3.9), f (x
k
) =
1
2h
[ 3 f(x
k
) + 4 f(x
k+1
) f(x
k+2
)].
116 NUMERICAL METHODS
We get the second order approximation as
f (0.3) =
1
0 6 .
[ 3 f(0.3) + 4 f(0.6) f(0.9)]
=
1
0 6 .
[ 3(1.8221) + 4(3.3201) 6.0496] = 2.9408.
The exact value is f(0.3) = 2e
0.6
= 2(1.8221) = 3.6442.
The errors in the approximations are as follows:
First order approximation: | 4.9933 3.6442 | = 1.3491.
Second order approximation: | 2.9408 3.6442 | = 0.7034.
Full data: | 3.6851 3.6442 | = 0.0409.
From (3.5), we have the following approximation for s = 1.
f (x
0
+ sh) = f (x
0
+ h) =
1 1
12
2
2
0
4
0
h
f f
f (0.3) =
1
0 09
0 6759
1
12
0 4570 7 0869
.
. ( . ) .
= .
The first order approximation gives
f (0.3) =
1
2
h
2
f(0.3) =
1
2
h
[f(0.9) 2f(0.6) + f(0.3)]
=
1
009 .
[6.0496 2(3.3201) + 1.8221] = 13.6833.
The exact value is f (0.3) = 4e
0.6
= 7.2884
The errors in the approximations are as follows:
First order approximation: | 13.6833 7.2884 | = 6.3949.
Full data: | 7.0869 7.2884 | = 0.2015.
Example 3.5 The following data gives the velocity of a particle for 8 seconds at an interval of
2 seconds. Find the initial acceleration using the entire data.
Time (sec) 0 2 4 6 8
Velocity (m/sec) 0 172 1304 4356 10288
Solution If v is the velocity, then initial acceleration is given by
dv
dt
t
=0
.
We shall use the forward difference formula to compute the first derivative at t = 0. The
step length is h = 2.
We form the forward difference table for the given data.
NUMERICAL DIFFERENTIATION AND INTEGRATION 117
Forward difference table. Example 3.5.
x f(x) f
2
f
3
f
4
f
0 0
172
2 172 960
1132 960
4 1304 1920 0
3052 960
6 4356 2880
5932
8 10288
We have the following result:
f (x
0
) =
1 1
2
1
3
0
2
0
3
0
h
f f f +
...
f (0) =
1
2
172
1
2
960
1
3
960 +
( ) ( )
= 6.
3.2.1.2 Derivatives Using Newtons Backward Difference Formula
Consider the data (x
i
, f(x
i
)) given at equispaced points x
i
= x
0
+ ih, where h is the step length.
The Newtons backward difference formula is given by
f(x) = f(x
n
) + (x x
n
)
1
1! h
f(x
n
) + (x x
n
)(x x
n1
)
1
2
2
! h
2
f(x
n
) + ...
+ (x x
n
)(x x
n1
) ... (x x
1
)
1
n h
n
!
n
f(x
n
). (3.14)
Let x be any point near x
n
. Let x x
n
= sh. Then, the formula simplifies as
f(x) = f(x
n
+ sh) = f(x
n
) + sf(x
n
) +
s s ( )
!
+ 1
2
2
f(x
n
) +
s s s ( )( )
!
+ + 1 2
3
3
f(x
n
)
+
s s s s ( )( )( )
!
+ + + 1 2 3
4
4
f(x
n
) +
s s s s s ( )( )( )( )
!
+ + + + 1 2 3 4
5
5
f(x
n
) + ...
+
s s s s n
n
( )( ) ... ( )
!
+ + + 1 2 1
n
f(x
n
). (3.15)
Note that s = [(x x
n
)/h] < 0.
The magnitudes of the successive terms on the right hand side become smaller and
smaller.
118 NUMERICAL METHODS
Differentiating (3.15) with respect to x, we get
df
dx
df
ds
ds
dx h
df
ds
= =
1
=
1 1
2
2 1
1
6
3 6 2
1
24
4 18 22 6
2 2 3 3 2 4
h
f s f s s f s s s f
n n n n
+ + + + + + + + +
( ) ( ) ( )
+
1
120
5 40 105 100 24
4 3 2 5
( ) ... s s s s f
n
+ + + + +
. (3.16)
At x = x
n
, we get s = 0. Hence, we obtain the approximation to the first derivative f (x
n
) as
f (x
n
) =
1 1
2
1
3
1
4
1
5
2 3 4 5
h
f f f f f
n n n n n
+ + + + +
... . (3.17)
At x = x
n1
, we have x
n1
= x
n
h = x
n
+ sh. We obtain s = 1. Hence, the approximation to the
first derivative f (x
n1
) is given by
f (x
n1
) =
1 1
2
1
6
1
12
1
20
2 3 4 5
h
f f f f f
n n n n n
+
... . (3.18)
Differentiating (3.16) with respect to x again, we get
d f
dx h
d
ds
df
ds
ds
dx h
d
ds
df
ds
2
2 2
1 1
=
=
1 1
6
6 6
1
24
12 36 22
2
2 3 2 4
h
f s f s s f
n n n
+ + + + +
( ) ( )
+
1
120
20 120 210 100
3 2 5
( ) ... s s s f
n
+ + + +
. (3.19)
At x = x
n
, that is, at s = 0, we obtain the approximation to the second derivative f (x) as
f (x
n
) =
1 11
12
5
6
137
180
2
2 3 4 5 6
h
f f f f f
n n n n n
+ + + + +
... . (3.20)
At x = x
n1
, we get s = 1. Hence, we obtain the approximation to the second derivative
f (x
n1
) as
f (x
n1
) =
1 1
12
1
12
2
2 4 5
h
f f f
n n n
+
... . (3.21)
We use the formulas (3.17), (3.18), (3.20) and (3.21) when the entire data is to be used.
NUMERICAL DIFFERENTIATION AND INTEGRATION 119
Remark 4 We use the backward difference formulas for derivatives, when we need the values
of the derivatives near the end of table of values.
Example 3.6 Using the operator relation, derive approximations to the derivatives
f(x
n
), f(x
n
) in terms of the backward differences.
Solution From the operator relation E = e
hD
, where D = d/dx, we obtain
hDf(x
n
) = [log E] f(x
n
) = log [(1 )
1
] f(x
n
) = log (1 ) f(x
n
)
= +
+
+
+
+
2 3 4 5
2 3 4 5
... f(x
n
)
or f (x
n
) =
1 1
2
1
3
1
4
1
5
2 3 4 5
h
f f f f f
n n n n n
+ + + + +
...
h
2
D
2
f(x
n
) = [log (1 )]
2
f(x
n
) =
+
+
+
+
+
2 3 4 5
2
2 3 4 5
...
f(x
n
)
= + + + +
2 3 4 5
11
12
5
6
... ( ) f x
n
or f (x
n
) =
1 11
12
5
6
2
2 3 4 5
h
f f f f
n n n n
+ + + +
... .
Example 3.7 Find f (3) using the Newtons backward difference formula, for the data
x 1.0 1.5 2.0 2.5 3.0
f(x) 1.5 2.875 3.5 2.625 0.5
Solution The step length is h = 0.5 and x = x
n
+ sh = 3.0 + s(0.5). For x = 3.0, we get
s = 0. We have the following backward difference table.
Backward difference table. Example 3.7.
x f(x) f
2
f
3
f
4
f
1.0 1.5
1.375
1.5 2.875 0.75
0.625 0.75
2.0 3.5 1.5 0.0
0.875 0.75
2.5 2.625 2.25
3.125
3.0 0.5
120 NUMERICAL METHODS
From the formula
f (x
n
) =
1 1
2
1
3
1
4
1
5
2 3 4 5
h
f f f f f
n n n n n
+ + + + +
... ,
we obtain f (3) =
1
0 5 .
3 125
1
2
2 25
1
3
0 75 . ( . ) ( . ) + +
= 9.
Example 3.8 Find f (2.5), f (2) and f (2.5) using the Newtons backward difference method,
for the data of the function f(x) = e
x
+ 1.
x 1.0 1.5 2.0 2.5
f(x) 3.7183 5.4817 8.3891 13.1825
Find the magnitudes of the actual errors.
Solution The step length is h = 0.5 and x = x
n
+ sh = 2.5 + s(0.5). For x = 2.5, we get
s = 0. The backward difference table is given below.
Backward difference table. Example 3.8.
x f(x) f
2
f
3
f
1.0 3.7183
1.7634
1.5 5.4817 1.1440
2.9074 0.7420
2.0 8.3891 1.8860
4.7934
2.5 13.1825
From the formula
f (x
n
) =
1 1
2
1
3
1
4
1
5
2 3 4 5
h
f f f f f
n n n n n
+ + + + +
...
,
we obtain f (2.5) =
1
0 5
4 7934
1
2
18860
1
3
07420
.
. ( . ) ( . ) + +
= 11.9675.
The exact value is f (2.5) = e
2.5
= 12.1875. The magnitude of the error in the solution is
| Error | = | 12.1875 11.9675 | = 0.2150.
For x = 2.0, we get s = 1. From the formula
f (x
n1
) =
1 1
2
1
6
1
12
1
20
2 3 4 5
h
f f f f f
n n n n n
+
... ,
NUMERICAL DIFFERENTIATION AND INTEGRATION 121
we get f (2) =
1
0 5
1
2
1
6
2 3
.
f f f
n n n
=
1
0 5
4 7934
1
2
18860
1
6
0 7420
.
. ( . ) ( . )
= 7.4535.
The exact value is f (2) = e
2
= 7.3891. The magnitude of the error in the solution is
| Error | = | 7.3891 7.4535 | = 0.0644.
For x = 2.5, we get s = 0. From the formula
f (x
n
) =
1
2
h
+ + + +
2 3 4 5
11
12
5
6
f f f f
n n n n
...
,
we get f (2.5) =
1
0 25 .
[1.8660 + 0.7420] = 10.5120.
The exact value is f (2.5) = e
2.5
= 12.1875. The magnitude of the error in the solution is
| Error | = | 12.1875 10.5120 | = 1.6705.
Example 3.9 The following data represents the function f(x) = e
2x
.
x 0.0 0.3 0.6 0.9 1.2
f(x) 1.0000 1.8221 3.3201 6.0496 11.0232
Find f (1.2) f (0.9) and f (1.2), using the Newtons backward difference method.
Compute the magnitudes of the errors.
Solution The step length is h = 0.3. We have the following backward difference table.
Backward difference table. Example 3.9.
x f(x) f
2
f
3
f
4
f
0.0 1.0000
0.8221
0.3 1.8221 0.6759
1.4980 0.5556
0.6 3.3201 1.2315 0.4570
2.7295 1.0126
0.9 6.0496 2.2441
4.9736
1.2 11.0232
122 NUMERICAL METHODS
From x = x
n
+ sh = 1.2 + s(0.3), we get for x = 1.2, s = 0. Using the formula
f (x
n
) =
1 1
2
1
3
1
4
1
5
2 3 4 5
h
f f f f f
n n n n n
+ + + + +
... ,
we get f (1.2) =
1
0 3
4 9736
1
2
2 2441
1
3
10126
1
4
0 4570
.
. ( . ) ( . ) ( . ) + + +
= 21.8248.
The exact value is f (1.2) = 2e
2.4
= 22.0464.
The magnitude of the error is
| Error | = | 22.0464 21.8248 | = 0.2216.
From x = x
n
+ sh = 1.2 + s(0.3), we get for x = 0.9, s = 1. Using the formula
f (x
n1
) =
1 1
2
1
6
1
12
1
20
2 3 4 5
h
f f f f f
n n n n n
+
...
,
we get f (0.9) =
1
0 3
4 9736
1
2
2 2441
1
6
10126
1
12
0 4570
.
. ( . ) ( . ) ( . )
= 12.1490.
The exact value is f (0.9) = 2e
1.8
= 12.0993.
The magnitude of the error is
| Error | = | 12.0993 12.1490 | = 0.0497.
From x = x
n
+ sh = 1.2 + s(0.3), we get for x = 1.2, s = 0. Using the formula
f (x
n
) =
1
2
h
+ + + +
2 3 4 5
11
12
5
6
f f f f
n n n n
...
,
we get f (1.2) =
1
0 09
2 2441 10126
11
12
0 4570
.
. . ( . ) + +
= 40.8402.
The exact value is f (1.2) = 4e
2.4
= 44.0927.
The magnitude of the error is
| Error | = | 40.8402 44.0927 | = 3.2525.
3.2.1.3 Derivatives Using Divided Difference Formula
The divided difference interpolation polynomial fitting the data (x
i
, f(x
i
)), i = 0, 1, 2,, n is
given by
f(x) = f(x
0
) + (x x
0
) f [x
0
, x
1
] + (x x
0
)(x x
1
) f [x
0
, x
1
, x
2
] + ...
+ (x x
0
)(x x
1
) (x x
2
) f [x
0
, x
1
, x
2
] + ...
+ (x x
0
)(x x
1
) ... (x x
n1
) f [x
0
, x
1
,... x
n
] (3.22)
NUMERICAL DIFFERENTIATION AND INTEGRATION 123
Differentiating with respect to x, we get
f (x) = f [x
0
, x
1
] + [(x x
0
) + (x x
1
)] f [x
0
, x
1
, x
2
] + [(x x
1
)(x x
2
) + (x x
0
)(x x
2
)
+ (x x
0
)(x x
1
)] f [x
0
, x
1
, x
2
, x
3
] + [(x x
1
)(x x
2
)(x x
3
) + (x x
0
)(x x
2
)(x x
3
)
+ (x x
0
)(x x
1
) (x x
3
) + (x x
0
)(x x
1
)(x x
2
)] f [x
0
, x
1
, x
2
, x
3
, x
4
] + ... (3.23)
If the derivative f (x) is required at any particular point x = x
*
, then we substitute x = x
*
in (3.23). If the data is equispaced, then the formula is simplified.
Differentiating (3.23) again, we obtain
f (x) = 2f [x
0
, x
1
, x
2
] + 2[(x x
0
) + (x x
1
) + (x x
2
)] f [x
0
, x
1
, x
2
, x
3
]
+ 2[(x x
0
)(x x
1
) + (x x
0
)(x x
2
) + (x x
0
)(x x
3
) + (x x
1
)(x x
2
)
+ (x x
1
)(x x
3
) + (x x
2
)(x x
3
)] f [x
0
, x
1
, x
2
, x
3
, x
4
] + ... (3.24)
If the second derivative f (x) is required at any point x = x
*
, then we substitute x = x
*
in
(3.24). Again, if the data is equispaced, then the formula is simplified.
However, we can also determine the Newtons divided differences interpolation polyno-
mial and differentiate it to obtain f (x) and f (x).
Example 3.10 Find the first and second derivatives at x = 1.6, for the function represented by
the following tabular data:
x 1.0 1.5 2.0 3.0
f(x) 0.0 0.40547 0.69315 1.09861
[A.U. Nov./Dec. 2005]
Solution The data is not equispaced. We use the divided difference formulas to find the
derivatives. We have the following difference table:
Divided differences table. Example 3.10.
x f(x) First d.d Second d.d Third d.d
1.0 0.00000
0.81094
1.5 0.40547 0.235580
0.57536 0.061157
2.0 0.69315 0.113267
0.40546
3.0 1.09861
Substituting x = 1.6 in the formula
f (x) = f [x
0
, x
1
] + [(x x
0
) + (x x
1
)] f [x
0
, x
1
, x
2
] + [(x x
1
)(x x
2
) + (x x
0
)(x x
2
)
+ (x x
0
)(x x
1
)] f [x
0
, x
1
, x
2
, x
3
]
124 NUMERICAL METHODS
we obtain f (1.6) = 0.81094 + [(1.6 1.0) + (1.6 1.5)] ( 0.23558) + [(1.6 1.5)(1.6 2.0)
+ (1.6 1.0)(1.6 2.0) + (1.6 1.0)(1.6 1.5)] (0.061157)
= 0.81094 + 0.7 ( 0.23558) 0.22(0.061157) = 0.63258.
Substituting x = 1.6 in the formula
f (x) = 2 f [x
0
, x
1
, x
2
] + 2[(x x
0
) + (x x
1
) + (x x
2
)] f [x
0
, x
1
, x
2
, x
3
]
we obtain f (1.6) = 2( 0.23558) + 2[(1.6 1.0) + (1.6 1.5) + (1.6 2.0)](0.061157)
= 0.47116 + 0.03669 = 0.43447.
Remark 5 Often, in applications, we require the maximum and/ or minimum of a function
given as a tabulated data. We may obtain the interpolation polynomial, differentiate it and
set it equal to zero to find the stationary points. Alternatively, we can use the numerical
differentiation formula for finding the first derivative, set it equal to zero to find the station-
ary points. The numerical values obtained for the second derivatives at these stationary points
decides whether there is a maximum or a minimum at these points.
REVIEW QUESTIONS
1. What are the drawbacks of numerical differentiation?
Solution Numerical differentiation has two main drawbacks. (i) On the right hand
side of the approximation to f (x), we have the multiplying factor 1/h, and on the right
hand side of the approximation to f (x), we have the multiplying factor 1/h
2
. Since h is
small, this implies that we may be multiplying by a large number. For example, if
h = 0.01, the multiplying factor on the right hand side of the approximation to f (x) is
100, while the multiplying factor on the right hand side of the approximation to f (x) is
10000. Therefore, the round-off errors in the values of f(x) and hence in the forward
differences, when multiplied by these multiplying factors may seriously effect the solu-
tion and the numerical process may become unstable. (ii) When a data is given, we do
not know whether it represents a continuous function or a piecewise continuous func-
tion. It is possible that the function may not be differentiable at some points in its
domain. If we try to find the derivatives at these points where the function is not differ-
entiable, the result is unpredictable.
2. Given the data (x
i
, f(x
i
)), i = 0, 1, 2,, n at equispaced points x
i
= x
0
+ ih where h is the
step length, write the formula to compute f (x
0
), using the Newtons forward difference
formula.
Solution In terms of the forward differences, we have the formula
f (x
0
) =
1 1
2
1
3
1
4
1
5
0
2
0
3
0
4
0
5
0
h
f f f f f + +
... .
3. Given the data (x
i
, f(x
i
)), i = 0, 1, 2,, n at equispaced points x
i
= x
0
+ ih, where h is the
step length, write the formula to compute f (x
0
), using the Newtons forward difference
formula.
NUMERICAL DIFFERENTIATION AND INTEGRATION 125
Solution In terms of the forward differences, we have the formula
f (x
0
) =
1 11
12
5
6
137
180
2
2
0
3
0
4
0
5
0
6
0
h
f f f f f + +
... .
4. Given the data (x
i
, f(x
i
)), i = 0, 1, 2,, n at equispaced points x
i
= x
0
+ ih, where h is the
step length, write the formula to compute f (x
n
) using the Newtons backward differ-
ence formula.
Solution In terms of the backward differences, we have the formula
f (x
n
) =
1 1
2
1
3
1
4
1
5
2 3 4 5
h
f f f f f
n n n n n
+ + + + +
... .
5. Given the data (x
i
, f(x
i
)), i = 0, 1, 2,, n at equispaced points x
i
= x
0
+ ih, where h is the
step length, write the formula to compute f (x
n1
), using the Newtons backward differ-
ence formula.
Solution In terms of the backward differences, we have the formula
f (x
n1
) =
1 1
2
1
6
1
12
1
20
2 3 4 5
h
f f f f f
n n n n n
+
... .
6. Given the data (x
i
, f(x
i
)), i = 0, 1, 2,, n at equispaced points ,
0
ih x x
i
+ = where h is
the step length, write the formula to compute f (x
n
), using the Newtons backward
difference formula.
Solution In terms of the backward differences, we have the formula
f (x
n
) =
1 11
12
5
6
137
180
2
2 3 4 5 6
h
f f f f f
n n n n n
+ + + + +
... .
7. What is the error in the following approximation?
f (x
k
) =
1
h
[f(x
k+1
) f(x
k
)].
Solution Using the Taylor series expansion of f(x
k+1
), we get the error of approxima-
tion as
E(f, x
k
) = f (x
k
)
1
h
[f(x
k
+ h) f(x
k
)] =
h
2
f (x
k
) + ...
8. What is the error in the following approximation?
f (x
k
) =
1
2h
[ 3 f(x
k
) + 4f(x
k+1
) f(x
k+2
)].
Solution Using the Taylor series expansion of f(x
k+1
) and f(x
k+2
), we get the error of
approximation as
E(f, x
k
) = f (x
k
)
1
2h
[ 3 f(x
k
) + 4f(x
k+1
) f(x
k+2
)] =
h
f x
k
2
3
( ) + ...
126 NUMERICAL METHODS
EXERCISE 3.1
1. The following data gives the velocity of a particle for 20 seconds at an interval of 5
seconds. Find the initial acceleration using the entire data.
Time (sec) 0 5 10 15 20
Velocity (m/sec) 0 3 14 69 228
(A.U. April/May 2004)
2. Compute f (0) and f (4) from the data
x 0 1 2 3 4
y 1 2.718 7.381 20.086 54.598
(A.U. May 2000)
3. Find the maximum and minimum values of y tabulated below.
x 2 1 0 1 2 3 4
y 1 0.25 0 0.25 2 15.75 56
4. Find the value of x for which f(x) is maximum in the range of x given, using the follow-
ing table. Find also the maximum value of f(x).
x 9 10 11 12 13 14
y 1330 1340 1320 1250 1120 930
(A.U. Nov./Dec. 2004)
5. For the given data
x 1.0 1.1 1.2 1.3 1.4 1.5 1.6
y 7.989 8.403 8.781 9.129 9.451 9.750 10.031
find dy/dx, d
2
y/dx
2
at 1.1. (A.U. Nov./Dec. 2003)
6. The first derivative at a point x
k
, is approximated by
f(x
k
) = [f(x
k
+ h) f(x
k
h)]/(2h).
Find the error term using the Taylor series.
7. From the following table
x 1.0 1.2 1.4 1.6 1.8 2.0 2.2
y 2.7183 3.3201 4.0552 4.9530 6.0496 7.3891 9.0250
obtain dy/dx, d
2
y/dx
2
at x = 1.2. (A.U. Nov./Dec. 2006)
NUMERICAL DIFFERENTIATION AND INTEGRATION 127
8. Obtain the value of f (0.04) using an approximate formula for the given data
x 0.01 0.02 0.03 0.04 0.05 0.06
y 0.1023 0.1047 0.1071 0.1096 0.1122 0.1148
(A.U. Nov./Dec. 2003)
9. Find the value of sec 31
w(x) f(x) dx =
k
n
=
0
k
f(x
k
)
=
0
f(x
0
) +
1
f(x
1
) +
2
f(x
2
) + ... +
n
f(x
n
). (3.26)
The tabulated points x
k
s are called abscissas, f(x
k
)s are called the ordinates and
k
s
are called the weights of the integration rule or quadrature formula (3.26).
We define the error of approximation for a given method as
R
n
(f) =
a
b
w(x) f(x) dx
k
n
=
0
k
f(x
k
). (3.27)
Order of a method An integration method of the form (3.26) is said to be of order p, if it
produces exact results, that is R
n
= 0, for all polynomials of degree less than or equal to p. That
is, it produces exact results for f(x) = 1, x, x
2
, ...., x
p
. This implies that
R
n
(x
m
) =
a
b
w(x) x
m
dx
k
n
=
0
k
x
k
m
= 0, for m = 0, 1, 2, , p.
The error term is obtained for f(x) = x
p+1
. We define
c =
a
b
w(x) x
p+1
dx
k
n
=
0
k
x
k
p+1
(3.28)
where c is called the error constant. Then, the error term is given by
NUMERICAL DIFFERENTIATION AND INTEGRATION 129
R
n
(f) =
a
b
w(x) f(x) dx
k
n
=
0
k
f(x
k
)
=
c
p ( ) ! + 1
f
(p+1)
(), a < < b. (3.29)
The bound for the error term is given by
| R
n
(f) |
| |
( ) !
max | ( )
( )
c
p
f x
a x b
p
+
+
1
1
. (3.30)
If R
n
(x
p+1
) also becomes zero, then the error term is obtained for f(x) = x
p+2
.
3.3.2 Integration Rules Based on Uniform Mesh Spacing
When w(x) = 1 and the nodes x
k
s are prescribed and are equispaced with x
0
= a, x
n
= b, where
h = (b a)/n, the methods (3.26) are called Newton-Cotes integration rules. The weights
k
s
are called Cotes numbers.
We shall now derive some Newton-Cotes formulas. That is, we derive formulas of the
form
I =
a
b
f(x) dx =
k
n
=
0
k
f(x
k
)
=
0
f(x
0
) +
1
f(x
1
) +
2
f(x
2
) + ... +
n
f(x
n
). (3.31)
We note that,
a
b
f(x) dx defines the area under the curve y = f(x), above the x-axis,
between the lines x = a, x = b.
3.3.2.1 Trapezium Rule
This rule is also called the trapezoidal rule. Let the curve
y = f(x), a x b, be approximated by the line joining the
points P(a, f(a)), Q(b, f(b)) on the curve (see Fig. 3.1).
Using the Newtons forward difference formula, the
linear polynomial approximation to f(x), interpolating at
the points P(a, f(a)), Q(b, f(b)), is given by
f(x) = f(x
0
) +
1
h
(x x
0
) f(x
0
) (3.32)
where x
0
= a, x
1
= b and h = b a. Substituting in (3.31),
we obtain
I =
a
b
x
x
x
x
x
x
f x dx f x dx f x dx
h
x x dx f
= = +
( ) ( ) ( ) ( )
0
1
0
1
0
1
0 0 0
1
= (x
1
x
0
) f(x
0
) +
1 1
2
0
2
0
0
1
h
x x f
x
x
( )
y
O
x
Q
P
a b
Fig. 3.1. Trapezium rule.
130 NUMERICAL METHODS
= (x
1
x
0
) f(x
0
) +
1
2h
[f(x
1
) f(x
0
)](x
1
x
0
)
2
= hf(x
0
) +
h
2
[f(x
1
) f(x
0
)]
=
h
2
[f(x
1
) + f(x
0
)] =
( ) b a
2
[f(b) + f(a)].
The trapezium rule is given by
I =
a
b
f(x) dx =
h
2
[f(x
1
) + f(x
0
)] =
( ) b a
2
[f(b) + f(a)]. (3.33)
Remark 6 Geometrically, the right hand side of the trapezium rule is the area of the trap-
ezoid with width b a, and ordinates f(a) and f(b), which is an approximation to the area
under the curve y = f(x) above the x-axis and the ordinates x = a and x = b.
Error term in trapezium rule We show that the trapezium rule integrates exactly polyno-
mial of degree
. 1
That is, using the definition of error given in (3.27), we show that
R
1
(f, x) = 0 for f(x) = 1, x.
Substituting f(x) = 1, x in (3.27), we get
f(x) = 1: R
1
(f, x) =
a
b
dx
( ) b a
2
(2) = (b a) (b a) = 0.
f(x) = x: R
1
(f, x) =
a
b
x dx
( ) b a
2
(b + a) =
1
2
(b
2
a
2
)
1
2
(b
2
a
2
) = 0.
Hence, the trapezium rule integrates exactly polynomial of degree 1, and the method
is of order 1.
Let f(x) = x
2
. From (3.28), we get
c =
a
b
x
2
dx
( ) b a
2
(b
2
+ a
2
) =
1
3
(b a)
3
1
2
(b
3
+ a
2
b ab
2
a
3
)
=
1
6
(a
3
3a
2
b + 3ab
2
b
3
) =
1
6
(b a)
3
.
Using (3.29), the expression for the error is given by
R
1
(f, x) =
c
2!
f () =
( )
( ) ( )
b a
f
h
f
=
3 3
12 12
(3.34)
where a b.
The bound for the error is given by
| R
1
(f, x) |
( )
, max | ( )|
b a
M
h
M M f x
a x b
= =
3
2
3
2 2
12 12
where . (3.35)
NUMERICAL DIFFERENTIATION AND INTEGRATION 131
If the length of the interval [a, b] is large, then b a is also large and the error expres-
sion given (3.35) becomes meaningless. In this case, we subdivide [a, b] into a number of
subintervals of equal length and apply the trapezium rule to evaluate each integral. The rule
is then called the composite trapezium rule.
Composite trapezium rule Let the interval [a, b] be subdivided into N equal parts of length h.
That is, h = (b a)/N. The nodal points are given by
a = x
0
, x
1
= x
0
+ h, x
2
= x
0
+ 2h, ..., x
N
= x
0
+ Nh = b.
We write
a
b
x
x
x
x
x
x
x
x
f x dx f x dx f x dx f x dx f x dx
N
N
N
= = + + +
( ) ( ) ( ) ( ) ... ( )
0 0
1
1
2
1
.
There are N integrals. Using the trapezoidal rule to evaluate each integral, we get the
composite trapezoidal rule as
a
b
f x dx
h
= ( )
2
[{f(x
0
) + f(x
1
)} + {f(x
1
) + f(x
2
)} + ... + {f(x
N1
) + f(x
N
)}]
=
h
2
[f(x
0
) + 2{f(x
1
) + f(x
2
) + ... + f(x
N1
)} + f(x
N
)]. (3.36)
The composite trapezium rule is also of order 1.
The error expression (3.34) becomes
R
1
(f, x) =
h
f f f x x
N N N N
3
1 2 1
12
[ ( ) ( ) ... ( )], . + + + < <
(3.37)
The bound on the error is given by
| R
1
(f, x) |
h
f f f
N
3
1 2
12
[| ( )| | ( )| ... | ( )|] + + +
Nh
M
b a h
M
3
2
2
2
12 12
=
( )
(3.38)
or | R
1
(f, x) |
( ) b a
N
M
3
2
2
12
where M
2
= max | ( )|
a x b
f x
and Nh = b a.
This expression is a true representation of the error in the trapezium rule. As we increase
the number of intervals, the error decrases.
Remark 7 Geometrically, the right hand side of the composite trapezium rule is the sum of
areas of the N trapezoids with width h, and ordinates f(x
i1
) and f(x
i
), i = 1, 2, ...., N. This sum
is an approximation to the area under the curve y = f(x) above the x-axis and the ordinates
x = a and x = b.
132 NUMERICAL METHODS
Remark 8 We have noted that the trapezium rule and the composite trapezium rule are of
order 1. This can be verified from the error expressions given in (3.34) and (3.37). If f(x) is a
polynomial of degree 1, then f (x) = 0. This result implies that error is zero and the trape-
zium rule produces exact results for polynomials of degree 1.
Example 3.11 Derive the trapezium rule using the Lagrange linear interpolating polynomial.
Solution The points on the curve are P(a, f(a)), Q(b, f(b)) (see Fig. 3.1). Lagrange linear inter-
polation gives
f(x) =
( )
( )
( )
( )
( )
( )
x b
a b
f a
x a
b a
f b
=
1
( ) b a
[{f(b) f(a)} x + {bf(a) af(b)}].
Substituting in the integral, we get
I =
a
b
a
b
f x dx
b a
f b f a x bf a af b dx
=
+ ( )
( )
[{ ( ) ( )} { ( ) ( )}]
1
=
1 1
2
2 2
( )
{ ( ) ( )} ( ) { ( ) ( )}( )
b a
f b f a b a bf a af b b a
=
1
2
(b + a)[ f(b) f(a)] + bf(a) af(b)
=
( ) b a
2
[f(a) + f(b)]
which is the required trapezium rule.
Example 3.12 Find the approximate value of I =
0
1
1
+
dx
x
, using the trapezium rule with 2, 4
and 8 equal subintervals. Using the exact solution, find the absolute errors.
Solution With N = 2, 4 and 8, we have the following step lengths and nodal points.
N = 2: h =
b a
N
=
1
2
. The nodes are 0, 0.5, 1.0.
N = 4: h =
b a
N
=
1
4
. The nodes are 0, 0.25, 0.5, 0.75, 1.0.
N = 8: h =
b a
N
=
1
8
. The nodes are 0, 0.125, 0.25, 0.375, 0.5, 0.675, 0.75, 0.875, 1.0.
NUMERICAL DIFFERENTIATION AND INTEGRATION 133
We have the following tables of values.
N = 2: x 0 0.5 1.0
f(x) 1.0 0.666667 0.5
N = 4: We require the above values. The additional values required are the following:
x 0.25 0.75
f (x) 0.8 0.571429
N = 8: We require the above values. The additional values required are the following:
x 0.125 0.375 0.625 0.875
f (x) 0.888889 0.727273 0.615385 0.533333
Now, we compute the value of the integral.
N = 2: I
1
=
h
2
[f(0) + 2f(0.5) + f(1.0)]
= 0.25 [1.0 + 2(0.666667) + 0.5] = 0.708334.
N = 4: I
2
=
h
2
[f(0) + 2{f(0.25) + f(0.5) + f(0.75)} + f(1.0)]
= 0.125 [1.0 + 2 {0.8 + 0.666667 + 0.571429} + 0.5] = 0.697024.
N = 8: I
3
=
h
2
[f(0) + 2{f(0.125) + f(0.25) + f(0.375) + f(0.5)
+ f(0.625) + f(0.75) + f(0.875)} + f(1.0)]
= 0.0625[1.0 + 2{0.888889 + 0.8 + 0.727273 + 0.666667 + 0.615385
+ 0.571429 + 0.533333} + 0.5] = 0.694122.
The exact value of the integral is I = ln 2 = 0.693147.
The errors in the solutions are the following:
| Exact I
1
| = | 0.693147 0.708334 | = 0.015187
| Exact I
2
| = | 0.693147 0.697024 | = 0.003877
| Exact I
3
| = | 0.693147 0.694122 | = 0.000975.
Example 3.13 Evaluate I =
1
2
5 3
+
dx
x
with 4 and 8 subintervals using the trapezium rule.
Compare with the exact solution and find the absolute errors in the solutions. Comment on the
magnitudes of the errors obtained. Find the bound on the errors.
Solution With N = 4 and 8, we have the following step lengths and nodal points.
N = 4: h =
b a
N
=
1
4
. The nodes are 1, 1.25, 1.5, 1.75, 2.0.
134 NUMERICAL METHODS
N = 8: h =
b a
N
=
1
8
. The nodes are 1, 1.125, 1.25, 1.375, 1.5, 1.675, 1.75, 1.875, 2.0.
We have the following tables of values.
N = 4: x 1.0 1.25 1.5 1.75 2.0
f (x) 0.125 0.11429 0.10526 0.09756 0.09091
N = 8: We require the above values. The additional values required are the following.
x 1.125 1.375 1.625 1.875
f(x) 0.11940 0.10959 0.10127 0.09412
Now, we compute the value of the integral.
N = 4: I
1
=
h
2
[f(1) + 2 {f(1.25) + f(1.5) + f(1.75)} + f(2.0)]
= 0.125 [0.125 + 2 {0.11429 + 0.10526 + 0.09756} + 0.09091]
= 0.10627.
N = 8: I
2
=
h
2
[f(1) + 2{f(1.125) + f(1.25) + f(1.375) + f(1.5)
+ f(1.625) + f(1.75) + f(1.875)} + f(2.0)]
= 0.0625 [0.125 + 2{0.11940 + 0.11429 + 0.10959 + 0.10526 + 0.10127
+ 0.09756 + 0.09412} + 0.09091]
= 0.10618.
The exact value of the integral is
I =
1
3
5 3
1
3
11 8 010615
1
2
ln ( ) [ln ln ] . +
= = x .
The errors in the solutions are the following:
| Exact I
1
| = | 0.10615 0.10627 | = 0.00012.
| Exact I
2
| = | 0.10615 0.10618 | = 0.00003.
We find that | Error in I
2
|
1
4
| Error in I
1
|.
Bounds for the errors
| Error |
( ) b a h
M
2
2
12
, where M
2
= max
[ , ] 1 2
| f (x) |.
We have f(x) =
1
5 3
3
5 3
18
5 3
2 3
+
=
+
=
+ x
f x
x
f x
x
, ( )
( )
, ( )
( )
.
NUMERICAL DIFFERENTIATION AND INTEGRATION 135
M
2
= max
( )
[ , ] 1 2
3
18
5 3
18
512 +
=
x
= 0.03516.
h = 0.25: | Error |
( . ) 0 25
12
2
(0.03516) = 0.00018.
h = 0.125: | Error |
( . ) 0 125
12
2
(0.03516) = 0.000046.
Actual errors are smaller than the bounds on the errors.
Example 3.14 Using the trapezium rule, evaluate the integral I =
0
1
2
6 10
+ +
dx
x x
, with 2 and
4 subintervals. Compare with the exact solution. Comment on the magnitudes of the errors
obtained.
Solution With N = 2 and 4, we have the following step lengths and nodal points.
N = 2: h = 0.5. The nodes are 0.0, 0.5, 1.0.
N = 4: h = 0.25. The nodes are 0.0, 0.25, 0.5, 0.75, 1.0.
We have the following tables of values.
N = 2: x 0.0 0.5 1.0
f (x) 0.1 0.07547 0.05882
N = 4: We require the above values. The additional values required are the following.
x 0.25 0.75
f (x) 0.08649 0.06639
Now, we compute the value of the integral.
N = 2: I
1
=
h
2
[f(0.0) + 2 f(0.5) + f(1.0)]
= 0.25 [0.1 + 2(0.07547) + 0.05882] = 0.07744.
N = 4: I
2
=
h
2
[f(0.0) + 2{f(0.25) + f(0.5) + f(0.75)} + f(1.0)]
= 0.125[0.1 + 2(0.08649 + 0.07547 + 0.06639) + 0.05882] = 0.07694.
The exact value of the integral is
I =
0
1
2
1
0
1
1 1
3 1
3 4 3 007677
+ +
= +
= =
dx
x
x
( )
tan ( ) tan ( ) tan ( ) . .
The errors in the solutions are the following:
| Exact I
1
| = | 0.07677 0.07744 | = 0.00067
| Exact I
2
| = | 0.07677 0.07694 | = 0.00017.
136 NUMERICAL METHODS
We find that
| Error in I
2
|
1
4
| Error in I
1
|.
Example 3.15 The velocity of a particle which starts from rest is given by the following table.
t (sec) 0 2 4 6 8 10 12 14 16 18 20
v (ft/sec) 0 16 29 40 46 51 32 18 8 3 0
Evaluate using trapezium rule, the total distance travelled in 20 seconds.
Solution From the definition, we have
v =
ds
dt
, or s =
v dt.
Starting from rest, the distance travelled in 20 seconds is
s =
0
20
v dt.
The step length is h = 2. Using the trapezium rule, we obtain
s =
h
2
[f(0) + 2{f(2) + f(4) + f(6) + f(8) + f(10) + f(12) + f(14)
+ f(16) + f(18)} + f(20)]
= 0 + 2{16 + 29 + 40 + 46 + 51 + 32 + 18 + 8 + 3} + 0 = 486 feet.
3.3.2.2 Simpsons 1/3 Rule
In the previous section, we have shown that the trapezium rule of integration integrates exactly
polynomials of degree 1, that is, the order of the formula is 1. In many science and engineering
applications, we require methods which produce more accurate results. One such method is
the Simpsons 1/3 rule.
Let the interval [a, b] be subdivided into two equal parts with step length h = (b a)/2.
We have three abscissas x
0
= a, x
1
= (a + b)/2, and x
2
= b.
Then, P(x
0
, f(x
0
)), Q(x
1
f(x
1
)), R(x
2
, f(x
2
)) are three points on the curve y = f(x). We
approximate the curve y = f(x), a x b, by the parabola joining the points P, Q, R, that is, we
approximate the given curve by a polynomial of degree 2. Using the Newtons forward difference
formula, the quadratic polynomial approximation to f(x), interpolating at the points
P(x
0
, f(x
0
)), Q(x
1
f(x
1
)), R(x
2
, f(x
2
)), is given by
f(x) = f(x
0
) +
1 1
2
0 0
2
0 1
2
0
h
x x f x
h
x x x x f x ( ) ( ) ( )( ) ( ) +
.
Substituting in (3.31), we obtain
a
b
x
x
x
x
f x dx f x dx f x
h
x x f x
h
x x x x f x dx
= = + +
( ) ( ) ( ) ( ) ( ) ( )( ) ( )
0
2
0
2
0 0 0
2
0 1
2
0
1 1
2
NUMERICAL DIFFERENTIATION AND INTEGRATION 137
= (x
2
x
0
) f(x
0
) +
1 1
2
2 2
0
2
0 1 0 0 1
0
2
h
x x f x I hf x h f x I
x
x
( ) ( ) ( ) ( )
+ = + + .
Evaluating I
1
, we obtain
I
1
=
1
2 3 2
2
3
0 1
2
0 1
2
0
0
2
h
x
x x
x
x x x f x
x
x
+ +
( ) ( )
=
1
12
2 3 6
2
2
3
0
3
0 1 2
2
0
2
0 1 2 0
2
0
h
x x x x x x x x x x f x [ ( ) ( )( ) ( )] ( ) + +
=
1
12
2 3 6
2
2 0 2
2
0 2 0
2
0 1 2 0 0 1
2
0
h
x x x x x x x x x x x x f x ( ) [ ( ) ( )( ) ] ( ) + + + + + .
Substituting x
2
= x
0
+ 2h, x
1
= x
0
+ h, we obtain
I
1
=
1
6
2 3 6 4 3 4 6 2 6 6
0
2
0
2
0
2
0
2
0
2
0
2
0
h
x hx h x hx h x hx f x [ ( ) ( ) ] ( ) + + + + + +
=
1
6
2
3
2 2
0
2
0
h
h f x
h
f x ( ) ( ) ( ) = .
Hence
a
b
x
x
f x dx f x dx hf x h f x
h
f x
= = + + ( ) ( ) ( ) ( ) ( )
0
2
2 2
3
0 0
2
0
=
h
3
[6f(x
0
) + 6{f(x
1
) f(x
0
)} + {f(x
0
) 2f(x
1
) + f(x
2
)}]
=
h
3
[f(x
0
) + 4f(x
1
) + f(x
2
)] (3.39)
In terms of the end points, we can also write the formula as
a
b
f x dx
b a
f a f
a b
f x
=
+
+
( )
( )
( ) ( )
6
4
2
2 (3.40)
This formula is called the Simpsons 1/3 rule.
We can also evaluate the integral
x
x
f x dx
0
2
( ) , as follows. We have
x
x
x
x
f x dx f x
h
x x f x
h
x x x x f x dx
0
2
0
2
0 0 0
2
0 1
2
0
1 1
2
= + +
( ) ( ) ( ) ( ) ( )( ) ( ) .
138 NUMERICAL METHODS
Let [(x x
0
)/h] = s. The limits of integration become:
for x = x
0
, s = 0, and for x = x
2
, s = 2.
We have dx = h ds. Hence,
x
x
f x dx h f x s f x s s f x ds
0
2
0
2
0 0
2
0
1
2
1
= + +
( ) ( ) ( ) ( ) ( )
= h s f x
s
f x
s s
f x ( ) ( ) ( )
0
2
0
3 2
2
0
0
2
2
1
2 3 2
+ +
= h 2 2
1
3
0 0
2
0
f x f x f x ( ) ( ) ( ) + +
=
h
3
[6f(x
0
) + 6{f(x
1
) f(x
0
)} + {f(x
0
) 2f(x
1
) + f(x
2
)}]
=
h
3
[f(x
0
) + 4f(x
1
) + f(x
2
)]
which is the same formula as derived earlier.
Error term in Simpson 1/3 rule. We show that the Simpsons rule integrates exactly poly-
nomials of degree 3. That is, using the definition of error given in (3.27), we show that
R
2
(f, x) = 0 for f(x) = 1, x, x
2
, x
3
.
Substituting f(x) = 1, x, x
2
, x
3
in (3.27), we get
f(x) = 1: R
2
(f, x) =
a
b
dx
b a
( )
6
(6) = (b a) (b a) = 0.
f(x) = x: R
2
(f, x) =
a
b
x dx
b a
a
a b
b
+
+
( )
6
4
2
=
1
2
(b
2
a
2
)
1
2
(b
2
a
2
) = 0.
f(x) = x
2
: R
2
(f, x) =
a
b
x dx
b a
a
a b
b
+
+
2 2
2
2
6
4
2
( )
=
1
3 3
3 3 2 2
( )
( )
[ ] b a
b a
a ab b
+ +
=
1
3
1
3
3 3 3 3
( ) ( ) b a b a = 0.
f(x) = x
3
: R
2
(f, x) =
a
b
x dx
b a
a
a b
b
+
+
3 3
3
3
6
4
2
( )
NUMERICAL DIFFERENTIATION AND INTEGRATION 139
=
1
4
(b
4
a
4
)
( ) b a
4
[a
3
+ a
2
b + ab
2
+ b
3
]
=
1
4
(b
4
a
4
)
1
4
(b
4
a
4
) = 0.
Hence, the Simpsons rule integrates exactly polynomials of degree 3. Therefore, the
method is of order 3. It is interesting to note that the method is one order higher than expected,
since we have approximated f(x) by a polynomial of degree 2 only.
Let f(x) = x
4
. From (3.28), we get
c =
a
b
x dx
b a
a
a b
b
+
+
4 4
4
4
6
4
2
( )
=
1
5
(b
5
a
5
)
( ) b a
24
(5a
4
+ 4a
3
b + 6a
2
b
2
+ 4ab
3
+ 5b
4
)
=
1
120
[24(b
5
a
5
) 5(b a)(5a
4
+ 4a
3
b + 6a
2
b
2
+ 4ab
3
+ 5b
4
)]
=
( ) b a
120
[b
4
4ab
3
+ 6a
2
b
2
4a
3
b + a
4
)]
=
( ) b a
5
120
.
Using (3.29), the expression for the error is given by
R(f, x) =
c
f
b a
f
h
f
4 2880 90
4
5
4
5
4
!
( )
( )
( ) ( )
( ) ( ) ( )
=
= (3.41)
since h = (b a)/2, and a b.
Since the method produces exact results, that is, R
2
(f, x) = 0, when f(x) is a polynomial
of degree 3, the method is of order 3.
The bound for the error is given by
| R(f, x) |
( ) b a
M
h
M
=
5
4
5
4
2880 90
, where M
4
= max | ( )|
( )
a x b
f x
4
. (3.42)
As in the case of the trapezium rule, if the length of the interval [a, b] is large, then
b a is also large and the error expression given in (3.41) becomes meaningless. In this case,
we subdivide [a, b] into a number of subintervals of equal length and apply the Simpsons 1/3
rule to evaluate each integral. The rule is then called the composite Simpsons 1/3 rule.
Composite Simpsons 1/3 rule We note that the Simpsons rule derived earlier uses three
nodal points. Hence, we subdivide the given interval [a, b] into even number of subintervals of
equal length h. That is, we obtain an odd number of nodal points. We take the even number of
intervals as 2N. The step length is given by h = (b a)/(2N). The nodal points are given by
140 NUMERICAL METHODS
a = x
0
, x
1
= x
0
+ h, x
2
= x
0
+ 2h, ..., x
2N
= x
0
+ 2N h = b.
The given interval is now written as
a
b
x
x
x
x
x
x
x
x
f x dx f x dx f x dx f x dx f x dx
N
N
N
= = + + +
( ) ( ) ( ) ( ) ... ( ) .
0
2
0
2
2
4
2 2
2
Note that there are N integrals. The limits of each integral contain three nodal points.
Using the Simpsons 1/3 rule to evaluate each integral, we get the composite Simpsons 1/3
rule as
a
b
f x dx
h
= ( )
3
[{f(x
0
) + 4f(x
1
) + f(x
2
)} + {f(x
2
) + 4 f(x
3
) + f(x
4
)} + ...
+ {f(x
2N2
) + 4f(x
2N1
) + f(x
2N
)}]
=
h
3
[f(x
0
) + 4{f(x
1
) + f(x
3
) + ...+ f(x
2N1
)} + 2{f(x
2
) + f(x
4
) + ...
+ f(x
2N2
)} + f(x
2N
)] (3.43)
The composite Simpsons 1/3 rule is also of order 3.
The error expression (3.34) becomes
R(f, x) =
h
f f f
N
5
4
1
4
2
4
90
[ ( ) ( ) ... ( )]
( ) ( ) ( )
+ + + , (3.44)
where x
0
, <
1
< x
2
, x
2
<
2
< x
4
, etc.
The bound on the error is given by
| R(f, x) |
h
f f f
N
5
4
1
4
2
4
90
| ( )| | ( )| ... | ( )|
( ) ( ) ( )
+ + +
Nh
M
b a h
M
5
4
4
4
90 180
=
( )
(3.45)
or | R(f, x) |
( ) b a
N
M
5
4
4
2880
where M
4
= max | ( )
( )
a x b
f x
4
| and N h = ( b a)/2.
This expression is a true representation of the error in the Simpsons 1/3 rule. We observe
that as N increases, the error decreases.
Remark 9 We have noted that the Simpson 1/3 rule and the composite Simpsons 1/3 rule are
of order 3. This can be verified from the error expressions given in (3.41) and (3.45). If f(x) is a
polynomial of degree 3, then f
(4)
(x) = 0. This result implies that error is zero and the composite
Simpsons 1/3 rule produces exact results for polynomials of degree 3.
NUMERICAL DIFFERENTIATION AND INTEGRATION 141
Remark 10 Note that the number of subintervals is 2N. We can also say that the number of
subintervals is n = 2N and write h = (b a)/n, where n is even.
Example 3.16 Find the approximate value of I =
0
1
dx
x 1 +
, using the Simpsons 1/3 rule with
2, 4 and 8 equal subintervals. Using the exact solution, find the absolute errors.
Solution With n = 2N = 2, 4 and 8, or N = 1, 2, 4 we have the following step lengths and nodal
points.
N = 1: h =
b a
N
=
2
1
2
. The nodes are 0, 0.5, 1.0.
N = 2: h =
b a
N
=
2
1
4
. The nodes are 0, 0.25, 0.5, 0.75, 1.0.
N = 4: h =
b a
N
=
2
1
8
. The nodes are 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0.
We have the following tables of values.
n = 2N = 2: x 0 0.5 1.0
f (x) 1.0 0.666667 0.5
n = 2N = 4: We require the above values. The additional values required are the following.
x 0.25 0.75
f(x) 0.8 0.571429
n = 2N = 8: We require the above values. The additional values required are the following.
x 0.125 0.375 0.625 0.875
f(x) 0.888889 0.727273 0.615385 0.533333
Now, we compute the value of the integral.
n = 2N = 2: I
1
=
h
3
[f(0) + 4f(0.5) + f(1.0)]
=
1
6
[1.0 + 4(0.666667) + 0.5] = 0.674444.
n = 2N = 4: I
2
=
h
3
[f(0) + 4{f(0.25) + f(0.75)} + 2f(0.5) + f(1.0)]
=
1
12
[1.0 + 4 {0.8 + 0.571429} + 2(0.666667) + 0.5] = 0.693254.
n = 2N = 8: I
3
=
h
3
[f(0) + 4{f(0.125) + f(0.375) + f(0.625) + f(0.875)}
+ 2{f(0.25) + f(0.5) + f(0.75)} + f(1.0)]
142 NUMERICAL METHODS
=
1
24
[1.0 + 4 {0.888889 + 0.727273 + 0.615385 + 0.533333}
+ 2 {0.8 + 0.666667 + 0.571429} + 0.5]
= 0.693155.
The exact value of the integral is I = ln 2 = 0.693147.
The errors in the solutions are the following:
| Exact I
1
| = | 0.693147 0.694444 | = 0.001297.
| Exact I
2
| = | 0.693147 0.693254 | = 0.000107.
| Exact I
3
| = | 0.693147 0.693155 | = 0.000008.
Example 3.17 Evaluate I =
1
2
5 3
+
dx
x
, using the Simpsons 1/3 rule with 4 and 8 subintervals.
Compare with the exact solution and find the absolute errors in the solutions.
Solution With N = 2N = 4, 8 or N = 2, 4, we have the following step lengths and nodal points.
N = 2: h =
b a
N
=
2
1
4
. The nodes are 1, 1.25, 1.5, 1.75, 2.0.
N = 4: h =
b a
N
=
2
1
8
. The nodes are 1, 1.125, 1.25, 1.375, 1.5, 1.675, 1.75, 1.875, 2.0.
We have the following tables of values.
n = 2N = 4: x 1.0 1.25 1.5 1.75 2.0
f (x) 0.125 0.11429 0.10526 0.09756 0.09091
n = 2N = 8: We require the above values. The additional values required are the following.
x 1.125 1.375 1.625 1.875
f(x) 0.11940 0.10959 0.10127 0.09412
Now, we compute the value of the integral.
n = 2N = 4: I
1
=
h
3
[f(1) + 4{(1.25) + f(1.75)} + 2f(1.5) + f(2.0)]
=
0 25
3
.
[0.125 + 4{0.11429 + 0.09756} + 2(0.10526) + 0.09091]
= 0.10615.
n = 2N = 8: I
2
=
h
3
[f(1) + 4{f(1.125) + f(1.375) + f(1.625) + f(1.875)}
+ 2{f(1.25) + f(1.5) + f(1.75)} + f(2.0)]
NUMERICAL DIFFERENTIATION AND INTEGRATION 143
=
0 125
3
.
[0.125 + 4{0.11940 + 0.10959 + 0.10127 + 0.09412}
+ 2{0.11429 + 0.10526 + 0.09756} + 0.09091]
= 0.10615.
The exact value of the integral is I =
1
3
[ln 11 ln 8] = 0.10615.
The results obtained with n = 2N = 4 and n = 2N = 8 are accurate to all the places.
Example 3.18 Using Simpsons 1/3 rule, evaluate the integral I =
0
1
2
6 10
+ +
dx
x x
, with 2 and
4 subintervals. Compare with the exact solution.
Solution With n = 2N = 2 and 4, or N = 1, 2, we have the following step lengths and nodal
points.
N = 1: h = 0.5. The nodes are 0.0, 0.5, 1.0.
N = 2: h = 0.25. The nodes are 0.0, 0.25, 0.5, 0.75, 1.0.
We have the following values of the integrand.
n = 2N = 2: x 0.0 0.5 1.0
f (x) 0.1 0.07547 0.05882
n = 2N = 4: We require the above values. The additional values required are the following.
x 0.25 0.75
f(x) 0.08649 0.06639
Now, we compute the value of the integral.
n = 2N = 2: I
1
=
h
3
[f(0.0) + 4 f(0.5) + f(1.0)]
=
0 5
3
.
[0.1 + 4(0.07547) + 0.05882] = 0.07678.
n = 2N = 4: I
2
=
h
3
[f(0.0) + 4 {f(0.25) + f(0.75)} + 2 f(0.5) + f(1.0)]
=
0 25
3
.
[0.1 + 4(0.08649 + 0.06639) + 2(0.07547) + 0.05882] = 0.07677.
The exact value of the integral is
I =
0
1
2
1
0
1
1 1
3 1
3 4 3 007677
+ +
= +
= =
dx
x
x
( )
tan ( ) tan ( ) tan ( ) . .
144 NUMERICAL METHODS
The errors in the solutions are the following:
| Exact I
1
| = | 0.07677 0.07678 | = 0.00001.
| Exact I
2
| = | 0.07677 0.07677 | = 0.00000.
Example 3.19 The velocity of a particle which starts from rest is given by the following table.
t (sec) 0 2 4 6 8 10 12 14 16 18 20
v (ft/sec) 0 16 29 40 46 51 32 18 8 3 0
Evaluate using Simpsons 1/3 rule, the total distance travelled in 20 seconds.
Solution From the definition, we have
v =
ds
dt
, or s =
v dt.
Starting from rest, the distance travelled in 20 seconds is
s =
0
20
v dt.
The step length is h = 2. Using the Simpsons rule, we obtain
s =
h
3
[f(0) + 4{f(2) + f(6) + f(10) + f(14) + f(18)} + 2{f(4) + f(8)
+ f(12) + f(16)} + f(20)]
=
2
3
[0 + 4{16 + 40 + 51 + 18 + 3} + 2{29 + 46 + 32 + 8} + 0]
= 494.667 feet.
3.3.2.3 Simpsons 3/8 Rule
To derive the Simpsons 1/3 rule, we have approximated f(x) by a quadratic polynomial. To
derive the Simpsons 3/8 rule, we approximate f(x) by a cubic polynomial. For interpolating by
a cubic polynomial, we require four nodal points. Hence, we subdivide the given interval [a, b]
into 3 equal parts so that we obtain four nodal points. Let h = (b a)/3. The nodal points are
given by
x
0
= a, x
1
= x
0
+ h, x
2
= x
0
+ 2h, x
3
= x
0
+ 3h.
Using the Newtons forward difference formula, the cubic polynomial approximation to
f(x), interpolating at the points
P(x
0
, f(x
0
)), Q(x
1
, f(x
1
)), R(x
2
, f(x
2
)), S(x
3
, f(x
3
))
is given by
NUMERICAL DIFFERENTIATION AND INTEGRATION 145
f(x) = f(x
0
) +
1
h
(x x
0
) f(x
0
) +
1
2
2
h
(x x
0
)(x x
1
)
2
f(x
0
)
+
1
6
3
h
(x x
0
)(x x
1
)(x x
2
)
3
f(x
0
).
Substituting in (3.31), and integrating, we obtain the Simpsons 3/8 rule as
a
b
x
x
f x dx f x dx
h
= = ( ) ( )
0
3 3
8
[f(x
0
) + 3f(x
1
) + 3f(x
2
) + f(x
3
)]. (3.46)
The error expression is given by
R
3
(f, x) =
3
80 6480
5 4
5
4
0 3
h f
b a
f x x
( ) ( )
( )
( )
( ), =
< < . (3.47)
Since the method produces exact results, that is, R
3
(f, x) = 0, when f(x) is a polynomial
of degree 3, the method is of order 3.
As in the case of the Simpsons 1/3 rule, if the length of the interval [a, b] is large, then
b a is also large and the error expression given in (3.47) becomes meaningless. In this case,
we subdivide [a, b] into a number of subintervals of equal length such that the number of
subintervals is divisible by 3. That is, the number of intervals must be 6 or 9 or 12 etc., so that
we get 7 or 10 or 13 nodal points etc. Then, we apply the Simpsons 3/8 rule to evaluate each
integral. The rule is then called the composite Simpsons 3/8 rule. For example, if we divide
[a, b] into 6 parts, then we get the seven nodal points as
x
0
= a, x
1
= x
0
+ h, x
2
= x
0
+ 2h, x
3
= x
0
+ 3h, ..., x
6
= x
0
+ 6h.
The Simpsons 3/8 rule becomes
a
b
x
x
x
x
f x dx f x dx f x dx
= + ( ) ( ) ( )
0
3
3
6
=
3
8
h
[{f(x
0
) + 3 f(x
1
) + 3 f(x
2
) + f(x
3
)} + {f(x
3
) + 3f(x
4
) + 3 f(x
5
) + f (x
6
)}]
=
3
8
h
[f(x
0
) + 3 f(x
1
) + 3 f(x
2
) + 2 f(x
3
) + 3 f(x
4
) + 3 f(x
5
) + f(x
6
)]
The error in this composite Simpsons 3/8 rule becomes
R
3
(f, x) =
3
80
h
5
[ f
(4)
(
1
) + f
(4)
(
2
)], x
0
<
1
< x
3
, x
3
<
2
< x
6
. (3.48)
In the general case, the bound for the error expression is given by
| R (f, x) | C h
4
M
4
where M
4
= max | ( )|
( )
a x b
f x
4
.
146 NUMERICAL METHODS
If f(x) is a polynomial of degree 3, then f
(4)
(x) = 0. This result implies that error
expression given in (3.47) or (3.48) is zero and the composite Simpsons 3/8 rule produces exact
results for polynomials of degree 3. Therefore, the formula is of order 3, which is same as the
order of the Simpsons 1/3 rule.
Remark 11 In Simpsons 3/8th rule, the number of subintervals is n = 3N. Hence, we have
h =
b a
N
h
b a
n
=
3
, or
where n is a multiple of 3.
Remark 12 Simpsons 3/8 rule has some disadvantages. They are the following: (i) The number
of subintervals must be divisible by 3. (ii) It is of the same order as the Simpsons 1/3 rule,
which only requires that the number of nodal points must be odd. (iii) The error constant c in
the case of Simpsons 3/8 rule is c = 3/80, which is much larger than the error constant c = 1/90,
in the case of Simpsons 1/3 rule. Therefore, the error in the case of the Simpsons 3/8 rule is
larger than the error in the case Simpson 1/3 rule. Due to these disadvantages, Simpsons 3/8
rule is not used in practice.
Example 3.20 Using the Simpsons 3/8 rule, evaluate I =
1
2
5 3
+
dx
x
with 3 and 6 subintervals.
Compare with the exact solution.
Solution With n = 3N = 3 and 6, we have the following step lengths and nodal points.
n = 3N = 3: h =
b a
N
=
3
1
3
. The nodes are 1, 4/3, 5/3, 2.0.
n = 3N = 6: h =
b a
N
=
3
1
6
. The nodes are 1, 7/6, 8/6, 9/6, 10/6, 11/6, 2.0
We have the following tables of values.
n = 3N = 3: x 1.0 4/3 5/3 2.0
f (x) 0.125 0.11111 0.10000 0.09091
n = 3N = 6: We require the above values. The additional values required are the following.
x 7/6 9/6 11/6
f(x) 0.11765 0.10526 0.09524
Now, we compute the value of the integral.
n = 3N = 3: I
1
=
3
8
h
[f(1) + 3 f(4/3) + 3 f(5/3) + f(2.0)]
= 0.125[0.125 + 3{0.11111 + 0.10000} + 0.09091] = 0.10616.
n = 3N = 6: I
2
=
3
8
h
[f(1) + 3{f(7/6) + f(8/6) + f(10/6) + f(11/6)}
+ 2 f(9/6)} + f(2.0)]
NUMERICAL DIFFERENTIATION AND INTEGRATION 147
=
1
16
[0.125 + 3 {0.11765 + 0.11111 + 0.10000 + 0.09524}
+ 2(0.10526) + 0.09091] = 0.10615.
The exact value of the integral is I =
1
3
[log 11 log 8] = 0.10615.
The magnitude of the error for n = 3 is 0.00001 and for n = 6 the result is correct to all
places.
3.3.2.4 Romberg Method (Integration)
In order to obtain accurate results, we compute the integrals by trapezium or Simpsons rules
for a number of values of step lengths, each time reducing the step length. We stop the compu-
tation, when convergence is attained (usually, the magnitude of the difference in successive
values of the integrals obtained by reducing values of the step lengths is less than a given
accuracy). Convergence may be obtained after computing the value of the integral with a number
of step lengths. While computing the value of the integral with a particular step length, the
values of the integral obtained earlier by using larger step lengths were not used. Further,
convergence may be slow.
Romberg method is a powerful tool which uses the method of extrapolation.
We compute the value of the integral with a number of step lengths using the same
method. Usually, we start with a coarse step length, then reduce the step lengths and re-
compute the value of the integral. The sequence of these values converges to the exact value of
the integral. Romberg method uses these values of the integral obtained with various step
lengths, to refine the solution such that the new values are of higher order. That is, as if the
results are obtained using a higher order method than the order of the method used. The
extrapolation method is derived by studying the error of the method that is being used.
Let us derive the Romberg method for the trapezium and Simpsons rules.
Romberg method for the trapezium rule
Let the integral
I =
a
b
f x dx
( )
be computed by the composite trapezium rule. Let I denote the exact value of the integral
and
T
I denote the value obtained by the composite trapezium rule.
The error, I
I
T
, in the composite trapezium rule in computing the integral is given by
I I
T
= c
1
h
2
+ c
2
h
4
+ c
3
h
6
+ ...
or I = I
T
+ c
1
h
2
+ c
2
h
4
+ c
3
h
6
+ ... (3.49)
where c
1
, c
2
, c
3
, ... are independent of h.
To illustrate the extrapolation procedure, first consider two error terms.
I = I
T
+ c
1
h
2
+ c
2
h
4
. (3.50)
148 NUMERICAL METHODS
Let I be evaluated using two step lengths h and qh, 0 < q < 1. Let these values be
denoted by I
T
(h) and I
T
(qh). The error equations become
I = I
T
(h) + c
1
h
2
+ c
2
h
4
. (3.51)
I = I
T
(qh) + c
1
q
2
h
2
+ c
2
q
4
h
4
. (3.52)
From (3.51), we obtain
I I
T
(h) = c
1
h
2
+ c
2
h
4
. (3.53)
From (3.52), we obtain
I
I
T
(qh) = c
1
q
2
h
2
+ c
2
q
4
h
4
. (3.54)
Multiply (3.53) by q
2
to obtain
q
2
[I I
T
(h)] = c
1
q
2
h
2
+ c
2
q
2
h
4
. (3.55)
Eliminating c
1
q
2
h
2
from (3.54) and (3.55), we obtain
(1 q
2
)I I
T
(qh) + q
2
I
T
(h) = c
2
q
2
h
4
(q
2
1).
Solving for I, we obtain
I =
I qh q I h
q
T T
( ) ( )
( )
2
2
1
c
2
q
2
h
4
.
Note that the error term on the right hand side is now of order O(h
4
).
Neglecting the O(h
4
) error term, we obtain the new approximation to the value of the
integral as
I I h
I qh q I h
q
T
T T ( )
( )
( ) ( )
( )
1
2
2
1
=
. (3.56)
We note that this value is obtained by suitably using the values of the integral obtained
with step lengths h and qh, 0 < q < 1. This computed result is of order, O(h
4
), which is higher
than the order of the trapezium rule, which is of O(h
2
).
For q = 1/2, that is, computations are done with step lengths h and h/2, the formula
(3.56) simplifies to
I h
I h I h
T
T T (1)
( )
( / ) ( / ) ( )
( / )
2 14
1 14
=
4 2
4 1
4 2
3
I h I h I h I h
T T T T
( / ) ( ) ( / ) ( )
=
. (3.57)
In practical applications, we normally use the sequence of step lengths h, h/2, h/2
2
, h/2
3
, ...
Suppose, the integral is computed using the step lengths h, h/2, h/2
2
. Using the results
obtained with the step lengths h/2, h/2
2
, we get
NUMERICAL DIFFERENTIATION AND INTEGRATION 149
I h
I h I h
T
T T ( )
( / )
( / ) ( / ) ( / )
( / )
1
2
4 14 2
1 14
=
4 4 2
4 1
4 4 2
3
I h I h I h I h
T T T T
( / ) ( / ) ( / ) ( / )
=
. (3.58)
Both the resultsI h I h
T T
( ) ( )
( ), ( / )
1 1
2
are of order, O(h
4
). Now, we can eliminate the O(h
4
)
terms of these two results to obtain a result of next higher order, O(h
6
). The multiplicative
factor is now (1/2)
4
= 1/16. The formula becomes
I h
I h I h I h I h
T
T T T T ( )
( ) ( ) ( ) ( )
( )
( / ) ( ) ( / ) ( )
2
1 1 1 1
16 2
16 1
16 2
15
=
. (3.59)
Therefore, we obtain the Romberg extrapolation procedure for the composite trapezium
rule as
I h
I h I h
T
m
m
T
m
T
m
m
( )
( ) ( )
( )
( / ) ( )
4 2
4 1
1 1
, m = 1, 2, ... (3.60)
where I h I h
T T
( )
( ) ( )
0
= .
The computed result is of order O(h
2m+2
).
The extrapolations using three step lengths h, h/2, h/2
2
, are given in Table 3.1.
Table 3.1. Romberg method for trapezium rule.
Step Value of I Value of I Value of I
Length O(h
2
) O(h
4
) O(h
6
)
h I(h)
I h
I h I h
( )
( )
( / ) ( )
1
4 2
3
=
h/2 I(h/2) I h
I h I h
( )
( ) ( )
( )
( / ) ( )
2
1 1
16 2
15
=
I h
I h I h
( )
( / )
( / ) ( / )
1
2
4 4 2
3
=
h/4 I(h/4)
Note that the most accurate values are the values at the end of each column.
Romberg method for the Simpsons 1/3 rule We can apply the same procedure as in trape-
zium rule to obtain the Rombergs extrapolation procedure for the Simpsons 1/3 rule.
Let I denote the exact value of the integral and I
S
denote the value obtained by the
composite Simpsons 1/3 rule.
150 NUMERICAL METHODS
The error, I I
S
, in the composite Simpsons 1/3 rule in computing the integral is given by
I I
S
= c
1
h
4
+ c
2
h
6
+ c
3
h
8
+ ...
or I = I
S
+ c
1
h
4
+ c
2
h
6
+ c
3
h
8
+ ... (3.61)
As in the trapezium rule, to illustrate the extrapolation procedure, first consider two
error terms.
I = I
S
+ c
1
h
4
+ c
2
h
6
. (3.62)
Let I be evaluated using two step lengths h and qh, 0 < q < 1. Let these values be
denoted by I
S
(h) and I
S
(qh). The error equations become
I = I
S
(h) + c
1
h
4
+ c
2
h
6
. (3.63)
I = I
S
(qh) + c
1
q
4
h
4
+ c
2
q
6
h
6
. (3.64)
From (3.63), we obtain
I I
S
(h) = c
1
h
4
+ c
2
h
6
. (3.65)
From (3.64), we obtain
I I
S
(qh) = c
1
q
4
h
4
+ c
2
q
6
h
6
. (3.66)
Multiply (3.65) by q
4
to obtain
q
4
[I I
S
(h)] = c
1
q
4
h
4
+ c
2
q
4
h
6
. (3.67)
Eliminating c
1
q
4
h
4
from (3.66) and (3.67), we obtain
(1 q
4
)I I
S
(qh) + q
4
I
S
(h) = c
2
q
4
h
6
(q
2
1).
Note that the error term on the right hand side is now of order O(h
6
). Solving for I, we
obtain
I =
I qh q I h
q
c q
q
S S
( ) ( )
( )
+
4
4
2
4
2
1 1
h
6
.
Neglecting the O(h
6
) error term, we obtain the new approximation to the value of the
integral as
I I h
I qh q I h
q
S
S S ( )
( )
( ) ( )
( )
1
4
4
1
=
. (3.68)
Again, we note that this value is obtained by suitably using the values of the integral
obtained with step lengths h and qh, 0 < q < 1. This computed result is of order, O(h
6
), which
is higher than the order of the Simpsons 1/3 rule, which is of O(h
4
).
For q = 1/2, that is, computations are done with step lengths h and h/2, the formula
(3.68) simplifies to
I h
I h I h
S
S S ( )
( )
( / ) ( / ) ( )
( / )
1
2 1 16
1 1 16
=
. (3.69)
In practical applications, we normally use the sequence of step lengths h, h/2, h/2
2
,
h/2
3
, ...
Suppose, the integral is computed using the step lengths h, h/2, h/2
2
. Using the results
obtained with the step lengths h/2, h/2
2
, we get
I h
I h I h
S
S S ( )
( / )
( / ) ( / ) ( / )
( / )
1
2
4 116 2
1 116
=
16 4 2
16 1
16 4 2
15
I h I h I h I h
S S S S
( / ) ( / ) ( / ) ( / )
=
. (3.70)
Both the results I h I h
T T
( ) ( )
( ), ( / )
1 1
2 are of order, O(h
6
). Now, we can eliminate the O(h
6
)
terms of these two results to obtain a result of next higher order, O(h
8
). The multiplicative
factor is now (1/2)
6
= 1/64. The formula becomes
I h
I h I h I h I h
S
S S S S ( )
( ) ( ) ( ) ( )
( )
( / ) ( ) ( / ) ( )
2
1 1 1 1
64 2
64 1
64 2
63
=
. (3.71)
Therefore, we obtain the Romberg extrapolation procedure for the composite Simpsons
1/3 rule as
I h
I h I h
S
m
m
S
m
S
m
m
( )
( ) ( )
( )
( / ) ( )
+
+
4 2
4 1
1 1 1
1
, m = 1, 2, ... (3.72)
where I h
S
( )
( )
0
= I
S
(h).
The computed result is of order O(h
2m+4
).
The extrapolations using three step lengths h, h/2, h/2
2
, are given in Table 3.2.
Table 3.2. Romberg method for Simpsons 1/3 rule.
Step Value of I Value of I Value of I
Length O(h
4
) O(h
6
) O(h
8
)
h I(h)
I h
I h I h
( )
( )
( / ) ( )
1
16 2
15
=
h/2 I(h/2) I
(2)
(h) =
64 2
63
1 1
I h I h
( ) ( )
( / ) ( )
I h
I h I h
( )
( / )
( / ) ( / )
1
2
16 4 2
15
=
h/4 I(h/4)
152 NUMERICAL METHODS
Note that the most accurate values are the values at the end of each column.
Example 3.21 The approximations to the values of the integrals in Examples 3.12 and 3.13
were obtained using the trapezium rule. Apply the Rombergs method to improve the
approximations to the values of the integrals.
Solution In Example 3.12, the given integral is
I =
0
1
1
+
dx
x
The approximations using the trapezium rule to the integral with various values of the
step lengths were obtained as follows.
h = 1/2, N = 2: I = 0.708334; h = 1/4, N = 4: I = 0.697024.
h = 1/8, N = 8: I = 0.694122.
We have I
I I
( )
( / )
( / ) ( / ) ( . ) .
1
12
4 14 12
3
4 0 697024 0 708334
3
=
=
= 0.693254
I
I I
( )
( / )
( / ) ( / ) ( . ) .
1
14
4 18 14
3
4 0 694122 0 697024
3
=
=
= 0.693155.
I
I I
( )
( ) ( )
( / )
( / ) ( / ) ( . ) .
2
1 1
12
16 14 12
15
16 0 693155 0 693254
15
=
=
= 0.693148.
The results are tabulated in Table 3.3.
Magnitude of the error is
| I 0.693148 | = | 0.693147 0.693148 | = 0.000001.
Table 3.3. Romberg method. Example 3.21.
Step Value of I Value of I Value of I
Length O(h
2
) O(h
4
) O(h
6
)
1/2 0.708334
0.693254
1/4 0.697024 0.693148
0.693155
1/8 0.694122
In Example 3.13, the given integral is
I =
1
2
5 3
+
dx
x
.
The approximations using the trapezium rule to the integral with various values of the
step lengths were obtained as follows.
h = 1/4, N = 4: I = 0.10627; h = 1/8, N = 8: I = 0.10618.
NUMERICAL DIFFERENTIATION AND INTEGRATION 153
We have I
I I
(1)
( / )
( / ) ( / ) ( . ) .
14
4 18 14
3
4 010618 010627
3
=
=
= 0.10615.
Since the exact value is I = 0.10615, the result is correct to all places.
Example 3.22 The approximation to the value of the integral in Examples 3.16 was obtained
using the Simpsons 1/3 rule. Apply the Rombergs method to improve the approximation to the
value of the integral.
Solution In Example 3.16, the given integral is
I =
0
1
1
+
dx
x
.
The approximations using the Simpsons 1/3 rule to the integral with various values of
the step lengths were obtained as follows.
h = 1/2, n = 2N = 2: I = 0.694444; h = 1/4, n = 2N = 4: I = 693254;
h = 1/8, n = 2N = 8: I = 693155.
We have I
I I
( )
( / )
( / ) ( / ) ( . ) .
1
12
16 14 12
15
16 0 693254 0 694444
15
=
=
= 0.693175
I
I I
( )
( / )
( / ) ( / ) ( . ) .
1
14
16 18 14
15
16 0 693155 0 693254
15
=
=
= 0.693148
I
I I
( )
(1) (1)
( / )
( / ) ( / ) ( . ) .
2
12
64 14 12
63
64 0693148 0693175
63
=
=
= 0.693148.
The results are tabulated in Table 3.4.
Magnitude of the error is
| I 0.693148 | = | 0.693147 0.693148 | = 0.000001.
Table 3.4. Romberg method. Example 3.22.
Step Value of I Value of I Value of I
Length O(h
4
) O(h
6
) O(h
8
)
1/2 0.694444
0.693175
1/4 0.693254 0.693148
0.693148
1/8 0.693155
154 NUMERICAL METHODS
REVIEW QUESTIONS
1. What is the order of the trapezium rule for integrating
a
b
f x dx
=
3 3
12 12
where .
2. When does the trapezium rule for integrating
a
b
f x dx
( ) ?
Solution There is no restriction in the number of nodal points, required for using the
trapezium rule.
4. What is the geometric representation of the trapezium rule for integrating
a
b
f x dx
( ) ?
Solution Geometrically, the right hand side of the trapezium rule is the area of the
trapezoid with width b a, and ordinates f(a) and f(b), which is an approximation to the
area under the curve y = f(x) above the x-axis and the ordinates x = a, and x = b.
5. State the composite trapezium rule for integrating
a
b
f x dx
( ) =
h
2
[f(x
0
) + 2{f(x
1
) + f(x
2
) + ... + f(x
n1
)} + f(x
n
)]
where nh = (b a ). The bound on the error is given by
| Error |
nh
M
b a h
3
2
2
12 12
=
( )
M
2
where M
2
= max | ( )|
a x b
f x
and nh = b a.
6. What is the geometric representation of the composite trapezium rule for integrating
a
b
f x dx
( ) ?
Solution Geometrically, the right hand side of the composite trapezium rule is the sum
of areas of the n trapezoids with width h, and ordinates f(x
i1
) and f(x
i
) i = 1, 2, ..., n. This
NUMERICAL DIFFERENTIATION AND INTEGRATION 155
sum is an approximation to the area under the curve y = f(x) above the x-axis and the
ordinates x = a and x = b.
7. How can you deduce that the trapezium rule and the composite trapezium rule produce
exact results for polynomials of degree less than or equal to 1?
Solution The expression for the error in the trapezium rule is given by
R
1
(f, x) =
h
f
3
12
( )
and the expression for the error in the composite trapezium rule is given by
R
1
(f, x) =
h
3
12
[f (
1
) + f (
2
) + ... + f (
n
)], x
n1
<
n
<
n
.
If f(x) is a polynomial of degree 1, then f (x) = 0. This result implies that error is zero
and the trapezium rule produces exact results for polynomials of degree 1.
8. When does the Simpsons 1/3 rule for integrating
a
b
f x dx
( ) ?
Solution The number of nodal points must be odd for using the Simpsons 1/3 rule or
the number of subintervals must be even.
10. State the composite Simpsons 1/3 rule for integrating
a
b
f x dx
( ) =
h
3
[{f(x
0
) + 4f(x
1
) + f(x
2
)} + {f(x
2
) + 4f(x
3
) + f(x
4
)} + ...
+ {f(x
2N2
) + 4 f(x
2N1
) + f(x
2N
)}]
=
h
3
[f(x
0
) + 4{f(x
1
) + f(x
3
) + ... + f(x
2N1
)}
+ 2{f(x
2
) + f(x
4
) + ... + f(x
2N2
)} + f(x
2N
)]
The bound on the error is given by
| R(f, x) |
h
f f f
N
5
4
1
4
2
4
90
| ( )| | ( )| ... | ( )|
( ) ( ) ( )
+ + +
Nh
M
b a h
5
4
4
90 180
=
( )
M
4
156 NUMERICAL METHODS
where x
0
<
1
< x
2
, x
2
<
2
< x
4
, etc., M
4
= max | ( )|
( )
a x b
f x
4
and N h = (b a)/2.
11. How can you deduce that the Simpsons 1/3 rule and the composite Simpsons 1/3 rule
produce exact results for polynomials of degree less than or equal to 3?
Solution The expression for the error in the Simpsons 1/3 rule is given by
R(f, x) =
c
f
b a
f
h
f
4 2880 90
4
5
4
5
4
!
( )
( )
( ) ( )
( ) ( ) ( )
=
=
where h = (b a)/2, and a b.
The expression for the error in the composite Simpsons 1/3 rule is given by
R(f, x) =
h
f f f
N
5
4
1
4
2
4
90
[ ( ) ( ) ... ( )]
( ) ( ) ( )
+ + +
where x
0
<
1
< x
2
, x
2
<
2
< x
4
, etc.
If f(x) is a polynomial of degree 3, then f
(4)
(x) = 0. This result implies that error is zero
and the Simpson 1/3 rule produces exact results for polynomials of degree 3.
12. What is the restriction in the number of nodal points, required for using the Simpsons
3/8 rule for integrating
a
b
f x dx
( ) ?
Solution The number of subintervals must be divisible by 3.
13. What are the disadvantages of the Simpsons 3/8 rule compared with the Simpsons 1/3
rule?
Solution The disadvantages are the following: (i) The number of subintervals must be
divisible by 3. (ii) It is of the same order as the Simpsons 1/3 rule, which only requires
that the number of nodal points must be odd. (iii) The error constant c in the case of
Simpsons 3/8 rule is c = 3/80, which is much larger than the error constant c = 1/90, in
the case of Simpsons 1/3 rule. Therefore, the error in the case of the Simpsons 3/8 rule
is larger than the error in the case Simpson 1/3 rule.
14. Explain why we need the Romberg method.
Solution In order to obtain accurate results, we compute the integrals by trapezium
or Simpsons rules for a number of values of step lengths, each time reducing the step
length. We stop the computation, when convergence is attained (usually, the magnitude
of the difference between successive values of the integrals obtained with the reducing
values of the step lengths is less than a given accuracy). Convergence may be obtained
after computing the value of the integral with a number of step lengths. While computing
the value of the integral with a particular step length, the values of the integral obtained
earlier by using larger step lengths were not used. Further, convergence may be slow.
Romberg method is a powerful tool which uses the method of extrapolation. Romberg
method uses these computed values of the integrals obtained with various step lengths,
to refine the solution such that the new values are of higher order. That is, as if they are
obtained using a higher order method than the order of the method used.
NUMERICAL DIFFERENTIATION AND INTEGRATION 157
15. An integral I is evaluated by the trapezium rule with step lengths h and qh. Write the
Romberg method for improving the accuracy of the value of the integral.
Solution Let I
T
(h), I
T
(qh) denote the values of the integral evaluated using the step
lengths h and qh. The required Romberg approximation is given by
I I h
I qh q I h
q
T
T T ( )
( )
( ) ( )
( )
1
2
2
1
=
.
16. An integral I is evaluated by the composite trapezium rule with step lengths h, h/2, h/
2
2
, ..., h/2
m
, ... . Write the Romberg method for improving the accuracy of the value of
the integral.
Solution The required Romberg approximation is given by
I h
I h I h
T
m
m
T
m
T
m
m
( )
( ) ( )
( )
( / ) ( )
4 2
4 1
1 1
, m = 1, 2, ...
where I h
T
( )
( )
0
= I
T
(h).
17. An integral I is evaluated by the Simpsons 1/3 rule with step lengths h and qh. Write
the Romberg method for improving the accuracy of the value of the integral.
Solution Let I
S
(h), I
S
(qh) denote the values of the integral evaluated using the step
lengths h and qh. The required Romberg approximation is given by
I I h
I qh q I h
q
S
S S ( )
( )
( ) ( )
( )
1
4
4
1
=
.
18. An integral I is evaluated by the composite Simpsons 1/3 rule with step lengths h, h/2,
h/2
2
, ..., h/2
m
, ... . Write the Romberg method for improving the accuracy of the value of
the integral.
Solution The required Romberg approximation is given by
I h
I h I h
S
m
m
S
m
S
m
m
( )
( ) ( )
( )
( / ) ( )
+
+
4 2
4 1
1 1 1
1
, m = 1, 2, ...
where I h
S
( )
( )
0
= I
S
(h), m = 1, 2, ...
EXERCISE 3.2
1. Evaluate
1 2
1
/
dx
x
by trapezium rule, dividing the range into four equal parts.
(A.U. May/June 2006)
2. Using the trapezium rule, find
0
6
+
1
1
2
1
dx
x
taking 8 intervals. (A.U. April/May 2004)
7. Using the Simpsons 1/3 rule, evaluate
0
1
x e dx
x
taking four intervals. Compare the
result with actual value.
8. Evaluate
0
2
e dx
x
using the Simpsons rule with h = 1 and h = 1/2. Compare with exact
solution. Improve the result using Romberg integration.
9. Evaluate
0
6
2
1
+
dx
x
by (i) trapezium rule, (ii) Simpsons rule. Also, check the result by
actual integration. (A.U. Nov./Dec. 2004)
10. Compute
I
p
=
0
1
3
10
+
x
x
dx
p
for p = 0, 1
using trapezium rule and Simpsons 1/3 rule with the number of points 3, 5 and 9.
Improve the results using Romberg integration.
11. For the given data
x 0.7 0.9 1.1 1.3 1.5 1.7 1.9 2.1
f (x) 0.64835 0.91360 1.16092 1.36178 1.49500 1.35007 1.52882 1.44573
use Simpsons 1/3 rule for first six intervals and trapezium rule for the last interval to
evaluate
0.7
2.1
( )
f x dx. Also, use trapezium rule for the first interval and Simpsons 1/3
rule for the rest of intervals to evaluate
0.7
2.1
( )
+
dx
x
by Simpsons 1/3 rule and hence find the value of log
e
5, (n = 10).
(A.U. April/May 2005)
13. By dividing the range into ten equal parts, evaluate
0
+
dx
x
by dividing the range into six equal
parts. (A.U. Nov./Dec. 2004)
3.3.3 Integration Rules Based on Non-uniform Mesh Spacing
We have defined the general integration rule as
I =
a
b
k
n
k k
w x f x dx f x
=
=
( ) ( ) ( )
0
=
0
f(x
0
) +
1
f(x
1
) +
2
f(x
2
) + ... +
n
f(x
n
). (3.73)
When the abscissas are prescribed and are equispaced, that is, x
i
= x
0
+ ih, i = 1, 2,, n,
we have derived the trapezium and Simpsons rules (Newton-Cotes formulas). When the
abscissa are not prescribed in advance and they are also to be determined, then the formulas
using less number of abscissas can produce higher order methods compared to the Newton-
Cotes formulas. Such formulas are called Gaussian integration rules or formulas.
Gaussian integration rules can be obtained when the limits are finite or one of the
limits is infinite or both the limits are infinite.
We have the following Gaussian integration rules depending on the limits of integra-
tion and on the expression for the weight function w(x).
1. Gauss-Legendre integration rules
Limits of integration = [ 1, 1]. Weight function = w(x) = 1.
Abscissas = Zeros of the corresponding Legendre polynomial.
2. Gauss-Chebychev integration rules
Limits of integration = [ 1, 1]. Weight function = w(x) = 1/ 1
2
x .
Abscissas = Zeros of the corresponding Chebychev polynomial.
3. Gauss-Laguerre integration rules
Limits of integration = [0, ]. Weight function = w(x) = e
x
.
Abscissas = Zeros of the corresponding Laguerre polynomial.
4. Gauss-Hermite integration rules
Limits of integration = ( , ). Weight function = w(x) = e
x
2
. Abscissas = Zeros of the
corresponding Hermite polynomial.
160 NUMERICAL METHODS
For our discussion and derivation, we shall consider only the Gauss-Legendre integra-
tion rules. As per the terminology used in syllabus, we shall call these formulas as Gaussian
formulas.
3.3.3.1 Gauss-Legendre Integration Rules
Since the weight function is w(x) = 1, we shall write the integration rule as
I =
a
b
f x dx
( ) =
0
f(x
0
) +
1
f(x
1
) +
2
f(x
2
) + ... +
n
f(x
n
). (3.74)
As mentioned earlier, the limits of integration for Gauss-Legendre integration rules
are [ 1, 1]. Therefore, we transform the limits [a, b] to [ 1, 1], using a linear transformation.
Let the transformation be x = pt + q.
When x = a, we have t = 1: a = p + q.
When x = b, we have t = 1: b = p + q.
Solving, we get p(b a)/2, q = (b + a)/2.
The required transformation is x =
1
2
[(b a)t + (b + a)]. (3.75)
Then, f(x) = f{[(b a)t + (b + a)]/2} and dx = [(b a)/2]dt.
The integral becomes
I =
a
b
f x dx f b a t b a b a dt g t dt
= + +
=
( ) [( ) ( )] ( ) ( )
1
1
1
1
1
2
1
2
(3.76)
where g(t) =
1
2
( ) b a
f
1
2
[( ) ( )] b a t b a + +
.
Therefore, we shall derive formulas to evaluate
1
1
g t dt ( )
.
Without loss of generality, let us write this integral as
1
1
f x dx ( )
.
The required integration formula is of the form
1
1
f x dx ( )
=
0
f(x
0
) +
1
f(x
1
) +
2
f(x
2
) + ... +
n
f(x
n
). (3.77)
We shall follow the approach of method of undetermined coefficients to derive the
formulas.
Before deriving the methods, let us remember the definition of the order of a method
and the expression for the error of the method.
An integration method of the form (3.77) is said to be of order p, if it produces exact
results, that is error R
n
= 0, for all polynomials of degree less than or equal to p. That is, it
produces exact results for f(x) = 1, x, x
2
, ..., x
p
. When w(x) = 1, this implies that
NUMERICAL DIFFERENTIATION AND INTEGRATION 161
R
n
(x
m
) =
=
1
1
0
0 x dx x
m
k
n
k k
m
, for m = 0, 1, 2, , p.
The error term is obtained for f(x) = x
p+1
. We define
c =
+
=
+
1
1
1
0
1
x dx x
p
k
n
k k
p
(3.78)
where c is called the error constant. Then, the error term is given by
R
n
(f) =
1
1
0
f x dx f x
k
n
k k
( ) ( )
=
c
p
f a b
p
( ) !
( ),
( )
+
< <
+
1
1
(3.79)
If R
n
(x
p+1
) also becomes zero, then the error term is obtained for f(x) = x
p+2
.
Gauss one point rule (Gauss-Legendre one point rule)
The one point rule is given by
1
1
f x dx ( )
=
0
f(x
0
) (3.80)
where
0
0. The method has two unknowns
0
, x
0
. Making the formula exact for f(x) = 1, x, we
get
f(x) = 1:
1
1
dx = 2 =
0
.
f(x) = x:
1
1
xdx = 0 =
0
x
0
.
Since,
0
0, we get x
0
= 0.
Therefore, the one point Gauss formula is given by
1
1
f x dx ( )
= 2 f(0). (3.81)
Error of approximation
The error term is obtained when f(x) = x
2
. We obtain
c =
1
1
x
2
dx 0 =
2
3
.
The error term is given by.
R(f ) =
c
f f
2
1
3
1 1
!
( ) ( ), = < < . (3.82)
162 NUMERICAL METHODS
Remark 13 Since the error term contains f ( ) , Gauss one point rule integrates exactly poly-
nomials of degree less than or equal to 1. Therefore, the results obtained from this rule are
comparable with the results obtained from the trapezium rule. However, we require two
function evaluations in the trapezium rule whereas we need only one function evaluation in
the Gauss one point rule. If better accuracy is required, then the original interval [a, b] can be
subdivided and the limits of each subinterval can be transformed to [ 1, 1]. Gauss one point
rule can then be applied to each of the integrals.
Gauss two point rule (Gauss-Legendre two point rule)
The two point rule is given by
1
1
f x dx ( ) =
0
f(x
0
) +
1
f(x
1
) (3.83)
where
0
0,
1
0 and x
0
x
1
. The method has four unknowns
0
, x
0
,
1
, x
1
. Making the
formula exact for f(x) = 1, x, x
2
, x
3
, we get
f(x) = 1:
1
1
dx = 2 =
0
+
1
. (3.84)
f(x) = x:
1
1
x dx = 0 =
0
x
0
+
1
x
1
. (3.85)
f(x) = x
2
:
1
1
x
2
dx =
2
3
=
0
x
0
2
+
1
x
1
2
. (3.86)
f(x) = x
3
:
1
1
x
3
dx = 0 =
0
x
0
3
+
1
x
1
3
. (3.87)
Eliminating
0
from (3.85) and (3.87), we get
1 1
3
1 1 0
2
1 1 1 0 1 0
0 0 x x x x x x x x = + = , ( )( ) or
.
Now,
1
0 and x
0
x
1
. Hence, x
1
= 0, or x
1
= x
0
. If x
1
= 0, (3.85) gives x
0
= 0, which is
not possible. Therefore, x
1
= x
0
.
Substituting in (3.85), we get
0
1
= 0, or
0
=
1
.
Substituting in (3.84), we get
0
=
1
= 1.
Substituting in (3.86), we get x x x
0
2
0 1
1
3
1
3
= = = , or .
Therefore, the two point Gauss rule (Gauss-Legendre rule) is given by
1
1
1
3
1
3
f x dx f f ( ) . (3.88)
NUMERICAL DIFFERENTIATION AND INTEGRATION 163
Error of approximation
The error term is obtained when f(x) = x
4
. We obtain
c =
= =
1
1
4
1
9
1
9
2
5
2
9
8
45
x dx .
The error term is given by
R(f) =
c
f f
4
1
135
1 1
4 4
!
( ) ( ),
( ) ( )
= < < . (3.89)
Remark 14 Since the error term contains f
(4)
(), Gauss two point rule integrates exactly
polynomials of degree less than or equal to 3. Therefore, the results obtained from this rule
are comparable with the results obtained from the Simpsons rule. However, we require three
function evaluations in the Simpsons rule whereas we need only two function evaluations in
the Gauss two point rule. If better accuracy is required, then the original interval [a, b] can be
subdivided and the limits of each subinterval can be transformed to [ 1, 1]. Gauss two point
rule can then be applied to each of the integrals.
Gauss three point rule (Gauss-Legendre three point rule)
The three point rule is given by
1
1
f x dx ( ) =
0
f(x
0
) +
1
f(x
1
) +
2
f(x
2
) (3.90)
where
0
0,
1
0,
2
0, and x
0
x
1
x
2
. The method has six unknowns
0
, x
0
,
1
, x
1
,
2
, x
2
.
Making the formula exact for f(x) = 1, x, x
2
, x
3
, x
4
, x
5
, we get
f(x) = 1:
1
1
dx = 2 =
0
+
1
+
2
. (3.91)
f(x) = x:
1
1
x dx = 0 =
0
x
0
+
1
x
1
+
2
x
2
. (3.92)
f(x) = x
2
:
1
1
x
2
dx =
2
3
=
0 0
2
1 1
2
2 2
2
x x x + + . (3.93)
f(x) = x
3
:
= = + +
1
1
3
0 0
3
1 1
3
2 2
3
0 x dx x x x
. (3.94)
f(x) = x
4
:
= = + +
1
1
4
0 0
4
1 1
4
2 2
4
2
5
x dx x x x
. (3.95)
f(x) = x
5
:
= = + +
1
1
5
0 0
5
1 1
5
2 2
5
0 x dx x x x
. (3.96)
Solving this system as in the two point rule, we obtain
x
0
=
3
5
0
3
5
5
9
8
9
1 2 0 2 1
, , , , x x = = + = = = .
164 NUMERICAL METHODS
Therefore, the three point Gauss rule (Gauss-Legendre rule) is given by
+ +
1
1
1
9
5
3
5
8 0 5
3
5
f x dx f f f ( ) ( )
. (3.97)
Error of approximation
The error term is obtained when f(x) = x
6
. We obtain
c =
+ +
= =
1
1
6
6 6
1
9
5
3
5
0 5
3
5
2
7
6
25
8
175
x dx .
The error term is given by
R(f) =
c
f f f
6
8
6 175
1
15750
1 1
6 6 6
!
( )
( !)
( ) ( ),
( ) ( ) ( )
= = < < . (3.98)
Remark 15 Since the error term contains f
(6)
(), Gauss three point rule integrates exactly
polynomials of degree less than or equal to 5. Further, the error coefficient is very small
(1/15750 0.00006349). Therefore, the results obtained from this rule are very accurate. We
have not derived any Newton-Cotes rule, which can be compared with the Gauss three point
rule. If better accuracy is required, then the original interval [a, b] can be subdivided and the
limits of each subinterval can be transformed to [ 1, 1]. Gauss three point rule can then be
applied to each of the integrals.
Example 3.23 Evaluate the integral I =
1
2
4
2
1
+
x
x
dx, using Gauss one point, two point and
three point rules. Compare with the exact solution I = tan
1
(4) (/4).
Solution We reduce the interval [1, 2] to [ 1, 1] to apply the Gauss rules.
Writing x = a t + b, we get
1 = a + b, 2 = a + b.
Solving, we get a = 1/2, b = 3/2. Therefore, x = (t + 3)/2, dx = dt/2.
The integral becomes
I =
+
+ +
=
1
1
4
1
1
8 3
16 3
( )
[ ( ) ]
( )
t
t
dt f t dt
where f(t) = 8(t + 3)/[16 + (t + 3)
4
].
Using the one point Gauss rule, we obtain
I = 2 f(0) = 2
24
16 81
48
97 +
= = 0.494845.
Using the two point Gauss rule, we obtain
I = f
=
1
3
1
3
f f( 0.577350) + f(0.577350)
= 0.384183 + 0.159193 = 0.543376.
NUMERICAL DIFFERENTIATION AND INTEGRATION 165
Using the three point Gauss rule, we obtain
I =
1
9
5
3
5
8 0 5
3
5
f f f
+ +
( )
=
1
9
[5 f( 0.774597) + 8 f(0) + 5f(0.774597)]
=
1
9
[5(0.439299) + 8(0.247423) + 5(0.137889) = 0.540592.
The exact values is I = 0.540420.
The magnitudes of the errors in the one point, two point and three point rules are
0.045575, 0.002956, and 0.000172 respectively.
Example 3.24 Evaluate the integral I =
0
1
1
+
dx
x
, using the Gauss three point formula. Compare
with the exact solution.
Solution We reduce the interval [0, 1] to [ 1, 1] to apply the Gauss three point rule.
Writing x = a t + b, we get
0 = a + b, 1 = a + b
Solving, we get a = 1/2, b = 1/2. Therefore, x = (t + 1)/2, dx = dt/2.
The integral becomes
I =
+
=
1
1
1
1
3
dt
t
f t dt ( )
where f(t) = 1/(t + 3).
Using the three point Gauss rule, we obtain
I =
1
9
5
3
5
8 0 5
3
5
f f f
+ +
( )
=
1
9
[5(0.449357) + 8(0.333333) + 5(0.264929)] = 0.693122.
The exact solution is I = ln (2) = 0.693147.
The absolute error in the three point Gauss rule is 0.000025.
Example 3.25 Evaluate the integral I =
0
2
2
4
( 2 1)
1 ( 1)
+ +
+ +
x x
x
dx, by Gauss three point formula.
(A.U. April/May 2005)
Solution We reduce the interval [0, 2] to [ 1, 1] to apply the Gauss three point rule.
166 NUMERICAL METHODS
Writing , b t a x + = we get
0 = a + b, 2 = a + b.
Solving, we get a = 1, b = 1. Therefore, x = t + 1, and dx = dt.
The integral becomes
I =
+
+ +
=
1
1
2
4
1
1
2
1 2
( )
( )
( )
t
t
dt f t dt
where f(t) = (t + 2)
2
/[1 + (t + 2)
4
].
Using the three point Gauss rule, we obtain
I =
1
9
5
3
5
8 0 5
3
5
f f f
+ +
( )
=
1
9
[5(0.461347) + 8(0.235194) + 5(0.127742)] = 0.536422.
Remark 16 We have derived the Gauss-Legendre rules using the method of undetermined
parameters. However, all the Gaussian rules can be obtained using the orthogonal polynomials.
Consider the integration rule (3.73)
I =
a
b
w(x) f(x)dx =
0
f(x
0
) +
1
f(x
1
) +
2
f(x
2
) + ... +
n
f(x
n
). (3.99)
We state the following theorem which gives these rules.
Theorem 3.1 If the abscissas x
k
of the integration rule are selected as zeros of an orthogonal
polynomial, orthogonal with respect to the weight function w(x) over [a, b], then the formula
(3.99) has precision 2n + 1 (or the formula is exact for polynomials of degree 2n + 1). Further,
k
> 0.
The weights are given by
k
=
a
b
w(x) l
k
(x)dx
where l
k
(x), k = 0, 1, , n are the Lagrange fundamental polynomials.
For deriving the Gauss-Legendre formulas, we have w(x) = 1, [a, b] = [ 1, 1], and the
orthogonal polynomials are the Legendre polynomials P
k
(x). The weights are given by
k
=
1
1
l
k
(x)dx. (3.100)
Gauss-Legendre two point formula
The abscissas x
0
, x
1
are the zeros of the Legendre polynomial P
2
(x).
Setting P
2
(x) =
1
2
(3x
2
1) = 0, we obtain x =
1
3
.
NUMERICAL DIFFERENTIATION AND INTEGRATION 167
Let x
0
= 1/ 3 , and x
1
= 1/ 3 , we have
l
0
(x) =
x x
x x
1
0 1
, and l
1
(x) =
x x
x x
0
1 0
.
The weights are given by
0
=
= = =
1
1
0 1
1
1
1
1 1 l x dx l x dx ( ) , ( ) .
The two point rule is as given in (3.88).
Gauss-Legendre three point formula
The abscissas x
0
, x
1
, x
2
are the zeros of the Legendre polynomial P
3
(x).
Setting P
3
(x) =
1
2
(5x
3
3x) = 0, we obtain x = 0,
3
5
.
Let x
0
= 3 5 / , x
1
= 0, and x
2
= 3 5 / . We have
l
0
(x) =
( )( )
( )( )
, ( )
( )( )
( )( )
x x x x
x x x x
l x
x x x x
x x x x
=
1 2
0 1 0 2
1
0 2
1 0 1 2
,
l
2
(x) =
( )( )
( )( )
x x x x
x x x x
0 1
2 0 2 1
.
The weights are given by
0
=
= = = = =
1
1
0 1
1
1
1 2
1
1
2
5
9
8
9
5
9
l x dx l x dx l x dx ( ) , ( ) , ( )
.
The three point rule is as given in (3.97).
REVIEW QUESTIONS
1. Write the error term in the Gauss one point rule for evaluating the integral
1
1
f x dx ( ) .
Solution The error term in the Gauss one point rule is given by
R(f) =
1
3
f ( ) , 1 < < 1.
2. Write the error term in the Gauss two point rule for evaluating the integral
1
1
f x dx ( ) .
Solution The error term in the Gauss two point rule is given by
R(f) =
1
135
4
f
( )
( )
, 1 < < 1.
168 NUMERICAL METHODS
3. Write the error term in the Gauss three point rule for evaluating the integral
1
1
f x dx ( ) .
Solution The error term in the Gauss three point rule is given by
R(f ) =
1
15750
6
f
( )
( ) , 1 < < 1.
EXERCISE 3.3
1. Use three point Gauss formula to evaluate
1
2
dx
x
. (A.U. Nov./Dec. 2003)
2. Apply Gauss two point formula to evaluate
+
1
1
2
1
dx
x
. (A.U. April/May 2005)
3. Using three point Gauss formula, evaluate
0
1
2
1
+
dx
x
. (A.U. April/May 2004)
4. Evaluate
0
2
2
4
2 1
1 1
+ +
+ +
( )
( )
x x
x
dx by Gauss three point formula. (A.U. April/May 2005)
5. Using the three point Gauss quadrature, evaluate
0
1
4
1
+
dx
x
. (A.U. Nov./Dec. 2005)
6. Evaluate
0.2
1 5
2
.
e
x
dx using the three point Gauss quadrature. (A.U. April/May 2003)
7. Use two point and three point Gauss formula to evaluate I =
0
2
3 4
+
dx
x
. Compare with
the exact solution.
8. Use two point and three point Gauss formula to evaluate
0
2
2
2 10
+ +
dx
x x
.
9. Find the value of the integral I =
2
3
2
1
+
cos
sin
x
x
dx, using two point and three point Gauss
formulas.
10. In problem 7, write I = I
1
+ I
2
=
0
1
f(x) dx +
1
2
a
b
f x y dx
( , ) dy (3.101)
over a rectangle x = a, x = b, y = c, y = d. (Fig. 3.2).
3.3.4.1 Evaluation of Double Integrals Using Trapezium Rule
Evaluating the inner integral in (3.101) by trapezium rule, we obtain
I =
b a
f a y f b y dy
c
d
2
[ ( , ) ( , )] . (3.102)
Using the trapezium rule again to evaluate the integrals in (3.102), we obtain
I =
( )( )
[ ( , ) ( , ) ( , ) ( , )]
b a c d
f a c f a d f b c f b d
+ + +
4
. (3.103)
Notice that the points (a, c), (a, d), (b, c), (b, d) are
the four corners of the rectangle (Fig. 3.2). If we denote
h = b a, k = d c, we can write the formula as
I =
hk
4
[f(a, c) + f(a, d) + f(b, c) + f(b, d)]. (3.104)
The weights (coefficients of the ordinates f ) in the trapezium rule are given in the
computational molecule (Fig. 3.3).
Composite trapezium rule Divide the interval [a, b] into N equal subintervals each of length
h, and the interval [c, d] into M equal subintervals each of length k. We have
h =
b a
N
, x
0
= a, x
1
= x
0
+ h, x
2
= x
0
+ 2h, ..., x
N
= x
0
+ N h = b,
k =
d c
M
, y
0
= c, y
1
= y
0
+ k, y
2
= y
0
+ 2k, ..., y
M
= y
0
+ M k = d.
The general grid point is given by (x
i
, y
j
). Denote, f
ij
= f(x
i
, y
j
). That is,
f
00
= f(x
0
, y
0
) = f(a, c), f
10
= f(x
1
, y
0
), ..., f
N0
= f(x
N
, y
0
) = f(b, c), ...,
f
01
= f(x
0
, y
1
), f
11
= f(x
1
, y
1
), ..., f
0M
= f(x
0
, y
M
) = f(a, d), etc.
If we use the composite trapezium rule in both the directions, we obtain
I =
hk
4
[f
00
+ 2(f
01
+ f
02
+ ... + f
0M1
) + f
0M
+ 2
i
N
=
1
1
{f
i0
+ 2(f
i1
+ f
i2
+ ... + f
iM1
) + f
iM
} (3.105)
+ f
N0
+ 2(f
N1
+ f
N2
+ ... + f
NM1
) + f
NM
]
1
1 1
1
hk
4
( , )
dy
over a rectangle x = a, x = b, y = c, y = d. (Fig. 3.2).
To apply the Simpsons rule, let h = (b a)/2 and k = (d c)/2.
Evaluating the inner integral by Simpsons rule, we obtain
I =
h
c
d
3
[f(a, y) + 4f(a + h, y) + f(b, y)] dy (3.106)
where a + h = (a + b)/2.
Evaluating the integral again by Simpsons rule, we obtain
I =
hk
9
[{ f(a, c) + 4f(a, c + k) + f(a, d)} + 4{ f(a + h, c) + 4f(a + h, c + k)
+ f(a + h, d)} + { f(b, c) + 4f(b, c + k) + f(b, d)}]
174 NUMERICAL METHODS
=
hk
9
[{f(a, c) + f(a, d) + f(b, c) + f(b, d)} + 4{f(a, c + k)
+ f(a + h, c) + f(a + h, d) + f(b, c + k)} + 16 f(a + h, c + k)]. (3.107)
The weights (coefficients of the ordinates f )
in the Simpsons rule are given in the computational
molecule (Fig. 3.9) below.
Composite Simpsons rule
Divide the interval [a, b] into 2N equal parts each
of length h = (b a)/(2N).
Divide the interval [c, d] into 2M equal parts each
of length h = (d c)/(2M).
We have odd number of points on each mesh line and the total number of points, (2N + 1)
(2M + 1) is also odd.
The general grid point is given by (x
i
, y
j
). Denote, f
ij
= f(x
i
, y
j
).
For M = N = 2, the weights in the composite Simpsons rule are given in Fig. 3.10.
1
4
hk
9
2
4
1
4 2 4 1
4
2
4
1
4 2 4
16 8 16
8 4 8
16 8 16
Fig. 3.10. Weights in the Simpsons rule.
Example 3.28 Evaluate the integral
I =
y x
dx dy
x y = =
+ 1
1.5
1
2
using the Simpsons rule with h = 0.5 along x-axis and k = 0.25 along y-axis. The exact value of
the integral is I = 0.184401. Find the absolute error in the solution obtained by the Simpsons
rule.
Fig. 3.9. Weights in Simpsons
rule (3.107).
1
1 1
1
hk
9
4
4
16
4
4
NUMERICAL DIFFERENTIATION AND INTEGRATION 175
Solution We have a = 1, b = 2, c = 1, d = 1.5. With h
= 0.5, k = 0.25, we have the following nodal points as
given in Fig. 3.11.
The values at the nodal points are as follows.
f(1, 1) = 0.5, f(1, 1.25) = 0.444444,
f(1.5, 1) = f(1, 1.5) = 0.4,
f(1.5, 1.25) = 0.363636,
f(2, 1) = f(1.5, 1.5) = 0.333333,
f(2, 1.25) = 0.307692, f(2, 1.5) = 0.285714.
Simpson rule gives the value of the integral as
I =
hk
9
[{f(a, c) + f(a, d) + f(b, c) + f(b, d)} + 4{f(a, c + k)
+ f(a + h, c) + f(a + h, d) + f(b, c + k)} + 16f(a + h, c + k)]
=
0 125
9
.
[{f(1, 1) + f(2, 1) + f(1, 1.5) + f(2, 1.5)} + 4{f(1.5, 1) + f(1, 1.25)
+ f(2, 1.25) + f(1.5, 1.5)} + 16 f(1.5, 1.25)]
=
0 125
9
.
[{0.5 + 0.333333 + 0.4 + 0.285714} + 4{0.4 + 0.444444
+ 0.307692 + 0.333333} + 16(0.363636)] = 0.184432.
The magnitude of the error in the solution is given by
| 0.184401 0.184432 | = 0.000031.
Example 3.29 Evaluate
0
1
0
1
+
e dx dy
x y
using Simpson and trapezium rules.
(A.U. May/June 2006 ; A.U. Nov./Dec. 2006)
Solution Since the step lengths are not prescribed, we
use the minimum number of intervals required to use
both the trapezium and Simpsons rules.
Let h = k = 0.5. We have the following grid of points
(Fig. 3.12).
At the nodal points, we have the following values
of the integrand.
f(0, 0) = e
0
= 1.0, f(0.5, 0) = f(0, 0.5) = e
0.5
= 1.648720,
f(1, 0) = f(0, 1) = f(0.5, 0.5) = e
1
= 2.71828,
f(1, 0.5) = f(0.5, 1) = e
1.5
= 4.48169, f(1, 1) = e
2
= 7.389056.
Fig. 3.12. Nodal points. Example 3.29.
(0, 1)
(0.5, 0)
(0, 0.5)
(0, 0) (1, 0)
(1, 0.5)
(1, 1) (0.5, 1)
(0.5, 0.5)
(1, 1.5)
(1.5, 1)
(1, 1.25)
(1, 1) (2, 1)
(2, 1.25)
(2, 1.5) (1.5, 1.5)
(1.5, 1.25)
Fig. 3.11. Nodal points. Example 3.28.
176 NUMERICAL METHODS
Using the trapezoidal rule, we obtain
I =
hk
4
[{f(0, 0) + f(1, 0) + f(0, 1) + f(1, 1)} + 2{f(0.5, 0) + f(0, 0.5) + f(1, 0.5)
+ f(0.5, 1)} + 4 f(0.5, 0.5)]
= 0.0625[{1.0 + 2(2.71828) + 7.389056} + 2{2(1.64872)
+ 2(4.48169)} + 4(2.71828)] = 3.07627.
Using the Simpsons rule, we obtain
I =
hk
9
[{f(0, 0) + f(1, 0) + f(0, 1) + f(1, 1)} + 4{f(0.5, 0) + f(0, 0.5)
+ f(0.5, 1.0) + f(1.0, 0.5)} + 16 f(0.5, 0.5)]
=
0 25
9
.
[{1.0 + 2(2.71828) + 7.389056} + 4{2(1.64872)
+ 2(4.48169)} + 16(2.71828)] = 2.95448.
The exact solution is I = e e e
x y
= =
0
1
0
1
2
1 295249 ( ) .
.
The magnitudes of errors in the solutions are
Trapezium rule: | 3.07627 2.95249 | = 0.12378.
Simpsons rule: | 2.95448 2.95249 | = 0.00199.
EXERCISE 3.4
1. Using Simpsons 1/3 rule, evaluate
0
1
0
1
1
+ +
dx dy
x y
taking h = k = 0.5.
(A.U. April/May 2004)
2. Evaluate
0
1
0
1
1
+ +
dx dy
x y
using trapezium rule, taking h = 0.5, k = 0.25.
(A.U. Nov./Dec. 2006)
3. Evaluate
0
1
1
2
2 2
2
1 1
+ +
xy
x y
dy dx
( )( )
by trapezium rule, taking h = k = 0.25.
(A.U. Nov./Dec. 2004 ; A.U. Nov./Dec. 2005)
NUMERICAL DIFFERENTIATION AND INTEGRATION 177
4. Evaluate
1
2
1
2
2 2
+
dx dy
x y
numerically with h = 0.2 along x-direction and k = 0.25 in the
y-direction.
5. Using trapezium rule, evaluate
1 4
2 0
1 0
1 5
2
.
.
.
.
ln ( )
+ x y dy dx choosing x = 0.15 and
y = 0.25. (A.U. April/May 2003)
6. Using trapezium rule evaluate,
1
2
1
2
+
dx dy
x y
taking four sub-intervals.
(A.U. Nov./Dec. 2003)
7. Evaluate the double integral
1
1 5
1
1 5
2 2 1 2
. .
/
( )
+
dx dy
x y
using the trapezium rule and Simpsons
rule with two subintervals.
8. Evaluate the double integral
0
1
0
1
3 4
+ +
dx dy
x y ( )( )
using the trapezium rule and
Simpsons rule with two and four subintervals.
!" )59-45 ), 0165
Exercise 3.1
1. 1.0. 2. 0.2225, 52.170833.
3. y is maximum at s = 2.3792 or x = 0.3792. y(maximum) = 0.0723. y is minimum at
s = 1.1208 or x = 0.8792. y(minimum) = 0.2598.
4. y is maximum at s = 1.0546 or x = 10.0546. y(maximum) = 1339.8637. y is minimum at
s = 2.0546. y(minimum) = 1300.1363.
5. 3.9485, 3.5894.
6. (h
2
/6) f (x
k
) + ..., or as (h
2
/6) f (), x
k
h < < x
k
+ h.
7. 3.3202, 3.3211. 8. 0.2558.
9. (dy/d) = sec
2
. For = 31, (dy/d) = 0.023967. sec (31) = 0.1548.
10. 3. 11. 4.4235. Magnitude of error = 0.0582.
12. 135, 98. Since (dy/dx) is always positive, y is an increasing function. The maximum
value is obtained at x = 9. Maximum value = 922.
13. 135.
14. h = 0.2: 7.3875. h = 0.1: 7.31. Exact : 7.2885. Magnitudes of errors are 0.099 and 0.0245
respectively. Error is smaller for h = 0.1.
178 NUMERICAL METHODS
Exercise 3.2
(For comparison, the exact solutions are given, wherever it is necessary).
1. h = 0.125, 0.697024 2. h = 1, 35.65.
3. h = /6, 1.954097, Exact : 2.0.
4. h = 0.5, 0.411059. Exact: cos 1 cos 6 = 0.4199.
5. h = 2,360. 6. h = 0.25, 1.565588. Exact: 2 tan
1
1 = 570796.
7. h = 0.25, 1.000169. Exact : 1.
8. h = 1: 6.420728, h = 0.5: 6.391210. Romberg value = 6.389242. Exact: 6.389056.
9. h = 3, I
T
= 1.840541, I
S
= 1.427027. Exact: tan
1
6 = 1.405648.
10. Trapezium rule: (Romberg table).
p = 0 p = 1
h O(h
2
) O(h
4
) O(h
6
) h O(h
2
) O(h
4
) O(h
6
)
1/2 0.097110 1/2 0.072419
1/4 0.097504 0.097635 1/4 0.061305 0.057600
1/8 0.097604 0.097637 0.097637 1/8 0.054322 0.051994 0.051621
Simpsons rule: (Romberg table).
p = 0 p = 1
h O(h
4
) O(h
6
) O(h
8
) h O(h
4
) O(h
6
) O(h
8
)
1/2 0.097662 1/2 0.064740
1/4 0.097635 0.097633 1/4 0.056448 0.055895
1/8 0.097634 0.097634 0.097634 1/8 0.052283 0.052005 0.051944
11. 1.76351, 1.79099. The second result is more accurate.
12. h = 0.5, 0.402521, ln (0.5) = 1.610084. Exact: 1.609438.
13. h = /10, I
T
= 1.983524, I
S
= 2.000110. Exact: 2.
14. h = 1/6, 0.785396.
Exercise 3.3
(For comparison, the exact solutions are given, wherever it is necessary).
1. 2x = t + 3, f(t) = 1/(t + 3), 0.693122 2. 1.5.
3. 2x = t + 1, f(t) = 2/[4 + (t + 1)
2
], 0.785267
4. x = t + 1, f(t) = (t + 2)
2
/[1 + (t + 2)
4
], 0.586423.
5. 2x = t + 1, f(t) = 2/[16 + (t + 1)
4
], 0.216880.
NUMERICAL DIFFERENTIATION AND INTEGRATION 179
6. x = 0.65t + 0.85, f(t) = 0.65e
t + ( ) 0.65 0.85
2
, 0.658602.
7. x = t + 1, f(t) = 1/(4t + 7), I(Two point) = 0.320610, I(Three point) = 0.324390.
Exact : 0.324821.
8. x = t + 1, f(t) = 1/[9 + (t + 2)
2
]. I(Two point) = 0.154639. I(Three point) = 0.154548.
9. 2x = t + 5, f(t) = cos (t + 5)/[2(1 + sin {(t + 5)/2}], I(Two point) = 0.407017.
I(Three point) = 0.405428.
10. I
1
: 2x = t + 1, f(t) = 1/[2/{3 + 2(t + 1)}], I : 2x = t + 3, f(t) = 1/[2{3 + 2(t + 3)}],
Two point formula: I
1
= 0.211268, I
2
= 0.112971, I = 0.324239.
Three point formula: I
1
= 0.211799, I
2
= 0.112996, I = 0.324795. Exact: 0.324821.
Results are more accurate than in Problem 7.
Exercise 3.4
1. 9 points. 0.524074. 2. 15 points. 0.531953.
3. 25 points. 0.312330. 4. 30 points. 0.232316.
5. 15 points. 0.428875. 6. 25 points. 0.340668.
7. 9 points. I
T
= 0.142157, I
S
= 0.141900.
8. Two subintervals: I
T
= 0.064554, I
S
= 0.064199.
Four subintervals: I
T
= 0.064285, I
S
= 0.064195.
180
"
nitial Value Problems For
Ordinary Differential Equations
4.1 NTRODUCTON
The general form of an mth order ordinary differential equation is given by
(x, y, y, y, ..., y
(m)
) = 0. (4.1)
The order of a differential equation is the order of its highest order derivative and the
degree is the degree of the highest order derivative after the equation has been rationalized
in derivatives. A linear differential equation of order m can be written as
a
0
(x) y
(m)
(x) + a
1
(x) y
(m1)
(x) + ... + a
m1
(x) y(x) + a
m
(x) y(x) = r(x) (4.2)
where a
0
(x), a
1
(x), ..., a
m
(x) and r(x) are constants or continuous functions of x.
The general solution of the equations (4.1) or (4.2) contains m arbitrary constants. The
solution may be obtained in an implicit form as
g(x, y, c
1
, c
2
, ..., c
m
) = 0, (4.3)
or in an explicit form as
y = h(x, c
1
, c
2
, ..., c
m
) (4.4)
The m arbitrary constants c
1
, c
2
, ..., c
m
can be determined by prescribing m conditions of
the form
y(x
0
) = b
0
, y(x
0
) = b
1
, y(x
0
) = b
2
, ..., y
(m1)
(x
0
) = b
m1
. (4.5)
The conditions are prescribed at one point x
0
. This point x
0
is called the initial point and
the conditions (4.5) are called initial conditions. The differential equation (4.1) or (4.2) to-
gether with the initial conditions (4.5) is called an initial value problem.
A first order initial value problem can be written as
y = f (x, y), y(x
0
) = b
0
(4.6)
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 181
Reduction of second order equation to a first order system
Let the second order initial value problem be given as
a
0
(x) y(x) + a
1
(x) y(x) + a
2
(x) y(x) = r(x),
y(x
0
) = b
0
, y(x
0
) = b
1
(4.7)
We can reduce this second order initial value problem to a system of two first order
equations.
Define u
1
= y. Then, we have the system
u
1
= y = u
2
, u
1
(x
0
) = b
0
,
u
2
= y =
1
0
a x ( )
[r(x) a
1
(x) y(x) a
2
(x) y(x)]
=
1
0
a x ( )
[r(x) a
1
(x) u
2
a
2
(x) u
1
], u
2
(x
0
) = b
1
.
The system is given by
u
u
u
f x u u
1
2
2
2 1 2
( , , )
,
u x
u x
b
b
1 0
2 0
0
1
( )
( )
(4.8)
where f
2
(x, u
1
, u
2
) =
1
0
a x ( )
[r(x) a
1
(x) u
2
a
2
(x) u
1
].
In general, we may have a system as
y
y
f x y y
f x y y
1
2
1 1 2
2 1 2
( , , )
( , , )
,
y x
y x
b
b
1 0
2 0
0
1
( )
( )
. (4.9)
In vector notation, denote
y = [y
1
, y
2
]
T
, f = [f
1
, f
2
]
T
, b = [b
0
, b
1
]
T
.
Then, we can write the system as
y = f(x, y),
y(x
0
) = b. (4.10)
Therefore, the methods derived for the solution of the first order initial value problem
dy
dx
= f(x, y), y(x
0
) = y
0
(4.11)
can be used to solve the system of equations (4.9) or (4.10), that is, the second order initial
value problem (4.7), by writing the method in vector form.
Example 4.1 Reduce the following second order initial value problems into systems of first
order equations:
(i) 2y 5y + 6y = 3x, y(0) = 1, y(0) = 2.
(ii) x
2
y + (2x + 1)y + 3y = 6, y(1) = 2, y(1) = 0.5.
182 NUMERICAL METHODS
Solution
(i) Let u
1
= y. Then, we have the system
u
1
= u
2
u
1
(0) = 1,
u
2
=
1
2
5 6
1
2
5 6 0 2
2 1 2
[3 ] [3 ], ( ) . x y y x u u u + = + =
The system may be written as
u
u
f x u u
f x u u
u
u
1
2
1 1 2
2 1 2
1
2
0
0
1
2
( , , )
( , , )
,
( )
( )
where f
1
(x, u
1
, u
2
) = u
2
and f
2
(x, u
1
, u
2
) = [3x + 5u
2
6u
1
]/2.
(ii) Let u
1
= y. Then, we have the system
u
1
= u
2
, u
1
(1) = 2,
u
2
=
1
2 1 3
1
2 1 3 1 0 5
2 2
2 1 2
x
x y y
x
x u u u [6 ( ) ] [6 ( ) ], ( ) . + = + = .
The system may be written as
u
u
f x u u
f x u u
u
u
1
2
1 1 2
2 1 2
1
2
1
1
2
05
( , , )
( , , )
,
( )
( ) .
where f
1
(x, u
1
, u
2
) = u
2
and f
2
(x, u
1
, u
2
) = [6 (2x + 1)u
2
3u
1
]/x
2
.
We assume the existence and uniqueness of solutions of the problems that we are considering.
Numerical methods We divide the interval [x
0
, b] on which the solution is desired, into a
finite number of subintervals by the points
x
0
< x
1
< x
2
< ... < x
n
= b.
The points are called mesh points or grid points. The spacing between the points is
given by
h
i
= x
i
x
i1
, i = 1, 2, ..., n. (4.12)
If the spacing is uniform, then h
i
= h = constant, i = 1, 2, ..., n.
For our discussions, we shall consider the case of uniform mesh only.
4.2 8NGLE 8TEP AND MULT 8TEP METHOD8
The methods for the solution of the initial value problem
y = f(x, y), y(x
0
) = y
0
(4.13)
can be classified mainly into two types. They are (i) single step methods, and (ii) multi step
methods.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 183
We denote the numerical solution and the exact solution at x
i
by y
i
and y(x
i
) respectively.
Single step methods In single step methods, the solution at any point x
i+1
is obtained using
the solution at only the previous point x
i
. Thus, a general single step method can be written as
y
i+1
= y
i
+ h (x
i+1
, x
i
, y
i+1
, y
i
, h) (4.14)
where is a function of the arguments x
i+1
, x
i
, y
i+1
, y
i
, h and depends on the right hand side
f(x, y) of the given differential equation. This function is called the increment function.
If y
i+1
can be obtained simply by evaluating the right hand side of (4.14), then the method
is called an explicit method. In this case, the method is of the form
y
i+1
= y
i
+ h (x
i
, y
i
, h). (4.15)
That is, we compute successively
y
1
= y
0
+ h (x
0
, y
0
, h), y
2
= y
1
+ h (x
1
, y
1
, h), ....
If the right hand side of (4.14) depends on y
i+1
also, then it is called an implicit method,
that is, we obtain a nonlinear algebraic equation for the solution of y
i+1
(if the differential
equation is nonlinear).
Local truncation error or discretization error The exact solution y(x
i
) satisfies the equation
y(x
i+1
) = y(x
i
) + h (x
i+1
, x
i
, y(x
i+1
), y(x
i
), h) + T
i+1
(4.16)
where T
i+1
is called the local truncation error or discretization error. Therefore, the Trunca-
tion error (T.E.) is defined by
T
i+1
= y(x
i+1
) y(x
i
) h (x
i+1
, x
i
, y(x
i+1
), y(x
i
), h ). (4.17)
Order of a method The order of a method is the largest integer p for which
1
1
h
T O h
i
p
+
= ( ) . (4.18)
Multi step methods In multi step methods, the solution at any point x
i+1
is obtained using
the solution at a number of previous points. Suppose that we use y(x) and y(x) at k + 1 previous
points x
i+1
, x
i
, x
i1
, ..., x
ik+1
. That is, the values
y
i+1
,
y
i
, y
i1
, ..., y
ik+1
, y
i+1
, y
i
, y
i1
,..., y
ik+1
are used to determine the approximation to y(x) at x
i+1
. We assume that the numerical solu-
tion is being obtained at x
i+1
and the solution values at all the required previous points are
known. We call the method as a k-step multi step method.
For example, a two step method uses the values y
i+1
,
y
i
, y
i1
, y
i+1
, y
i
, y
i1
and the method
can be written as
y
i+1
=
y
i
+ h (x
i+1
, x
i
, x
i1
, y
i+1
,
y
i
, y
i1
, h)
or as y
i+1
= y
i1
+ h (x
i+1
, x
i
, x
i1
, y
i+1
,
y
i
, y
i1
, h),
184 NUMERICAL METHODS
where depends on the right hand side f(x, y) of the given differential equation. This function
is called the increment function.
If y
i+1
can be obtained simply by evaluating the right hand side, then the method is
called an explicit method. In this case, the two step method is of the form
y
i+1
= y
i
+ h(x
i
, x
i1
, y
i
,
y
i1
, h)
or as y
i+1
= y
i1
+ h(x
i
, x
i1
, y
i
,
y
i1
, h).
If the right hand side depends on y
i+1
also, then it is called an implicit method, that is,
we obtain a nonlinear algebraic equation for the solution of y
i+1
(if the differential equation is
nonlinear).
A general k-step explicit method can be written as
y
i+1
= y
i
+ h(x
ik+1
, ..., x
i1
, x
i
, y
ik+1
, ..., y
i1
, y
i
, h)
and a general k-step implicit method can be written as
y
i+1
= y
i
+ h(x
ik+1
, ..., x
i
, x
i+1
, y
ik+1
, ..., y
i
, y
i+1
, h).
We now derive a few numerical methods.
4.3 TAYLOR 8ERE8 METHOD
Taylor series method is the fundamental numerical method for the solution of the initial value
problem given in (4.13).
Expanding y(x) in Taylor series about any point ,
i
x with the Lagrange form of remain-
der, we obtain
y(x) = y(x
i
) + (x x
i
) y(x
i
) +
1
2!
(x x
i
)
2
y(x
i
) + ... +
1
p!
(x x
i
)
p
y
(p)
(x
i
)
+
1
1
1 1
( ) !
( ) ( )
( )
p
x x y x h
i
p p
i
+
+
+ +
(4.19)
where 0 < < 1, x [x
0
, b] and b is the point up to which the solution is required.
We denote the numerical solution and the exact solution at x
i
by y
i
and y(x
i
) respec-
tively.
Now, consider the interval [x
i
, x
i+1
]. The length of the interval is h = x
i+1
x
i
.
Substituting x = x
i+1
in (4.19), we obtain
y(x
i+1
) = y(x
i
) + h y(x
i
) +
h
y x
h
p
y x
h
p
y x h
i
p
p
i
p
p
i
2 1
1
2 1 !
( ) ...
!
( )
( ) !
( )
( ) ( )
+ + +
+
+
+
+
.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 185
Neglecting the error term, we obtain the Taylor series method as
y
i+1
= y
i
+ hy
i
+
h
2
2!
y
i
+ ... +
h
p
y
p
i
p
!
( )
. (4.20)
Note that Taylor series method is an explicit single step method.
Using the definition given in (4.17), the truncation error of the method is given by
T
i+1
=
h
p
y x h
p
p
i
+
+
+
+
1
1
1 ( ) !
( )
( )
. (4.21)
Using the definition of the order given in (4.18), we say that the Taylor series method
(4.20) is of order p.
For p = 1, we obtain the first order Taylor series method as
y
i+1
= y
i
+ hy
i
= y
i
+ hf(x
i
, y
i
). (4.22)
This method is also called the Euler method. The truncation error of the Eulers method is
T.E. =
h
y x h
i i
2
2!
( ) + . (4.23)
Sometimes, we write this truncation error as
T.E. =
h
y x
h
y x
i i
2 3
2 3 !
( )
!
( ) ... + +
(4.24)
Since,
1
h
(T.E.) = O(h),
Euler method is a first order method. If the higher order derivatives can be computed, then
(4.24) can be used to predict the error in the method at any point.
Remark 1 Taylor series method cannot be applied to all problems as we need the higher order
derivatives. The higher order derivatives are obtained as
y = f(x, y), y =
f
x
f
y
dy
dx
f f f
x y
+ = + ,
y =
x
f
x
f
y
dy
dx y
f
x
f
y
dy
dx
dy
dx
+
+ +
= f
xx
+ 2f f
xy
+ f
2
f
yy
+ f
y
(f
x
+ f f
y
), etc.
The number of partial derivatives required, increases as the order of the derivative of y
increases. Therefore, we find that computation of higher order derivatives is very difficult.
Hence, we need suitable methods which do not require the computation of higher order
derivatives.
186 NUMERICAL METHODS
Remark 2 The bound on the truncation error of the Taylor series method of order p is given
by
| |
( ) !
( )
( ) !
( )
T
h
p
y x h
h
p
M
i
p
p
i
p
p +
+
+
+
+
=
+
+
+
1
1
1
1
1
1 1
(4.25)
where M
p+1
= max | ( )|
( )
x x b
p
y x
0
1
+
.
The bound on the truncation error of the Euler method (p = 1) is given by
| T.E. |
h
y x
x x b
2
2 0
max | ( )|
. (4.26)
Remark 3 For performing the error analysis of the numerical methods, we need the Taylor
series expansion of function of two variables. The Taylor expansion is given by
f(x + h, y + k) = f(x, y) +
h
x
k
y
f x y h
x
k
y
f x y
+ +
( , )
!
( , )
1
2
2
+ ...
= f(x, y) + (h f
x
+ k f
y
) +
1
2
2
2 2
!
( ) ... h f hk f k f
xx xy yy
+ + + (4.27)
Remark 4 Extrapolation procedure (as described in numerical integration for Romberg inte-
gration) can also be used for the solution of the ordinary differential equations. We illustrate
this procedure for Eulers method. Denote the numerical values obtained with step length h
by y
E
(h). Eulers method is of first order, that is, the error expression is given by
y(x) y
E
(h) = c
1
h + c
2
h
2
+ c
3
h
3
+ ... (4.28)
Repeating the computations with step length qh, 0 < q < 1, we get the error of approxi-
mation as
y(x) y
E
(qh) = c
1
(qh) + c
2
(qh)
2
+ c
3
(qh)
3
+ ... (4.29)
Eliminating c
1
, we obtain
q[y(x) y
E
(h)] [y(x) y
E
(qh)] = c
2
(q q
2
)h
2
+ ...
or (q
1)y(x) [q y
E
(x) y
E
(qh)] = c
2
(q q
2
)h
2
+ ...
Neglecting the O(h
2
) term, we get the new approximation to y(x) as
y(x)
[ ( ) ( )] q y h y qh
q
E E
1
. (4.30)
For q = 1/2, we get
y(x)
[( / ) ( ) ( / )]
( / )
12 2
12 1
y h y h
E E
=
[ ( / ) ( )] 2 2
2 1
y h y h
E E
= [2y
E
(h/2) y
E
(h)]. (4.31)
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 187
We can derive general formula for extrapolation. Let the step lengths be successively
reduced by the factor 2. That is, we use the step lengths, h, h/2, (h/2
2
), ... . The formula is given
by
y(x) y h
y h y h
E
m
m
E
m
E
m
m
( )
( ) ( )
( )
( / ) ( )
=
2 2
2 1
1 1
. (4.32)
For m = 1, we get the first column of approximations as
y(x)
2 2
2 1
0 0
y h y h
E E
( ) ( )
( / ) ( )
= 2 2
0 0
y h y h
E E
( ) ( )
( / ) ( ) . (4.33)
For m = 2, we get the second column of approximations as
y(x)
2 2
2 1
2 1 1
2
y h y h
E E
( ) ( )
( / ) ( )
. (4.34)
Example 4.2 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. Compare the results with the exact solution at x = 0.8. Extrapo-
late the result.
Solution We have y = f(x, y) = (x/y).
Euler method gives y
i+1
= y
i
+ h f (x
i
, y
i
) = y
i
+
hx
y
i
i
.
Initial condition gives x
0
= 0, y
0
= 1.
When h = 0.2, we get y
i+1
= y
i
+
0 2 . x
y
i
i
.
We have the following results.
y(x
1
) = y(0.2) y
1
= y
0
+
0 2
0
0
. x
y
= 1.0.
y(x
2
) = y(0.4) y
2
= y
1
+
0 2
10
0 2 0 2
10
1
1
.
.
. ( . )
.
x
y
= + = 1.04.
y(x
3
) = y(0.6) y
3
= y
2
+
0 2
104
0 2 0 4
104
2
2
.
.
. ( . )
.
x
y
= + = 1.11692
y(x
4
) = y(0.8) y
4
= y
3
+
0 2
111692
0 2 0 6
111692
3
3
.
.
. ( . )
.
x
y
= + = 1.22436.
When h = 0.1, we get y
i+1
= y
i
+
0 1 . x
y
i
i
.
We have the following results.
188 NUMERICAL METHODS
y(x
1
) = y(0.1) y
1
= y
0
+
0 1
0
0
. x
y
= 1.0.
y(x
2
) = y(0.2) y
2
= y
1
+
0 1
10
0 1 0 1
10
1
1
.
.
. ( . )
.
x
y
= + = 1.01.
y(x
3
) = y(0.3) y
3
= y
2
+
0 1
101
0 1 0 2
101
2
2
.
.
. ( . )
.
x
y
= + = 1.02980.
y(x
4
) = y(0.4) y
4
= y
3
+
0 1
10298
0 1 0 3
10298
3
3
.
.
. ( . )
.
x
y
= + = 1.05893.
y(x
5
) = y(0.5) y
5
= y
4
+
0 1
105893
0 1 0 4
105893
4
4
.
.
. ( . )
.
x
y
= + = 1.09670.
y(x
6
) = y(0.6) y
6
= y
5
+
0 1
10967
0 1 0 5
10967
5
5
.
.
. ( . )
.
x
y
= + = 1.14229.
y(x
7
) = y(0.7) y
7
= y
6
+
0 1
114229
0 1 0 6
114229
6
6
.
.
. ( . )
.
x
y
= + = 1.19482.
y(x
8
) = y(0.8) y
8
= y
7
+
0 1
119482
0 1 0 7
119482
7
7
.
.
. ( . )
.
x
y
= + = 1.25341.
The exact solution is y =
x
2
1 +
.
At x = 0.8, the exact value is y(0.8) =
1.64
= 1.28062.
The magnitudes of the errors in the solutions are the following:
h = 0.2: | 1.28062 1.22436 | = 0.05626.
h = 0.1: | 1.28062 1.25341 | = 0.02721.
Using (4.31), we get the extrapolated result as
y(0.8) = [2y
E
(h/2) y
E
(h)] = 2(1.25341) 1.22436 = 1.28246.
The magnitude of the error in the extrapolated result is given by
| 1.28062 1.28246 | = 0.00184.
Example 4.3 Consider the initial value problem y = x(y + 1), y(0) = 1. Compute y(0.2) with h
= 0.1 using (i) Euler method (ii) Taylor series method of order two, and (iii) fourth order Taylor
series method. If the exact solution is y = 1 + 2e
x
2
2 /
, find the magnitudes of the actual errors
for y(0.2). In the solutions obtained by the Euler method, find the estimate of the errors.
Solution We have f(x, y) = x(y + 1), x
0
= 0, y
0
= 1.
(i) Eulers method: y
i+1
= y
i
+ h f(x
i
, y
i
) = y
i
+ 0.1[x
i
(y
i
+ 1)].
With x
0
= 0, y
0
= 1, we get
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 189
y(0.1) y
1
= y
0
+ 0.1[x
0
(y
0
+ 1)] = 1 + 0.1[0] = 1.0.
With x
1
= 0.1, y
1
= 1.0, we get
y(0.2) y
2
= y
1
+ 0.1 [x
1
(y
1
+ 1)]
= 1.0 + 0.1[(0.1)(2)] = 1.02.
(ii) Taylor series second order method.
y
i+1
= y
i
+ h y
i
+
h
2
2!
y
i
= y
i
+ 0.1 y
i
+ 0.005y
i
.
We have y = xy + y + 1.
With x
0
= 0, y
0
= 1, we get
y
0
= 0, y
0
= x
0
y
0
+ y
0
+ 1 = 0 + 1 + 1 = 2.
y y y y y ( . ) . . 0 1 0 1 0 005
1 0 0 0
= + +
= 1 + 0 + 0.005 [ 2] = 1.01.
With x
1
= 0.1, y
1
= 1.01, we get
y
1
= 0.1(1.01 + 1) = 0.201.
y
1
= x
1
y
1
+ y
1
+ 1 = (0.1)(0.201) + 1.01 + 1 = 2.0301.
y(0.2) y
2
= y
1
+ 0.1 y
1
+ 0.005y
1
= 1 + 0 + 0.005 (2) + 0 +
0 0001
24
.
(6) = 1.010025.
With x
1
= 0.1, y
1
= 1.010025, we get
y
1
= 0.1(1.010025 + 1) = 0.201003.
y
1
= x
1
y
1
+ y
1
+ 1 = (0.1)(0.201003) + 1.010025 + 1 = 2.030125.
y
1
= x
1
y
1
+ 2y
1
= 0.1(2.030125) + 2(0.201003) = 0.605019,
y
1
(4)
= x
1
y
1
+ 3y
1
= 0.1(0.605019) + 3(2.030125) = 6.150877.
190 NUMERICAL METHODS
y(0.2) y
2
= 1.010025 + 0.1(0.201003) + 0.005(2.030125) +
0 001
6
.
(0.605019)
+
0 0001
24
.
(6.150877) = 1.040402.
The exact value is y(0.1) = 1.010025, y(0.2) = 1.040403.
The magnitudes of the actual errors at x = 0.2 are
Euler method: | 1.02 1.040403 | = 0.020403.
Taylor series method of second order: | 1.04025 1.040403 | = 0.000152.
Taylor series method of fourth order: | 1.040402 1.040403 | = 0.000001.
To estimate the errors in the Euler method, we use the approximation
T.E.
h
y x
i
2
2!
( )
.
We have y
0
= 0, y
0
= 2.
[Estimate of error in y(0.1) at x = 0.1]
0 01
2
.
(2) = 0.01.
y
1
= x
1
(y
1
+ 1) = 0.2,
y
1
= 1 + y
1
+ x
1
y
1
= 1 + 1 + 0.1(0.2) = 2.02.
[Estimate of error in y(0.2) at x = 0.2]
0 01
2
.
(2.02) = 0.0101.
Remark 4 In Example 4.3 (iii), notice that the contributions of the fourth and fifth terms on
the right hand side are 0.000101 and 0.000026 respectively. This implies that if the result is
required to be accurate for three decimal places only (the error is 0.0005), then we may
include the fourth term and the fifth term can be neglected.
Example 4.4 Find y at x = 0.1 and x = 0.2 correct to three decimal places, given
y 2y = 3e
x
, y(0) = 0. (A.U. Nov./Dec. 2006)
Solution The Taylor series method is given by
y y hy
h
y
h
y
h
y
i i i i i i +
= + + + + +
1
2 3 4
4
2 3 4 ! ! !
...
( )
We have y = 2y + 3e
x
, y = 2y + 3e
x
, y = 2y + 3e
x
, y
(4)
= 2y + 3e
x
.
With x
0
= 0, y
0
= 0, we get
y
0
= 2y
0
+ 3e
0
= 3, y
0
= 2y
0
+ 3 = 2(3) + 3 = 9,
y
0
= 2y
0
+ 3 = 2(9) + 3 = 21, y
0
(4)
= 2y
0
+ 3 = 2(21) + 3 = 45.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 191
The contribution of the fifth term on the right hand side of the Taylor series is
h
y
4
0
4
4
0 0001
24 !
.
( )
=
(45) = 0.000187 < 0.0005.
Therefore, it is sufficient to consider the five terms on the right hand side of the Taylor
series. We obtain
y(0.1) y
1
= y
0
+ 0.1 y
0
+ 0.005y
0
+
0 001
6
0 0001
24
0 0
4
. .
( )
y y +
= 0 + 0.1(3) + 0.005(9) +
0 001
6
21
0 0001
24
45
.
( )
.
( ) +
= 0.3 + 0.045 + 0.0035 + 0.000187 = 0.348687.
With x
1
= 0.1, y
1
= 0.348687, we get
y
1
= 2y
1
+ 3e
0.1
= 2(0.348687) + 3(1.105171) = 4.012887,
y
1
= 2y
1
+ 3e
0.1
= 2(4.012887) + 3(1.105171) = 11.341287,
y
1
= 2y
1
+ 3e
0.1
= 2(11.341287) + 3(1.105171) = 25.998087,
y y e
1
4
1
01
2 3
( ) .
= + = 2(25.998087) + 3(1.105171) = 55.311687.
The contribution of the fifth term on the right hand side of the Taylor series is
h
y
4
0
4
4
0 0001
24 !
.
( )
=
(55.311687) = 0.00023 < 0.0005.
Therefore, it is sufficient to consider the five terms on the right hand side of the Taylor
series. We obtain
y(0.2) y
2
= y
1
+ 0.1 y
1
+ 0.005 y
1
+
0001
6
00001
24
1 1
4
. .
( )
y y +
= 0.348687 + 0.1(4.012887) + 0.005 (11.341287)
+
0 001
6
25 998087
0 0001
24
55 311687
.
( . )
.
( . ) +
= 0.348687 + 0.401289 + 0.056706 + 0.004333 + 0.00023
= 0.811245.
It is interesting to check whether we have obtained the three decimal place accuracy in
the solutions.
The exact solution is y(x) = 3(e
2x
e
x
), and y(0.1) = 0.348695, y(0.2) = 0.811266.
The magnitudes of the errors are given by
| y(0.1) y
1
| = | 0.348695 0.348687 | = 0.000008.
| y(0.2) y
2
| = | 0.811266 0.811245 | = 0.000021.
192 NUMERICAL METHODS
Example 4.5 Find the first two non-zero terms in the Taylor series method for the solution of
the initial value problem
y = x
2
+ y
2
, y(0) = 0.
Solution We have f(x, y) = x
2
+ y
2
. We have
y(0) = 0, y(0) = 0 + [y(0)]
2
= 0,
y = 2x + 2yy, y(0) = 0 + 2y(0)y(0) = 0,
y = 2 + 2[yy + (y)
2
], y(0) = 2 + 2 [y(0) y(0) + {y(0)}
2
] = 2,
y
(4)
= 2[yy + 3yy], y
(4)
(0) = 2[y(0)y(0) + 3y(0)y(0)] = 0,
y
(5)
= 2[yy
(4)
+ 4yy + 3(y)
2
],
y
(5)
(0) = 2[y(0)y
(4)
(0) + 4y(0)y(0) + 3{y(0)}
2
] = 0,
y
(6)
= 2[yy
(5)
+ 5yy
(4)
+ 10yy],
y
(6)
(0) = 2[y(0)y
(5)
(0) + 5y(0)y
(4)
(0) + 10y(0)y(0)] = 0,
y
(7)
= 2[yy
(6)
+ 6yy
(5)
+ 15yy
(4)
+ 10(y)
2
],
y
(7)
(0) = 2[y(0) y
(6)
(0) + 6y(0)y
(5)
(0) + 15y(0)y
(4)
(0) + 10{y(0)}
2
] = 80.
The Taylor series with first two non-zero terms is given by
y(x) =
x x
3 7
3 63
+ .
We have noted earlier that from application point of view, the Taylor series method has
the disadvantage that it requires expressions and evaluation of partial derivatives of higher
orders. Since the derivation of higher order derivatives is difficult, we require methods which
do not require the derivation of higher order derivatives. Euler method, which is an explicit
method, can always be used. However, it is a first order method and the step length h has to be
chosen small in order that the method gives accurate results and is numerically stable (we
shall discuss this concept in a later section).
We now derive methods which are of order higher than the Euler method.
4.3.1 Modified Euler and Heuns Methods
First, we discuss an approach which can be used to derive many methods and is the basis for
Runge-Kutta methods, which we shall derive in the next section. However, all these methods
must compare with the Taylor series method when they are expanded about the point x = x
i
.
Integrating the differential equation y = f(x, y) in the interval [x
i
, x
i+1
], we get
x
x
x
x
i
i
i
i dy
dx
dx f x y dx
+ +
=
1 1
( , )
or y(x
i+1
) = y(x
i
) +
x
x
i
i
f x y dx
+
1
( , ) . (4.35)
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 193
Applying the mean value theorem of integral calculus to the right hand side, we obtain
y(x
i+1
) y(x
i
) = (x
i+1
x
i
) f (x
i
+ h, y(x
i
+ h)),
or y(x
i+1
) = y(x
i
) + h f (x
i
+ h, y(x
i
+ h)), 0 < < 1. (4.36)
Since x
i+1
x
i
= h. Any value of [0, 1] produces a numerical method.
We note that y and hence f(x, y) is the slope of the solution curve. In (4.35), the integrand
on the right hand side is the slope of the solution curve which changes continuously in [x
i
, x
i+1
].
If we approximate the continuously varying slope in [x
i
, x
i+1
] by a fixed slope or by a linear
combination of slopes at several points in [x
i
, x
i+1
], we obtain different methods.
Case 1 Let = 0. In this case, we are approximating the continuously varying slope in [x
i
, x
i+1
]
by the fixed slope at .
i
x We obtain the method
y
i+1
= y
i
+ hf(x
i
, y
i
),
which is the Euler method. The method is of first order.
Case 2 Let = 1. In this case, we are approximating the continuously varying slope in [x
i
, x
i+1
]
by the fixed slope at x
i+1
. We obtain the method
y
i+1
= y
i
+ hf(x
i+1
, y
i+1
), (4.37)
which is an implicit method as the nonlinear term f(x
i+1
, y
i+1
) occurs on the right hand side.
This method is called backward Euler method. The method is of first order.
The method can be made explicit by writing the approximation y
i+1
= y
i
+ hf (x
i
, y
i
) on
the right hand side of (4.37). Then, we have the explicit method
y
i+1
= y
i
+ hf(x
i+1
, y
i
+ hf(x
i
)). (4.38)
Case 3 Let = 1/2. In this case, we are approximating the continuously varying slope in
[x
i
, x
i+1
] by the fixed slope at x
i+1/2
. We obtain the method
y
i+1
= y
i
+ hf x
h
y x
h
i i
+ +
2 2
, .
However, x
i
+ (h/2) is not a nodal point. If we approximate y(x
i
+ (h/2)) on the right hand
side by Euler method with spacing h/2, that is,
y x
h
i
+
2
= y
i
+
h
2
f(x
i
, y
i
),
we get the method
y
i+1
= y
i
+ hf x
h
y
h
f x y
i i i i
+ +
2 2
, ( , ) . (4.39)
The method is called a modified Euler method or mid-point method. The slope at the
mid-point is replaced by an approximation to this slope.
194 NUMERICAL METHODS
Error of approximation
The truncation error in the method is given by
T.E. = y(x
i+1
) y(x
i
) hf x
h
y x
h
f x y
i i i i
+ +
2 2
, ( ) ( , )
= y hy
h
y y h f
h
f
h
f f h
x y
+ + +
+ + + +
2
2
2 2 2
... ) ... (three terms of
where all the terms are evaluated at (x
i
, y
i
). Using the expressions for y and y, we obtain
T.E. = y hf
h
f f f h
x y
+ + + + +
2
3
2
( ) ) ... (five terms of y
h f
h
f
h
f f h
x y
+ + + +
2 2
2
(three terms of ) ...
= (terms of h
3
) + ...
The truncation error is of order O(h
3
). Therefore, the method is of second order.
Case 4 Let the continuously varying slope in [x
i
, x
i+1
] be approximated by the mean of slopes
at the points x
i
and x
i+1
. Then, we obtain the method
y
i+1
= y
i
+
h
2
[f(x
i
, y
i
) + f(x
i+1
, y
i+1
)]
= y
i
+
h
2
[f
i
+ f
i+1
] (4.40)
where f(x
i
, y
i
) = f
i
and f(x
i+1
, y
i+1
) = f
i + 1
. The method is an implicit method. It is also called the
trapezium method. The method can be made explicit by writing the approximation
y
i+1
= y
i
+ hf(x
i
, y
i
) = y
i
+ h f
i
on the right hand side of (4.32). Then, we have the explicit method
y
i+1
= y
i
+
h
2
[f(x
i
, y
i
) + f(x
i+1
, y
i
+ h f
i
)]. (4.41)
The slope at the point x
i+1
is replaced by an approximation to this slope. The method is
called Heuns method or Euler-Cauchy method.
Error of approximation
The truncation error in the method is given by
T.E. = y(x
i+1
) y(x
i
)
h
2
[f(x
i
) + f(x
i
+ h, y
i
+ h f(x
i
))]
=
y hy
h
y y
h
f h f hf f h
x y
+ + +
+ + + +
2
2
2 2
2 ... ) ... (three terms of
where all the terms are evaluated at (x
i
, y
i
). Using the expressions for y and y, we obtain
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 195
T.E. =
y hf
h
f f f h
x y
+ + + + +
2
3
2
( ) ) ... (five terms of
y
h
2
[2f + h f
x
+ h f f
y
+ (three terms of h
2
) + ...]
= (terms of h
3
) + ...
The truncation error is of order O(h
3
). Therefore, the method is of second order.
Example 4.6 Solve the following initial value problem using the modified Euler method and
Heuns method with h = 0.1 for x [0, 0.3].
y = y + x, y(0) = 1.
Compare with the exact solution y(x) = 2e
x
x 1.
Solution
(i) Modified Euler method is given by
y
i+1
= y
i
+ h f x
h
y
h
f x y
i i i i
+ +
2 2
, ( , )
= y
i
+ 0.1 f(x
i
+ 0.05, y
i
+ 0.05 f(x
i
, y
i
)).
We have x
0
= 0, y
0
= 1.0, y
0
= f
0
= y
0
+ x
0
= 1.0
y(0.1) y
1
= y
0
+ 0.1 f(x
0
+ 0.05, y
0
+ 0.05 f
0
)
= 1.0 + 0.1 f(0.05, 1.05) = 1.0 + 0.1 (1.1) = 1.11.
x
1
= 0.1, y
1
= 1.11, y
1
= f
1
= y
1
+ x
1
= 1.11 + 0.1 = 1.21.
y(0.2) y
2
= y
1
+ 0.1 f(x
1
+ 0.05, y
1
+ 0.05 f
1
)
= 1.11 + 0.1 f(0.15, 1.11 + 0.05(1.21))
= 1.11 + 0.1 f(0.15, 1.1705) = 1.24205.
x
2
= 0.2, y
2
= 1.24205, y
2
= f
2
= y
2
+ x
2
= 1.24205 + 0.2 = 1.44205.
y(0.3) y
3
= y
2
+ 0.1 f(x
2
+ 0.05, y
2
+ 0.05 f
2
)
= 1.24205 + 0.1 f(0.25, 1.24205 + 0.05(1.44205))
= 1.24205 + 0.1 f(0.25, 1.31415) = 1.39846.
The errors in the solution are given in Table 4.1.
Table 4.1. Errors in the modified Euler method. Example 4.6.
Point Numerical solution Exact solution Magnitude of error
0.1 1.11 1.11034 0.00034
0.2 1.24205 1.24281 0.00076
0.3 1.39846 1.39972 0.00126
196 NUMERICAL METHODS
(ii) The Heuns method is given by
y
i+1
= y
i
+
h
2
[f(x
i
, y
i
) + f(x
i+1
, y
i
+ h f
i
)]
= y
i
+ 0.05 [f(x
i
, y
i
) + f(x
i+1
, y
i
+ 0.1 f
i
)]
Denote y
i
* = y
i
+ 0.1 f
i
. Then, we write the method as
y
i+1
= y
i
+ 0.05 [f(x
i
, y
i
) + f(x
i+1
, y
i
*)]
We have x
0
= 0, y
0
= 1.0, y
0
= f
0
= y
0
+ x
0
= 1.0, y
0
* = y
0
+ 0.1 f
0
= 1 + 0.1 (1) = 1.1.
y(0.1) y
1
= y
0
+ 0.05[f
0
+ f(x
1
, y
0
*)]
= 1.0 + 0.05[1.0 + 1.2] = 1.11.
x
1
= 0.1, y
1
= 1.11, y
1
= f
1
= y
1
+ x
1
= 1.11 + 0.1 = 1.21.
y
1
* = y
1
+ 0.1 f
1
= 1.11 + 0.1 (1.21) = 1.231.
y(0.2) y
2
= y
1
+ 0.05[f
1
+ f(x
2
, y
1
*)]
= 1.11 + 0.05[1.21 + f(0.2, 1.231)]
= 1.11 + 0.05 [1.21 + 1.431] = 1.24205.
x
2
= 0.2, y
2
= 1.24205, y
2
= f
2
= f(0.2, 1.24205) = 1.44205.
y
2
* = y
2
+ 0.1 f
2
= 1.24205 + 0.1 (1.44205) = 1.38626.
y(0.3) y
3
= y
2
+ 0.05 [f
2
+ f(x
3
, y
2
*)]
= 1.24205 + 0.05[f
2
+ f(0.3, 1.38626)]
= 1.24205 + 0.05[1.44205 + 1.68626] = 1.39847.
The errors in the solution are given in Table 4.2. Note that the modified Euler method
and the Heuns method have produced the same results in this problem.
Table 4.2. Errors in modified Euler method. Example 4.6.
Point Numerical solution Exact solution Magnitude of error
0.1 1.11 1.11034 0.00034
0.2 1.24205 1.24281 0.00076
0.3 1.39847 1.39972 0.00125
Example 4.7 For the following initial value problem, obtain approximations to y(0.2) and
y(0.4), using the modified Euler method and the Heuns method with h = 0.2.
y = 2xy
2
, y(0) = 1.
Compare the numerical solutions with the exact solution y(x) = 1/(1 + x
2
).
Solution
(i) Modified Euler method is given by
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 197
y
i+1
= y
i
+ hf x
h
y
h
f x y
i i i i
+ +
2 2
, ( , )
= y
i
+ 0.2 f(x
i
+ 0.1, y
i
+ 0.1 f(x
i
, y
i
)).
We have x
0
= 0, y
0
= 1, f(x, y) = 2xy
2
. Denote y
i
* = y
i
+ 0.1 f(x
i
, y
i
).
y
0
= f
0
= 0, y
0
* = y
0
+ 0.1 f
0
= 1.
y(0.2) y
1
= y
0
+ 0.2 f(0.1, 1) = 1 + 0.2 (0.2) = 1 0.04 = 0.96.
x
1
= 0.2, y
1
= 0.96, y
1
= f
1
= 2x
1
y
1
2
= 2(0.2)(0.96)
2
= 0.36864,
y
1
* = y
1
+ 0.1 f
1
= 0.96 + 0.1(0.36864) = 0.92314.
y(0.4) y
2
= y
1
+ 0.2 f(x
1
+ 0.1, y
1
*) = 0.96 + 0.2 f(0.3, 0.92314)
= 0.96 + 0.2 (0.51131) = 0.85774.
(ii) Heuns method is given by
y
i+1
= y
i
+
h
2
[f(x
i
, y
i
) + f(x
i+1
, y
i
+ hf
i
)]
= y
i
+ 0.1 [f(x
i
, y
i
) + f(x
i+1
, y
i
+ 0.2 f
i
)].
Denote y
i
* = y
i
+ 0.2 f
i
. Then, we write the method as
y
i+1
= y
i
+ 0.1 [f(x
i
, y
i
) + f(x
i+1
, y
i
*)]
We have x
0
= 0, y
0
= 1.0, y
0
= f
0
= 0, y
0
* = y
0
+ 0.2 f
0
= 1, x
1
= 0.2.
y(0.2) y
1
= y
0
+ 0.1 [f
0
+ f(x
1
, y
0
*)]
= 1.0 + 0.1[0.0 + f(0.2, 1.0)]
= 1.0 + 0.1 (0.4) = 0.96.
x
1
= 0.2, y
1
= 0.96, f
1
= f(0.2, 0.96) = 0.36864,
y
1
* = y
1
+ 0.2 f
1
= 0.96 + 0.2 (0.36864) = 0.88627, x
2
= 0.4.
y(0.4) y
2
= y
1
+ 0.1 [f
1
+ f(x
2
, y
1
*)]
= 0.96 + 0.1 [0.36864 + f(0.4, 0.88627)]
= 0.96 + 0.1 [0.36864 0.62838] = 0.86030.
The actual errors are given in the following Table 4.3.
Table 4.3. Errors in modified Euler and Heuns methods. Example 4.7.
Modified Euler method Heuns method
x Exact solution Num. solution | Error | Num. solution | Error |
0.2 0.96154 0.96 0.00154 0.96 0.00154
0.4 0.86207 0.85774 0.00433 0.86030 0.00177
198 NUMERICAL METHODS
REVIEW QUESTIONS
1. Define truncation error of a single step method for the solution of the initial value problem
y = f (x, y), y(x
0
) = y
0
.
Solution A single step method for the solution of the given initial value problem is
given by y
i+1
= y
i
+ h(x
i+1
, x
i
, y
i+1
, y
i
, h).
The exact solution y(x
i
) satisfies the equation
y(x
i+1
) = y(x
i
) + h(x
i+1
, x
i
, y(x
i+1
), y(x
i
), h) + T
i+1
where T
i+1
is called the local truncation error or discretization error. Therefore, the
Truncation error (T.E.) is defined by
T
i+1
= y(x
i+1
) y(x
i
) h(x
i+1
, x
i
, y(x
i+1
), y(x
i
), h).
2. Define the order of a numerical method for the solution of the initial value problem y = f(x, y),
y(x
0
) = y
0
.
Solution Let T
i+1
define the truncation error of the numerical method. The order of a
method is the largest integer p for which
1
1
h
T O h
i
p
+
= ( ).
3. Write the truncation error of the Eulers method.
Solution The truncation error of the Eulers method is
T.E. =
h
2
2!
y(x
i
+ h), 0 < < 1.
4. Write the bound on the truncation error of the Eulers method.
Solution The bound on the truncation error of the Euler method (p = 1) is given by
| T.E. |
h
y x
x x b
2
2 0
max | ( )|
.
5. What is the disadvantage of the Taylor series method ?
Solution Taylor series method requires the computation of higher order derivatives.
The higher order derivatives are given by
y = f(x, y), y =
f
x
f
y
dy
dx
+ = f
x
+ f f
y
,
y =
x
f
x
f
y
dy
dx y
f
x
f
y
dy
dx
dy
dx
+
+ +
= f
xx
+ 2 f f
xy
+ f
2
f
yy
+ f
y
(f
x
+ f f
y
), etc.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 199
The number of partial derivatives to be computed increases as the order of the derivative
of y increases. Therefore, we find that computation of higher order derivatives is very
difficult.
6. Write the bound on the truncation error of the Taylor series method.
Solution The bound on the truncation error of the Taylor series method of order p is
given by
| T
p+1
| =
h
p
y x h
h
p
M
p
p
i
p
p
+
+
+
+
+
+
+
1
1
1
1
1 1 ( ) !
( )
( ) !
( )
where M
p+1
= max | ( )|
( )
x x b
p
y x
0
1
+
.
7. What are the orders of (i) modified Euler method, (ii) Heuns method ?
Solution Modified Euler method and Heuns method are both second order methods.
EXERCISE 4.1
Solve the following initial value problems using (i) Euler method, (ii) modified Euler method,
and (iii) Heuns method with h = 0.1, x [1, 1.2]. Compare with the exact solution.
1. y = x + y, y(1) = 0.
2. y = y
2
, y(1) = 1.
3. Find an approximation to y(0.4), for the initial value problem
y = x
2
+ y
2
, y(0) = 1
using the Euler method with h = 0.1 and h = 0.2. Extrapolate the results to get a better
approximation to y(0.4).
4. Find an approximation to y(1.6), for the initial value problem
y = x + y
2
, y(1) = 1
using the Euler method with h = 0.1 and h = 0.2. Extrapolate the results to get a better
approximation to y(1.6).
5. Given the initial value problem,
y = 2x + cos y, y(0) = 1
show that it is sufficient to use Euler method with step length h = 0.2 to compute y(0.2)
with an error less than 0.05.
6. Use Taylor series method of order four to solve
y = x
2
+ y
2
, y(0) = 1
for x [0, 0.4] with h = 0.2
7. Apply Taylor series method of second order and Heuns method to integrate
y = 2x + 3y, y(0) = 1, x [0, 0.4]
with h = 0.1.
200 NUMERICAL METHODS
8. Obtain numerical solution correct to two decimals for the initial value problem
y = 3x + 4y, y(0) = 1, x [0, 0.2]
using the Taylor series method with h = 0.1.
9. Obtain numerical solution correct to two decimals for the initial value problem
y = 3x + y
2
, y(1) = 1, x [1, 1.2]
using the Taylor series method with h = 0.1.
In the following problems, obtain the solution by Taylor series method.
10. Find y at x = 0.1 if y = x
2
y 1, y(0) = 1. (A.U. Nov./Dec. 2004)
11. Find y(1.1) given that y = x + y, y(1) = 0. (A.U. Nov./Dec. 2006)
12. Find the values y at x = 0.1 and x = 0.2, given
y = x + y, y(0) = 1. (A.U. April/May 2005)
13. Get the value of y at x = h, given
y = x + y + xy, y(0) = 1. (A.U. Nov./Dec. 2006)
Using the modified Euler method, solve the following initial value problems.
14. Find y(0.1) if y = x
2
+ y
2
, y(0) = 1. (A.U. Nov./Dec. 2004)
15. Find y(0.2), given the initial value problem y = y x
2
+ 1, y(0) = 0.5.
(A.U. April/May 2003 ; Nov./Dec. 2006)
4.4 RUNGE-KUTTA METHOD8
Integrating the differential equation y = f (x, y) in the interval [x
i
, x
i+1
], we get
x
x
x
x
i
i
i
i dy
dx
dx f x y dx
+ +
=
1 1
( , ) . (4.42)
We have noted in the previous section, that y and hence f (x, y) is the slope of the
solution curve. Further, the integrand on the right hand side is the slope of the solution curve
which changes continuously in [x
i
, x
i+1
]. By approximating the continuously varying slope in
[x
i
, x
i+1
] by a fixed slope, we have obtained the Euler, Heuns and modified Euler methods. The
basic idea of Runge-Kutta methods is to approximate the integral by a weighted average of
slopes and approximate slopes at a number of points in [x
i
, x
i+1
]. If we also include the slope at
x
i+1
, we obtain implicit Runge-Kutta methods. If we do not include the slope at x
i+1
, we obtain
explicit Runge-Kutta methods. For our discussion, we shall consider explicit Runge-Kutta meth-
ods only. However, Runge-Kutta methods must compare with the Taylor series method when
they are expanded about the point x = x
i
. In all the Runge-Kutta methods, we include the slope
at the initial point x = x
i
, that is, the slope f(x
i
, y
i
).
Runge-Kutta method of second order
Consider a Runge-Kutta method with two slopes. Define
k
1
= h f(x
i
, y
i
),
k
2
= h f(x
i
+ c
2
h, y
i
+ a
21
k
1
),
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 201
y
i+1
= w
1
k
1
+ w
2
k
2
(4.43)
where the values of the parameters c
2
, a
21
, w
1
, w
2
are chosen such that the method is of high-
est possible order. Now, Taylor series expansion about x = x
i
, gives
y(x
i+1
) = y(x
i
) + hy(x
i
) +
h
y x
h
y x
i i
2 3
2 3 !
( )
!
( ) +
+ ...
= y(x
i
) + h f(x
i
, y(x
i
)) +
h
f ff
x y x
i
2
2
( ) +
+
h
3
6
[f
xx
+ 2ff
xy
+ f
2
f
yy
+ f
y
(f
x
+ ff
y
)]
x
i
+ ... (4.44)
We also have k
1
= hf
i
,
k
2
= hf(x
i
+ c
2
h, y
i
+ a
21
hf
i
)
= h f h c f a ff
h
c f c a f f a f f
i x y x xx xy yy x
i i
+ + + + + +
( ) ( ) ...
2 21
2
2
2
2 21 21
2 2
2
2
Substituting the values of k
1
and k
2
in (4.43), we get
y
i+1
= y
i
+ (w
1
+ w
2
) h f
i
+ h
2
(w
2
c
2
f
x
+ w
2
a
21
f f
y
)
x
i
+
h
w c f c a ff a f f
xx xy yy x
i
3
2 2
2
2 21 21
2 2
2
2 ( ) ... + + +
(4.45)
Comparing the coefficients of h and h
2
in (4.44) and (4.45), we obtain
w
1
+ w
2
= 1, c
2
w
2
= 1/2, a
21
w
2
= 1/2.
Solving these equations, we obtain
a
21
= c
2
, w
2
=
1
2
2
c
, w
1
= 1
1
2
2
c
,
where c
2
is arbitrary. It is not possible to compare the coefficients of h
3
as there are five terms
in (4.44) and three terms in (4.45). Therefore, the Runge-Kutta methods using two slopes (two
evaluations of f ) is given by
y
i+1
= y
i
+ 1
1
2
1
2
2
1
2
2
+
c
k
c
k (4.46)
where k
1
= h f(x
i
, y
i
),
k
2
= h f(x
i
+ c
2
h, y
i
+ c
2
k
1
).
We note that the method has one arbitrary parameter c
2
. We may choose any value for
c
2
such that 0 < c
2
< 1. Therefore, we have an infinite family of these methods.
If we choose c
2
= 1, we obtain the method
y
i+1
= y
i
+
1
2
(k
1
+ k
2
) (4.47)
202 NUMERICAL METHODS
k
1
= hf(x
i
, y
i
), k
2
= h f(x
i
+ h, y
i
+ k
1
)
which is the Heuns method or Euler-Cauchy method. Therefore, Heuns method derived in
the previous section can be written in the formulation of a Runge-Kutta method.
If we choose c
2
= 1/2, we get w
1
= 0. The method is given by
y
i+1
= y
i
+ k
2
(4.48)
k
1
= hf (x
i
, y
i
),
k
2
= hf x
h
y k
i i
+ +
2
1
2
1
,
which is the modified Euler method. Therefore, modified Euler method can also be written in
the formulation of a Runge-Kutta method.
Error of the Runge-Kutta method
Subtracting (4.45) from (4.44), we get the truncation error in the method as
T.E. = y(x
i+1
) y
i+1
= h
3
1
6 4
2
1
6
2 2
+ + + + +
c
f ff f f f f ff
xx xy yy y x y
x
i
{ } ( ) ... (4.49)
Since the truncation error is of order O(h
3
), the method is of second order for all values
of c
2
. Therefore, (4.46) gives an infinite family of second order methods. We may note that for
c
2
= 2/3, the first term inside the bracket in (4.49) vanishes and we get a method of minimum
truncation error. The method is given by
y
i+1
= y
i
+
1
4
(k
1
+ 3k
2
) (4.50)
where k
1
= hf(x
i
, y
i
),
k
2
= hf
x h y k
i i
+ +
2
3
2
3
1
,
.
Therefore, the method (4.50) is a second order method with minimum truncation error.
Runge-Kutta method of fourth order The most commonly used Runge-Kutta method is a
method which uses four slopes. The method is given by
y
i+1
= y
i
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
) (4.51)
k
1
= hf (x
i
, y
i
)
k
2
= hf x
h
y k
i i
+ +
2
1
2
1
, ,
k
3
= hf x
h
y k
i i
+ +
2
1
2
2
, ,
k
4
= hf (x
i
+ h, y
i
+ k
3
).
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 203
Remark 5 We would like to know as to why the Runge-Kutta method (4.51) is the most
commonly used method. Using two slopes in the method, we have obtained methods of second
order, which we have called as second order Runge-Kutta methods. The method has one
arbitrary parameter, whose value is suitably chosen. The methods using four evaluations of
slopes have two arbitrary parameters. The values of these parameters are chosen such that
the method becomes simple for computations. One such choice gives the method (4.51). All
these methods are of fourth order, that is, the truncation error is of order O(h
5
). The method
(4.51) is called the classical Runge-Kutta method of fourth order. If we use five slopes, we do
not get a fifth order method, but only a fourth order method. It is due to this reason the
classical fourth order Runge-Kutta method is preferred for computations.
Remark 6 All the single step methods (Taylor series, Runge-Kutta methods etc.) are self
starting. They do not require values of y and/or the values of the derivatives of y beyond the
previous point.
Example 4.8 Solve the initial value problem
y = 2xy
2
, y(0) = 1
with h = 0.2 on the interval [0, 0.4]. Use (i) the Heuns method (second order Runge-Kutta
method); (ii) the fourth order classical Runge-Kutta method. Compare with the exact solution
y(x) = 1/(1 + x
2
).
Solution
(i) The solution using Heuns method is given in Example 4.7. The solutions are
y(0.2) 0.96, y(0.4) 0.86030.
(ii) For i = 0, we have x
0
= 0, y
0
= 1.
k
1
= hf (x
0
, y
0
) = 2(0.2)(0)(1)
2
= 0,
k
2
= hf
x
h
y k
0 0 1
2
1
2
+ +
,
= 2(0.2)(0.1)(1)
2
= 0.04,
k
3
= hf
x
h
y k
0 0 2
2
1
2
+ +
,
= 2 (0.2)(0.1)(0.98)
2
= 0.038416,
k
4
= hf (x
0
+ h, y
0
+ k
3
) = 2(0.2)(0.2)(0.961584)
2
= 0.0739715,
y(0.2) y
1
= y
0
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
)
= 1.0 +
1
6
[0.0 0.08 0.076832 0.0739715] = 0.9615328.
For i = 1, we have x
1
= 0, y
1
= 0.9615328.
k
1
= hf (x
1
, y
1
) = 2(0.2)(0.2)(0.9615328)
2
= 0.0739636,
204 NUMERICAL METHODS
k
2
= hf
x
h
y k
1 1 1
2
1
2
+ +
,
= 2(0.2)(0.3) (0.924551)
2
= 0.1025753,
k
3
= hf
x
h
y k
1 1 2
2
1
2
+ +
,
= 2(0.2)(0.3)(0.9102451)
2
= 0.0994255,
k
4
= hf (x
1
+ h, y
1
+ k
3
) = 2(0.2)(0.4)(0.86210734)
2
= 0.1189166,
y(0.4) y
2
= y
1
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
)
= 0.9615328 +
1
6
[0.0739636 0.2051506 0.1988510
0.1189166]
= 0.8620525
The absolute errors in the numerical solutions are given in Table 4.4.
Table 4.4. Absolute errors in Heuns method and fourth order Runge-Kutta method. Example 4.8.
Heuns method Runge-Kutta method
x Exact solution Num. solution | Error | Num. solution | Error |
0.2 0.9615385 0.96 0.0015385 0.9615328 0.0000057
0.4 0.8620690 0.86030 0.0017690 0.8620525 0.0000165
Example 4.9 Given y = x
3
+ y, y(0) = 2, compute y(0.2), y(0.4) and y(0.6) using the Runge-Kutta
method of fourth order. (A.U. April/May 2004)
Solution We have x
0
= 0, y
0
= 2, f(x, y) = x
3
+ y, h = 0.2.
For i = 0, we have x
0
= 0, y
0
= 2.
k
1
= hf(x
0
, y
0
) = 0.2 f (0, 2) = (0.2)(2) = 0.4,
k
2
= hf
x
h
y k
0 0 1
2
1
2
+ +
,
= 0.2 f(0.1, 2.2)
= (0.2)(2.201) = 0.4402,
k
3
= hf
x
h
y k
0 0 2
2
1
2
+ +
,
= 0.2 f(0.1, 2.2201)
= (0.2)(2.2211) = 0.44422,
k
4
= hf (x
0
+ h, y
0
+ k
3
) = 0.2 f (0.2, 2.44422)
= (0.2)(2.45222) = 0.490444,
y(0.2) y
1
= y
0
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
)
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 205
= 2.0 +
1
6
[0.4 + 2(0.4402) + 2(0.44422) + 0.490444]
= 2.443214.
For i = 1, we have x
1
= 0.2, y
1
= 2.443214.
k
1
= h f (x
1
, y
1
) = 0.2 f(0.2, 2.443214) = (0.2)(2.451214) = 0.490243,
k
2
= hf x
h
y k
1 1 1
2
1
2
+ +
,
= 0.2 f(0.3, 2.443214 + 0.245122)
= (0.2)(2.715336) = 0.543067,
k
3
= hf
x
h
y k
1 1 2
2
1
2
+ +
,
= 0.2 f(0.3, 2.443214 + 0.271534)
= (0.2)(2.741748) = 0.548350,
k
4
= hf (x
1
+ h, y
1
+ k
3
) = 0.2 f(0.4, 2.443214 + 0.548350)
= (0.2)(3.055564) = 0.611113,
y(0.4) y
2
= y
1
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
)
= 2.443214 +
1
6
[0.490243 + 2(0.543067) + 2(0.548350) + 0.611113]
= 2.990579.
For i = 2, we have x
2
= 0.4, y
2
= 2.990579.
k
1
= hf (x
2
, y
2
) = 0.2 f (0.4, 2.990579) = (0.2)(3.054579) = 0.610916,
k
2
= hf x
h
y k
2 2 1
2
1
2
+ +
,
= 0.2f (0.5, 2.990579 + 0.342104)
= (0.2)(3.457683) = 0.691537,
k
4
= hf (x
2
+ h, y
2
+ k
3
) = 0.2 f (0.6, 2.990579 + 0.691537)
= (0.2) (3.898116) = 0.779623.
y(0.6) y
3
= y
2
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
)
= 2.990579 +
1
6
[0.610916 + 2(0.684207) + 2(0.691537) + 0.779623]
= 3.680917.
206 NUMERICAL METHODS
REVIEW QUESTIONS
1. Write the Heuns method for solving the first order initial value problems in the Runge-
Kutta formulation.
Solution Heuns method can be written as follows
y
i+1
= y
i
+
1
2
(k
1
+ k
2
)
k
1
= hf (x
i
, y
i
),
k
2
= hf (x
i
+ h, y
i
+ k
1
).
2. Write the modified Euler method for solving the first order initial value problems in the
Runge-Kutta formulation.
Solution Modified Euler method can be written as follows
y
i+1
= y
i
+ k
2
k
1
= hf (x
i
, y
i
)
k
2
= hf x
h
y k
i i
+ +
2
1
2
1
, .
3. Why is the classical Runge-Kutta method of fourth order, the most commonly used
method for solving the first order initial value problems ?
Solution Using two slopes in the method, we can obtain methods of second order, which
are called as the second order Runge-Kutta methods. The method has one arbitrary
parameter, whose value is suitably chosen. The methods using four evaluations of slopes
have two arbitrary parameters. All these methods are of fourth order, that is the trun-
cation error is of order O(h
5
). The values of these parameters are chosen such that the
method becomes simple for computations. One such choice gives the classical Runge-
Kutta method of fourth order. If we use five slopes, we do not get a fifth order method,
but only a fourth order method. It is due to this reason, the classical fourth order Runge-
Kutta method is preferred for computations.
EXERCISE 4.2
In the following problems, obtain the solution by the fourth order Runge-Kutta method.
1. Find f(0.4), f(0.6), given the initial value problem y = y x
2
+ 1, y(0) = 0.5.
(A.U. April/May 2003)
2. Solve
dy
dx
y x
y x
=
+
2 2
2 2
with y(0) = 1 at x = 0.2. (A.U. April/May 2005, Nov./Dec. 2004)
3. Find y(0.1) and y(0.2) for the initial value problem y = x + y
2
, y(0) = 1.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 207
4. Find y(0.4) given that y = x + y
2
, y(0) = 1.3456. Take h = 0.2.
5. Determine y(0.2) with h = 0.1, for the initial value problem y = x
2
+ y
2
, y(0) = 1.
6. Find an approximate value of y when x = 0.2 and x = 0.4 given that y = x + y, y(0) = 1,
with h = 0.2. (A.U. May/June 2006, Nov./Dec. 2006)
7. Determine y(0.2), y(0.4) with h = 0.2, for the initial value problem y = x
3
+ 3y, y(0) = 1.
8. Solve
dy
dx
y x
y x
=
+
2
2
, y(0) = 1 at x = 0.2 with h = 0.1.
4.5 8Y8TEM OF FR8T ORDER NTAL VALUE PROBLEM8
In section 4.1, we have discussed the reduction of a second order initial value problem to a
system of first order initial value problems. For the sake of completeness, let us repeat this
procedure.
Let the second order initial value problem be given as
a
0
(x) y(x) + a
1
(x)y(x) + a
2
(x)y(x) = r(x) (4.52)
y(x
0
) = b
0
, y(x
0
) = b
1
.
Define u
1
= y. Then, we have the system
u
1
= y = u
2
, u
1
(x
0
) = b
0
,
u
2
= y =
1
0
a x ( )
[r(x) a
1
(x) y(x) a
2
(x) y(x)]
=
1
0
a x ( )
[r(x) a
1
(x) u
2
a
2
(x) u
1
], u
2
(x
0
) = b
1
.
The system is given by
u
u
u
f x u u
u x
u x
b
b
1
2
2
2 1 2
1 0
2 0
0
1
( , , )
,
( )
( )
(4.53)
where f
2
(x, u
1
, u
2
) =
1
0
a x ( )
[r(x) a
1
(x) u
2
a
2
(x) u
1
].
In general, we may have a system as
y
y
f x y y
f x y y
y x
y x
b
b
1
2
1 1 2
2 1 2
1 0
2 0
0
1
( , , )
( , , )
,
( )
( )
. (4.54)
In vector notation, denote
y = [y
1
, y
2
]
T
, f = [f
1
, f
2
]
T
, b = [b
0
, b
1
]
T
.
208 NUMERICAL METHODS
Then, we can write the system as
y = f(x, y),
y(x
0
) = b. (4.55)
Therefore, the methods derived for the solution of the first order initial value problem
dy
dx
= f(x, y), y(x
0
) = y
0
(4.56)
can be used to solve the system of equations (4.54) or (4.55), that is, the second order initial
value problem (4.52), by writing the method in vector form.
4.5.1 Taylor Series Method
In vector format, we write the Taylor series method (4.20) of order p as
y
i+1
= y
i
+ hy
i
+
h h
p
i
p
i
p
2
2!
...
!
( )
y y + +
(4.57)
where
y
i
k i
k
i
k
k
k
i i i
k
k
i i i
y
y
d
dx
f x y y
d
dx
f x y y
( ) ,
( )
( )
,
,
( , , )
( , , )
=
1
2,
1
1
1 1 2,
1
1
2 1 2,
.
In component form, we obtain
(y
1
)
i+1
= (y
1
)
i
+ h(y
1
)
i
+
h
y
h
p
y
i
p
p
i
2
1 1
2
( ) ...
!
( )
( )
+ +
. (4.58)
(y
2
)
i+1
= (y
2
)
i
+ h(y
2
)
i
+
h
y
h
p
y
i
p
p
i
2
2 2
2
( ) ...
!
( )
( )
+ +
. (4.59)
Eulers method for solving the system is given by
( y
1
)
i+1
= ( y
1
)
i
+ h( y
1
)
i
= (y
1
)
i
+ h f
1
(x
i
, (y
1
)
i
, (y
2
)
i
). (4.60)
( y
2
)
i+1
= ( y
2
)
i
+ h( y
2
)
i
= ( y
2
)
i
+ h f
2
(x
i
, ( y
1
)
i
, (y
2
)
i
). (4.61)
4.5.2 Runge-Kutta Fourth Order Method
In vector format, we write the Runge-Kutta fourth order method (4.51) as
y
i+1
= y
i
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
), i = 0, 1, 2, (4.62)
where k
1
=
k
k
k
k
k
k
k
k
11
21
2
12
22
3
13
23
4
14
24
, , , k k k (4.63)
k
n1
= hf
n
(x
i
, (y
1
)
i
, (y
2
)
i
), n = 1, 2.
k
n2
= hf
n
x
h
y k y k
i i i
+ + +
2
1
2
1
2
1 11 2 21
, ( ) , ( ) , n = 1, 2.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 209
k
n3
= hf
n
x
h
y k y k
i i i
+ + +
2
1
2
1
2
1 12 2 22
, ( ) , ( )
,
n = 1, 2.
k
n4
= hf
n
(x
i
+ h, (y
1
)
i
+ k
13
, (y
2
)
i
+ k
23
), n = 1, 2.
Note that we have used the matrix notation for representing the column vectors k
1
, k
2
,
k
3
, k
4
. Some books use the notation (k
1
, l
1
), (k
2
, l
2
), (k
3
, l
3
), (k
4
, l
4
) for representing the column
vectors k
1
, k
2
, k
3
, k
4
.
In explicit form, we write the method as
(y
1
)
i+1
= (y
1
)
i
+
1
6
(k
11
+ 2k
12
+ 2k
13
+ k
14
),
(y
2
)
i+1
= (y
2
)
i
+
1
6
(k
21
+ 2k
22
+ 2k
23
+ k
24
).
If we denote y
1
= u, y
2
= v, then we can write the equations as
u
i+1
= u
i
+
1
6
(k
11
+ 2k
12
+ 2k
13
+ k
14
), (4.64)
v
i+1
= v
i
+
1
6
(k
21
+ 2k
22
+ 2k
23
+ k
24
). (4.65)
Example 4.10 Solve the initial value problem
u = 3u + 2v, u(0) = 0
v = 3u 4v, v(0) = 0.5,
with h = 0.2 on the interval [0, 0.4], using the Runge-Kutta fourth order method.
Solution For i = 0, we have x
0
= 0, u
0
= 0, v
0
= 0.5.
k
11
= hf
1
(x
0
, u
0
, v
0
) = 0.2 (3u
0
+ 2v
0
) = 0.2(0 + 2(0.5)) = 0.2.
k
21
= hf
2
(x
0
, u
0
, v
0
) = 0.2 (3u
0
4v
0
) = 0.2(0 4(0.5)) = 0.4.
k
12
= hf
1
x
h
u k v k
0 0 11 0 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.1, 0 + 0.1, 0.5 0.2) = 0.2 f
1
(0.1, 0.1, 0.3)
= 0.2[ 3(0.1) + 2(0.3)] = 0.06.
k
22
= hf
2
x
h
u k v k
0 0 11 0 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.1, 0.1, 0.3) = 0.2[3(0.1) 4(0.3)] = 0.18.
k
13
= hf
1
x
h
u k v k
0 0 12 0 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.1, 0.03, 0.5 0.09) = 0.2 f
1
(0.1, 0.03, 0.41)
= 0.2 [3(0.03) + 2(0.41)] = 0.146.
210 NUMERICAL METHODS
k
23
= hf
2
x
h
u k v k
0 0 12 0 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.1, 0.03, 0.41) = 0.2 [3(0.03) 4(0.41)] = 0.31.
k
14
= hf
1
(x
0
+ h, u
0
+ k
13
, v
0
+ k
23
)
= 0.2 f
1
(0.2, 0.146, 0.5 0.31) = 0.2 f
1
(0.2, 0.146, 0.19)
= 0.2[ 3(0.146) + 2(0.19)] = 0.0116.
k
24
= hf
2
(x
0
+ h, u
0
+ k
13
, v
0
+ k
23
)
= 0.2 f
2
(0.2, 0.146, 0.19) = 0.2 [3(0.146) 4(0.19)] = 0.0664.
u(0.2) u
1
= u
0
+
1
6
(k
11
+ 2k
12
+ 2k
13
+ k
14
)
= 0 +
1
6
(0.2 + 0.12 + 0.292 0.0116) = 0.1001.
v(0.2) v
1
= v
0
+
1
6
(k
21
+ 2k
22
+ 2k
23
+ k
24
)
= 0.5 +
1
6
( 0.4 0.36 0.62 0.0644) = 0.2593
For , 1 = i we have x
1
= 0.2, u
1
= 0.1001, v
0
= 0.2593.
k
11
= hf
1
(x
1
, u
1
, v
1
) = 0.2 ( 3u
1
+ 2v
1
)
= 0.2[ 3(0.1001) + 2(0.2593)] = 0.0437.
k
21
= hf
2
(x
1
, u
1
, v
1
) = 0.2 (3u
1
4v
1
)
= 0.2[3(0.1001) 4(0.2593)] = 0.1474.
k
12
= hf
1
x
h
u k v k
1 1 11 1 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.3, 0.1220, 0.1856)
= 0.2 [ 3(0.1220) + 2(0.1856)] = 0.0010.
k
22
= hf
2
x
h
u k v k
1 1 11 1 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.3, 0.1220, 0.1856)
= 0.2[3(0.1220) 4(0.1856)] = 0.0753.
k
13
= hf
1
x
h
u k v k
1 1 12 1 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.3, 0.1006, 0.2217)
= 0.2 [3(0.1006) + 2(0.2217)] = 0.0283.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 211
k
23
= hf
2
x
h
u k v k
1 1 12 1 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.3, 0.1006, 0.2217)
= 0.2 [3(0.1006) 4(0.2217)] = 0.1170.
k
14
= hf
1
(x
1
+ h, u
1
+ k
13
, v
1
+ k
23
)
= 0.2 f
1
(0.4, 0.1284, 0.1423)
= 0.2[ 3(0.1284) + 2(0.1423)] = 0.0201.
k
24
= hf
2
(x
1
+ h, u
1
+ k
13
, v
1
+ k
23
)
= 0.2 f
2
(0.4, 0.1284, 0.1423)
= 0.2[3(0.1284) 4(0.1423)] = 0.0368.
u(0.4) u
2
= u
1
+
1
6
(k
11
+ 2k
12
+ 2k
13
+ k
14
)
= 0.1001 +
1
6
(0.0437 + 0.0020 + 0.0566 0.0201) = 0.1138.
v(0.4) v
2
= v
1
+
1
6
(k
21
+ 2k
22
+ 2k
23
+ k
24
)
= 0.2593 +
1
6
( 0.1474 0.1506 0.2340 0.0368) = 0.1645.
Example 4.11 Compute approximations to y(0.4) and y(0.4), for the initial value problem
y + 4y = cos t, y(0) = 1, y(0) = 0
using (i) Taylor series method of fourth order, (ii) Runge-Kutta method of fourth order, with
step length h = 0.2. If exact solution is given by y(t) = (2 cos 2t + cos t)/3, find the magnitudes of
the errors.
Solution Let y = u. Reducing the given second order equation to a system of first order
equations, we obtain
u = v, u(0) = 1,
v = cos t 4y = cos t 4u, v(0) = 0.
(i) Taylor series method of fourth order gives
u
i+1
= u
i
+ hu
i
+
h
u
h
u
h
u
i i i
2 3 4
4
2 6 24
+ +
( )
= u
i
+ 0.2 u
i
+ 0.02 u
i
+
0 008
6
0 0016
24
4
. .
( )
+ u u
i i
v
i+1
= v
i
+ hv
i
+
h
v
h
v
h
v
i i i
2 3 4
4
2 6 24
+ +
( )
212 NUMERICAL METHODS
= v
i
+ 0.2 v
i
+ 0.02v
i
+
0 008
6
0 0016
24
4
. .
( )
v v
i i
+ .
We have u = v, v = cos t 4u, u = v, v = sin t 4u,
u = v,
v = cos t 4u, u
(4)
= v, v
(4)
= sin t 4u.
For i = 0: u
0
= 1, v
0
= 0, t
0
= 0.
u
0
= v
0
= 0, v
0
= 1 4u
0
= 1 4 = 3, u
0
= v
0
= 3, v
0
= 4u
0
= 0,
u
0
= v
0
= 0, v
0
= 1 4u
0
= 1 + 12 = 11,
u
0
(4)
= v
0
= 11, v
0
(4)
= 4u
0
= 0.
u(0.2) = u
1
= u
0
+ 0.2u
0
+ 0.02u
0
+
0 008
6
0 0016
24
0 0
4
. .
( )
u u +
= 1 + 0 + 0.02 ( 3) + 0 +
0 0016
24
.
(11) = 0.940733
v(0.2) = v
1
= v
0
+ 0.2v
0
+ 0.02v
0
+
0 008
6
0 0016
24
0 0
4
. .
( )
v v +
= 0 + 0.2 ( 3) + 0 +
0 008
6
.
(11) + 0 = 0.585333.
For i = 1: u
1
= 0.940733, v
1
= 0.585333, t
1
= 0.2.
u
1
= v
1
= 0.585333,
v
1
= cos (0.2) 4u
1
= 0.980067 4(0.940733) = 2.782865,
u
1
= v
1
= 2.782865,
v
1
= sin (0.2) 4u
1
= 0.198669 4( 0.585333) = 2.142663,
u = v
1
= 2.142663,
v
1
= cos (0.2) 4u
1
= 0.980067 4( 2.782865) = 10.151393,
u
1
(4)
= v
1
= 10.151393,
v
1
(4)
= sin (0.2) 4u
1
= 0.198669 4(2.142663) = 8.371983.
u(0.4) = u
2
= u
1
+ 0.2u
1
+ 0.02u
1
+
0 008
6
0 0016
24
1 1
4
. .
( )
+ u u
= 0.940733 + 0.2( 0.585333) + 0.02( 2.782865)
+
0008
6
.
(2.142663) +
0 0016
24
.
(10.151393) = 0.771543.
v(0.4) = v
2
= v
1
+ 0.2 v
1
+ 0.02 v
1
+
0 008
6
00016
24
1 1
4
. .
( )
v v +
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 213
= 0.585333 + 0.2( 2.782865) + 0.02(2.142663)
+
0008
6
.
(10.151393) +
0 0016
24
.
( 8.371983) = 1.086076.
The exact solutions are
u(0.2) =
1
3
[2 cos (0.4) + cos (0.2)] = 0.940730.
v(0.2) =
1
3
[4 sin (0.4) + sin (0.2)] = 0.585448.
u(0.4) =
1
3
[2 cos (0.8) + cos (0.4)] = 0.771491.
v(0.4) =
1
3
[4 sin (0.8) + sin (0.4)] = 1.086281.
The magnitudes of errors in the solutions are
| u(0.2) u
1
| = | 0.940730 0.940733 | = 0.000003,
| v(0.2) v
1
| = | 0.585448 + 0.585333 | = 0.000115,
| u(0.4) u
2
| = | 0.771491 0.771543 | = 0.000052,
| v(0.4)
v
2
| = | 1.086281 + 1.086076 | = 0.000205.
(ii) For i = 0, we have t
0
= 0, u
0
= 1, v
0
= 0, f
1
(u, v) = v, f
2
(u, v) = cos t 4u.
k
11
= hf
1
(t
0
, u
0
, v
0
) = hf
1
(0, 1, 0) = 0.
k
21
= hf
2
(t
0
, u
0
, v
0
) = hf
2
(0, 1, 0) = 0.2 (1 4) = 0.6.
k
12
= hf
1
t
h
u k v k
0 0 11 0 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.1, 1 + 0.0, 0.0 0.3) = 0.2 f
1
(0.1, 1.0, 0.3)
= 0.2 ( 0.3) = 0.06.
k
22
= hf
2
t
h
u k v k
0 0 11 0 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.1, 1.0, 0.3) = 0.2 [cos (0.1) 4] = 0.600999.
k
13
= hf
1
t
h
u k v k
0 0 12 0 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.1, 1.0 0.03, 0.0 0.3004995)
= 0.2 f
1
(0.1, 0.97, 0.3004995)
= 0.2 ( 0.3004995) = 0.060100.
214 NUMERICAL METHODS
k
23
= hf
2
t
h
u k v k
0 0 12 0 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.1, 0.97, 0.3004995)
= 0.2 [cos (0.1) 4(0.97)] = 0.576999.
k
14
= hf
1
(t
0
+ h, u
0
+ k
13
, v
0
+ k
23
)
= 0.2 f
1
(0.2, 1.0 0.060100, 0.576999)
= 0.2 f
1
(0.2, 0.939900, 0.576999)
= 0.2 ( 0.576999) = 0.115400.
k
24
= hf
2
(t
0
+ h, u
0
+ k
13
, v
0
+ k
23
)
= 0.2 f
2
(0.2, 0.939900, 0.576999)
= 0.2 [cos (0.2) 4(0.939900)] = 0.555907.
u(0.2) u
1
= u
0
+
1
6
(k
11
+ 2k
12
+ 2k
13
+ k
14
)
= 1.0 +
1
6
[0.0 + 2( 0.06) + 2( 0.060100) 0.115400] = 0.940733.
v(0.2) v
1
= v
0
+
1
6
(k
21
+ 2k
22
+ 2k
23
+ k
24
)
= 0.0 +
1
6
[ 0.6 + 2( 0.600999) + 2( 0.576999) 0.555907]
= 0.585317.
For i = 1, we have t
1
= 0.2, u
1
= 0.940733, v
1
= 0.585317.
k
11
= hf
1
(t
1
, u
1
, v
1
) = 0.2 f
1
(0.2, 0.940733, 0.585317)
= 0.2[ 0.585317] = 0.117063.
k
21
= hf
2
(t
1
, u
1
, v
1
) = h f
2
(0.2, 0.940733, 0.585317)
= 0.2 [cos (0.2) 4(0.940733)] = 0.556573.
k
12
= hf
1
t
h
u k v k
1 1 11 1 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.3, 0.882202, 0.863604)
= 0.2 ( 0.863604) = 0.172721.
k
22
= h f
2
t
h
u k v k
1 1 11 1 21
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.3, 0.882202, 0.863604)
= 0.2 [cos (0.3) 4(0.882202)] = 0.514694.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 215
k
13
= hf
1
t
h
u k v k
1 1 12 1 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
1
(0.3, 0.854372, 0.842664)
= 0.2[ 0.842664] = 0.168533.
k
23
= hf
2
t
h
u k v k
1 1 12 1 22
2
1
2
1
2
+ + +
, ,
= 0.2 f
2
(0.3, 0.854372, 0.842664)
= 0.2 [cos (0.3) 4(0.854372)] = 0.492430.
k
14
= hf
1
(t
1
+ h, u
1
+ k
13
, v
1
+ k
23
)
= 0.2 f
1
(0.4, 0.772200, 1.077747) = 0.2 [ 1.077747] = 0.215549.
k
24
= hf
2
(t
1
+ h, u
1
+ k
13
, v
1
+ k
23
)
= 0.2 f
2
(0.4, 0.772200, 1.077747)
= 0.2 [cos (0.4) 4(0.772200)] = 0.433548.
u(0.4) u
2
= u
1
+
1
6
(k
11
+ 2k
12
+ 2k
13
+ k
14
)
= 0.940733 +
1
6
[ 0.117063 + 2( 0.172721) + 2( 0.168533) 0.215549]
= 0771546.
v(0.4) v
2
= v
1
+
1
6
(k
21
+ 2k
22
+ 2k
23
+ k
24
)
= 0.585317 +
1
6
[ 0.556573 + 2( 0.514694) + 2( 0.492430) 0.433548]
= 1.086045.
The magnitudes of errors in the solutions are
| u(0.2) u
1
| = | 0.940730 0.940733 | = 0.000003,
| v(0.2) v
1
| = | 0.585448 + 0.585317 | = 0.000131,
| u(0.4) u
2
| = | 0.771491 0.771546 | = 0.000055,
| v(0.4) v
2
| = | 1.086281 + 1.086045 | = 0.000236.
EXERCISE 4.3
Reduce the following second order initial value problems to systems of first order initial value
problems.
1. y + 3y + 2y = e
2t
, with y(0) = 1 and y(0) = 1.
216 NUMERICAL METHODS
2. y 6y + 5y = sin 2t, with y(0) = 0 and y(0) = 1.
3. y 2y + y = te
t
, with y(0) = 0.5 and y(0) = 0.8.
Solve the following second order initial value problems by Taylor series method.
4. y 2y + 2y = e
2t
sin t, with y(0) = 0.4 and y(0) = 0.6. Find y(0.1).
(A.U.April/May 2003)
5. y + 3y + 2y = e
t
, with y(0) = 1 and y(0) = 1. Find y(0.2) with h = 0.2.
6. y 4y + 4y = e
2t
, with y(0) = 0.5 and y(0) = 1. Find y(0.2) with h = 0.1.
7. y 6y + 5y = e
t
, with y(0) = 0 and y(0) = 1. Find y(0.1) with h = 0.1.
In the following second order initial value problems, obtain the solution by the fourth order
Runge-Kutta method.
8. Consider the second order initial value problem
y 2y + 2y = e
2t
sin t, with y(0) = 0.4 and y(0) = 0.6.
Find y(0.2). (A.U. April/May 2003)
9. Given y + y + y = 0, y(0) = 1, y(0) = 0, find the value of y(0.1). (A.U. Nov./Dec. 2006)
10. y + 3y + 2y = e
t
, with y(0) = 1 and y(0) = 1. Find y(0.2) with h = 0.1.
11. y + 2y + y = te
t
, with y(0) = 0.5 and y(0) = 0.8. Find y(0.2) with h = 0.2.
12. What are the values of k
1
and l
1
in the Runge-Kutta method of fourth order, to solve
y + xy + y = 0, y(0) = 1, y(0) = 0. (A.U. April/May 2005)
4.6 MULT 8TEP METHOD8 AND PREDCTOR-CORRECTOR METHOD8
In section 4.2, we have defined the explicit and implicit multi step methods for the solution of
the initial value problem
y = f (x, y), y(x
0
) = b
0
.
(4.66)
A general k-step explicit method can be written as
y
i+1
= y
i
= h(x
ik+1
, ..., x
i1
, x
i
, y
ik+1
, ..., y
i1
, y
i
, h) (4.67)
and a general k-step implicit method can be written as
y
i+1
= y
i
= h(x
ik+1
, ..., x
i
, x
i+1
, y
ik+1
, ..., y
i
, y
i+1
, h). (4.68)
Remark 7 Multi step methods are not self starting, since a k-step multi step method requires
the k previous values y
i
, y
i1
, ..., y
ik+1
. The k values that are required for starting the application
of the method are obtained by using some single step method like Eulers method, Taylor
series method or Runge-Kutta method, which is of the same or lower order than the order of
the multi step method.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 217
Let us construct a few multi step methods.
Integrating the differential equation y = f(x, y) in the interval [x
i
, x
i+1
], we get
x
x
x
x
i
i
i
i dy
dx
dx f x y dx
+ +
=
1 1
( , ) .
or y x y x f x y dx
i i
x
x
i
i
( ) ( ) ( , )
+
= +
+
1
1
. (4.69)
To derive the methods, we approximate the integrand f(x, y) by a suitable interpolation
polynomial.
In general, we may integrate the differential equation y = f(x, y) in the interval
[x
im
, x
i+1
]. We get
x
x
x
x
i m
i
i m
i dy
dx
dx f x y dx
+
=
1 1
( , )
or y x y x f x y dx
i i m
x
x
i m
i
( ) ( ) ( , )
+
= +
1
1
.
For m = 0, we get (4.69).
4.6.1 Predictor Methods (Adams-Bashforth Methods)
All predictor methods are explicit methods.
We have k data values, (x
i
, f
i
)(x
i1,
f
i1
), ..., (x
ik+1
, f
ik+1
). For this data, we fit the Newtons
backward difference interpolating polynomial of degree k 1 as (see equation (2.47) in
chapter 2)
P
k1
(x) = f(x
i
+ sh) = f(x
i
) + sf(x
i
) +
s s ( )
!
+ 1
2
2
f(x
i
) + ...
+
s s s s k
k
f x
k
i
( )( ) ... ( )
( ) !
( )
+ + +
1 2 2
1
1
. (4.70)
Note that s = [(x x
i
)/h] < 0.
The expression for the error is given by
T.E. =
s s s s k
k
( )( ) ... ( )
( ) !
+ + + 1 2 1
h
k
f
(k)
() (4.71)
where lies in some interval containing the points x
i
, x
i1
, ..., x
ik+1
and x. We replace f(x, y) by
P
k1
(x) in (4.69). The limits of integration in (4.69) become
for x = x
i
, s = 0 and for x = x
i+1
, s = 1.
Also, dx = hds. We get
y
i+1
= y
i
+ h
0
1
2 3
1
2
1
1
6
1 2
+ + + + + + +
f s f s s f s s s f ds
i i i i
( ) ( )( ) ...
218 NUMERICAL METHODS
Now,
0
1
0
1
1
2
1
5
6
= + = s dx s s ds , ( )
,
0
1
0
1
1 2
9
4
1 2 3
251
30
+ + = + + + = s s s ds s s s s ds ( )( ) , ( )( )( ) .
Hence, we have
y
i+1
= y
i
+ h f f f f f
i i i i i
+ + + + +
1
2
5
12
3
8
251
720
2 3 4
... . (4.72)
These methods are called Adams-Bashforth methods.
Using (4.71), we obtain the error term as
T
k
= h
k+1
0
1
1 2 1
+ + + s s s s k
k
( )( ) ... ( )
( ) !
f
(k)
() ds
= h
k+1
0
1
g(s) f
(k)
() ds. (4.73)
Since, g(s) does not change sign in [0, 1], we get by the mean value theorem
T
k
= h
k+1
f
(k)
(
1
)
0
1
g(s)ds, 0 <
1
< 1 (4.74)
where g(s) =
1
k!
[s(s + 1) ... (s + k 1)].
Alternately, we write the truncation error as
T.E. = y(x
n+1
) y
n+1
Using Taylor series, we expand y(x
n+1
), y
n+1
about x
n
, and simplify. The leading term
gives the order of the truncation error.
Remark 8 From (4.74), we obtain that the truncation error is of order O(h
k+1
). Therefore, a k-
step Adams-Bashforth method is of order k.
By choosing different values for k, we get different methods.
k = 1: We get the method
y
i+1
= y
i
+ hf
i
(4.75)
which is the Eulers method. Using (4.74), we obtain the error term as
T
1
=
h
f
h
y
2
1
2
1
2 2
= ( ) ( ) .
Therefore, the method is of first order.
k = 2: We get the method
y
i+1
= y
i
+ h f f y h f f f
i i i i i i
+
= + +
1
2
1
2
1
( )
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 219
= y
i
+
h
2
[3f
i
f
i1
]. (4.76)
For using the method, we require the starting values y
i
and y
i1
.
Using (4.74), we obtain the error term as
T
2
=
5
12
5
12
3
2
3
2
h f h y = ( ) ( ) .
Therefore, the method is of second order.
k = 3: We get the method
y
i+1
= y
i
+ h
f f f
i i i
+ +
1
2
5
12
2
= y
i
+ h
f f f f f f
i i i i i i
+ + +
1
2
5
12
2
1 1 2
( ) ( )
= y
i
+
h
12
[23f
i
16f
i1
+ 5f
i2
]. (4.77)
For using the method, we require the starting values y
i
, y
i1
and y
i2
.
Using (4.74), we obtain the error term as
T
3
=
3
8
h
4
f
(3)
(
3
) =
3
8
h
4
y
(4)
(
3
).
Therefore, the method is of third order.
k = 4: We get the method
y
i+1
= y
i
+ h
f f f f
i i i i
+ + +
1
2
5
12
3
8
2 3
= y
i
+ h
f f f f f f f f f f
i i i i i i i i i i
+ + + + +
1
2
5
12
2
3
8
3 3
1 1 2 1 2 3
( ) ( ) ( )
= y
i
+
h
24
[55f
i
59f
i1
+ 37f
i2
9f
i3
]. (4.78)
For using the method, we require the starting values y
i
, y
i1
, y
i2
and y
i3.
Using (4.74), we obtain the error term as
T
4
=
251
720
251
720
5 4
4
5 5
4
h f h y
( ) ( )
( )
=
.
Therefore, the method is of fourth order.
Remark 9 The required starting values for the application of the Adams-Bashforth methods
are obtained by using any single step method like Eulers method, Taylor series method or
Runge-Kutta method.
220 NUMERICAL METHODS
Example 4.12 Find the approximate value of y(0.3) using the Adams-Bashforth method of
third order for the initial value problem
y = x
2
+ y
2
, y(0) = 1
with h = 0.1. Calculate the starting values using the corresponding Taylor series method with
the same step length.
Solution We have f(x, y) = x
2
+ y
2
, x
0
= 0, y
0
= 1.
The Adams-Bashforth method of third order is given by
y
i+1
= y
i
+
h
12
[23f
i
16f
i1
+ 5f
i2
].
We need the starting values, y
0
, y
1
, y
2
. The initial condition gives y
0
= 1.
The third order Taylor series method is given by
y
i+1
= y
i
+ hy
i
+
h
y
h
y
i i
2 3
2 6
+ .
We have y = x
2
+ y
2
, y = 2x + 2yy, y = 2 + 2[yy + (y)
2
].
We obtain the following starting values.
i = 0 : x
0
= 0, y
0
= 1, y
0
= 1, y
0
= 2, y
0
= 8.
y(0.1) y
1
= y
0
+ 0.1 y
0
+
0 01
2
0 001
6
0 0
. .
y y +
= 1 + 0.1(1) + 0.005(2) +
0 001
6
.
(8) = 1.111333.
i = 1: x
1
= 0.1, y
1
= 1.111333, y
1
= 1.245061,
y
1
= 2.967355, y
1
= 11.695793.
y(0.2) y
2
= y
1
+ 0.1 y
1
+
0 01
2
0 001
6
1 1
. .
y y +
= 1.111333 + 0.1(1.245061) + 0.005 (2.967355) +
0 001
6
.
(11.695793)
= 1.252625.
Now, we apply the given Adams-Bashforth method. We have
x
2
= 0.2, y
2
= 1.252625, y
2
= f
2
= 1.609069.
For i = 2, we obtain
y(0.3) y
3
= y
2
+
h
12
[23f
2
16f
1
+ 5 f
0
]
= y
2
+
0 1
12
.
[23(1.609069) 16(1.245061) + 5(1)] = 1.436688.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 221
Example 4.13 Find the approximate value of y(0.4) using the Adams-Bashforth method of
fourth order for the initial value problem
y = x + y
2
, y(0) = 1
with h = 0.1. Calculate the starting values using the Eulers method with the same step length.
Solution We have f(x, y) = x + y
2
, x
0
= 0, y
0
= 1.
The Adams-Bashforth method of fourth order is given by
y
i+1
= y
i
+
h
24
[55f
i
59f
i1
+ 37f
i2
9f
i3
].
We need the starting values, y
0
, y
1
, y
2
, y
3
. The initial condition gives y
0
= 1.
Eulers method is given by
y
i+1
= y
i
+ h y
i
= y
i
+ h f
i
.
We obtain the following starting values.
i = 0: x
0
= 0, y
0
= 1, y
0
= f
0
= 1.
y(0.1) y
1
= y
0
+ 0.1 y
0
= 1 + 0.1(1) = 1.1.
i = 1: x
1
= 0.1, y
1
= 1.1, y
1
= f(0.1, 1.1) = 1.31.
y(0.2) y
2
= y
1
+ 0.1 y
1
= 1.1 + 0.1(1.31) = 1.231.
i = 2 : x
2
= 0.2, y
2
= 1.231, y
2
= f(0.2, 1.231) = 1.715361.
y(0.3) y
3
= y
2
+ 0.1 y
2
= 1.231 + 0.1(1.715361) = 1.402536.
Now, we apply the given Adams-Bashforth method. We have
x
3
= 0.3, y
3
= 1.402536, y
3
= f
3
= 2.267107.
For i = 3, we obtain
y(0.4) y
4
= y
3
+
0 1
24
.
[55 f
3
59f
2
+ 37f
1
9f
0
]
= 1.402536 +
0 1
24
.
[55(2.267107) 59(1.715361) + 37(1.31) 9(1)]
= 1.664847.
4.6.2 Corrector Methods
All corrector methods are implicit methods.
4.6.2.1 Adams-Moulton Methods
Consider the k + 1 data values, (x
i+1
, f
i+1
), (x
i
, f
i
), (x
i1
, f
i1
), ..., (x
ik+1
, f
ik+1
) which include the
current data point. For this data, we fit the Newtons backward difference interpolating poly-
nomial of degree k as (see equation (2.47) in chapter 2)
222 NUMERICAL METHODS
P
k
(x) = f(x
i
+ sh) = f(x
i+1
) + (s 1) f(x
i+1
) +
( )
!
s s 1
2
2
f(x
i+i
) + ...
+
( ) ( )( ) ... ( )
( ) !
( )
s s s s s k
k
f x
k
i
+ + +
+
1 1 2 2
1
(4.79)
where s = [(x x
i
)/h] < 0.
The expression for the error is given by
T.E. =
( ) ( )( ) ... ( )
( ) !
s s s s s k
k
+ + +
+
1 1 2 1
1
h
k+1
f
(k+1)
() (4.80)
where lies in some interval containing the points x
i+1
, x
i
, ..., x
nk+1
and x. We replace f(x, y) by
P
k
(x) in (4.69). The limits of integration in (4.69) become
for x = x
i
, s = 0, and for x = x
i+1
, s = 1.
Also, dx = hds. We get
y
i+1
= y
i
+ h
0
1
1 1
2
1
1
1
2
1
+ + +
+ +
f s f s s f
i i i
( ) ( )
+
1
6
1 1
3
1
( ) ( ) ... s s s f
i
+ +
+
ds
Now,
0
1
1
1
2
= ( ) , s ds
0
1
3 2
0
1
1
3 2
1
6
= ( ) s s ds
s s
0
1
4 2
0
1
1 1
4 2
1
4
+ =
= ( ) ( ) s s s ds
s s
.
0
1
1 1 2
19
30
+ + = ( ) ( )( ) s s s s ds .
Hence, we have
y
i+1
= y
i
+ h
f f f f f
i i i i i + + + + +
1 1
2
1
3
1
4
1
1
2
1
12
1
24
19
720
...
(4.81)
These methods are called Adams-Moulton methods.
Using (4.80), we obtain the error term as
T
k
= h
k+2
0
1
1 1 2 1
1
+ + +
+
( ) ( )( ) ... ( )
( ) !
s s s s s k
k
f
(k+1)
() ds
= h
k+2
0
1
1
+
g s f ds
k
( ) ( )
( )
(4.82)
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 223
where g(s) =
1
1 ( ) ! k +
[(s 1)s(s + 1) ... (s + k 1)].
Since g(s) does not change sign in [0, 1], we get by the mean value theorem
T
k
= h
k+2
f
(k+1)
(
1
)
0
1
g s ds ( ) , 0 <
1
< 1. (4.83)
Remark 10 From (4.83), we obtain that the truncation error is of order O(h
k+2
). Therefore, a
k-step Adams-Moulton method is of order k + 1.
By choosing different values for k, we get different methods.
k = 0 : We get the method
y
i+1
= y
i
+ hf
i +1
(4.84)
which is the backward Eulers method. Using (4.83), we obtain the error term as
T
1
=
h
f
h
y
2
1
2
1
2 2
= ( ) ( ) .
Therefore, the method is of first order.
k = 1: We get the method
y
i+1
= y
i
+ h f f y h f f f
i i i i i i + + + +
= +
1 1 1 1
1
2
1
2
( )
= y
i
+
h
2
[ f
i+1
+ f
i
]. (4.85)
This is also a single step method and we do not require any starting values. This method
is also called the trapezium method.
Using (4.83), we obtain the error term as
T
2
=
1
12
h
3
f (
2
) =
1
12
h
3
y(
2
).
Therefore, the method is of second order.
k = 2: We get the method
y
i + 1
= y
i
+ h f f f
i i i + + +
1 1
2
1
1
2
1
12
= y + h f f f f f f
i i i i i i + + +
+
1 1 1 1
1
2
1
12
2 ( ) ( )
= y
i
+
h
12
[5f
i + 1
+ 8f
i
f
i 1
]. (4.86)
224 NUMERICAL METHODS
For using the method, we require the starting values . ,
1 i i
y y
Using (4.83), we obtain the error term as
T
3
=
1
24
1
24
4 3)
3
4 4
3
h f h y
( ( )
( ) ( ) = .
Therefore, the method is of third order.
k = 3: We get the method
y
i+1
= y
i
+ h f f f f
i i i i + + + +
1 1
2
1
3
1
1
2
1
12
1
24
= y
i
+ h f f f f f f
i i i i i i + + +
+
1 1 1 1
1
2
1
12
2 ( ) ( )
1
24
(f
i+1
3f
i
+ 3f
i1
f
i2
)
= y
i
+
h
24
[9f
i+1
+ 19f
i
5f
i1
+ f
i2
]. (4.87)
For using the method, we require the starting values y
i
, y
i1
, y
i2
.
Using (4.83), we obtain the error term as
T
4
=
19
720
19
720
5 4
4
5 5
4
h f h y
( ) ( )
( ) ( ) =
.
Therefore, the method is of fourth order.
4.6.2.2 Milne-Simpson Methods
To derive the Milnes methods, we integrate the differential equation y = f(x, y) in the interval
[x
i1
, x
i+1
]. We get
x
x
x
x
i
i
i
i dy
dx
dx f x y dx
+
=
1
1
1
1
( , )
.
or y(x
i+1
) = y(x
i1
) +
x
x
i
i
f x y dx
1
1
( , ) . (4.88)
To derive the methods, we use the same approximation, follow the same procedure and
steps as in Adams-Moulton methods. The interval of integration for s is [ 1, 1]. We obtain
y
i+1
= y
i1
+ h
0
1
1 1
2
1
1
1
2
1
+ + +
+ +
f s f s s f
i i i
( ) ( )
+
1
6
1 1
3
1
( ) ( ) ... s s s f
i
+ +
+
ds
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 225
Now,
1
1
(s 1) ds = 2,
0
1
(s 1)s ds =
2
3
,
1
1
(s 1)s(s + 1) ds = 0,
1
1
(s 1)s(s + 1)(s + 2) ds =
24
90
.
Hence, we have
y
i+1
= y
i1
+ h 2 2
1
3
0
1
90
1 1
2
1
3
1
4
1
f f f f f
i i i i i + + + + +
+ +
( ) ... . (4.89)
These methods are called Milnes methods.
The case k = 2, is of interest for us. We obtain the method as
y
i+1
= y
i1
+ h
2 2
1
3
1 1
2
1
f f f
i i i + + +
+
= y
i1
+ h
2 2
1
3
2
1 1 1 1
f f f f f f
i i i i i i + + +
+ +
( ) ( )
= y
i1
+
h
3
[f
i+1
+ 4f
i
+ f
i1
)]. (4.90)
This method is also called the Milne-Simpsons method.
For using the method, we require the starting values y
i
, y
i1
.
The error term is given by
Error =
1
90
1
90
5 4 5 5
h f h y
( ) ( )
( ) ( ) = .
Therefore, the method is of fourth order.
Remark 11 The methods derived in this section are all implicit methods. Therefore, we need
to solve a nonlinear algebraic equation for obtaining the solution at each point. Hence, these
methods are not used as such but in combination with the explicit methods. This would give
rise to the explicit-implicit methods or predictor-corrector methods, which we describe in the
next section.
4.6.2.3 Predictor-Corrector Methods
In the previous sections, we have derived explicit single step methods (Eulers method, Taylor
series methods and Runge-Kutta methods), explicit multi step methods (Adams-Bashforth
methods) and implicit methods (Adams-Moulton methods, Milne-Simpson methods) for the
solution of the initial value problem y = f(x, y), y(x
0
) = y
0
. If we perform analysis for numerical
stability of these methods (we shall discuss briefly this concept in the next section), we find
that all explicit methods require very small step lengths to be used for convergence. If the
solution of the problem is required over a large interval, we may need to use the method
thousands or even millions of steps, which is computationally very expensive. Most implicit
methods have strong stability properties, that is, we can use sufficiently large step lengths for
computations and we can obtain convergence. However, we need to solve a nonlinear alge-
226 NUMERICAL METHODS
braic equation for the solution at each nodal point. This procedure may also be computationally
expensive as convergence is to be obtained for the solution of the nonlinear equation at each
nodal point. Therefore, we combine the explicit methods (which have weak stability proper-
ties) and implicit methods (which have strong stability properties) to obtain new methods.
Such methods are called predictor-corrector methods or P-C methods.
Now, we define the predictor-corrector methods. We denote P for predictor and C for
corrector.
P: Predict an approximation to the solution y
i+1
at the current point, using an explicit
method. Denote this approximation as y
i
p
+1
( )
.
C: Correct the approximation y
i
p
+1
( )
, using a corrector, that is, an implicit method. Denote
this corrected value as y
i
c
+1
( )
. The corrector is used 1 or 2 or 3 times, depending on the
orders of explicit and implicit methods used.
Remark 12 The order of the predictor should be less than or equal to the order of the corrector.
If the orders of the predictor and corrector are same, then we may require only one or two
corrector iterations at each nodal point. For example, if the predictor and corrector are both of
fourth order, then the combination (P-C method) is also of fourth order and we may require
one or two corrector iterations at each point. If the order of the predictor is less than the order
of the corrector, then we require more iterations of the corrector. For example, if we use a first
order predictor and a second order corrector, then one application of the combination gives a
result of first order. If corrector is iterated once more, then the order of the combination increases
by one, that is the result is now of second order. If we iterate a third time, then the truncation
error of the combination reduces, that is, we may get a better result. Further iterations may
not change the results.
We give below a few examples of the predictor-corrector methods.
Example 1
Predictor P: Euler method:
y y hf x y
n
p
n n n +
= +
1
( )
( , ) . (4.91)
Error term =
h
f
h
y
2
1
2
1
2 2
= ( ) ( ) .
Corrector C: Backward Euler method (4.84):
y y hf x y
n
c
n n n
p
+ + +
= +
1 1 1
( ) ( )
( , )
. (4.92)
Error term =
h
f
h
y
2
1
2
1
2 2
= ( ) ( ) .
Both the predictor and corrector methods are of first order. We compute
y y hf x y
n n n n +
= +
1
0 ( )
( , ).
y y hf x y
n n n n + + +
= +
1
1
1 1
0 ( ) ( )
( , )
.
y y hf x y
n n n n + + +
= +
1
2
1 1
1 ( ) ( )
( , ), etc.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 227
Example 2
Predictor P: Euler method:
y y hf x y
n
p
n n n +
= +
1
( )
( , )
. (4.93)
Corrector C: Trapezium method (4.85):
y y
h
f x y f x y
n
c
n n n n n
p
+ + +
= + +
1 1 1
2
( ) ( )
[ ( , ) ( , )]
. (4.94)
Error term =
1
12
1
12
3
2
3
2
h f h y = ( ) ( ) .
The predictor is of first order and the corrector is of second order. We compute
y y hf x y
n n n n +
= +
1
0 ( )
( , )
.
y y
h
f x y f x y
n n n n n n + + +
= + +
1
1
1 1
0
2
( ) ( )
[ ( , ) ( , )]
.
y y
h
f x y f x y
n n n n n n + + +
= + +
1
2
1 1
1
2
( ) ( )
[ ( , ) ( , )]
, etc.
Example 3 Adams-Bashforth-Moulton predictor-corrector method of fourth order.
Both the predictor and corrector methods are of fourth order.
Predictor P: Adams-Bashforth method of fourth order.
y y
h
f f f f
i
p
i i i i i +
= + +
1 1 2 3
24
55 59 37 9
( )
[ ]
. (4.95)
Error term =
251
720
251
720
5 4
4
5 5
4
h f h y
( ) ( )
( ) ( ) = .
The method requires the starting values y
i
, y
i1
, y
i2
and y
i3
.
Corrector C: Adams-Moulton method of fourth order.
y y
h
f x y f f f
i
c
i i i
p
i i i + + +
= + + +
1 1 1 1 2
24
9 19 5
( ) ( )
[ ( , ) ]
. (4.96)
Error term =
19
720
5 4
4
h f
( )
( ) =
19
720
5 5
4
h y
( )
( ) .
The method requires the starting values y
i
, y
i1
, y
i2
.
The combination requires the starting values y
i
, y
i1
, y
i2
and y
i3
.
That is, we require
the values y
0
, y
1
, y
2
, y
3
. Initial condition gives the value y
0
.
In the syllabus, this method is also referred to as Adams-Bashforth predictor-corrector
method.
Example 4 Milnes predictor-corrector method.
Both the predictor and corrector methods are of fourth order.
228 NUMERICAL METHODS
Predictor P: Adams-Bashforth method of fourth order.
y y
h
f f f
i
p
i i i i +
= + +
1 3 1 2
4
3
2 2
( )
[ ]
. (4.97)
Error term =
14
45
14
45
5 4 5 5
h f h y
( ) ( )
( ) ( ) = .
The method requires the starting values y
i
, y
i1
, y
i2
and y
i3
.
Corrector C: Milne-Simpsons method of fourth order.
y y
h
f x y f f
i
c
i i i
p
i i + + +
= + + +
1 1 1 1 1
3
4
( ) ( )
[ ( , ) )]
. (4.98)
Error term =
1
90
1
90
5 4 5 5
h f h y
( ) ( )
( ) ( ) = .
The method requires the starting values y
i
, y
i1
.
The combination requires the starting values y
i
, y
i1
, y
i2
and y
i3
. That is, we require
the values y
0
, y
1
, y
2
, y
3
. Initial condition gives the value y
0
.
Remark 13 Method (4.97) is obtained in the same way as we have derived the Adams-Bashforth
methods. Integrating the given differential equation y = f(x, y) on the interval
(x
i3
, x
i+1
), we obtain
x
x
x
x
i
i
i
i dy
dx
dx f x y dx
+
=
3
1
3
1
( , )
or y(x
i+1
) = y(x
i3
) +
f x y dx
x
x
i
i
( , )
3
1
.
Replace the integrand on the right hand side by the same backward difference polyno-
mial (4.70) and derive the method in the same way as we have done in deriving the explicit
Adams-Bashforth methods. We obtain the method as
y y h f f f f f
i i i i i i i +
= + + + + +
1 3
2 3 4
4 4
8
3
0
14
35
( ) ... . (4.99)
Retaining terms up to
3
f
i
, we obtain the method
y y h f f f f
i i i i i i +
= + + +
1 3
2 3
4 4
8
3
0 ( )
=
y h f f f f f f
i i i i i i i
+ + +
3 1 1 2
4 4
8
3
2 ( ) (
= y
h
f f f
i i i i
+ +
3 1 2
4
3
2 2 [ ]
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 229
The error term is given by
T.E. =
14
45
14
45
5 4 5 5
h f h y
( ) ( )
( ) ( ) = .
Therefore, the method is of fourth order.
Example 4.14 Using the Adams-Bashforth predictor-corrector equations, evaluate y(1.4), if y
satisfies
dy
dx
y
x x
+ =
1
2
and y(1) = 1, y(1.1) = 0.996, y(1.2) = 0.986, y(1.3) = 0.972. (A.U. Nov./Dec. 2006)
Solution The Adams-Bashforth predictor-corrector method is given by
Predictor P: Adams-Bashforth method of fourth order.
y y
h
f f f f
i
p
i i i i i +
= + +
1 1 2 3
24
55 59 37 9
( )
[ ]
.
The method requires the starting values y
i
, y
i1
, y
i2
and y
i3
.
Corrector C: Adams-Moulton method of fourth order.
y y
h
f x y f f f
i
c
i i i
p
i i i + + +
= + + +
1 1 1 1 2
24
9 19 5
( ) ( )
[ ( , ) ]
The method requires the starting values y
i
, y
i1
, y
i2
.
The combination requires the starting values y
i
, y
i1
, y
i2
and y
i3
. That is, we require
the values y
0
, y
1
, y
2
, y
3
. With h = 0.1, we are given the values
y(1) = 1, y(1.1) = 0.996, y(1.2) = 0.986, y(1.3) = 0.972.
We have f(x, y) =
1
2
x
y
x
.
Predictor application
For i = 3, we obtain
y y y
h
f f f f
p
4
0
4 3 3 2 1 0
24
55 59 37 9
( ) ( )
[ ] = = + +
We have f
0
= f(x
0
, y
0
) = f(1, 1) = 1 1 = 0,
f
1
= f(x
1
, y
1
) = f(1.1, 0.996) = 0.079008,
f
2
= f(x
2
, y
2
) = f(1.2, 0.986) = 0.127222,
f
3
= f(x
3
, y
3
) = f(1.3, 0.972) = 0.155976.
y
4
0
0 972
01
24
55 0155976 59 0127222 37 0 079008 9 0
( )
.
.
[ ( . ) ( . ) ( . ) ( )] = + +
= 0.955351.
230 NUMERICAL METHODS
Corrector application
Now, f x y ( , )
( )
4 4
0
= f(1.4, 0.955351) = 0.172189.
First iteration
y y y
h
f x y f f f
c
4 4 3 4 4
0
3 2 1
24
9 19 5
(1) ( ) ( )
[ ( , ) ] = = + + +
= 0.972 +
0 1
24
.
[9( 0.172189) + 19( 0.155976) 5( 0.127222)
+ ( 0.079008)] = 0.955516.
Second iteration
f( , )
( )
x y
4 4
1
= f(1.4, 0.955516) = 0.172307.
y y
h
f x y f f f
4
2
3 4 4
1
3 2 1
24
9 19 5
( ) ( )
[ ( , ) ] = + + +
= 0.972 +
0 1
24
.
[9( 0.172307) + 19( 0.155976) 5( 0.127222)
+ ( 0.079008)] = 0.955512.
Now, | y y
4
2
4
1 ( ) ( )
| = | 0.955512 0.955516 | = 0.000004.
Therefore, y(1.4) = 0.955512. The result is correct to five decimal places.
Example 4.15 Given y = x
3
+ y, y(0) = 2, the values y(0.2) = 2.073, y(0.4) = 2.452, and y(0.6)
= 3.023 are got by Runge-Kutta method of fourth order. Find y(0.8) by Milnes predictor-corrector
method taking h = 0.2. (A.U. April/May 2004)
Solution Milnes predictor-corrector method is given by
Predictor P: Adams-Bashforth method of fourth order.
y y
h
f f f
i
p
i i i i +
= + +
1 3 1 2
4
3
2 2
( )
[ ]
.
Corrector C: Milne-Simpsons method of fourth order.
y y
h
f x y f f
i
c
i i i
p
i i + + +
= + + +
1 1 1 1 1
3
4
( ) ( )
[ ( , ) ].
The method requires the starting values y
i
, y
i1
, y
i2
and y
i3
. That is, we require the
values y
0
, y
1
, y
2
, y
3
. Initial condition gives the value y
0
.
We are given that
f(x, y) = x
3
+ y, x
0
= 0, y
0
= 2, y(0.2) = y
1
= 2.073,
y(0.4) = y
2
= 2.452, y(0.6) = y
3
= 3.023.
INITIAL VALUE PROBLEMS FOR ORDINARY DIFFERENTIAL EQUATIONS 231
Predictor application
For i = 3, we obtain
y y y f f f
p
4
0
4 0 3 2 1
4 0 2
3
2 2
( ) ( )
( . )
[ ] = = + +
.
We have f
0
= f(x
0
, y
0
) = f(0, 2) = 2,
f
1
= f(x
1
, y
1
) = f(0.2, 2.073) = 2.081,
f
2
= f(x
2
, y
2
) = f(0.4, 2.452) = 2.516,
f
3
= f(x
3
, y
3
) = f(0.6, 3.023) = 3.239.
y
4
0
2
0 8
3
( )
.
= +
[2(3.239) 2.516 + 2(2.081)] = 4.1664.
Corrector application
First iteration For i = 3, we get
y y f x y f f
4 2 4 4
0
3 2
02
3
4
(1) ( )
.
[ ( , ) ] = + + +
Now, f x y ( , )
( )
4 4
0
= f(0.8, 4.1664) = 4.6784.
y
4
1
2 452
0 2
3
( )
.
.
= +
[4.6784 + 4(3.239) + 2.516] = 3.79536.
Second iteration
y y f x y f f
4
2
2 4 4 3 2
0 2
3
4
( ) (1)
.
[ ( , ) ] = + + +
Now, f x y ( , )
( )
4 4
1
= f(0.8, 4.6784) = 4.30736.
y
4
2
2 452
0 2
3
( )
.
.
= + [4.30736 + 4(3.239) + 2.516] = 3.770624.
We have | y y
4
2
4
1 ( ) ( )
, or b = a + nh.
The points a = x
0
, x
1
= x
0
+ h, x
2
= x
0
+ 2h, ....., x
i
= x
0
+ ih, ....., x
n
= x
0
+ nh = b, are called
the nodes or nodal points or lattice points (Fig. 5.1).
a = x
0
x
1
h h
x
2
h
x
i1
x
i
x
i+1
x = b
n
Fig. 5.1 Nodes.
We denote the numerical solution at any point x
i
by y
i
and the exact solution by y(x
i
).
In Chapter 3, we have derived the following approximations to the derivatives.
Approximation to y(x
i
) at the point x = x
i
(i) Forward difference approximation of first order or O(h) approximation:
y(x
i
)
1
h
[y(x
i+1
) y(x
i
)], or y
i
=
1
h
[y
i+1
y
i
]. (5.8)
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 243
(ii) Backward difference approximation of first order or O(h) approximation:
y(x
i
)
1
h
[y(x
i
) y(x
i1
)], or y
i
=
1
h
[y
i
y
i1
]. (5.9)
(iii) Central difference approximation of second order or O(h
2
) approximation:
y(x
i
)
1
2h
[y(x
i+1
) y(x
i1
)], or y
i
=
1
2h
[y
i+1
y
i1
]. (5.10)
Approximation to y(x
i
) at the point x = x
i
Central difference approximation of second order or O(h
2
) approximation:
y(x
i
)
1
2
h
[y(x
i+1
) 2y(x
i
) + y(x
i1
)],
or y
i
=
1
2
h
[y
i+1
2y
i
+ y
i1
]. (5.11)
Applying the differential equation (5.3) at the nodal point x = x
i
, we obtain
y(x
i
) + p(x
i
) y(x
i
) + q(x
i
) y(x
i
) = r(x
i
). (5.12)
Since y(a) = y(x
0
) = A and y(b) = y(x
n
) = B are prescribed, we need to determine the
numerical solutions at the n 1 nodal points x
1
, x
2
, ..., x
i
, ...., x
n1
.
Now, y(x
i
) is approximated by one of the approximations given in Eqs. (5.8), (5.9), (5.10)
and y(x
i
) is approximated by the approximation given in Eq.(5.11). Since the approximations
(5.10) and (5.11) are both of second order, the approximation to the differential equation is of
second order. However, if y(x
i
) is approximated by (5.8) or (5.9), which are of first order, then
the approximation to the differential equation is only of first order. But, in many practical
problems, particularly in Fluid Mechanics, approximations (5.8), (5.9) give better results (non-
oscillatory solutions) than the central difference approximation (5.10).
Using the approximations (5.10) and (5.11) in Eq.(5.12), we obtain
1
2
h
[y
i+1
2y
i
+ y
i1
] +
p x
h
i
( )
2
[y
i+1
y
i1
] + q(x
i
) y
i
= r
i
or 2[y
i+1
2y
i
+ y
i1
] + h p(x
i
) [y
i+1
y
i1
] + 2h
2
q(x
i
) y
i
= 2h
2
r
i
.
Collecting the coefficients, we can write the equation as
a
i
y
i1
+ b
i
y
i
+ c
i
y
i+1
= d
i
, i = 1, 2, , n 1 (5.13)
where a
i
= 2 h p(x
i
), b
i
= 4 + 2h
2
q(x
i
), c
i
= 2 + h p(x
i
), d
i
= 2h
2
r(x
i
).
Let us now apply the method at the nodal points. We have the following equations.
At x = x
1
, or i = 1:
a
1
y
0
+ b
1
y
1
+ c
1
y
2
= d
1
, or b
1
y
1
+ c
1
y
2
= d
1
a
1
A = d
1
*
. (5.14)
At x = x
i
, i = 2, 3, , n 2 :
a
i
y
i1
+ b
i
y
i
+ c
i
y
i +1
= d
i
(5.15)
244 NUMERICAL METHODS
At x = x
n1
, or i = n 1:
a
n1
y
n2
+ b
n1
y
n1
+ c
n1
y
n
= d
n1
, or a
n1
y
n2
+ b
n1
y
n1
= d
n1
c
n1
B = d
n1
*
. (5.16)
Eqs.(5.14), (5.15), (5.16) give rise to a system of (n 1) (n 1) equations Ay = d for the
unknowns y
1
, y
2
, ..., y
i
, ..., y
n1
, where A is the coefficient matrix and
y = [y
1
, y
2
, ..., y
i
, ..., y
n1
]
T
, d = [ d
1
*
, d
2
, ..., d
i
, ..., d
n2
, d
n1
*
]
T
.
It is interesting to study the structure of the coefficient matrix A. Consider the case
when the interval [a, b] is subdivided into n = 10 parts. Then, we have 9 unknowns, y
1
, y
2
, ....,
y
9
, and the coefficient matrix A is as given below.
Remark 1 Do you recognize the structure of A? It is a tri-diagonal system of algebraic equations.
Therefore, the numerical solution of Eq.(5.2) or Eq.(5.3) by finite differences gives rise to a
tri-diagonal system of algebraic equations, whose solution can be obtained by using the Gauss
elimination method or the Thomas algorithm. Tri-diagonal system of algebraic equations is
the easiest to solve. In fact, even if the system is very large, its solution can be obtained in a
few minutes on a modern desk top PC.
A =
b c
a b c
a b c
a b c
a b c
a b c
a b c
a b c
b c
1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9
0 0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0 0
Remark 2 Does the system of equations (5.13) always converge? We have the following sufficient
condition: If the system of equations (5.13) is diagonally dominant, then it always converges.
Using the expressions for a
i
, b
i
, c
i
, we can try to find the bound for h for which this condition is
satisfied.
Example 5.1 Derive the difference equations for the solution of the boundary value problem
y + p(x) y + q(x) y = r(x), x [a, b]
y(a) = A, y(b) = B
using central difference approximation for y and forward difference approximation for y.
Solution Using the approximations
= + =
+ +
y
h
y y y y
h
y y
i i i i i i i
1
2
1
2
1 1 1
[ ], [ ]
in the differential equation, we obtain
1
2
2
1 1 1
h
y y y
p x
h
y y q x y r x
i i i
i
i i i i i
[ ]
( )
[ ] ( ) ( )
+ +
+ + + =
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 245
or [y
i+1
2y
i
+ y
i1
] + h p(x
i
) [y
i+1
y
i
] + h
2
q(x
i
) y
i
= h
2
r
i
or y
i1
+ b
i
y
i
+ c
i
y
i+1
= d
i
, i = 1, 2, , n 1
where b
i
= 2 h p(x
i
) + h
2
q(x
i
), c
i
= 1 + h p(x
i
), d
i
= h
2
r
i
.
The system again produces a tri-diagonal system of equations.
Example 5.2 Derive the difference equations for the solution of the boundary value problem
y + p(x) y + q(x) y = r(x), x [a, b]
y(a) = A, y(b) = B
using central difference approximation for y and backward difference approximation for y.
Solution Using the approximations
= +
+
y
h
y y y
i i i i
1
2
2
1 1
[ ]
, =
y
h
y y
i i i
1
1
[ ]
in the differential equation, we obtain
1
2
2
1 1 1
h
y y y
p x
h
y y q x y r x
i i i
i
i i i i i
[ ]
( )
[ ] ( ) ( )
+
+ + + =
or [y
i+1
2y
i
+ y
i1
] + h p(x
i
) [y
i
y
i1
] + h
2
q(x
i
)y
i
= h
2
r
i
or a
i
y
i1
+ b
i
y
i
+ y
i + 1
= d
i
, i = 1, 2, , n 1
where a
i
= 1 h p(x
i
), b
i
= 2 + h p(x
i
) + h
2
q(x
i
), d
i
= h
2
r
i
.
The system again produces a tri-diagonal system of equations.
Example 5.3 Solve the boundary value problem x y + y = 0, y(1) = 1, y(2) = 2 by second order
finite difference method with h = 0.25.
Solution We have h = 0.25 and n =
b a
h
=
2 1
0 25 .
= 4.
We have five nodal points x
0
= 1.0, x
1
= 1.25, x
2
= 1.5, x
3
= 1.75, x
4
= 2.0.
We are given the data values y(x
0
) = y
0
= y(1) = 1, y(x
4
) = y
4
= y(2) = 2.
We are to determine the approximations for y(1.25), y(1.5), y(1.75). Using the central
difference approximation for y
i
, we get
x
h
y y y y
i
i i i i
2
1 1
2 0 [ ] ,
+
+ + =
or 16x
i
y
i1
+ (1 32x
i
) y
i
+ 16x
i
y
i+1
= 0.
We have the following difference equations.
For i = 1, x
1
= 1.25, y
0
= 1.0 : 20y
0
39y
1
+ 20y
2
= 0 or 39y
1
+ 20y
2
= 20
For i = 2, x
2
= 1.5 : 24y
1
47y
2
+ 24y
3
= 0.
For i = 3, x
3
= 1.75, y
4
= 2.0 : 28y
2
55y
3
+ 28y
4
= 0 or 28y
2
55y
3
= 56.
246 NUMERICAL METHODS
We have the following system of equations
39 20 0
24 47 24
0 28 55
20
0
56
1
2
3
y
y
y
.
We can solve this system using Gauss elimination. We obtain
39 20 0 20
24 47 24 0
0 28 55 56
39
1 20 39 0 20 39
24 47 24 0
0 28 55 56
1
, ,
/ /
R
, R
2
24R
1
,
1 20 39 0 20 39
0 1353 39 24 480 39
0 28 55 56
1353 39
1 20 39 0 20 39
0 1 936 1353 480 1353
0 28 55 56
2
/ /
/ / ,
( / )
,
/ /
/ /
R
,
R
3
28R
2
,
1 20 39 0 20 39
0 1 936 1353 480 1353
0 0 48207 1353 89208 1353
/ /
/ /
/ /
From the last equation, we get y
3
=
89208
48207
= 1.85052.
Back substitution gives y
2
=
480
1353
936
1353
+ (1.85052) = 1.63495,
y
1
=
20
39
(1 + 1.63495) = 1.35126.
Example 5.4 Using the second order finite difference method, find y(0.25), y(0.5), y(0.75) sat-
isfying the differential equation y y = x and subject to the conditions y(0) = 0, y(1) = 2.
Solution We have h = 0.25 and n =
b a
h
=
1 0
0 25 .
= 4.
We have five nodal points x
0
= 0.0, x
1
= 0.25, x
2
= 0.5, x
3
= 0.75, x
4
= 1.0.
We are given the data values y(x
0
) = y
0
= y(0) = 0, y(x
4
) = y
4
= y(1) = 2.
We are to determine the approximations for y(0.25), y(0.5), y(0.75). Using the central
difference approximation for y
i
, we get
1
2
2
1 1
h
y y y y x
i i i i i
[ ]
+
+ = , or 16y
i1
33y
i
+ 16y
i+1
= x
i
.
We have the following difference equations.
For i = 1, x
1
= 0.25, y
0
= 0.0 : 16y
0
33y
1
+ 16y
2
= 0.25 or 33y
1
+ 16y
2
= 0.25,
For i = 2, x
2
= 0.5 : 16y
1
33 y
2
+ 16y
3
= 0.5,
For i = 3, x
3
= 0.75, y
4
= 2.0 : 16y
2
33y
3
+ 16y
4
= 0.75 or 16y
2
33y
3
= 31.25.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 247
We have the following system of equations
33 16 0
16 33 16
0 16 33
0 25
0 5
3125
1
2
3
y
y
y
.
.
.
.
We can solve this system using Gauss elimination. We obtain
33 16 0 0 25
16 33 16 0 5
0 16 33 3125
33
1 0 48485 0 0 007576
16 33 16 0 5
0 16 33 56
1
.
.
.
, ,
. .
.
R
, R
2
16R
1
,
1 0 48485 0 0 007576
0 25 2424 16 0 621216
0 16 33 3125
25 2424
1 0 48485 0 0 007576
0 1 0 63385 0 02461
0 16 33 3125
2
. .
. .
.
,
( . )
,
. .
. .
.
R
,
R
3
16R
2
,
1 0 48485 0 0 007576
0 1 0 63385 0 02461
0 0 22 8584 30 85624
. .
. .
. .
.
From the last equation, we get y
3
=
30 85624
22 8584
.
.
= 1.34989.
Back substitution gives
y
2
= 0.02461 + 0.63385(1.34989) = 0.83102,
y
1
= 0.007576 + 0.48485(0.83102) = 0.39534.
Example 5.5 Solve the boundary value problem y + 5y + 4y = 1, y(0) = 0, y(1) = 0 by finite
difference method. Use central difference approximations with h = 0.25. If the exact solution is
y(x) = Ae
x
+ Be
4x
+ 0.25, where A =
e e
e
3
3
4(1 )
, B = 0.25 A
find the magnitude of the error and percentage relative error at x = 0.5.
Solution We have h = 0.25 and n =
b a
h
=
1 0
0 25 .
= 4.
We have five nodal points x
0
= 0.0, x
1
= 0.25, x
2
= 0.5, x
3
= 0.75, x
4
= 1.0.
We are given the data values y(x
0
) = y
0
= y(0) = 0, y(x
4
) = y
4
= y(1) = 0.
We are to determine the approximations for y(0.25), y(0.5), y(0.75). Using the central
difference approximations, we get
1
2
5
2
2
1 1 1 1
h
y y y
h
y y
i i i i i
[ ] ( )
+ +
+ +
+ 4y
i
= 1,
or 16[ y
i+1
2y
i
+ y
i1
] + 10(y
i+1
y
i1
) + 4y
i
= 1, or 6y
i1
28y
i
+ 26y
i+1
= 1.
248 NUMERICAL METHODS
We have the following difference equations.
For i = 1, x
1
= 0.25, y
0
= 0.0 : 6y
0
28y
1
+ 26y
2
= 1 or 28y
1
+ 26y
2
= 1.
For i = 2, x
2
= 0.5 : 6y
1
28y
2
+ 26y
3
= 1.
For i = 3, x
3
= 0.75, y
4
= 0 : 6y
2
28y
3
+ 26y
4
= 1 or 6y
2
28y
3
= 1.
We have the following system of equations
28 26 0
6 28 26
0 6 28
1
1
1
1
2
3
y
y
y
.
We can solve this system using Gauss elimination. We obtain
28 26 0 1
6 28 26 1
0 6 28 1
28
1 092857 0 003571
6 28 26 1
0 6 28 1
1
, ,
. .
R
, R
2
6R
1
1 0 92857 0 0 03571
0 22 42858 26 121426
0 6 28 1
22 42858
1 0 92857 0 0 03571
0 1 115924 0 05414
0 6 28 1
2
. .
. . ,
( . )
,
. .
. .
R
R
3
6R
2
,
1 0 92857 0 0 03571
0 1 115924 0 05414
0 0 2104456 132484
. .
. .
. .
.
From the last equation, we get y
3
=
132484
2104456
.
.
= 0.06295.
Back substitution gives
y
2
= 0.05414 1.15924(0.06295) = 0.12711,
y
1
= 0.03571 0.92857(0.12711) = 0.15374.
We also have A = 0.70208, B = 0.45208, y(0.5) = Ae
0.5
+ Be
2
= 0.11465.
Now, | error at x = 0.5 | = | y
2
y(0.5) | = | 0.12711 + 0.11465 | = 0.01246.
Percentage relative error =
0 01246
0 11465
.
.
(100) = 10.8%.
Example 5.6 Solve the boundary value problem
(1 + x
2
)y + 4xy + 2y = 2, y(0) = 0, y(1) = 1/2
by finite difference method. Use central difference approximations with h = 1/3.
Solution We have h = 1/3. The nodal points are x
0
= 0, x
1
= 1/3, x
2
= 2/3, x
3
= 1.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 249
Using the central difference approximations, we obtain
1
1 2
4
2
2
2
2
1 1 1 1
h
x y y y
x
h
y y y
i i i i
i
i i i
( )[ ] ( ) + + + +
+ +
= 2
or [ ( ) ] [ ( )] [ ( ) ] 9 1 6 2 18 1 9 1 6
2
1
2 2
1
+ + + + + +
+
x x y x y x x y
i i i i i i i i
= 2.
We have the following difference equations.
For i = 1, x
1
= 1/3, y
0
= 0 :
9 1
1
9
2 2 18 1
1
9
9 1
1
9
2
0 1
+
+ +
+ +
y y y
2
= 2
or 18y
1
+ 12y
2
= 2.
For i = 2, x
1
= 2/3, y
3
= 1/2 :
9 1
4
9
4 2 18 1
4
9
9 1
4
9
4
1 2
+
+ +
+ +
y y y
3
= 2
or 9y
1
24y
2
= 6.5.
Solving the equations
9y
1
+ 6y
2
= 1, 9y
1
24y
2
= 6.5
we obtain y
1
=
15
162
0 092592
49 5
162
0 305556
2
= = = . ,
.
. y .
REVIEW QUESTIONS
1. Write the first order difference approximations for y(x
i
) based on (i) forward differ-
ences, (ii) backward differences.
Solution
(i) y(x
i
) = [ y
i+1
y
i
]/(h), (ii) y(x
i
) = [y
i
y
i1
]/h, where h is the step length.
2. Write the second order difference approximations for (i) y(x
i
), (ii) y(x
i
) based on central
differences.
Solution (i) y(x
i
) = [y
i+1
y
i1
]/(2h), (ii) y(x
i
) = [y
i+1
2y
i
+ y
i1
]/h
2
,
where h is the step length.
3. Finite difference methods when applied to linear second order boundary value prob-
lems in ordinary differential equations produce a system of linear equations Ay = b.
What is the structure of the coefficient matrix A ?
Solution Tridiagonal matrix.
4. What types of methods are available for the solution of linear system of algebraic
equations ?
Solution (i) Direct methods. (ii) Iterative methods.
250 NUMERICAL METHODS
5. When iterative methods are used to solve the linear system of algebraic equations,
under what conditions convergence to the exact solution is guaranteed?
Solution A sufficient condition for convergence is that the coefficient matrix A should
be diagonally dominant, that is, | | | |
,
a a
ii
j i j
n
ij
1
. That is, in this case convergence is
guaranteed. Since it is a sufficient condition, it implies that the system may converge
even if the system is not diagonally dominant.
EXERCISE 5.1
Solve the following boundary value problems using the finite difference method and central
difference approximations.
1. y = xy, y(0) = 0, y(1) = 1 with h = 0.25.
2. y = y + 1, y(0) = 0, y(1) = e 1 with h = 1/3. If the exact solution is y(x) = e
x
1, find the
absolute errors at the nodal points.
3. y = (y + 1)/4, y(0) = 0, y(1) = e 1 with h = 1/4.
4. y = y + 1, y(0) = 1, y(1) = 2(e 1) with h = 1/3. If the exact solution is y(x) = 2e
x
x 1,
find the absolute errors at the nodal points.
5. y
y = 4xe
x
, y(0) = 0, y(1) = 1 with h = 0.25.
6. y = 2x
2
y + x
1
, y(2) = 0, y(3) = 0 with h = 1/3.
7. y + 3y + 2y = 1, y(0) = 1, y(1) = 0 with h = 1/3.
8. y 3y + 2y = 0, y(1) = 2, y(2) = 0 with h = 1/4.
9. x
2
y = 2y x, y(2) = 0, y(3) = 0 with h = 1/3.
10. Solve the boundary value problem y 10y = 0, y(0) = 0, y(1) = 1 with h = 0.25, by using
central difference approximation to y and (i) central difference approximation to y, (ii)
backward difference approximation to y, (iii) forward difference approximation to y. If
the exact solution is y(x) = (e
10x
1)/(e
10
1), compare the magnitudes of errors at the
nodal points in the three methods.
5.3 CLA88FCATON OF LNEAR 8ECOND ORDER PARTAL DFFERENTAL
EOUATON8
In this and later sections, we shall study the numerical solution of some second order linear
partial differential equations. Most of the mathematical models of the physical systems give
rise to a system of linear or nonlinear partial differential equations. Since analytical methods
are not always available for solving these equations, we attempt to solve by numerical meth-
ods. The numerical methods can broadly be classified as finite element methods and finite
difference methods. We shall be considering only the finite difference methods for solving
some of these equations.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 251
First, we classify the linear second order partial differential equation
Au
xx
+ 2Bu
xy
+ Cu
yy
+ Du
x
+ Eu
y
+ Fu
+ G = 0 (5.17)
where A, B, C, D, E, F and G are functions of x, y or are real constants.
The partial differential equation is called a
Elliptic equation if B
2
AC < 0 (5.18 i)
Parabolic equation if B
2
AC = 0 (5.18 ii)
Hyperbolic equation if B
2
AC > 0 . (5.18 iii)
Remark 3 Some books write the coefficient of
xy
u
in Eq.(5.17) as B. Then, the condition in
Eq.(5.18) changes to B
2
4AC. Note that the lower order terms do not contribute to the classi-
fication of the partial differential equation.
The simplest examples of the above equations are the following:
Parabolic equation: u
t
= c
2
u
xx
, (One dimensional heat equation). (5.19)
Hyperbolic equation: u
tt
= c
2
u
xx
, (One dimensional wave equation). (5.20)
Elliptic equation: u
xx
+ u
yy
= 0, (Two dimensional Laplace equation). (5.21)
We can verify that
in Eq.(5.19), A = c
2
, B = 0, C = 0 and B
2
AC = 0.
in Eq.(5.20), A = c
2
, B = 0, C = 1 and B
2
AC = c
2
> 0.
in Eq.(5.21), A = 1, B = 0, C = 1 and B
2
AC = 1 < 0.
Remark 4 What is the importance of classification? Classification governs the number and
type of conditions that should be prescribed in order that the problem has a unique solution.
For example, for the solution of the one dimensional heat equation (Eq.(5.19)), we require an
initial condition to be prescribed, u(x, 0) = f(x), and the conditions along the boundary lines x
= 0, and x = l, where l is the length of the rod (boundary conditions), are to be prescribed.
Suppose that the one dimensional wave equation (Eq.(5.20)) represents the vibrations
of an elastic string of length l. Here, u(x, t) represents the displacement of the string in the
vertical plane. For the solution of this equation, we require two initial conditions to be pre-
scribed, the initial displacement u(x, 0) = f(x), the initial velocity u
t
(x, 0) = g(x), and the
conditions along the boundary lines x = 0 and x = l, (boundary conditions), are to be prescribed.
For the solution of the Laplaces equation (Eq.(5.21)), we require the boundary condi-
tions to be prescribed on the bounding curve.
Remark 5 Elliptic equation together with the boundary conditions is called an elliptic boundary
value problem. The boundary value problem holds in a closed domain or in an open domain
which can be conformally mapped on to a closed domain. For example, Laplaces equation
(Eq.(5.21)) may be solved inside, say, a rectangle, a square or a circle etc. Both the hyperbolic
and parabolic equations together with their initial and boundary conditions are called initial
value problems. Sometimes, they are also called initial-boundary value problems. The initial
value problem holds in either an open or a semi-open domain. For example, in the case of the
one dimensional heat equation (Eq.(5.19)), x varies from 0 to l and t > 0. In the case of the one
dimensional wave equation (Eq.(5.20)), x varies from 0 to l and t > 0.
252 NUMERICAL METHODS
Example 5.7 Classify the following partial differential equations.
(a) u
xx
= 6u
x
+ 3u
y
. (b) 2u
xx
+ 3u
yy
u
x
+ 2u
y
= 0.
(c) u
tt
+ 4u
tx
+ 4u
xx
+ 2u
x
+ u
t
= 0. (d) u
xx
+ 2xu
xy
+ (1 y
2
)u
yy
= 0.
Solution
(a) Write the given equation as u
xx
6u
x
3u
y
= 0. We have A = 1, B = 0, C = 0 and
B
2
AC = 0. Hence, the given partial differential equation is a parabolic equation.
(b) We have A = 2, B = 0, C = 3 and B
2
AC = 6 < 0.Hence, the given partial differential
equation is an elliptic equation.
(c) We have A = 1, B = 2, C = 4 and B
2
AC = 0. Hence, the given partial differential
equation is a parabolic equation.
(d) We have A = 1, B = x, C = 1 y
2
and B
2
AC = x
2
(1 y
2
) = x
2
+ y
2
1. Hence, if
x
2
+ y
2
1 > 0, that is, outside the unit circle
x
2
+ y
2
= 1, the given partial differential equa-
tion is an hyperbolic equation. If x
2
+ y
2
1
= 0, that is, on the unit circle x
2
+ y
2
= 1, the
given partial differential equation is a para-
bolic equation. If x
2
+ y
2
1 < 0,that is, inside
the unit circle x
2
+ y
2
= 1, the given partial
differential equation is an elliptic equation
(see Fig. 5.2).
EXERCISE 5.2
Classify the following partial differential equations.
1. u
xx
+ 4u
yy
= u
x
+ 2u
y
= 0. 2. u
xx
u
yy
+ 3u
x
+ 4u
y
= 0.
3. u
xx
+ 4xu
xy
+ (1 4y
2
)u
yy
= 0. 4. u
tt
+ (5 + 2x
2
)u
xt
+ (1 + x
2
)(4 + x
2
)u
xx
= 0.
5. u
xx
+ 4u
xy
+ (x
2
+ 4y
2
)u
yy
= x
2
+ y
2
.
5.4 FNTE DFFERENCE METHOD8 FOR LAPLACE AND PO88ON EOUATON8
In this section, we consider the solution of the following boundary value problems governed by
the given partial differential equations along with suitable boundary conditions.
(a) Laplaces equation: u
xx
+ u
yy
=
2
u = 0, with u(x, y) prescribed on the boundary, that
is, u(x, y) = f(x, y) on the boundary.
(b) Poissons equation: u
xx
+ u
yy
=
2
u = G(x, y), with u(x, y) prescribed on the boundary,
that is, u(x, y) = g(x, y) on the boundary.
In both the problems, the boundary conditions are called Dirichlet boundary conditions
and the boundary value problem is called a Dirichlet boundary value problem.
Finite difference method We have a two dimensional domain (x, y) R. We superimpose on
this domain R, a rectangular network or mesh of lines with step lengths h and k respectively,
Fig. 5.2. Example 5.7.
Parabolic
Hyperbolic
x + y = 1
2 2
Elliptic
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 253
parallel to the x- and y-axis. The mesh of lines is called a grid. The points of intersection of the
mesh lines are called nodes or grid points or mesh points. The grid points are given by (x
i
, y
j
),
(see Figs. 5.3 a, b), where the mesh lines are defined by
x
i
= ih, i = 0, 1, 2, ...; y
j
= jk, j = 0, 1, 2, ...
If h = k, then we have a uniform mesh. Denote the numerical solution at (x
i
, y
j
) by u
i, j
.
y
O x
x O
y
Fig. 5.3a. Nodes in a rectangle. Fig. 5.3b. Nodes in a square.
At the nodes, the partial derivatives in the differential equation are replaced by suit-
able difference approximations. That is, the partial differential equation is approximated by a
difference equation at each nodal point. This procedure is called discretization of the partial
differential equation. We use the following central difference approximations.
(u
x
)
i, j
=
1
2h
(u
i+1, j
u
i1, j
), (u
y
)
i, j
=
1
2k
(u
i
,
j+1
u
i, j1
),
(u
xx
)
i, j
=
1
2
h
(u
i+1, j
2u
i, j
+ u
i1, j
), (u
yy
)
i, j
=
1
2
k
(u
i
,
j+1
2u
i, j
+ u
i
,
j1
).
Solution of Laplaces equation We apply the Laplaces equation at the nodal point (i, j).
Inserting the above approximations in the Laplaces equation, we obtain
(u
xx
)
i, j
+ (u
yy
)
i, j
=
1
2
h
(u
i+1, j
2u
i, j
+ u
i1, j
) +
1
2
k
(u
i
,
j+1
2u
i, j
+ u
i,
j1
) = 0 (5.22)
or (u
i+1, j
2u
i, j
+ u
i1, j
) + p
2
(u
i, j+1
2u
i, j
+ u
i, j1
) = 0, where p = h/k. (5.23)
If h = k, that is, p = 1 (called uniform mesh spacing), we obtain the difference approximation as
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0 (5.24)
This approximation is called the standard five point formula. We can write this formula as
u
i, j
=
1
4
(u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
). (5.25)
We observe that u
i, j
is obtained as the mean of the values at the four neighbouring
points in the x and y directions.
The nodal points that are used in computations are given in Fig.5.4.
Remark 6 The nodes in the mesh are numbered in an orderly way. We number them from left
to right and from top to bottom or from bottom to top. A typical numbering is given in Figs.5.5a,
5.5b.
254 NUMERICAL METHODS
i + 1, j
i, j 1
i, j + 1
i, j
i 1, j
Fig. 5.4. Standard five point formula.
u
1
u
2
u
3
u
4
u
5
u
6
u
7
u
8
u
9
u
7
u
8
u
9
u
4
u
5
u
6
u
1
u
2
u
3
Fig. 5.5a. Numbering of nodes. Fig. 5.5b. Numbering of nodes.
System of equations governing the solutions The difference approximation (5.23) or (5.24),
to the Laplace equation u
xx
+ u
yy
=
2
u = 0 is applied at all the nodes and the boundary
conditions are used to simplify the equations. The resulting system is a linear system of alge-
braic equations Au = d.
Structure of the coefficient matrix Let us write the system of equations that arise when
we have nine nodes as given in Fig.5a. Since the boundary values are known, we have the
following system of equations.
At 1: u
2
+ u
4
4u
1
= b
1
, or 4u
1
+ u
2
+ u
4
= b
1
,
At 2: u
1
+ u
5
+ u
3
4u
2
= b
2
, or u
1
4u
2
+ u
3
+ u
5
= b
2
,
At 3: u
2
+ u
6
4u
3
= b
3
, or u
2
4u
3
+ u
6
= b
3
,
At 4: u
1
+ u
7
+ u
5
4u
4
= b
4
, or u
1
4u
4
+ u
5
+ u
7
= b
4
,
At 5: u
2
+ u
4
+ u
8
+ u
6
4u
5
= 0, or u
2
+ u
4
4u
5
+ u
6
+ u
8
= 0,
At 6: u
3
+ u
5
+ u
9
4u
6
= b
6
, or u
3
+ u
5
4u
6
+ u
9
= b
6
,
At 7: u
4
+ u
8
4u
7
= b
7
, or u
4
4u
7
+ u
8
= b
7
,
At 8: u
5
+ u
7
+ u
9
4u
8
= b
8
, or u
5
+ u
7
4u
8
+ u
9
= b
8
,
At 9: u
6
+ u
8
4u
9
= b
9
.
where b
1
, b
2
, b
3
, b
4
, b
6
, b
7
, b
8
, b
9
are the contributions from the boundary values.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 255
We have the following linear algebraic system of equations,
4 1 0 1 0 0 0 0 0
1 4 1 0 1 0 0 0 0
0 1 4 0 0 1 0 0 0
1 0 0 4 1 0 1 0 0
0 1 0 1 4 1 0 1 0
0 0 1 0 1 4 0 0 1
0 0 0 1 0 0 4 1 0
0 0 0 0 1 0 1 4 1
0 0 0 0 0 1 0 1 4
0
1
2
3
4
5
6
7
8
9
1
2
3
4
6
7
8
9
u
u
u
u
u
u
u
u
u
b
b
b
b
b
b
b
b
2 2
2
3 3
3
4 4
4
2 6 24
2 ...
+ u h
u
x
h u
x
h u
x
h u
x
+ +
2 2
2
3 3
3
4 4
4
2 6 24
...
+
u h
u
y
h u
y
h u
y
h u
y
u + + + + +
2 2
2
3 3
3
4 4
4
2 6 24
2 ...
+
u h
u
y
h u
y
h u
y
h u
y
i j
+ +
2 2
2
3 3
3
4 4
4
2 6 24
...
,
256 NUMERICAL METHODS
= h
u
x
u
y
h u
x
u
y
h u
x
u
y
i j i j
2
2
2
2
2
4 4
4
4
4
4 4
4
4
4
12 12
+ +
= +
...
, ,
+ ...
since,
2
2
2
2
u
x
u
y
+ = 0.
The truncation error of the method (5.23) when h = k, is given by
T.E = (u
i+1, j
2u
i, j
+ u
i1, j
) + (u
i, j+1
2u
i, j
+ u
i, j1
)
=
h u
x
u
y
i j
4 4
4
4
4
12
,
+ ...
using the above derivation. Hence, the truncation error of the method is of order O(h
4
).
The order of the formula (5.23) is defined as
Order =
1
2
h
(T.E) = O(h
2
).
We say that the method is of second order.
What is the importance of the order of the finite difference formulas? When a method con-
verges, it implies that the errors in the numerical solutions 0 as h 0. Suppose that a
method is of order O(h
2
). Then, if we reduce the step length h by a factor, say 2, and re-
compute the numerical solution using the step length h/2, then the error becomes O[(h/2)
2
] =
[O(h
2
)]]/4. Therefore, the errors in the numerical solutions are reduced by a factor of 4. This
can easily be checked at the common points between the two meshes.
Another five point formula The standard five point formula (5.23) or (5.24) at (i, j) uses the
four neighbours, (i + 1, j), (i 1, j), (i, j + 1), (i, j 1), on the x and y axis. We can obtain another
five point formula by using the four neighbours on the diagonals, (i + 1, j + 1), (i 1,
j + 1), (i + 1, j 1), (i 1, j 1). The five point formula for solving the Laplaces equation is
given by
(u
xx
)
i, j
+ (u
yy
)
i, j
=
1
2
2
h
(u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
4u
i, j
) = 0 (5.26)
or u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
4u
i, j
= 0 (5.27)
or u
i, j
=
1
4
(u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
). (5.28)
Note the factor 2 in the denominator of (5.26). This formula is called the diagonal five
point formula. The nodal points are given in Fig.5.6. Using the Taylor series expansions as in
Remark 8, we obtain the error or truncation error (T.E) in the formula as
T.E =
h u
x
u
x y
u
y
i j
4 4
4
4
2 2
4
4
6
6
+ +
,
+ ...
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 257
The order of the formula is given by
Order =
1
2
h
(T.E) = O(h
2
).
Therefore, the orders of the standard and the diagonal five point formulas are the same.
Solution of the system of equations The solution of the system of equations can be ob-
tained by direct or iterative methods. For the purpose of our study, we shall consider the
solution of the system of equations Au = d by Gauss elimination (a direct method) and an
iterative method called Liebmann iteration, which is the application of Gauss-Seidel iterative
method to the present system. When the order of the system of equations is not large, say
about 50 equations, we use the direct methods. Di-
rect methods require the loading of all the elements
of the coefficient matrix and the right hand side
vector into the memory of the computer, which may
not be possible if the system is large. When the or-
der of the system is large, which is the case in most
practical problems, we use the iterative methods.
In fact, in many problems, we encounter thousands
of equations. Iterative methods do not require the
loading of all the elements of the coefficient matrix
and the right hand side vector. Information of few
equations only can be loaded at a time.
Solution of Poisson equation Consider the solution of the Poissons equation
u
xx
+ u
yy
=
2
u = G(x, y),
with u(x, y) prescribed on the boundary, that is, u(x, y) = g(x, y) on the boundary.
Eqs. (5.23)-(5.25) become
(u
xx
)
i, j
+ (u
yy
)
i, j
=
1
2
h
(u
i+1, j
2u
i, j
+ u
i1, j
) +
1
2
k
(u
i, j+1
2u
i, j
+ u
i, j1
) = G
i, j
(5.29)
or (u
i+1, j
2u
i, j
+ u
i1, j
) + p
2
(u
i, j+1
2u
i, j
+ u
i, j1
) = h
2
G
i, j
, (5.30)
where G
i, j
= G(x
i
, y
j
) and p = h/k.
If h = k, that is, p = 1, we obtain the difference approximation as
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= h
2
G
i, j
. (5.31a)
This approximation is called the standard five point formula for Poissons equation.
The formula (5.30) is of order O(h
2
+ k
2
) and formula (5.31a) is of order O(h
2
). We also call it a
second order formula.
When h = k, the diagonal five point formula for solving the Poissons equation can be
written as
u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
4u
i, j
= 2h
2
G
i, j
. (5.31b)
We shall illustrate the application of the finite difference method through the following
examples.
i + 1, j 1
i + 1, j + 1
i 1, j + 1
i 1, j 1
i, j
Fig. 5.6. Diagonal five point formula.
258 NUMERICAL METHODS
Example 5.8 Solve u
xx
+ u
yy
= 0 numerically for the following
mesh with uniform spacing and with boundary conditions as
shown below in the figure 5.7.
Solution We note that the partial differential equation and
the boundary conditions are symmetric about the diagonals
AC and BD. Hence, u
1
= u
4
and u
2
= u
3
. Therefore, we need to
solve for two unknowns u
1
and u
2
. We use the standard five
point formula
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0.
We obtain the following difference equations.
At 1: u
2
+ 3 + 3 + u
3
4u
1
= 0,
or 4u
1
+ 2u
2
= 6, or 2u
1
+ u
2
= 3.
At 2: 6 + 6 + u
1
+ u
4
4u
2
= 0, or 2u
1
4u
2
= 12.
Adding the two equations, we get 3u
2
= 15, or u
2
= 5.
From the first equation, we get 2u
1
= u
2
+ 3 = 5 + 3 = 8, or u
1
= 4.
Example 5.9 Solve u
xx
+ u
yy
= 0 numerically for the following
mesh with uniform spacing and with boundary conditions
as shown below in the figure 5.8.
Solution We note that the partial differential equation and
the boundary conditions are symmetric about the diagonal
BD. Hence, u
2
= u
3
and we need to determine . and ,
4 2 1
u u u
We use the standard five point formula
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0.
We obtain the following difference equations.
At1: u
2
+ 2 + 2 + u
3
4u
1
= 0, or 4u
1
+ 2u
2
= 4, or 2u
1
+ u
2
= 2.
At 2 6 + 4 + u
1
+ u
4
4u
2
= 0, or u
1
4u
2
+ u
4
= 10.
At 4: 8 + u
2
+ u
3
+ 8 4u
4
= 0, or 2u
2
4u
4
= 16, or u
2
2u
4
= 8.
We solve the system of equations using the Gauss elimination method. We use the
augmented matrix [A|d].
2 1 0 2
1 4 1 10
0 1 2 8
2
1 12 0 1
1 4 1 10
0 1 2 8
1 12 0 1
0 72 1 11
0 1 2 8
1
2 1
; ,
/
; ,
/
/
R
R R
;
R
R R
2
3 2
72
1 0 1
0 1 2 7 22 7
0 1 2 8
1 1 2 0 1
0 1 2 7 22 7
0 0 12 7 78 7
( / )
, / / ; ,
/
/ /
/ /
1/ 2
.
D
3
3
C
6
A
6
6
3
B
3 6
u
1
u
2
u
3
u
4
Fig. 5.7. Example 5.8.
D
2
2
C
4
A
4
6
8
B
8 6
u
1
u
2
u
3
u
4
Fig. 5.8. Example 5.9.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 259
Solving the last equation, we get u
4
=
78
12
65 = . .
Substituting in the second equation, we get u
2
=
22
7
13
7
35
7
5 + = = .
Substituting in the first equation, we get u
1
= 1 +
5
2
35 = . .
Example 5.10 Solve u
xx
+ u
yy
= 0 numerically for the following
mesh with uniform spacing and with boundary conditions as
shown below in the figure 5.9.
Solution We note that the boundary conditions have no sym-
metry. Therefore, we need to find the values of the four un-
knowns . and , ,
4 3 2 1
u u u u We use the standard five point for-
mula
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0.
We obtain the following difference equations.
At1: u
2
+ 2 + 0 + u
3
4u
1
= 0, or 4u
1
+ u
2
+ u
3
= 2.
At 2 1 + 3 + u
1
+ u
4
4u
2
= 0, or u
1
4u
2
+ u
4
= 4.
At 3: u
4
+ u
1
+ 0 + 0 4u
3
= 0, or u
1
4u
3
+ u
4
= 0.
At 4: 2 + u
2
+ u
3
+ 0 4u
4
= 0, or u
2
+ u
3
4u
4
= 2.
We solve the system of equations using the Gauss elimination method. We use the
augmented matrix [A|d].
4 1 1 0 2
1 4 0 1 4
1 0 4 1 0
0 1 1 4 2
4
1 14 1 4 0 12
1 4 0 1 4
1 0 4 1 0
0 1 1 4 2
1
2 1 3 1
; ,
/ / /
; , ,
R
R R R R
1 1 4 1 4 0 12
0 15 4 1 4 1 9 2
0 1 4 15 4 1 12
0 1 1 4 2
15
4
1 1 4 1 4 0 12
0 1 1 15 4 15 18 15
0 1 4 15 4 1 12
0 1 1 4 2
1
4
2
3 2
4 2
/ / /
/ / /
/ / /
; ;
/ / /
/ / /
/ / /
,
,
R
R R
R R
1 14 14 0 12
0 1 115 4 15 18 15
0 0 56 15 16 15 4 5
0 0 16 15 56 15 48 15
56 15
1 14 14 0 12
0 1 115 4 15 18 15
0 0 1 16 56 12 56
0 0 16 15 56 15 48 15
3
/ / /
/ / /
/ / /
/ / /
( / )
,
/ / /
/ / /
/ /
/ / /
R
;
0
2
0
3
1
2
0 0
u
1
u
2
u
3
u
4
Fig. 5.9. Example 5.10.
260 NUMERICAL METHODS
R
4
16
15
R
3
,
1 14 14 0 12
0 1 115 415 1815
0 0 1 1656 1256
0 0 0 2880 840 2880 840
/ / /
/ / /
/ /
/ /
.
Last equation gives u
4
= 1.
Substituting in the third equation, we get u
3
=
12
56
16
56
28
56
05 + = = . .
Substituting in the second equation, we get u
2
=
18
15
1
30
4
15
45
30
+ + = = 1.5.
Substituting in the first equation, we get u
1
=
1
2
3
8
1
8
1 + + = .
Example 5.11 Solve u
xx
+ u
yy
= 0 numerically under the bound-
ary conditions
u(x, 0) = 2x, u(0, y) = y,
u(x, 1) = 2x 1, u(1, y) = 2 y
with square mesh of width h = 1/3.
Solution The mesh is given in Fig.5.10. We need to find the
values of the four unknowns u
1
, u
2
, u
3
and u
4
. We use the
standard five point formula
u
i+1, j
+ u
i1, j
+ u
i, j +1
+ u
i, j1
4u
i, j
= 0.
Using the boundary conditions, we get the boundary values as
u
5
= u
1
3
1
2
3
1
1
3
2
3
1
4
3
1
1
3
0
2
3
2
3
6 7
, , , , ,
= = =
= = =
= u u u u
u
8
= u
1
2
3
2
2
3
4
3
0
1
3
1
3
1
1
3
2
1
3
5
3
9 10
, , , , ,
= = =
= =
= = u u u u
,
u
11
= u
1
3
0
2
3
2
3
0
4
3
12
, , ,
= =
= u u .
We obtain the following difference equations.
At1: u
2
+ u
5
+ u
7
+ u
3
4u
1
= 0, or 4u
1
+ u
2
+ u
3
= 1.
At 2: u
8
+ u
6
+ u
1
+ u
4
4u
2
= 0, or u
1
4u
2
+ u
4
= 5/3.
At 3: u
4
+ u
1
+ u
9
+ u
11
4u
3
= 0, or u
1
4u
3
+ u
4
= 1/3.
At 4: u
10
+u
2
+ u
3
+ u
12
4u
4
= 0, or u
2
+ u
3
4u
4
= 3.
u
1
u
2
u
3
u
4
u
5
u
6
u
8
u
10
u
7
u
9
u
11
u
12
Fig. 5.10. Example 5.11.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 261
We solve the system of equations using the Gauss elimination method. We use the
augmented matrix [A|d].
4 1 1 0 1
1 4 0 1 5 3
1 0 4 1 13
0 1 1 4 3
4
1 0 25 0 25 0 0 25
1 4 0 1 5 3
1 0 4 1 13
0 1 1 4 3
1
2 1 3 1
/
/
; ,
. . .
/
/
; , ,
R
R R R R
1 0 25 0 25 0 0 25
0 375 0 25 1 141667
0 0 25 375 1 0 08333
0 1 1 4 3
375
2
. . .
. . .
. . .
;
.
R
1 025 025 0 025
0 1 006667 026667 037778
0 025 375 1 008333
0 1 1 4 3
. . .
. . .
. . . ;
R R
R R
R
3 2
4 2
3
0 25
1 0 25 0 25 0 0 25
0 1 0 06667 0 26667 0 37778
0 0 373333 106667 0 17778
0 0 106667 373333 3377778
373333
. ,
,
. . .
. . .
. . .
. . .
;
.
,
1 0 25 0 25 0 0 25
0 1 0 06667 0 26667 0 37778
0 0 1 0 28572 0 04762
0 0 106667 373333 3 37778
. . .
. . .
. .
. . .
; R
4
1.06667 R
3
,
1 025 025 0 025
0 1 006667 026667 037778
0 0 1 028572 004762
0 0 0 342856 342857
. . .
. . .
. .
. .
.
Last equation gives u
4
= 1.
Substituting in the third equation, we get u
3
= 0.04762 + 0.28572 = 0.33334.
Substituting in the second equation, we get
u
2
= 0.37778 + 0.06667 (0.33334) + 0.26667 = 0.66667.
Substituting in the first equation, we get u
1
= 0.25 + 0.25(0.66667 + 0.33334) = 0.
Example 5.12 Solve the boundary value problem for the Poisson equation
u
xx
+ u
yy
= x
2
1, | x | 1, | y | 1,
u = 0 on the boundary of the square
using the five point formula with square mesh of width h = 1/2.
262 NUMERICAL METHODS
Solution The mesh is given in Fig.5.11. The partial differential equation and the boundary
conditions are symmetric about x-and y-axis. We need to find the values of the four unknowns
u
1
, u
2
, u
3
and u
4
. We use the standard five point formula
0 0 0 0 0
0
0
0
0
0 0 0
0
0
x
y
u
4
u
3
u
4
u
2
u
1
u
2
u
4
u
3
u
4
0
Fig. 5.11. Example 5.12.
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= h
2
G
i, j
= 0.25(x
i
2
1).
We obtain the following difference equations.
At 1(0, 0): u
2
+ u
3
+ u
2
+ u
3
4u
1
= 0.25,
or 2u
1
+ u
2
+ u
3
= 0.125.
At 2(0.5, 0): 0 + u
4
+ u
1
+ u
4
4u
2
= 0.25(0.25 1) = 0.1875,
or u
1
4u
2
+ 2u
4
= 0.1875.
At 3(0, 0.5): u
4
+ 0 + u
4
+ u
1
4u
3
= 0.25(0 1) = 0.25,
or u
1
4u
3
+ 2u
4
= 0.25.
At 4(0.5, 0.5): 0 + 0 + u
3
+ u
2
4u
4
= 0.25(0.25 1) = 0.1875,
or u
2
+ u
3
4u
4
= 0.1875.
We solve the system of equations using the Gauss elimination method. We use the
augmented matrix [A|d].
2 1 1 0 0 125
1 4 0 2 0 1875
1 0 4 2 0 25
0 1 1 4 0 1875
2
1 0 5 0 5 0 0 0625
1 4 0 2 0 1875
1 0 4 2 0 25
0 1 1 4 0 1875
1
.
.
.
.
; ,
. . .
.
.
.
R
; R
2
R
1
, R
3
R
1
,
1 05 05 0 00625
0 35 05 2 025
0 05 35 2 03125
0 1 1 4 01875
35
1 05 05 0 00625
0 1 014286 057143 007143
0 05 35 2 03125
0 1 1 4 01875
2
. . .
. . .
. . .
.
;
.
,
. . .
. . .
. . .
.
R
;
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 263
R R
R R
R
3 2
4 2
3
0 5
1 0 5 0 5 0 0 0625
0 1 0 14286 0 57143 0 07143
0 0 3 42857 2 28572 0 34822
0 0 114286 3 42857 0 25893
3 42857
. ,
,
. . .
. . .
. . .
. . .
;
.
,
1 05 05 0 00625
0 1 014286 057143 007143
0 0 1 066667 010156
0 0 114286 342857 025893
. . .
. . .
. .
. . .
; R
4
1.14286 R
3
,
1 0 5 0 5 0 0 0625
0 1 0 14286 0 57143 0 07143
0 0 1 0 66667 0 10156
0 0 0 2 66667 0 37500
. . .
. . .
. .
. .
.
Last equation gives u
4
=
0 37500
2 66667
.
.
= 0.14062.
Substituting in the third equation, we get u
3
= 0.10156 + 0.66667(0.14062) = 0.19531.
Substituting in the second equation, we get
u
2
= 0.07143 + 0.14286(0.19531) + 0.57143(0.14062) = 0.17969.
Substituting in the first equation, we get u
1
= 0.5(0.17969 + 0.19531) + 0.0625 = 0.25.
Iterative methods We mentioned earlier that when the order of the system of equations is
large, which is the case in most practical problems, we use iterative methods. In fact, in many
practical applications, we encounter thousands of equations. There are many powerful itera-
tive methods available in the computer software, which are variants of successive over relaxa-
tion (SOR) method, conjugate gradient method etc. However, we shall discuss here, the imple-
mentation of the Gauss-Seidel method for the solution of the system of equations obtained in
the application of the finite difference methods. Let us recall the properties of the Gauss-
Seidel method.
(a) A sufficient condition for convergence is that the coefficient matrix A, of the system
of equations is diagonally dominant.
(b) The method requires an initial approximation to the solution vector u. If no suitable
approximation is available, then u = 0 can be taken as the initial approximation.
(c) Using the initial approximations, we update the value of the first unknown u
1
. Using
this updated value of u
1
and the initial approximations to the remaining variables,
we update the value of u
2
. We continue until all the values are updated. We repeat
the procedure until the required accuracy is obtained.
Liebmann iteration We use the above procedure to compute the solution of the difference
equations for the Laplaces equation or the Poisson equation.
The initial approximations are obtained by judiciously using the standard five point
formula (5.25)
264 NUMERICAL METHODS
u
i, j
=
1
4
(u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
)
or the diagonal five point formula (5.28)
u
i, j
=
1
4
(u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
)
after setting the values of one or two variables as zero.
If in some problems, these two formulas cannot be used (see Example 5.14), then we set the
values of required number of variables as zero.
For the mesh defined in Fig. 5.12, we write the following Liebmann iteration
u u u u u
i j
k
i j
k
i j
k
i j
k
i j
k
,
( )
,
( )
,
( )
,
( )
,
( ) +
+
+ +
= + + +
1
1
1
1
1
1 1
1
4
, , (5.32)
where the values at the nodes (i, j 1), (i 1, j) are al-
ready updated (when the numbering of unknowns is from
bottom to top). If the numbering is from top to bottom,
then the iteration becomes
u u u u u
i j
k
i j
k
i j
k
i j
k
i j
k
,
( )
,
( )
,
( )
,
( )
,
( ) +
+
+
+
+
= + + +
1
1
1
1
1
1 1
1
4
, , .
Stopping criteria for iteration
We stop the iterations when the following criterion
is satisfied
|
u u
i
k
i
k ( ) ( ) +
1
| given error tolerance for all i.
For example, if we want two decimal places accuracy for the solution, then we iterate until
the condition
|
u u
i
k
i
k ( ) ( ) +
1
| 0.005 for all i (5.33)
is satisfied.
Similarly, if we want three decimal places accuracy for the solution, then we iterate until
the condition
|u u
i
k
i
k ( ) ( ) +
1
| 0.0005 for all i (5.34)
is satisfied.
We illustrate the method through the following problems.
Example 5.13 Solve u
xx
+ u
yy
= 0 numerically, using five point formula and Liebmann iteration,
for the following mesh with uniform spacing and with boundary conditions as shown below in
the figure 5.13. Obtain the results correct to two decimal places.
Solution We note that the boundary conditions have no symmetry. Therefore, we need to find
the values of the four unknowns u
1
, u
2
, u
3
and u
4
. We use the standard five point formula
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0.
i, j 1
i + 1, j
i, j + 1
i 1, j
i, j
Fig. 5.12. Standard five point formula.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 265
We obtain the following difference equations.
At1: u
2
+ 2 + 2 + u
3
4u
1
= 0, or 4u
1
+ u
2
+ u
3
= 4.
At 2 1 + 3 + u
1
+ u
4
4u
2
= 0, or u
1
4u
2
+ u
4
= 4.
At 3: u
4
+ u
1
+ 3 + 0 4u
3
= 0, or u
1
4u
3
+ u
4
= 3.
At 4: 2 + u
2
+ u
3
+ 0 4u
4
= 0, or u
2
+ u
3
4u
4
= 2.
Using these equations, we write the difference equations at
the grid points as
u
1
= 0.25(4 + u
2
+ u
3
),
u
2
= 0.25(4 + u
1
+ u
4
),
u
3
= 0.25(3 + u
1
+ u
4
),
u
4
= 0.25(2 + u
2
+ u
3
),
and write the iteration procedure as
u u u
k k k
1
1
2 3
0 25 4
( ) ( ) ( )
. ( )
+
= + + ,
u u u
k k k
2
1
1
1
4
0 25 4
( ) ( ) ( )
. ( )
+ +
= + + ,
u u u
k k k
3
1
1
1
4
0 25 3
( ) ( ) ( )
. ( )
+ +
= + + ,
u u u
k k k
4
1
2
1
3
1
0 25 2
( ) ( ) ( )
. ( )
+ + +
= + + .
Initial approximations
Set u
4
= u
4
0 ( )
= 0. Using the diagonal five point formula at the first node, we obtain
u
1
0 ( )
= 0.25(u
4
+ 3 + 2 + 3) = 0.25(0 + 3 + 2 + 3) = 2.
Now, we can use the standard five point formula to obtain initial approximations at the
nodes 2, 3, 4. We obtain
u u u
2
0
1
0
4
0
0 25 1 3
( ) ( ) ( )
. ( ) = + + +
= 0.25(1 + 3 + 2 + 0) = 1.5.
u u u
3
0
4
0
1
0
0 25 3 0
( ) ( ) ( )
. ( ) = + + +
= 0.25(0 + 2 + 3 + 0) = 1.25.
u u u
4
0
2
0
3
0
0 25 2 0
( ) ( ) ( )
. ( ) = + + +
= 0.25(2 + 1.5 + 1.25 + 0) = 1.1875.
First iteration
u u u
1
1
2
0
3
0
0 25 4
( ) ( ) ( )
. ( ) = + +
= 0.25(4 + 1.5 + 1.25) = 1.6875,
u u u
2
1
1
1
4
0
0 25 4
( ) ( ) ( )
. ( ) = + +
= 0.25(4 + 1.6875 + 1.1875) = 1.71875,
2
2
3
3
1
2
0 0
u
1
u
2
u
3
u
4
2
Fig. 5.13. Example 5.13.
266 NUMERICAL METHODS
u u u
3
1
1
1
4
0
0 25 3
( ) ( ) ( )
. ( ) = + + = 0.25(3 + 1.6875 + 1.1875) = 1.46875,
u u u
4
1
2
1
3
1
0 25 2
( ) ( ) ( )
. ( ) = + + = 0.25(2 + 1.71875 + 1.46875) = 1.29688.
Second iteration
u u u
1
2
2
1
3
1
0 25 4
( ) ( ) ( )
. ( ) = + + = 0.25(4 + 1.71875 + 1.46875) = 1.79688,
u u u
2
2
1
2
4
1
0 25 4
( ) ( ) ( )
. ( ) = + + = 0.25(4 + 1.79688 + 1.29688) = 1.77344,
u u u
3
2
1
2
4
1
0 25 3
( ) ( ) ( )
. ( ) = + + = 0.25 (3 + 1.79688 + 1.29688) = 1.52344,
u u u
4
2
2
2
3
2
0 25 2
( ) ( ) ( )
. ( ) = + + = 0.25(2 + 1.77344 + 1.52344) = 1.32422.
Third iteration
u u u
1
3)
2
2
3
2
0 25 4
( ( ) ( )
. ( ) = + +
= 0.25(4 + 1.77344 + 1.52344) = 1.82422,
u u u
2
3)
1
3)
4
2
0 25 4
( ( ( )
. ( ) = + +
= 0.25(4 + 1.82422 + 1.32422) = 1.78711,
u u u
3
3)
1
3)
4
2
0 25 3
( ( ( )
. ( ) = + +
= 0.25(3 + 1.82422 + 1.32422) = 1.53711,
u u u
4
3)
2
3)
3
3)
0 25 2
( ( (
. ( ) = + +
= 0.25(2 + 1.78711 + 1.53711) = 1.33106.
Fourth iteration
u u u
1
4
2
3)
3
3)
0 25 4
( ) ( (
. ( ) = + + = 0.25(4 + 1.78711 + 1.53711) = 1.83106,
u u u
2
4
1
4
4
3)
0 25 4
( ) ( ) (
. ( ) = + + = 0.25(4 + 1.83106 + 1.33106) = 1.79053,
u u u
3
4
1
4
4
3)
0 25 3
( ) ( ) (
. ( ) = + + = 0.25(3 + 1.83106 + 1.33106) = 1.54053,
u u u
4
4
2
4
3
4
0 25 2
( ) ( ) ( )
. ( ) = + + = 0.25(2 + 1.79053 + 1.54053) = 1.33277.
Fifth iteration
u u u
1
5
2
4
3
4
0 25 4
( ) ( ) ( )
. ( ) = + +
= 0.25(4 + 1.79053 + 1.54053) = 1.83277,
u u u
2
5
1
5
4
4
0 25 4
( ) ( ) ( )
. ( ) = + +
= 0.25(4 + 1.83277 + 1.33277) = 1.79139,
u u u
3
5
1
5
4
4
0 25 3
( ) ( ) ( )
. ( ) = + +
= 0.25(3 + 1.83277 + 1.33277) = 1.54139,
u u u
4
5
2
5
3
5
0 25 2
( ) ( ) ( )
. ( ) = + + = 0.25(2 + 1.79139 + 1.54139) = 1.33320.
At this stage, the magnitudes of the errors in the successive iterations are
| |
( ) ( )
u u
1
5
1
4
= | 1.83277 1.83106 | = 0.00171,
| |
( ) ( )
u u
2
5
2
4
= | 1.79139 1.79053 | = 0.00086,
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 267
| |
( ) ( )
u u
3
5
3
4
= | 1.54139 1.54053 | = 0.00086,
| |
( ) ( )
u u
4
5
4
4
= | 1.33320 1.33277 | = 0.00043.
All the errors are < 0.005. Hence, the fifth iteration values are correct to two decimal
places. We take these values as the required solutions.
Example 5.14 Solve the boundary value problem
u
xx
+ u
yy
= x + y + 1, 0 x 1, 0 y 1,
u = 0 on the boundary
numerically using five point formula and Liebmann iteration, with mesh length h = 1/3.
Obtain the results correct to three decimal places.
Solution The mesh is given in Fig.5.14. We note that all the boundary values are zero. There
is symmetry with respect the line y = x. Hence, u
1
= u
4
. Therefore, we need to find the values
of the three unknowns u
1
, u
2
and u
3
. We use the standard five point formula
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= h
2
G
i, j
=
1
9
(x
i
+ y
j
+ 1).
We obtain the following difference equations.
At 1: u
2
+ 0 + 0 + u
3
4u
1
=
1
9
1
3
2
3
1
2
9
+ +
,
= or 4u
1
+ u
2
+ u
3
=
2
9
.
At 2: 0 + 0 + u
1
+ u
4
4u
2
=
1
9
2
3
2
3
1
7
27
+ +
,
= or 2u
1
4u
2
=
7
27
.
At 3: u
4
+ u
1
+ 0 + 0 4u
3
=
1
9
1
3
1
3
1
5
27
+ +
,
=
or 2u
1
4u
3
=
5
27
.
Using these equations, we write the difference equations
at the grid points as
u
1
= 0.25(u
2
+ u
3
0.222222),
u
2
= 0.25(2u
1
0.259259),
u
3
= 0.25(2u
1
0.185185),
and write the iteration procedure as
u u u
k k k
1
1
2 3
0 25 0 222222
( ) ( ) ( )
. ( . )
+
= + ,
u u
k k
2
1
1
1
0 25 2 0 259259
( ) ( )
. ( . )
+ +
=
u u
k k
3
1
1
1
025 2 0185185
( ) ( )
. ( . ).
+ +
=
Fig. 5.14. Example 5.14.
0
0
0
0
0
0
0 0
u
1
u
2
u
3
u
4
268 NUMERICAL METHODS
Initial approximations Since the boundary values are all zero, we cannot use the standard or
diagonal five point formulas to obtain the initial approximations. Hence, as in Gauss-Seidel
method, we assume u u
2
0
3
0
0
( ) ( )
= = .
First iteration
u u u
1
1
2
0
3
0
0 25 0 222222
( ) ( ) ( )
. ( . ) = + = 0.05556,
u u
2
1
1
1
0 25 2 0 259259
( ) ( )
. ( . ) =
= 0.25( 0.111112 0.259259) = 0.092593,
u u
3
1
1
1
0 25 2 0 185185
( ) ( )
. ( . ) =
= 0.25( 0.111112 0.185185) = 0.074074.
Second iteration
u u u
1
2
2
1
3
1
0 25 0 222222
( ) ( ) ( )
. ( . ) = + = 0.25( 0.092593 0.074074 0.222222) = 0.097222
u u
2
2
1
2
0 25 2 0 259259
( ) ( )
. ( . ) =
= 0.25( 0.194444 0.259259) = 0.113426,
u u
3
2
1
2
0 25 2 0 185185
( ) ( )
. ( . ) =
= 0.25( 0.194444 0.185185) = 0.094907.
Third iteration
u u u
1
3)
2
2
3
2
0 25 0 222222
( ( ) ( )
. ( . ) = + = 0.25( 0.113426 0.09407 0.222222) = 0.107639,
u u
2
3)
1
3)
0 25 2 0 259259
( (
. ( . ) =
= 0.25( 0.215278 0.259259) = 0.118634,
u u
3
3)
1
3)
0 25 2 0 185185
( (
. ( . ) = = 0.25( 0.215278 0.185185) = 0.100116.
Fourth iteration
u u u
1
4
2
3)
3
3)
0 25 0 222222
( ) ( (
. ( . ) = +
= 0.25( 0.118634 0.100116 0.222222) = 0.110243,
u u
2
4
1
4
0 25 2 0 259259
( ) ( )
. ( . ) =
= 0.25( 0.220486 0.259259) = 0.119936,
u u
3
4
1
4
0 25 2 0 185185
( ) ( )
. ( . ) =
= 0.25(
0.220486
0.185185) = 0.101418.
Fifth iteration
u u u
1
5
2
4
3
4
0 25 0 222222
( ) ( ) ( )
. ( . ) = + = 0.25( 0.119936 0.101418 0.222222) = 0.110894,
u u
2
5
1
5
0 25 2 0 259259
( ) ( )
. ( . ) = = 0.25( 0.221788 0.259259) = 0.120262,
u u
3
5
1
5
0 25 2 0 185185
( ) ( )
. ( . ) = = 0.25( 0.221788 0.185185) = 0.101740.
Sixth iteration
u u u
1
6
2
5
3
5
0 25 0 222222
( ) ( ) ( )
. ( . ) = + = 0.25( 0.120262 0.101740 0.222222) = 0.111056,
u u
2
6
1
6
0 25 2 0 259259
( ) ( )
. ( . ) =
= 0.25( 0.222112 0.259259) = 0.120343,
u u
3
6
1
6
0 25 2 0 185185
( ) ( )
. ( . ) =
= 0.25( 0.222112 0.185185) = 0.101824.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 269
At this stage, the magnitudes of the errors in the successive iterations are
| |
( ) ( )
u u
1
6
1
5
= | 0.111056 + 0.110894 | = 0.000162,
| |
( ) ( )
u u
2
6
2
5
= | 0.120343 + 0.120262 | = 0.000081,
| |
( ) ( )
u u
3
6
3
5
= | 101824 + 0.101740 | = 0.000084.
All the errors are < 0.0005. Hence, the fifth iteration values are correct to three decimal
places. We take these values as the required solutions.
Example 5.15 Using the Liebmann method, solve the equation
u
xx
+ u
yy
= 0 for the following square mesh with boundary values
as shown in figure. Iterate until the maximum difference between
successive values at any point is less than 0.001.
Solution The mesh is given in Fig.5.15. Number the nodes as
. and , ,
4 3 2 1
u u u u The partial differential equation and the
boundary values are symmetric with respect to line BD. Hence,
u
2
= u
3
. We have three unknowns . and ,
4 2 1
u u u We use the
standard five point formula
u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0.
We obtain the following difference equations.
At 1: u
2
+ 1 + 1 + u
2
4u
1
= 0, or 2u
1
+ u
2
= 1.
At 2: 4 + 2 + u
1
+ u
4
4u
2
= 0, or u
1
4u
2
+ u
4
= 6.
At 4: 5 + u
2
+ u
2
+ 5 4u
4
= 0, or u
2
2u
4
= 5.
Using these equations, we write the difference equations at the grid points as
u
1
= 0.5(1 + u
2
), u
2
= 0.25(6 + u
1
+ u
4
), u
4
= 0.5(5 + u
2
).
and write the iteration procedure as
u u
k k
1
1
2
0 5 1
( ) ( )
. ( )
+
= + , u u u
k k k
2
1
1
1
4
0 25 6
( ) ( ) ( )
. ( )
+ +
= + + , u u
k k
4
1
2
1
0 5 5
( ) ( )
. ( )
+ +
= + .
Initial approximations
Since the value at the corner point D is not given, we need to use the standard five point
difference formula. Hence, we set u
2
= 0 and u
3
= 0. We have the following initial approxima-
tions.
u u
1
0
4
0
0 25 0 1 1 0 0 5 0 25 5 0 0 5 2 5
( ) ( )
. ( ) . , . ( ) . = + + + = = + + + = .
We can update u
2
also and take the initial approximation as
u u u
2
0
1
0
4
0
0 25 4 2 0 25 6 0 5 2 5 2 25
( ) ( ) ( )
. ( ) . ( . . ) . . = + + + = + + =
Otherwise, u
1
1 ( )
becomes same as u
1
0 ( )
.
1
1
2
2
4
5
5 4
u
1
u
2
u
3
u
4
D
A B
C
Fig. 5.15. Example 5.15.
270 NUMERICAL METHODS
First iteration
u u
1
1
2
0
0 5 1 0 5 1 2 25 1625
( ) ( )
. ( ) . ( . ) . . = + = + =
u u u
2
1
1
1
4
0
0 25 6
( ) ( ) ( )
. ( ) = + +
= 0.25(6 + 1.625 + 2.5) = 2.53125.
u u
4 2
05 5 05 5 253125 376563
(1) (1)
. ( ) . ( . ) . . = + = + =
Second iteration
u u
1
2
2
1
0 5 1 0 5 1 2 53125 176563
( ) ( )
. ( ) . ( . ) . . = + = + =
u u u
2
2
1
2
4
1
0 25 6
( ) ( ) ( )
. ( ) = + + = 0.25(6 + 1.76563 + 3.76563) = 2.88282.
u u
4
2
2
2
0 5 5 0 5 5 2 88282 3 94141
( ) ( )
. ( ) . ( . ) . . = + = + =
Third iteration
u u
1
3)
2
2
0 5 1 0 5 1 2 88282 194141
( ( )
. ( ) . ( . ) . . = + = + =
u u u
2
3)
1
3)
4
2
0 25 6
( ( ( )
. ( ) = + +
= 0.25(6 + 1.94141 + 3.94141) = 2.97070.
u u
4
3)
2
3)
0 5 5 0 5 5 2 97070 3 98535
( (
. ( ) . ( . ) . = + = + =
Fourth iteration
u u
1
4
2
3)
0 5 1 0 5 1 2 97070 198535
( ) (
. ( ) . ( . ) . . = + = + =
u u u
2
4
1
4
4
3)
0 25 6 0 25
( ) ( ) (
. ( ) . = + + = (6 + 1.98535 + 3.98535) = 2.99268.
u u
4
4
2
4
0 5 5 0 5 5 2 99268 3 99634
( ) ( )
. ( ) . ( . ) . = + = + = .
Fifth iteration
u u
1
5
2
4
0 5 1 0 5 1 2 99268 199634
( ) ( )
. ( ) . ( . ) . = + = + =
.
u u u
2
5
1
5
4
4
0 25 6 0 25
( ) ( ) ( )
. ( ) . = + + =
(6 + 1.99634 + 3.99644) = 2.99817.
u u
4
5
2
5
0 5 5 0 5 5 2 99817 3 99909
( ) ( )
. ( ) . ( . ) . = + = + =
.
Sixth iteration
u u
1
6
2
5
0 5 1 0 5 1 2 99817 199909
( ) ( )
. ( ) . ( . ) . = + = + = .
u u u
2
6
1
6
4
5
0 25 6 0 25
( ) ( ) ( )
. ( ) . = + + = (6 + 1.99909 + 3.99909) = 2.99955.
u u
4
6
2
6
0 5 5 0 5 5 2 99955 3 99977
( ) ( )
. ( ) . ( . ) . = + = + = .
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 271
Seventh iteration
u u
1 2
6
0 5 1 0 5 1 2 99955 199978
(7) ( )
. ( ) . ( . ) . = + = + =
.
u u u
2 1 4
6
0 25 6 0 25
(7) (7) ( )
. ( ) . = + + =
(6 + 1.99978 + 3.99977) = 2.99989.
u u
4 2
0 5 5 0 5 5 2 99989 3 99994
(7) (7)
. ( ) . ( . ) . = + = + =
.
At this stage, the magnitudes of the errors in the successive iterations are
| |
(7) ( )
u u
1 1
6
= | 1.99978 1.99909 | = 0.00069,
| |
(7) ( )
u u
2 2
6
= | 2.99989 2.99955 | = 0.00034,
| |
(7) ( )
u u
4 4
6
= | 3.99994 3.99977 | = 0.00017.
All the errors are < 0.001. Hence, the seventh iteration values are taken as the required
solutions.
u
1
1.99978, u
2
= u
3
2.99989, u
4
3.99994.
REVIEW QUESTIONS
1. Write the Laplace equation in two dimensions.
Solution u
xx
+ u
yy
= 0.
2. Write the Poisson equation in two dimensions.
Solution u
xx
+ u
yy
= G(x, y).
3. Write the general linear second order partial differential equation in two variables.
Solution Au
xx
+ 2Bu
xy
+ Cu
yy
+ Du
x
+ Eu
y
+ Fu + G = 0,
where A, B, C, D, E, F, G are functions of x, y.
4. When is the linear second order partial differential equation
Au
xx
+ 2Bu
xy
+ Cu
yy
+ Du
x
+ Eu
y
+ Fu + G = 0
called an elliptic or hyperbolic or parabolic equation?
Solution The given linear second order partial differential equation is called (i) an
elliptic equation when B
2
AC < 0, (ii) a hyperbolic equation when B
2
AC > 0, and (iii)
a parabolic equation when B
2
AC = 0.
5. Write the standard five point formula for the solution of (i) Laplaces equation u
xx
+ u
yy
= 0, (ii) Poisson equation u
xx
+ u
yy
= G(x, y), for uniform mesh spacing h.
Solution
(i) u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0.
(ii) u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= h
2
G
i, j
.
6. Write the diagonal five point formula for the solution of (i) Laplaces equation u
xx
+ u
yy
= 0, (ii) Poisson equation u
xx
+ u
yy
= G(x, y), for uniform mesh spacing h.
272 NUMERICAL METHODS
Solution
(i) u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
4u
i, j
= 0.
(ii) u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
4u
i, j
= 2h
2
G
i, j
.
6. What is the order and truncation error of the standard five point formula for the solution of
Laplaces equation u
xx
+ u
yy
= 0, with uniform mesh spacing?
Solution The method is u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
4u
i, j
= 0.
Order = 2, or O(h
2
).
T.E =
h u
x
u
y
i j
4 4
4
4
4
12
+
,
...
7. What is the order and truncation error of the diagonal five point formula for the solution of
Laplaces equation u
xx
+ u
yy
= 0, with uniform mesh spacing ?
Solution The method is u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
4u
i, j
= 0.
Order = 2, or O(h
2
).
T.E =
h u
x
u
x y
u
y
i j
4 4
4
4
2 2
4
4
6
6
+ +
,
+ ...
8. When do we normally use the diagonal five point formula while finding the solution of
Laplace or Poisson equation?
Solution We use the diagonal five point formula to obtain initial approximations for
the solutions to start an iterative procedure like Liebmann iteration.
9. Finite difference methods when applied to Laplace equation or Poisson equation give
rise to a system of algebraic equations Au = d. Name the types of methods that are
available for solving these systems.
Solution
(i) Direct methods like Gauss elimination method or Gauss-Jordan method can be used
when the system of equations is small.
(ii) Iterative methods like Gauss-Jacobi method or Gauss-Seidel method can be used
when the system of equations is large.
10. When do we use the Liebmann method?
Solution We use the Liebmann method to compute the solution of the difference
equations for the Laplaces equation or the Poisson equation. The initial approximations
are obtained by judiciously using the standard five point formula
u
i, j
=
1
4
(u
i+1, j
+ u
i1, j
+ u
i, j+1
+ u
i, j1
)
or the diagonal five point formula
u
i, j
=
1
4
(u
i+1, j+1
+ u
i1, j+1
+ u
i+1, j1
+ u
i1, j1
)
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 273
after setting the values of one or two variables as zero. If in some problems, these two
formulas cannot be used, then we set the values of required number of variables as zero.
11. What is the condition of convergence for the system of equations obtained, when we
apply finite difference methods for Laplaces or Poisson equation?
Solution A sufficient condition for convergence of the system of equations is that the
coefficient matrix A of the system of equations Au = d, is diagonally dominant. This
implies that convergence may be obtained even if A is not diagonally dominant.
12. What is the importance of the order of a finite difference method?
Solution When a method converges, it implies that the errors in the numerical solutions
0 as h 0. Suppose that a method is of order O(h
2
). Then, if we reduce the step
length h by a factor, say 2, and re-compute the numerical solution using the step length
h/2, then the error becomes O[(h/2)
2
] = [O(h
2
)]/4. That is, the errors in the numerical
solutions are reduced by a factor of 4. This can easily be checked at the common points
between the two meshes.
EXERCISE 5.3
Find the solution of the Laplace equation u
xx
+ u
yy
= 0 in the given region R, subject to the given
boundary conditions, using the standard five point formula.
1. 2.
u
1
u
2
u
3
u
4
8/9 5/9
5/9
8/9 1/9
4/9
1/9 4/9
1
0
0
2
5
6
5 3
u
1
u
2
u
3
u
4
Fig. 5.16. Problem 1. Fig. 5.17. Problem 2.
3. 4.
u
1
u
2
u
3
u
4
400 500
500
400 100
200
100 200
u
1
u
2
u
3
u
4
3 6
6
3 0
0
0 0
Fig. 5.18. Problem 3. Fig. 5.19. Problem 4.
274 NUMERICAL METHODS
5. R is a square of side 3 units. Boundary conditions are u(0, y) = 0, u(3, y) = 3 + y, u(x, 0)
= x, u(x, 3) = 2x. Assume step length as h = 1.
6. R is a square of side 1 unit. u(x, y) = x y on the boundary. Assume h = 1/3.
Find the solution of the Poissons equation u
xx
+ u
yy
= G(x, y) in the region R, subject to the
given boundary conditions.
7. R : 0 x 1, 0 y 1. G(x, y) = 4. u(x, y) = x
2
+ y
2
on the boundary and h = 1/3.
8. R : 0 x 1, 0 y 1. G(x, y) = 3x + 2y. u(x, y) = x y on the boundary and h = 1/3.
9. R : 0 x 3, 0 y 3. G(x, y) = x
2
+ y
2
. u(x, y) = 0 on the boundary and h = 1.
10. In Problems 2, 3, 4, 8, 9, solve the system of equations using the Liebmann iteration. In
Problem 2, take the value at the top left hand point as 2. In Problem 3, take the value
at the top left hand point as 300. In Problem 4, take the value at the top left hand point
as 0.Perform four iterations in each case.
5.5 FNTE DFFERENCE METHOD FOR HEAT CONDUCTON EQUATON
In section 5.3, we have defined the linear second order partial differential equation
Au
xx
+ 2Bu
xy
+ Cu
yy
+ Du
x
+ Eu
y
+ Fu + G = 0
as a parabolic equation if B
2
AC = 0. A parabolic equation holds in an open domain or in a
semi-open domain. A parabolic equation together with the associated conditions is called an
initial value problem or an initial-boundary value problem. The simplest example of a para-
bolic equation is the following problem.
Consider a thin homogeneous, insulated bar or a wire of length l. Let the bar be located
on the x-axis on the interval [0, l]. Let the rod have a source of heat. For example, the rod may
be heated at one end or at the middle point or has some source of heat. Let u(x, t) denote the
temperature in the rod at any instant of time t. The problem is to study the flow of heat in the
rod. The partial differential equation governing the flow of heat in the rod is given by the
parabolic equation
u
t
= c
2
u
xx
, 0 x l, t > 0. (5.35)
where c
2
is a constant and depends on the material properties of the rod. In order that the
solution of the problem exists and is unique, we need to prescribe the following conditions.
(i) Initial condition At time t = 0, the temperature is prescribed, u(x, 0) = f(x), 0 x l.
(ii) Boundary conditions Since the bar is of length l, boundary conditions at x = 0 and at
x = l are to be prescribed. These conditions are of the following types:
(a) Temperatures at the ends of the bar is prescribed
u(0, t) = g(t), u(l, t) = h(t), t > 0. (5.36)
(b) One end of the bar, say at x = 0, is insulated. This implies the condition that
u
x
= 0, at x = 0 for all time t.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 275
At the other end, the temperature may be prescribed, u(l, t) = h(t), t > 0.
Alternatively, we may have the condition that the end of the bar at x = l is insulated.
Since both initial and boundary conditions are prescribed, the problem is also called an
initial boundary value problem.
For our discussion, we shall consider only the boundary conditions given in (5.36).
Mesh generation Superimpose on the domain 0 x l, t > 0, a rectangular network of mesh
lines. Let the interval [0, l] be divided into M equal parts. Then, the mesh length along the
x-axis is h = l/M. The points along the x-axis are x
i
= ih, i = 0, 1, 2, ..., M. Let the mesh length
along the t-axis be k and define t
j
= jk. The mesh points are (x
i
, t
j
) We call t
j
as the jth time
level (see Fig.5.20). At any point (x
i
, t
j
), we denote the numerical solution by u
i, j
and the exact
solution by u(x
i
, t
j
).
Remark 9 Finite difference methods are
classified into two categories: explicit
methods and implicit methods. In explicit
methods, the solution at each nodal point
on the current time level is obtained by
simple computations (additions, sub-
tractions, multiplications and divisions)
using the solutions at the previous one or
more levels. In implicit methods, we solve
a linear system of algebraic equations for
all the unknowns on any mesh line t = t
j+1
.
When a method uses the nodal values on
two time levels t
j
and t
j+1
, as in Fig. 5.20,
then it is called a two level formula. When
a method uses the nodal values on three
time levels t
j1
, t
j
and t
j+1
then it is called a
three level formula.
Let us derive a few methods.
Explicit methods
In Chapter 2, we have derived the relationships between the derivatives and forward differences.
Denote
t
as the forward difference in the t-direction. Then, we can write Eq.(2.31) as
u
t k
u
k
u
t t t
= + = +
1
1
1 1
2
2
[log ( )] ... .
(5.37)
Now, use the approximation
u
t k
u
k
u u
i j
t i j i j i j
=
+
,
, , ,
[ ]
1 1
1
. (5.38)
t
Level j + 1
Level j
Level j 1
x Level 0
O
Fig. 5.20. Nodes.
276 NUMERICAL METHODS
Using central differences, we also have the approximation
2
2 2
2
2
1 1
1 1
2
u
x h
u
h
u u u
i j
x i j i j i j i j
= +
+
,
, , , ,
[ ]. (5.39)
Therefore, an approximation to the heat conduction equation (5.35) at the point (x
i
, t
j+1
), is
1
2
1
2
2
1 1
k
u u
c
h
u u u
i j i j i j i j i j
[ ] [ ]
, , , , , + +
= + .
or u
i, j+1
u
i, j
= [ ]
, , ,
u u u
i j i j i j +
+
1 1
2
or u
i, j+1
= u
i, j
+ [ ]
, , ,
u u u
i j i j i j +
+
1 1
2
or u
i, j+1
= u
i1, j
+ (1 2)u
i, j
+ u
i+1, j
(5.40)
where = kc
2
/h
2
, is called the mesh ratio parameter.
Note that the value u
i, j+1
at the node
(x
i
, t
j+1
) is being obtained explicitly using the
values on the previous time level t
j
. The nodes
that are used in the computations are given in
Fig.5.21. This method is called the Schmidt
method. It is a two level method.
Truncation error of the Schmidt method
We have the method as
u
i, j+1
u
i, j
= [ ]
, , ,
u u u
i j i j i j +
+
1 1
2 .
Expanding in Taylors series, we obtain the left hand and right hand sides as
u x t k u x t u k
u
t
k u
t
u k
u
t
k u
t
i j i j
( , ) ( , ) ... ... + = + + +
= + +
2 2
2
2 2
2
2 2
[u(x
i+1
, t
j
) 2u(x
i
, t
j
) + u(x
i1
, t
j
)]
=
kc
h
2
2
u h
u
x
h u
x
h u
x
u u h
u
x
h u
x
h u
x
+ + + +
+ + +
2 2
2
3 3
3
2 2
2
3 3
3
2 6
2
2 6
... ...
=
kc
h
h
u
x
h u
x
2
2
2
2
2
4 4
4
12
+ +
... = kc
2
2
2
2 4
4
12
u
x
h u
x
+ +
...
where all the terms on the right hand sides are evaluated at (x
i
, t
j
). The truncation error is given
by
T.E = u(x
i
,
t
j
+ k) u(x
i
, t
j
) [u(x
i+1
, t
j
) 2u(x
i
, t
j
) + u(x
i1
, t
j
)]
= k
u
t
k u
t
kc
u
x
h u
x
+ +
+ +
2 2
2
2
2
2
2 4
4
2 12
... ...
i, j + 1
i, j i + 1, j
i 1, j
Level j + 1
Level j
Fig. 5.21. Schmidt method.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 277
=
k
u
t
c
u
x
2
2
2
+
k u
t
kh c u
x
2 2
2
2 2 4
4
2 12
+ ...
Now, using the differential equation
u
t
c
u
x
=
2
2
2
, and
2
2
u
t t
u
t
=
= c
2
t
u
x
2
2
= c
4
2
2
2
2
x
u
x
= c
4
4
4
u
x
,
we obtain
T.E =
k c u
x
kh c u
x
kh c u
x
2 4 4
4
2 2 4
4
2 2 4
4
2 12 12
6 1
+ = +
= =
u
=
3
2
,
u u
2
3
0
2 0
,
,
=
=
sin
2
3
3
2
=
= 0.866025.
The boundary conditions give the values u
0, j
= 0, u
3, j
= 0,
for all j.
(i) We have = 1/2, h = 1/3, k = h
2
= 1/18. The
computations are to be done for two time steps, that is,
upto t = 1/9. For = 1/2, we get the method
u
i, j+1
=
1
2
(u
i1, j
+ u
i+1, j
), j = 0, 1 ; i = 1, 2.
We have the following values.
For j = 0: i = 1: u
1, 1
= 0.5(u
0,0
+ u
2, 0
) = 0.5(0 + 0.866025) = 0.433013.
i = 2: u
2, 1
= 0.5(u
1,0
+ u
3, 0
) = 0.5(0.866025 + 0) = 0.433013.
t
0 1/3 2/3 1 x
Fig. 5.22. Example. 5.16.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 279
For j = 1: i = 1: u
1, 2
= 0.5(u
0, 1
+ u
2,1
) = 0.5(0 + 0.433013) = 0.216507.
i = 2: u
2, 2
= 0.5(u
1,1
+ u
3,1
) = 0.5(0.433013 + 0) = 0.216507.
After two steps t = 2k = 1/9. Hence,
u
1
3
1
9
2
3
1
9
0 216507 , , . .
u
(ii) We have = 1/4, h = 1/3, k = h
2
= 1/36. The computations are to be done for four time steps,
that is, upto t = 1/9. For = 1/4, we get the method
u
i, j+1
=
1
4
(u
i1, j
+ 2u
i, j
+ u
i+1, j
), j = 0, 1, 2, 3 ; i = 1, 2.
We have the following values.
For j = 0: i = 1: u
1,1
= 0.25(u
0,0
+ 2u
1,0
+ u
2,0
) = 0.25[0 + 3(0.866025)] = 0.649519.
i = 2: u
2,1
= 0.25(u
1,0
+ 2u
2,0
+ u
3,0
) = 0.25[3(0.866025) + 0] = 0.649519.
For j = 1: i = 1: u
1,2
= 0.25(u
0,1
+ 2u
1,1
+ u
2,1
) = 0.25[0 + 3(0.649519)] = 0.487139.
i = 2: u
2,2
= 0.25(u
1,1
+ 2u
2,1
+ u
3,1
) = 0.25[3(0.649519) + 0] = 0.487139.
For j = 2: i = 1: u
1,3
= 0.25(u
0,2
+ 2u
1,2
+ u
2,2
) = 0.25[0 + 3(0.487139)] = 0.365354.
i = 2: u
2,3
= 0.25(u
1,2
+ 2u
2,2
+ u
3,2
) = 0.25[3(0.487139) + 0] = 0.365354.
For j = 3: i = 1: u
1,4
= 0.25(u
0,3
+ 2u
1,3
+ u
2,3
) = 0.25[0 + 3(0.365354)] = 0.274016.
i = 2: u
2,4
= 0.25(u
1,3
+ 2u
2,3
+ u
3,3
) = 0.25[3(0.365354) + 0] = 0.274016.
After four steps t = 4k = 1/9. Hence,
u
1
3
1
9
2
3
1
9
0 274016 , , .
u ,
(iii) We have = 1/6, h = 1/3, k = h
2
= 1/54. The computations are to be done for six time steps,
that is, upto t = 1/9. For = 1/6, we get the method
u
i, j+1
=
1
6
(u
i1, j
+ 4u
i, j
+ u
i+1, j
), j = 0, 1, 2, 3, 4, 5 ; i = 1, 2.
We have the following values.
For j = 0: i = 1: u
1,1
=
1
6
(u
0,0
+ 4u
1,0
+ u
2,0
) =
1
6
[0 + 5(0.866025)] = 0.721688.
i = 2: u
2,1
=
1
6
(u
1,0
+ 4u
2,0
+ u
3,0
) =
1
6
[5(0.866025) + 0] = 0.721688.
For j = 1: i = 1: u
1,2
=
1
6
(u
0,1
+ 4u
1,1
+ u
2,1
) =
1
6
[0 + 5(0.721688)] = 0.601407.
i = 2: u
2,2
=
1
6
(u
1,1
+ 4u
2,1
+ u
3,1
) =
1
6
[5(0.721688) + 0] = 0.601407.
280 NUMERICAL METHODS
For j = 2: i = 1: u
1,3
=
1
6
(u
0,2
+ 4u
1,2
+ u
2,2
) =
1
6
[0 + 5(0.601407)] = 0.501173.
i = 2: u
2,3
=
1
6
(u
1,2
+ 4u
2,2
+ u
3,2
) =
1
6
[5(0.601407) + 0] = 0.501173.
For j = 3: i = 1: u
1,4
=
1
6
(u
0,3
+ 4u
1,3
+ u
2,3
) =
1
6
[0 + 5(0.501173)] = 0.417644.
i = 2: u
2,4
=
1
6
(u
1,3
+ 4u
2,3
+ u
3,3
) =
1
6
[5(0.501173) + 0] = 0.417644.
For j = 4: i = 1: u
1,5
=
1
6
(u
0,4
+ 4u
1,4
+ u
2,4
) =
1
6
[0 + 5(0.417644)] = 0.348037.
i = 2: u
2,5
=
1
6
(u
1,4
+ 4u
2,4
+ u
3,4
) =
1
6
[5(0.417644) + 0] = 0.348037.
For j = 5: i = 1: u
1,6
=
1
6
(u
0,5
+ 4u
1,5
+ u
2,5
) =
1
6
[0 + 5(0.348037)] = 0.290031.
i = 2: u
2,6
=
1
6
(u
1,5
+ 4u
2,5
+ u
3,5
) =
1
6
[5(0.348037) + 0] = 0.290031.
After six steps t = 6k = 1/9. Hence,
u
1
3
1
9
2
3
1
9
0 290031 , , .
u .
The magnitudes of errors at x = 1/3 and at x = 2/3 are same. The exact solution at t = 1/9 is
u u
1
3
1
9
2
3
1
9 9 3
0 289250
2
, , exp sin . .
The magnitudes of errors are the following:
= 1/2 : | 0.216507 0.289250 | = 0.072743.
= 1/4 : | 0.274016 0.289250 | = 0.015234.
= 1/6 : | 0.290031 0.289250 | = 0.000781.
We note that the higher order method produced better results.
Example 5.17 Solve u
xx
= 32 u
t
, 0 x 1, taking h = 0.5 and
u(x, 0) = 0, 0 x 1, u(0, t) = 0, u(1, t) = t, t > 0.
Use an explicit method with = 1/2. Compute for four time steps.
Solution The given partial differential equation is
u
t
=
1
32
1
32
2
= u c
xx
and .
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 281
The step length is h = 0.25. We have five nodal
points on each mesh line (see Fig.5.23). We are to find
the solutions at three internal points.
The Schmidt method is given by
u
i, j+1
= u
i1, j
+ (1 2)u
i, j
+ u
i+1, j
.
For = 1/2, the method becomes
u
i, j+1
= 0.5 (u
i1, j
+ u
i+1, j
),
j = 0, 1, 2, 3 ; i = 1, 2, 3.
We have k =
h
c
2
2
1
2
1
16
32 1 =
= ( ) .
The initial condition gives the values u
0, 0
= u
1,0
= u
2,0
= u
3,0
= u
4,0
= 0.
The boundary conditions give the values u
0, j
= 0, u
4, j
= t
j
= jk = j, for all j.
We obtain the following solutions.
For j = 0: i = 1: u
1,1
= 0.5(u
0,0
+ u
2,0
) = 0.
i = 2: u
2,1
= 0.5(u
1,0
+ u
3,0
) = 0.
i = 3: u
3,1
= 0.5(u
2,0
+ u
4,0
) = 0.
For j = 1: i = 1: u
1,2
= 0.5(u
0,1
+ u
2,1
) = 0.5(0 + 0) = 0.
i = 2: u
2,2
= 0.5(u
1,1
+ u
3,1
) = 0.5(0 + 0) = 0.
i = 3: u
3,2
= 0.5(u
2,1
+ u
4,1
) = 0.5(0 + 1) = 0.5.
For j = 2: i = 1: u
1,3
= 0.5(u
0,2
+ u
2,2
) = 0.5(0 + 0) = 0.
i = 2: u
2,3
= 0.5(u
1,2
+ u
3,2
) = 0.5(0 + 0.5) = 0.25.
i = 3: u
3,3
= 0.5(u
2,2
+ u
4,2
) = 0.5(0 + 2) = 1.0.
For j = 3: i = 1: u
1,4
= 0.5(u
0,3
+ u
2,3
) = 0.5(0 + 0.25) = 0.125.
i = 2: u
2,4
= 0.5(u
1,3
+ u
3,3
) = 0.5(0 + 1.0) = 0.5.
i = 3: u
3,4
= 0.5(u
2,3
+ u
4,3
) = 0.5(0.25 + 3) = 1.625.
The approximate solutions are u(0.25, 4) 0.125, u (0.5, 4) 0.5, u(0.75, 4) 1.625.
Implicit methods
Explicit methods have the disadvantage that they have a stability condition on the mesh ratio
parameter . We have seen that the Schmidt method is stable for 0.5. This condition severely
restricts the values that can be used for the step lengths h and k. In most practical problems,
where the computation is to be done up to large value of t, these methods are not useful because
the time taken is too high. In such cases, we use the implicit methods. We shall discuss the most
t
0 0.25 0.5 0.75 1
x
Fig. 5.23. Example 5.17.
282 NUMERICAL METHODS
popular and useful method called the Crank-Nicolson method. There are a number of ways of
deriving this method. We describe one of the simple ways. Denote
t
as the backward difference in
the time direction. From Eq.(2.32), we write the relation
k
u
t
u
t t t t
= = + + +
log ( ) ... 1
1
2
1
3
2 3
u. (5.46)
Now, approximate k
u
t
u
t t
t
t
1
2 1 1 2
2
( / )
u. (5.47)
If we expand the operator on the right hand side, we get
= + + +
t
t
t t t t t
1 1 2
1
1
2
1
1
2
1
4
1
2
( / )
...
which agrees with the first two terms on the right hand side of (5.46). Applying the differential
equation at the nodal point (i, j +1), (see Fig.5.24), we obtain
u
t
c
u
x
i j
i j
+
+
,
,
1
2
2
2
1
. (5.48)
Using the approximation given in (5.47) to left hand side and the central difference ap-
proximation (5.39) to the right hand side, we obtain
1
1 1 2
1
2
2
2
1
k
u
c
h
u
t
t
i j x i j
=
+ +
( / )
, ,
or
t
u
i, j+1
=
kc
h
2
2
1
1
2
2
1
+ t x i j
u
,
,
or
t
u
i,j+1
=
x i j t x i j
u u
2
1
2
1
1
2
, , + +
,
or
=
+ + + t i j x i j x t i j
u u u
, , , 1
2
1
2
1
1
2
.
or =
+ + + t i j x i j x i j i j
u u u u
, , , , 1
2
1
2
1
1
2
, ,
,
or
=
+ + + t i j x i j x i j x i j
u u u u
, , , ,
{ }
1
2
1
2
1
2
1
2
,
or = +
+ + t i j x i j x i j
u u u
, , ,
( )
1
2
1
2
2
, (5.49)
or u u u u
i j i j x i j x i j , , , ,
( )
+ +
= +
1
2
1
2
2
,
or u u u u
i j x i j i j x i j , , , , + +
= +
1
2
1
2
2 2
2
1
2 2
1
2
1 1 1 1 1 1 1
u u u u u u
i j i j i j i j i j i j , , , , , ,
( ) ( )
, (5.50)
where = kc
2
/h
2
. This method is called the Crank-Nicolson method.
The nodal points that are used in the method are given in Fig.5.24.
l 1, j + 1 l, j + 1 l + 1, j + 1
l + 1, j l, j l 1, j
Level j + 1
Level j
Fig. 5.24. Nodes in Crank-Nicolson method.
Remark 14 From the right hand side of Eq.(5.49), we note that it is the mean of the central
difference approximations,
x
u
2
, to the right hand side of the differential equation on the levels j
and j + 1. This concept of taking the mean of the central difference approximations to the right
hand side of a given differential equation is often generalized to more complicated differential
equations.
Remark 15 The order of the Crank-Nicolson method is O(k
2
+ h
2
).
Remark 16 Implicit methods often have very strong stability properties. Stability analysis of the
Crank-Nicolson method shows that the method is stable for all values of the mesh ratio param-
eter . This implies that there is no restriction on the values of the mesh lengths h and k.
Depending on the particular problem that is being solved, we may use sufficiently large values of
the step lengths. Such methods are called unconditionally stable methods.
Computational procedure The initial condition u(x, 0) = f(x) gives the solution at all the nodal
points on the initial line (level 0). The boundary conditions u(0, t) = g(t), u(l, t) = h(t), t > 0 give the
solutions at all the nodal points on the lines x = 0 and x = l for all time levels. We choose a value
for and h. This gives the value of the time step length k. Alternately, we may choose the values
for h and k. The difference equations at all nodal points on the first time level are written. This
system of equations is solved to obtain the values at all the nodal points on this time level. The
computations are repeated for the required number of steps. If we perform m steps of computa-
tion, then we have computed the solutions up to time t
m
= mk.
Remark 17 Do you recognize the system of equations that is obtained if we apply the Crank-
Nicolson method? Again, it is a tri-diagonal system of equations. It uses the three consecutive
unknowns u
i1, j+1
, u
i, j+1
and u
i+1, j+1
on the current time level. This is the advantage of the
method.
Let us illustrate the application of the method.
284 NUMERICAL METHODS
Example 5.18 Solve the equation u
t
= u
xx
subject to the conditions
u(x, 0) = sin ( x), 0 x 1, u(0, t) = u(1, t) = 0
using the Crank-Nicolson method with, h = 1/3, k = 1/36. Do one time step.
(A.U. Nov/Dec. 2006)
Solution We have
c
2
= 1, h =
1
3
, k =
1
36
, =
kc
h
2
2
1
36
= (9) =
1
4
. (Fig.5.25).
Crank-Nicolson method is given by
+ + = + +
+ + + + +
2
1
2 2
1
2
1 1 1 1 1 1 1
u u u u u u
i j i j i j i j i j i j , , , , , ,
( ) ( )
For , 4 / 1 = we have the method as
+ = + +
+ + + + +
1
8
5
4
1
8
1
8
3
4
1
8
1 1 1 1 1 1 1
u u u u u u
i j i j i j i j i j i j , , , , , ,
or + = + +
+ + + + +
u u u u u u
i j i j i j i j i j i j 1 1 1 1 1 1 1
10 6
, , , , , ,
, j = 0 ; i = 1, 2.
The initial condition gives the values
u
0,0
= 0, u
1,0
= sin (/3) = ( 3 /2) = u
2,0
, u
3,0
= 0.
The boundary conditions give the values u
0, j
= 0 = u
3,
j
for all j,
We have the following equations.
For j = 0, i = 1 : u
0,1
+ 10 u
1,1
u
2,1
= u
0,0
+ 6u
1,0
+ u
2,0
or 10u
1,1
u
2,1
=
6 3
2
3
2
7 3
2
+ = = 6.06218.
i = 2: u
1,1
+ 10u
2,1
u
3,1
= u
1,0
+ 6u
2,0
+ u
3,0
or u
1,1
+ 10u
2,1
= u
1,0
+ 6u
2,0
=
3
2
6 3
2
7 3
2
+ = = 6.06218.
Subtracting the two equations, we get 11u
1,1
11u
2,1
= 0. Hence, u
1,1
= u
2,1
. The solution is given by
u
1,1
= u
2,1
=
6 06218
9
.
= 0.67358.
Example 5.19 Solve u
xx
= u
t
in 0 < x < 2, t > 0,
u(0, t) = u(2, t) = 0, t > 0 and u(x, 0) = sin ( x/ 2), 0 x 2,
using x = 0.5, t = 0.25 for one time step by Crank-Nicolson implicit finite difference method.
(A.U Apr/May 2003)
t
0 1/3 2/3 1 x
Fig. 5.25. Example 5.18.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 285
Solution We have c
2
= 1, x = 0.5, t = 0.25, =
c t
x
2
2
0 25
0 25
=
.
.
= 1.
Crank-Nicolson implicit finite difference method is given by
+ + = + +
+ + + + +
2
1
2 2
1
2
1 1 1 1 1 1 1
u u u u u u
i j i j i j i j i j i j , , , , , ,
( ) ( )
.
For = 1, we have the method as
+ = +
+ + + + +
1
2
2
1
2
1
2
1
2
1 1 1 1 1 1 1
u u u u u
i j i j i j i j i j , , , , ,
or + = +
+ + + + +
u u u u u
i j i j i j i j i i j 1 1 1 1 1 1
4
, , , , ,
,
j = 0 ; i = 1, 2, 3,
The initial condition gives the values
u
0,0
= 0, u
1,0
= sin(/4) = (1/ 2 ) = 0.70711,
u
2,0
= sin (/2) = 1, u
3, 0
= sin (3/4) = (1/ 2 ) = 0.70711.
The boundary conditions give the values u
0, j
= 0 = u
4, j
for all j.
t
0 0.5 1.0 1.5 2.0 x
Fig. 5.26. Example 5.19.
We have the following equations.
For : 1 , 0 = = i j u
0,1
+ 4u
1,1
u
2,1
= u
0,0
+ u
2,0
or 4u
1,1
u
2,1
= 1,
i = 2: u
1,1
+ 4u
2,1
u
3,1
= u
1,0
+ u
3,0
or u
1,1
+ 4u
2,1
u
3,1
= 1.41421,
i = 3: u
2,1
+ 4u
3,1
u
4,1
= u
2,0
+ u
4,0
or u
2,1
+ 4u
3,1
= 1.
Subtracting the first and third equations, we get 4u
1,1
4u
3,1
= 0. Hence, u
1,1
= u
3,1
. We
have the system of equations as
4u
1,1
u
2,1
= 1, and 2u
1,1
+ 4u
2,1
= 1.41421.
Using determinants, the solution is obtained as
u
1,1
=
5 41421
14
.
= 0.38673, u
2,1
=
7 65684
14
.
= 0.54692.
Example 5.20 Solve by Crank-Nicolson method the equation u
xx
= u
t
subject to
u(x, 0) = 0, u(0, t) = 0 and u(1, t) = t,
for two time steps. (A.U Nov/Dec. 2003, Nov/Dec. 2006)
286 NUMERICAL METHODS
Solution Since the values of the step lengths h and k are not given, let us assume h = 0.25 and
= 1. Hence, k = h
2
= 0.0625. (Fig. 5.27).
Crank-Nicolson implicit finite difference method is given by
+ +
+ + + +
2
1
2
1 1 1 1 1
u u u
i j i j i j , , ,
( )
=
2
1
2
1 1
u u u
i j i j i j +
+ +
, , ,
( ) .
For = 1, we have the method as
+ = +
+ + + + +
1
2
2
1
2
1
2
1
2
1 1 1 1 1 1 1
u u u u u
i j i j i j i j i j , , , , ,
or
+ = +
+ + + + +
u u u u u
i j i j i j i j i j 1 1 1 1 1 1 1
4
, , , , ,
,
j = 0 ; i = 1, 2, 3..
The initial condition gives the values u
i, 0
= 0 for all i.
The boundary conditions give the values u
0, j
= 0, for all j and u
4, j
= t
j
= jk = 0.0625 j.
We have the following equations.
For j = 0, i = 1 : u
0,1
+ 4u
1,1
u
2,1
= u
0,0
+ u
2,0
or 4u
1,1
u
2,1
= 0,
i = 2 : u
1,1
+ 4u
2,1
u
3,1
= u
1,0
+ u
3,0
or u
1,1
+ 4u
2,1
u
3,1
= 0,
i = 3 : u
2,1
+ 4u
3,1
u
4,1
= u
2,0
+ u
4,0
or u
2,1
+ 4u
3,1
= 0.0625.
The system of equations is given by
4 1 0
1 4 1
0 1 4
0
0
0 0625
1 1
2,1
3 1
u
u
u
,
,
.
.
We solve this system by Gauss elimination.
4 1 0
1 4 1
0 1 4
0
0
0 0625
.
, Perform
R
1
4
, then R
2
+ R
1
.
1 14 0 0
0 15 4 1 0
0 1 4 0 0625
/
/
.
,
Perform
R
2
15 4 ( / )
, then R
3
+ R
2
.
1 14 0 0
0 1 4 15 0
0 0 56 15 0 0625
/
/
/ .
,
The last equation gives u
3,1
= 0.0625
15
56
= 0.01674.
The second equation gives u
2,1
=
4
15
4
15
0 01674 0 00446
3 1
= u
,
. . .
The first equation gives u
1,1
=
1
4
1
4
0 00446 0 00112
2,1
= u . . .
t
0 0.25 0.5 0.75 1
x
Fig. 5.27. Example 5.20.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 287
For j = 1, i = 1 : u
0,2
+ 4u
1,2
u
2,2
= u
0,1
+ u
2,1
= 0 + 0.00446,
or 4u
1,2
u
2,2
= 0.00446.
i = 2: u
1,2
+ 4u
2,2
u
3,2
= u
1,1
+ u
3,1
= 0.00112 + 0.01674 = 0.01786.
i = 3: u
2,2
+ 4u
3,2
u
4,2
= u
2,1
+ u
4,1
= 0.00446 + 0,
or u
2,2
+ 4u
3,2
= 0.00446 + 0.125 = 0.12946.
The system of equations is given by
4 1 0
1 4 1
0 1 4
0 00446
0 01786
0 12946
1 2
2, 2
3 2
u
u
u
,
,
.
.
.
.
We solve this system by Gauss elimination.
4 1 0 0 00446
1 4 1 0 01786
0 1 4 0 12946
.
.
.
. Perform
R
1
4
, then R
2
+ R
1
.
1 14 0 0 001115
0 15 4 1 0 018975
0 1 4 0 12946
/ .
/ .
.
.
Perform
R
2
15 4 ( / )
, then R
3
+ R
2
.
1 14 0 0 001115
0 1 4 15 0 00506
0 0 56 15 0 13452
/ .
/ .
/ .
.
The last equation gives u
3, 2
=
15
56
0.13452 = 0.036032.
The second equation gives u
2, 2
=
4
15
4
15
0 036032 0 014669
3 2
= u
,
. . .
The first equation gives u
1, 2
=
1
4
1
4
0 014669 0 004782
2,2
= u . . .
REVIEW QUESTIONS
1. Write the one dimensional heat conduction equation and the associated conditions.
Solution The heat conduction equation is given by
u
t
= c
2
u
xx
, 0 x l, t > 0.
The associated conditions are the following.
Initial condition At time t = 0, the temperature is prescribed, u(x, 0) = f(x), 0 x l.
Boundary conditions Since the bar is of length l, boundary conditions at x = 0 and at
x = l are to be prescribed.
u(0, t) = g(t), u(l, t) = h(t), t > 0.
288 NUMERICAL METHODS
2. What is an explicit method for solving the heat conduction equation?
Solution In explicit methods, the solution at each nodal point on the current time level is
obtained by simple computations (additions, subtractions, multiplications and divisions)
using the solutions at the previous one or more levels.
3. Write the Schmidt method for solving the one dimensional heat conduction equation.
Solution The Schmidt method for solving the heat conduction equation
u
t
= c
2
u
xx
, 0 x l, t > 0
is given by u
i, j+1
= u
i1, j
+ (1 2)u
i, j
+ u
i+1, j
; j = 0, 1, .... ; i = 1, 2, ...
where = kc
2
/h
2
, is the mesh ratio parameter and h and k are the step lengths in the x
and t directions respectively.
4. What is the order and truncation error of the Schmidt method?
Solution The order of the method is O(k + h
2
). For a fixed value of , the method behaves
like an O(h
2
) method. The truncation error of the method is given by
T.E =
kh c u
x
2 2 4
4
12
6 1 ( ) ...
5. Write the Bender-Schmidt method for solving the one dimensional heat conduction equa-
tion.
Solution The Bender-Schmidt method for solving the heat conduction equation
u
t
= c
2
u
xx
, 0 x l, t > 0
is given by u
i, j+1
=
1
2
(u
i1,
j
+ u
i+1, j
). This method is a particular case of the Schmidt
method in which we use the value = 1/2.
6. Write the particular case of the Schmidt method which is of order O(k
2
+ h
4
).
Solution The higher order O(k
2
+ h
4
) method is obtained by setting = 1/6 in the Schmidt
method. The method is given by
u
i, j+1
=
1
6
[u
i1, j
+ 4u
i, j
+ u
i+1, j
].
For a fixed value of , the method behaves like an O(h
4
) method.
7. When do we call a numerical method as stable?
Solution A numerical method is said to be stable when the cumulative effect of all errors
tend to zero as the computation progresses.
8. What is the condition of stability for the Schmidt method?
Solution Schmidt method is stable when the mesh ratio parameter satisfies the condi-
tion 1/2.
9. Is the Bender-Schmidt method for solving the heat conduction equation stable?
Solution The Bender-Schmidt method is obtained from the Schmidt method by setting
= 1/2. Schmidt method is stable when the mesh ratio parameter satisfies the condition
1/2. Hence, Bender-Schmidt method is also stable.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 289
10. Define an implicit method for solving the heat conduction equation.
Solution In implicit methods, we solve a linear system of algebraic equations for all the
unknowns on any mesh line t = t
j+1
.
11. Define two level and three level methods.
Solution When a method uses the nodal values on two time levels t
j
and t
j+1
, then it is
called a two level formula. When a method uses the nodal values on three time levels
t
j1
, t
j
and t
j+1
, then it is called a three level formula.
12. Write the Crank-Nicolson method for solving the one dimensional heat conduction
equation.
Solution The Crank-Nicolson method for solving the one dimensional heat conduction
equation u
t
= c
2
u
xx
, 0 x l, t > 0, is given by
u
i, j+1
2 2
2
1
2
x i j i j x i j
u u u
, , , +
= +
or
+ + = + +
+ + + + +
2
1
2 2
1
2
1 1 1 1 1 1 1
u u u u u u
i j i j i j i j i j i j , , , , , ,
( ) ( )
where = kc
2
/h
2
, is the mesh ratio parameter and h and k are the step lengths in the x
and t directions respectively.
13. What is the order of the Crank-Nicolson method for solving the heat conduction equation?
Solution The order of the Crank-Nicolson method is O(k
2
+ h
2
).
14. What is the condition of stability for the Crank-Nicolson method?
Solution The Crank-Nicolson method is stable for all values of the mesh ratio parameter
. The method is also called an unconditionally stable method.
15. What type of system of equations do we get when we apply the Crank-Nicolson method to
solve the one dimensional heat conduction equation?
Solution We obtain a linear tridiagonal system of algebraic equations.
EXERCISE 5.4
1. Solve u
t
= u
xx
, 0 x 1,with u(x, 0) = x(1 x), 0 x 1 and u(0, t) = u(1, t) = 0 for all
t > 0. Use explicit method with h = 0.25 and = 0.25. Compute for four time steps.
2. Solve u
xx
= 16u
t
, 0 x 1,with u(x, 0) = x(1 x), 0 x 1 and u(0, t) = u(1, t) = 0 for all
t > 0. Use Schmidt method with h = 0.25 and = 1/6. Compute for four time steps.
3. Solve u
xx
= 4u
t
, 0 x 1, with u(x, 0) = 2x for x [0, 1/2] and 2(1 x) for x [1/2, 1]; and
u(0, t) = u(1, t) = 0 for all t > 0. Use Schmidt method with h = 0.25 and = 0.5. Compute for
four time steps.
4. Solve the heat conduction equation u
t
= u
xx
, 0 x 1, with u(x, 0) = sin(2 x), 0 x 1, and
u(0, t) = u(1, t) = 0 using the Schmidt method. Assume h = 0.25. Compute with
(i) = 1/2 for two time steps, (ii) = 1/4 for four time steps, (iii) = 1/6 for six time steps.
290 NUMERICAL METHODS
5. Solve u
t
= u
xx
, 0 x 5, t 0, given that u(x, 0) = 20, u(0, t) = 0, u(5, t) = 100. Compute u
for one time step with h = 1, by Crank-Nicolson method. (A.U Apr/May 2005)
6. Solve the heat equation u
t
= u
xx
, 0 x 1, subject to the initial and boundary conditions
u(x, 0) = sin ( x), 0 x 1, u(0, t) = u(1, t) = 0
using the Crank-Nicolson method with, h = 1/3, = 1/6. Integrate for one time step. Find
the maximum absolute error if the exact solution is u(x, t) = exp(
2
t) sin (x).
7. Find the solution of the equation u
t
= u
xx
, subject to the conditions
u(x, 0) = 6x, for x [0, 1] and 6(2 x), x [1, 2], u(0, t) = 0 = u(2, t)
using the Crank-Nicolson method with h = 0.4, = 1/2. Integrate for one time step.
8. Solve the heat equation u
t
= u
xx
, 0 x 1, subject to the initial and boundary conditions
u(x, 0) = sin (2 x), 0 x 1, u(0, t) = u(1, t) = 0
using the Crank-Nicolson method with, h = 0.25, = 0.8. Integrate for two time steps.
If the exact solution of the problem is u(x, t) = exp( 4
2
t) sin (2x), find the magnitudes of
the errors on the second time step.
9. Find the solution of the equation 16u
xx
= u
t
, 0 x 1 subject to the conditions
u(x, 0) = 1 x, for 0 x 1, u(0, t) = 1 t, u(1, t) = 0
using the Crank-Nicolson method with h = 0.25, = 1/2. Integrate for two time steps.
10. Find the solution of the equation 4u
t
= u
xx
, 0 x 1 subject to the conditions
u(x, 0) = 3x, for x [0, 1/2] and 3(1 x), x [1/2, 1], u(0, t) = 0 = u(1, t)
using the Crank-Nicolson method with h = 0.25, k = 1/32. Integrate for two time steps.
5.6 FNTE DFFERENCE METHOD FOR WAVE EQUATON
In section 5.3, we have defined the linear second order partial differential equation
Au
xx
+ 2Bu
xy
+ Cu
yy
+ Du
x
+ Eu
y
+ Fu + G = 0
as an hyperbolic equation if B
2
AC > 0. An hyperbolic equation holds in an open domain or in a
semi-open domain. The simplest example of an hyperbolic equation is the one dimensional wave
equation.
Study of the behavior of waves is one of the important areas in engineering. All vibration
problems are governed by wave equations.
Consider the problem of a vibrating elastic string of length l, located on the x-axis on the
interval [0, l]. Let ) , ( t x u denote the displacement of the string in the vertical plane. Then, the
vibrations of the elastic string is governed by the one dimensional wave equation
u
tt
= c
2
u
xx
, 0 x l, t > 0. (5.51)
where c
2
is a constant and depends on the material properties of the string, the tension T in the
string and the mass per unit length of the string.
In order that the solution of the problem exists and is unique, we need to prescribe the
following conditions.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 291
(i) Initial condition Displacement at time t = 0 or initial displacement is given by
u(x, 0) = f(x), 0 x l. (5.52 a)
Initial velocity: u
t
(x, 0) = g(x), 0 x l. (5.53 b)
(ii) Boundary conditions We consider the case when the ends of the string are fixed. Since
the ends are fixed, we have the boundary conditions as
u(0, t) = 0, u(l, t) = 0, t > 0. (5.53)
Since both the initial and boundary conditions are prescribed, the problem is called an initial
boundary value problem.
Mesh generation The mesh is generated as in the case of the heat conduction equation. Super-
impose on the region 0 x l, t > 0, a rectangular network of mesh lines. Let the interval [0, l] be
divided into M parts. Then, the mesh length along the x-axis is h = l/M. The points along the x-
axis are x
i
= ih, i = 0, 1, 2, ..., M. Let the mesh length along the t-axis be k and define t
j
= jk. The
mesh points are (x
i
, t
j
) as given in Fig. 5.20. We call t
j
as the jth time level. At any point (x
i
, t
j
),
we denote the numerical solution by
j i
u
,
and the exact solution by u(x
i
, t
j
).
As in the case of the heat conduction equation, we can derive explicit and implicit methods
for the solution of the wave equation.
Let us derive a few methods.
Explicit methods
Using central differences, we write the approximations
2
2 2
2
2
1 1
1 1
2
u
x h
u
h
u u u
i j
x i j i j i j i j
= +
+
,
, , , ,
[ ]. (5.54)
2
2 2
2
2
1 1
1 1
2
u
t k
u
k
u u u
i j
t i j i j i j i j
= +
+
,
, , , ,
[ ]
(5.55)
Applying the differential equation (5.51) at the nodal point (x
i
,
t
j
), and using the central
difference approximations, (5.54), (5.55), we get
1
2 2
2
1 1
2
2
1 1
k
u u u
c
h
u u u
i j i j i j i j i j i j
[ ] [ ]
, , , , , , + +
+ = +
or u u u r u u u
i j i j i j i j i j i j , , , , , ,
[ ]
+ +
+ = +
1 1
2
1 1
2 2
or u u u r u u u
i j i j i j i j i j i j , , , , , ,
[ ]
+ +
= + +
1 1
2
1 1
2 2
or u r u r u u u
i j i j i j i j i j , , , , ,
( ) [ ]
+ +
= + +
1
2 2
1 1 1
2 1 (5.56)
where r = kc/h, is called the mesh ratio parameter.
The nodes that are used in the computations are given in Fig.5.28.
292 NUMERICAL METHODS
i 1, j
i, j + 1
i, j i + 1, j
i, j 1
Level j + 1
Level j
Level j 1
Fig. 5.28. Nodes in explicit method.
Remark 18 We note that the minimum number of levels required for any method (explicit or
implicit) is three. Therefore, the method is always a three level method. The value u
i, j+1
at the
node (x
i
, t
j+1
) is being obtained by the formula in Eq. (5.56), explicitly using the values on the
previous time levels t
j
and t
j1
.
Truncation error of the explicit method
We have the method as
u u u r u u u
i j i j i j i j i j i j , , , , , ,
[ ]
+ +
+ = +
1 1
2
1 1
2 2 .
Expanding in Taylors series, we obtain
u(x
i
, t
j
+ k) 2u(x
i
, t
j
) + u(x
i
, t
j
k)
=
u k
u
t
k u
t
k u
t
k u
t
+ + + + +
2 2
2
3 3
3
4 4
4
2 6 24
...
+ + +
2
2 6 24
2 2
2
3 3
3
4 4
4
u u k
u
t
k u
t
k u
t
k u
t
...
=
k
u
t
k u
t
2
2
2
4 4
4
12
+ +
...
r
2
[u(x
i+1
, t
j
) 2u(x
i
, t
j
) + u(x
i1
, t
j
)]
=
k c
h
u h
u
x
h u
x
h u
x
h u
x
2 2
2
2 2
2
3 3
3
4 4
4
2 6 24
+ + + + +
...
+ + +
2
2 6 24
2 2
2
3 3
3
4 4
4
u u h
u
x
h u
x
h u
x
h u
x
...
=
k c
h
h
u
x
h u
x
2 2
2
2
2
2
4 4
4
12
+ +
... = k
2
c
2
2
2
2 4
4
12
u
x
h u
x
+ +
...
where all the terms on the right hand sides are evaluated at (x
i
, t
j
). The truncation error is given
by
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 293
T.E = [u(x
i
, t
j
+ k) 2u(x
i
, t
j
) + u(x
i
, t
j
k)] r
2
[u(x
i+1
, t
j
) 2u(x
i
, t
j
) + u(x
i1
, t
j
)]
= k
u
t
k u
t
k c h
u
x
h u
x
2
2
2
4 4
4
2 2 2
2
2
2 4
4
12 12
+ +
+ +
... ...
= k
2
2
2
2
2
2
4 4
4
2 2 2 4
4
12 12
u
t
c
u
x
k u
t
k h c u
x
+ + ...
Now, using the differential equation
2
2
2
2
2
u
t
c
u
x
=
and
4
4
u
t
= c
2
2
2
2
2
4
2
2
2
2
4
4
4
t
u
x
c
x
u
x
c
u
x
=
we obtain
T.E. =
k c u
x
k h c u
x
k h c
r
u
x
4 4 4
4
2 2 2 4
4
2 2 2
2
4
4
12 12 12
1
+ = +
u
t
x g x ( , ) ( ) 0 = .
If we write the central difference approximation, we obtain
u
t
x
k
u u g x
i i i
( , ) [ ] ( )
, ,
0
1
2
1 1
=
. (5.61)
This approximation introduces the external points u
i ,1
. Solving for u
i , 1
from (5.61), we get
u
i ,1
= u
i,1
2kg(x
i
). (5.62)
Now, we use the method (5.56) or (5.59) at the nodes on the level t = k, that is, for j = 0.
We get
u r u r u u u
i i i i i , , , ,
( ) [ ]
1
2
0
2
1 0 1 0 1
2 1 = + +
+
. (5.63 a)
The external points
1 , i
u
, that are introduced in this equation are eliminated by using
the relation in (5.62).
u
i,1
= 2(1 r
2
)u
i,0
+ r
2
[ ] [ ( )]
, , ,
u u u kg x
i i i i +
+
1 0 1 0 1
2
or 2u
i,1
= 2(1 r
2
)u
i,0
+ r
2
[ ] ( )
, ,
u u kg x
i i i +
+ +
1 0 1 0
2 . (5.63 b)
This gives the values at all nodal points on the level t = k.
For example, if the initial condition is prescribed as
u
t
x ( , ) 0 0 =
, then we get from
(5.62), u
i, 1
= u
i,1
. The formula (5.63b) becomes
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 295
2u
i,1
= 2(1 r
2
)u
i,0
+ r
2
[u
i+1,0
+ u
i1,0
]
or u
i,1
= (1 r
2
)u
i,0
+
r
2
2
[u
i+1,0
+ u
i1,0
]. (5.64)
For r = 1, the method simplifies to
u
i,1
=
1
2
[u
i+1,0
+ u
i1,0
]. (5.65)
Thus, the solutions at all nodal points on level 1 are obtained. For t > k, that is for j 1,
we use the method (5.56) or (5.59). The computations are repeated for the required number of
steps. If we perform m steps of computation, then we have computed the solutions up to time
t
m
= mk.
Let us illustrate the method through some problems.
Example 5.21 Solve the wave equation
u
tt
= u
xx
, 0 x 1, subject to the conditions
u(x, 0) = sin ( x), u
t
(x, 0) = 0, 0 x 1, u(0, t) = u(1, t) = 0, t > 0
using the explicit method with h = 1/4 and (i) k = 1/8, (ii) k = 1/4. Compute for four time steps for
(i), and two time steps for (ii). If the exact solution is u(x, t) = cos ( t) sin ( x), compare the
solutions at times t = 1/4 and t = 1/2.
Solution The explicit method is given by
u
i j , +1
= 2(1 r
2
)u
i,j
+ r
2
[u
i+1,j
+ u
i1, j
] u
i, j1
.
We are given c = 1 and h = 1/4. Hence, we have five nodes on each time level (see
Fig.5.30). We have to find the solution at three interior points.
The initial conditions give the values
(a) u
i,0
= sin (i /4), i = 0, 1, 2, 3, 4
u
0, 0
= 0, u
1, 0
= sin (/4) = (1/ 2 ) = 0.70711, u
2,0
= sin (/2) = 1,
u
3,0
= sin (3/4) = (1/ 2 ) = 0.70711, u
4,0
= sin () = 0.
(b) u
t
(x, 0) = 0 gives u
i,1
= u
i, 1
.
The boundary conditions give the values u
0, j
= 0, u
4, j
= 0, for all j.
(i) When k = 1/8, we get r =
k
h
= =
1
8
4
1
2
( ) . The method
becomes
u
i, j+1
= 2 1
1
4
1
4
1 1 1
+ +
+
u u u u
i j i j i j i j , , , ,
[ ]
= 1.5u
i, j
+ 0.25[u
i+1, j
+ u
i1, j
] u
i, j1
,
j = 0, 1, 2, 3 ; i = 1, 2, 3. (5.66)
The computations are to be done for four time
steps, that is, up to t = 1/2 or j = 0, 1, 2, 3.
t
0 0.25 0.5 0.75 1.0 x
Fig. 5.30. Example. 5.21.
296 NUMERICAL METHODS
We have the following values.
For j = 0 : Since u
t
(x, 0) = 0 we obtain u
i, 1
= u
i, 1
. The method simplifies to
u
i,1
= 0.75u
i,0
+ 0.125[u
i+1,0
+ u
i1,0
].
i = 1 : u
1,1
= 0.75u
1,0
+ 0.125(u
2,0
+ u
0,0
)
= 0.75(0.70711) + 0.125(1 + 0) = 0.65533.
i = 2 : u
2,1
= 0.75u
2,0
+ 0.125(u
3,0
+ u
1,0
)
= 0.75 + 0.125(0.70711 + 0.70711) = 0.92678.
i = 3 : u
3,1
= 0.75u
3,0
+ 0.125(u
4,0
+ u
2,0
)
= 0.75(0.70711) + 0.125(0 + 1) = 0.65533.
For j = 1: We use the formula (5.66).
i = 1 : u
1,2
= 1.5u
1,1
+ 0.25[u
2,1
+ u
0,1
] u
1,0
= 1.5(0.65533) + 0.25(0.92678 + 0) 0.70711 = 0.50758.
i = 2 : u
2,2
= 1.5 u
2,1
+ 0.25[u
3,1
+ u
1,1
] u
2,0
= 1.5(0.92678) + 0.25(0.65533 + 0.65533) 1.0 = 0.71784.
i = 3 : u
3,2
= 1.5u
3,1
+ 0.25[u
4,1
+ u
2,1
] u
3,0
= 1.5(0.65533) + 0.25(0 + 0.92678) 0.70711 = 0.50758.
For j = 2 :
i = 1 : u
1,3
= 1.5u
1,2
+ 0.25[u
2,2
+ u
0,2
] u
1,1
= 1.5(0.50758) + 0.25(0.71784 + 0) 0.65533 = 0.28550.
i = 2 : u
2,3
= 1.5u
2,2
+ 0.25[u
3,2
+ u
1,2
] u
2,1
= 1.5(0.71784) + 0.25(0.50788 + 0.50788) 0.92678 = 0.40377.
i = 3 : u
3,3
= 1.5u
3,2
+ 0.25[u
4,2
+ u
2,2
] u
3,1
= 1.5(0.50758) + 0.25(0 + 0.717835) 0.65538 = 0.28550.
For j = 3 :
i = 1 : u
1,4
= 1.5u
1,3
+ 0.25[u
2,3
+ u
0,3
] u
1,2
= 1.5(0.285499) + 0.25(0.403765 + 0) 0.50758 = 0.02161.
i = 2 : u
2,4
= 1.5u
2,3
+ 0.25[u
3,3
+ u
1,3
] u
2,2
= 1.5(0.4037625) + 0.25(2)(0.285499) 0.717835 = 0.03056.
i = 3 : u
3,4
= 1.5u
3,3
+ 0.25[u
4,3
+ u
2,3
] u
3,2
= 1.5(0.285499) + 0.25(0 + 0.40377) 0.50758 = 0.02161.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 297
(ii) When k = 1/4, h = 1/4, we get r =
k
h
= =
1
4
4 1 ( ) .The computations are to be done for two time
steps, that is, up to t = 1/2 or j = 0, 1. For r = 1, we get the method as
u u u u
i j i j i j i j , , , , + +
= +
1 1 1 1
, j = 0, 1 ; i = 1, 2, 3. (5.67)
We have the following values.
For j = 0 : u
i,1
= u
i, 1
, simplifies the method as
u
i,1
= u
i1,0
+ u
i+1,0
u
i,1
, or u
i, 1
= 0.5(u
i1,0
+ u
i+1,0
).
i = 1 : u
1,1
= 0.5(u
0,0
+ u
2,0
) = 0.5[0 + 1] = 0.5.
i = 2 : u
2,1
= 0.5(u
1,0
+ u
3,0
) = 0.5(2)(0.70711) = 0.70711.
i = 3 : u
3,1
= 0.5(u
2,0
+ u
4,0
) = 0.5(1 + 0) = 0.5.
For j = 1 : We use the formula (5.67).
i = 1 : u
1, 2
= u
0, 1
+ u
2,1
u
1,0
= 0 + 0.70711 0.70711 = 0.0
i = 2 : u
2,2
= u
1,1
+ u
3,1
u
2,0
= 0.5 + 0.5 1.0 = 0.0.
i = 3 : u
3,2
= u
2,1
+ u
4,1
u
3,0
= 0.70711 + 0 0.70711 = 0.0.
The exact solution and the magnitudes of errors are as follows:
At t = 0.25 : u(0.25, 0.25) = u(0.75, 0.25) = 0.5, u(0.5, 0.25) = 0.70711.
For r = 1/2: The magnitudes of errors are the following:
| u(0.25, 0.25) u
1,2
| = | 0.50758 0.5 | = 0.00758,
| u(0.5, 0.25) u
2,2
| = | 0.717835 0.70711 | = 0.0107,
| u(0.75, 0.25) u
3,2
| = | 0.50758 0.5 | = 0.00758.
For r = 1, we obtain the exact solution.
At t = 0.5 : u(0.25, 0.5) = u(0.75, 0.5) = u(0.5, 0.5) = 0.0.
For r = 1/2 : The magnitudes of errors are 0.02161, 0.03056, and 0.02161.
For r = 1, we obtain the exact solution.
Example 5.22 Solve u
tt
= 4u
xx
, with boundary conditions u(0, t) = 0 = u(4, t), t > 0 and the
initial conditions u
t
(x, 0) = 0, u(x, 0) = x(4 x).
(A.U., Nov/Dec 2006)
Solution We have c
2
= 4. The values of the step
lengths h and k are not prescribed. The number of
time steps up to which the computations are to be
performed is not prescribed. Therefore, let us assume
that we use an explicit method with h = 1 and
k = 0.5. Let the number of time steps up to which
the computations are to be performed be 4. Then,
we have
t
0 1.0 2.0 3.0 4.0
x
Fig. 5.31. Example 5.22.
298 NUMERICAL METHODS
r =
ck
h
=
2 0 5
1
( . )
= 1.
The explicit formula is given by (see (5.59))
u u u u
i j i j i j i j , , , , . + +
= +
1 1 1 1 , j = 0, 1, 2, 3 ; i = 1, 2, 3. (5.68)
The boundary conditions give the values u
0, j
= 0, u
4, j
= 0, for all j (see Fig. 5.31).
The initial conditions give the following values.
u(x, 0) = x(4 x), gives u
0,0
= 0, u
1,0
= u(1, 0) = 3,
u
2,0
= u(2, 0) = 4, u
3,0
= u(3, 0) = 3, u
4,0
= u(4, 0) = 0.
Central difference approximation to u
t
(x, 0) = 0 gives u
i,1
= u
i,1
.
We have the following results.
For j = 0: Since, u
i,1
= u
i,1
, the formula simplifies to u
i,1
= 0.5(u
i+1,0
+ u
i1,0
).
i = 1 : u
1,1
= 0.5(u
2,0
+ u
0,0
) = 0.5(4 + 0) = 2,
i = 2 : u
2,1
= 0.5(u
3,0
+ u
1,0
) = 0.5(3 + 3) = 3,
i = 3: u
3,1
= 0.5(u
4,0
+ u
2,0
) = 0.5(0 + 4) = 2.
These are the solutions at the interior points on the time level t = 0.5.
For j = 1: We use the formula (5.68), to give u
i,2
= u
i+1,1
+ u
i1,1
u
i, 0
.
i = 1: u
1,2
= u
2,1
+ u
0,1
u
1,0
= 3 + 0 3 = 0,
i = 2: u
2,2
= u
3,1
+ u
1,1
u
2,0
= 2 +2 4 = 0,
i = 3: u
3,2
= u
4,1
+ u
2,1
u
3,0
= 0 + 3 3 = 0.
These are the solutions at the interior points on the time level t = 1.0.
For j = 2: We use the formula (5.68), to give u
i,3
= u
i+1,2
+ u
i1,2
u
i,1
.
i = 1: u
1,3
= u
2,2
+ u
0,2
u
1,1
= 0 + 0 2 = 2,
i = 2: u
2,3
= u
3,2
+ u
1,2
u
2,1
= 0 + 0 3 = 3,
i = 3: u
3,3
= u
4,2
+ u
2,2
u
3,1
= 0 + 0 2 = 2.
These are the solutions at the interior points on the time level t = 1.5.
For j = 3: We use the formula (5.68), to give u
i,4
= u
i+1,3
+ u
i1,3
u
i,2
.
i = 1: u
1,4
= u
2,3
+ u
0,3
u
1,2
= 3 + 0 0 = 3,
i = 2: u
2,4
= u
3,3
+ u
1,3
u
2,2
= 2 2 0 = 4,
i = 3: u
3,4
= u
4,3
+ u
2,3
u
3,2
= 0 3 0 = 3.
These are the solutions at the interior points on the required fourth time level t = 2.0.
Example 5.23 Solve u
xx
= u
tt
, 0 < x < 1, t > 0, given u(x, 0) = 0, u
t
(x, 0) = 0, u(0, t) = 0 and
u(1, t) = 100 sin ( t). Compute for four time steps with h = 0.25. (A.U. Nov/Dec. 2003)
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 299
Solution We have c = 1 and h = 0.25, (see Fig. 5.30). The value of the step length k is not
prescribed. Since the method is not specified, we use an explicit method.
We assume k = 0.25 so that r = 1. The method is given by
u u u u
i j i j i j i j , , , ,
,
+ +
= +
1 1 1 1
j = 0, 1, 2, 3; i = 1, 2, 3.
The boundary conditions give the values
u
0, j
= 0, for all j, and u
4, j
= 100 sin ( jk) = 100 sin ( j/4).
That is, u
4,0
= 0, u
4, 1
= 100 sin (/4) = (100/ 2 ) = 50 2 ,
u
4,2
= 100 sin (/2) = 100,
u
4,3
= 100 sin (3/4) = (100/ 2 ) = 50 2 , u
4,4
= 100 sin () = 0.
For j = 0: Since, u
i ,1
= u
i, 1
, the formula simplifies to u
i,1
= 0.5(u
i+1,0
+ u
i1,0
).
i = 1: u
1,1
= 0.5(u
2,0
+ u
0,0
) = 0.5(0 + 0) = 0,
i = 2: u
2,1
= 0.5(u
3,0
+ u
1,0
) = 0.5(0 + 0) = 0
i = 3: u
3,1
= 0.5(u
4,0
+ u
2,0
) = 0.5(0 + 0) = 0.
These are the solutions at the interior points on the time level t = 0.25.
For j = 1: We use the formula (5.68), to give u
i,2
= u
i+1,1
+ u
i1,1
u
i,0.
i = 1: u
1,2
= u
2,1
+ u
0,1
u
1,0
= 0,
i = 2: u
2,2
= u
3,1
+ u
1,1
u
2,0
= 0,
i = 3: u
3,2
= u
4,1
+ u
2,1
u
3,0
= 50 2 + 0 0 = 50 2 .
These are the solutions at the interior points on the time level t = 0.5.
For j = 2: We use the formula (5.68), to give u
i,3
= u
i+1,2
+ u
i1,2
u
i,1
.
i = 1: u
1,3
= u
2,2
+ u
0,2
u
1,1
= 0 + 0 + 0 = 0,
i = 2: u
2,3
= u
3,2
+ u
1,2
u
2,1
= 50 2 + 0 0 = 50 2 ,
i = 3: u
3,3
= u
4,2
+ u
2,2
u
3,1
= 100 + 0 0 = 100.
These are the solutions at the interior points on the time level t = 0.75.
For j = 3: We use the formula (5.68), to give u
i,4
= u
i+1,3
+ u
i1,3
u
i,2
.
i = 1: u
1,4
= u
2,3
+ u
0,3
u
1,2
= 50 2 + 0 0 = 50 2 ,
i = 2: u
2,4
= u
3,3
+ u
1,3
u
2,2
= 100 + 0 0 = 100,
i = 3: u
3,4
= u
4,3
+ u
2,3
u
3,2
= 50 2 + 50 2 50 2 = 50 2 .
These are the solutions at the interior points on the required fourth time level t = 1.0.
300 NUMERICAL METHODS
Implicit methods
Explicit methods have the disadvantage that they have a stability condition on the mesh ratio
parameter r = (ck)/h. Explicit methods are stable for r 1.0. This condition restricts the values
that can be used for the step lengths h and k. In most practical problems, where the computa-
tion is to be done up to a large value of t, these methods are not useful because the time
consumed is too high. In such cases, we use the implicit methods. We derive the following two
implicit methods.
(i) We write the following approximations at (x
i
, t
j
).
2
2 2
2
1 u
t k
u
i j
t i j
=
,
,
. (5.69)
2
2 2
2
1 1
1
2
u
x h
u u
i j
x i j i j
= +
+
,
, ,
[ ]. (5.70)
Hence, the difference approximation to the wave equation at the node (x
i
, t
j
) is given by
1
2
2
2
2
2
2
1 1
k
u
c
h
u u
t i j x i j i j
, , ,
[ ], = +
+
or
t i j x i j i j
u
r
u u
2
2
2
1 1
2
, , ,
[ ] = +
+
(5.71)
or u u u
i j i j i j , , , +
+
1 1
2 =
r
u u
x i j x i j
2
2
1
2
1
2
[ ]
, ,
+
+
or u
r
u u u
r
u
i j x i j i j i j x i j , , , , , + +
= +
1
2
2
1 1 1
2
2
1
2
2
2
. (5.72)
where r = (kc/h). We can expand the central differences and write
x i j i j i j i j
u u u u
2
1 1 1 1 1 1
2
, , , , + + + + +
= + ,
x i j i j i j i j
u u u u
2
1 1 1 1 1 1
2
, , , , +
= + .
We get
r
u r u
r
u u
r
u r u
r
u
i j i j i j i j i j i j i j
2
1 1
2
1
2
1 1
2
1 1
2
1
2
1 1
2
1
2
2
2
1
2
+ + + + +
+ + = + + +
, , , , , , ,
( ) ( ) .
The nodal points that are used in the method are given in Fig.5.32.
i 1, j + 1
i 1, j 1
i, j 1 i + 1, j 1
i + 1, j + 1 i, j + 1
i, j
Level j
Level j + 1
Level j 1
Fig. 5.32. Nodes in implicit method (5.72).
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 301
Remark 22 Using Taylor series expansions, we can show that the truncation error of the
method given in Eq.(5.72) is O(k
4
+ k
2
h
2
). Hence, the order of the method is O(k
2
+ h
2
).
(ii) We use the approximation (5.69) for
2
2
u
t
, and the following approximation for
2
2
u
x
.
2
2 2
2
1 1
1 u
x h
u u u
i j
x i j i j i j
= +
+
,
, , ,
[ ].
The difference approximation to the wave equation at the node (x
i
, t
j
) is given by
1
2
2
2
2
2
1 1
k
u
c
h
u u u
t i j x i j i j i j
, , , ,
[ ] = +
+
or
t i j x i j i j i j
u r u u u
2 2 2
1 1 , , , ,
[ ] = +
+
(5.73)
or u u u r u u u
i j i j i j x i j x i j x i j , , , , , ,
[ ]
+ +
+ = +
1 1
2 2
1
2 2
1
2
or u r u u u r u r u
i j x i j i j i j x i j x i j , , , , , , + +
= +
1
2 2
1 1
2 2 2 2
1
2 (5.74)
where r = (kc/h). We can expand the central differences and write
x i j i j i j i j
u u u u
2
1 1 1 1 1 1
2
, , , , + + + + +
= + ,
x i j i j i j i j
u u u u
2
1 1 1 1 1 1
2
, , , , +
= + .
The nodal points that are used in the method are given in Fig.5.33.
Remark 23 Using Taylor series expansions, we can show that the truncation error of the
method given in Eq.(5.73) is again of order O(k
4
+ k
2
h
2
). Hence, the order of the method is
O(k
2
+ h
2
).
Remark 24 Implicit methods often have very strong stability properties. Stability analysis of
the above implicit methods (5.72) and (5.74) shows that the methods are stable for all values
of the mesh ratio parameter
r
. Hence, the methods are unconditionally stable. This implies
that there is no restriction on the values of the mesh lengths h and k. Depending on the
particular problem that is being solved, we may use sufficiently large values of the step lengths.
i 1, j + 1
i 1, j
i 1, j 1 i, j 1 i + 1, j 1
i + 1, j
i + 1, j + 1 i, j + 1
i, j
Level j + 1
Level j
Level j 1
Fig. 5.33. Nodes in implicit method (5.74).
302 NUMERICAL METHODS
Computational procedure
The initial condition u(x, 0) = f(x) gives the solution at all the nodal points on the initial line
(level 0). The boundary conditions u(0, t) = g(t), u(l, t) = h(t), t > 0 give the solutions at all the
nodal points on the lines x = 0 and x = l for all time levels. We choose the values for k and h.
This gives the value of the mesh ratio parameter r. Alternately, we may choose the values for
r and h.
On level 1, we use the same approximation as in the case of the explicit method, that is, we
approximate
u
i,1
= u
i,1
2kg(x
i
).
Now, we apply the finite difference method (5.72) or (5.74) on level 1.
For example, consider the method given in (5.72). We obtain for j = 0,
u
r
u u u
r
u
i x i i i x i , , , , , 1
2
2
1 0 1
2
2
1
2
2
2
= +
or u
i,1
r
u u u kg
r
u kg
x i i i i x i i
2
2
1 0 1
2
2
1
2
2 2
2
2
, , , ,
( ) ( ) = +
or 2 2 2 2 2
1
2
1 1 1 1 1 0
2
1 1
u r u u u u kg kr g g g
i i i i i i i i i , , , , ,
( ) ( ). + = + +
+ +
(5.75)
If the initial condition is, u
t
(x, 0) = 0, then the method simplifies as
r u r u r u u
i i i i
2
1 1
2
1
2
1 1 0
2 1 2
+
+ + =
, , , ,
( ) . (5.76)
The right hand side in (5.75) or (5.76) is computed. For i = 1, 2,, M 1, we obtain a
system of equations for u
1,1
, u
2,1
, ..., u
M1, 1
. This system of equations is solved to obtain the
values at all the nodal points on the time level 1. For j > 0, we use the method (5.72) or (5.74)
and solve a system of equations on each mesh line. The computations are repeated for the
required number of steps. If we perform m steps of computation, then we have computed the
solutions up to time t
m
= mk.
Remark 25 Do you recognize the system of equations that is obtained on each time level?
Again, it is a tri-diagonal system of equations. It uses the three consecutive unknowns u
i1
,
j+1
,
u
i, j+1
and u
i+1, j+1
on the current time level j + 1.
Let us illustrate the application of the methods.
Example 5.24 Solve the wave equation
u
tt
= u
xx
, 0 x 1, subject to the conditions
u(x, 0) = sin( x), u
t
(x, 0) = 0, 0 x 1, u(0, t) = u(1, t) = 0, t > 0.
Use an implicit method with h = 1/4 and k = 1/4. Compute for two time levels.
Solution We have
c = 1, h =
1
4
, k =
1
4
, r =
kc
h h
=
1
(4) = 1. (Fig.5.34).
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 303
For r = 1, we have the method (5.72) as
u u u u u
i j x i j i j i j x i j , , , , , + +
= +
1
2
1 1
2
1
1
2
2
1
2
or u u u u u u u u u
i j i j i j i j i j i j i j i j i j , , , , , , , , ,
( ) ( )
+ + + + + +
+ = + +
1 1 1 1 1 1 1 1 1 1 1 1
1
2
2 2
1
2
2
or + = + +
+ + + + +
0 5 2 0 5 2 2 0 5
1 1 1 1 1 1 1 1 1 1
. . . ( )
, , , , , , ,
u u u u u u u
i j i j i j i j i j i j i j
j = 0,1 ; i = 1, 2, 3.
The boundary conditions give the values u
0, j
= 0 = u
4, j
for all j.
The initial condition u(x, 0) = sin ( x), gives the values
u
0,0
= 0, u
1,0
= sin(/4) = (1/ 2 ),
u
2,0
= sin(/2) = 1,
u
3,0
= sin(3/4) = (1/ 2 ), u
4,0
= 0.
The initial condition u
t
(x, 0) = 0, gives the values
u
i,1
= u
i,1.
Therefore, for j = 0, we get the equation
0.5u
i1,1
+ 2u
i,1
0.5u
i+1,1
= 2u
i,0
2u
i,1
+ 0.5(u
i1,1
+ u
i+1,1
)
or u
i1,1
+ 4u
i,1
u
i+1,1
= 2u
i,0
.
We have the following equations for j = 0.
i = 1: u
0,1
+ 4u
1,1
u
2,1
= 2u
1,0
or 4u
1,1
u
2,1
= 2
1
2
2
= = 1.41421.
i = 2: u
1,1
+ 4u
2,1
u
3,1
= 2u
2,0
= 2.
i = 3: u
2,1
+ 4u
3,1
u
4,1
= 2u
3,0
or u
2,1
+ 4u
3,1
= 2
1
2
2
= = 1.41421.
Subtracting the first and third equations, we get 4u
1,1
4u
3,1
= 0. Hence, u
1,1
= u
3,1
.
Therefore, we have the equations
4u
1,1
u
2,1
= 1.41421, and 2u
1,1
+ 4u
2,1
= 2.
The solution is given by
u
1,1
=
7 65684
14
054692
10 82842
14
077346
3 1 2 1
.
. ,
.
. .
, ,
= = = = u u
t
0 1/4 2/4 3/4 1.0
x
Fig. 5.34. Example. 5.24.
304 NUMERICAL METHODS
For j > 0, we use the method (5.72).
u
r
u u u
r
u
i j x i j i j i j x i j , , , , , + +
= +
1
2
2
1 1
2
2
1
2
2
2
or u
r
u u u
i j i j i j i j , , , ,
( )
+ + + + +
+
1
2
1 1 1 1 1
2
2
= 2
2
2
1
2
1 1 1 1 1
u u
r
u u u
i j i j i j i j i j , , , , ,
( ) + +
+
.
For j = 1, we get (with r = 1)
i = 1: 0.5u
0,2
+ 2u
1,2
0.5u
2,2
= 2u
1,1
2u
1,0
+ 0.5(u
2,0
+ u
0,0
)
or 2u
1,2
0.5u
2,2
= 2(0.54692) 2(0.70711) + 0.5(1.0 + 0) + 0.5(0) = 0.17962.
i = 2: 0.5u
1,2
+ 2u
2,2
0.5u
3,2
= 2u
2,1
2u
2,0
+ 0.5(u
3,0
+ u
1,0
)
= 2(0.77364) 2(1) + 0.5(2)(0.70711) = 0.25403.
i = 3: 0.5u
2,2
+ 2u
3,2
0.5u
4,2
= 2u
3,1
2u
3,0
+ 0.5(u
4,0
+ u
2,0
)
or 0.5u
2,2
+ 2u
3,2
= 2(0.54692)
2(0.70711) + 0.5(0 + 1.0) + 0.5(0) = 0.17962.
Subtracting the first and third equations, we get 2u
1,2
2u
3,2
= 0. Hence, u
1,2
= u
3,2
.
Therefore, we have the equations
2u
1,2
0.5u
2,2
= 0.17962, and u
1,2
+ 2u
2,2
= 0.25403.
The solution is given by
u
1,2
=
0 486255
35
013893
0 68768
35
3 2 2 2
.
.
. ,
.
.
, ,
= = = u u = 0.19648.
REVIEW QUESTIONS
1. Write the one dimensional wave equation governing the vibrations of an elastic string.
Solution The one dimensional wave equation governing the vibrations of an elastic
string is given by
u
tt
= c
2
u
xx
, 0 x l, t > 0.
where c
2
depends on the material properties of the string, the tension T in the string
and the mass per unit length of the string.
2. Write an explicit method for solving the one dimensional wave equation
u
tt
= c
2
u
xx
, 0 x l, t > 0.
Solution An explicit method for solving the one dimensional wave equation is given
by
u r u r u u u j i
i j i j i j i j i j , , , , ,
( ) [ ] , , , , ..., , , , ...
+ +
= + + = =
1
2 2
1 1 1
2 1 0 1 2 1 2 3
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 305
where r = (kc)/h, and h and k are step lengths in the x direction and t directions
respectively.
3. What is the order and truncation error of the method given in Problem 2?
Solution The order of the method is O(k
2
+ h
2
). The truncation error is given by
T.E. =
k h c
r
u
x
2 2 2
2
4
4
12
1 ( ) ... +
.
4. Write an explicit method for solving the one dimensional wave equation
u
tt
= c
2
u
xx
, 0 x l, t > 0
when r = [(kc)/h] = 1.
Solution The method is given by
u u u u
i j i j i j i j , , , , + +
= +
1 1 1 1
.
5. For what values of r = [(kc)/h] is the explicit method for the one dimensional wave
equation stable?
Solution The explicit method is stable for r 1.
6. For what values of , the explicit method for solving the hyperbolic equation
2
2 2
2
2
1 u
x c
u
t
= is stable, where =
c t
x
4 1 1 0
1 4 0 1
1 0 4 1
0 1 1 4
1
2
3
4
, u
u
u
u
u
and
i
b , i = 1, 2, 3, 4 are obtained from boundary conditions. In
Problems 1 to 9, we have solved the systems by Gauss elimina-
tion method.
1. b = [4/3, 0, 0, 4/3]
T
, u
1
= 1/3, u
2
= 0, u
3
= 0, u
4
= 1/3.
2. b = [1, 7, 3, 11]
T
, u
1
= 1, u
2
= 3, u
3
= 2, u
4
= 4.
3. b = [ 600, 1000, 200, 600]
T
, u
1
= 300, u
2
= 400, u
3
= 200, u
4
= 300. (By symmetry
we can start by setting u
1
= u
4
).
4. b = [ 3, 12, 0, 3]
T
, u
1
= 2, u
2
= 4, u
3
= 1, u
4
= 2. (By symmetry we can start by setting
u
1
= u
4
).
5. b = [ 2, 9, 1, 6]
T
, u
1
= 5/3, u
2
= 10/3, u
3
= 4/3, u
4
= 8/3.
6. b = [4/3, 0, 0, 4/3]
T
, u
1
= 1/3, u
2
= 0, u
3
= 0, u
4
= 1/3. (By symmetry we can start by
setting u
2
= u
3
).
7. b = [ 10/9, 22/9, 2/9, 10/9]
T
, u
1
= 5/9, u
2
= 8/9, u
3
= 2/9, u
4
= 5/9.
8. b = [43/27, 10/27, 5/27, 28/27]
T
, u
1
= 101/216, u
2
= 35/216, u
3
= 25/216, u
4
= 41/
216.
9. b = [5, 8, 2, 5]
T
, u
1
= 5/2, u
2
= 13/4, u
3
= 7/4, u
4
= 5/2. (By symmetry we can start
by setting u
1
= u
4
).
10. We obtain the initial approximation u
1
0 ( )
using the five point diagonal formula and , 0
4
= u
whereas u u u
2
0
3
0
4
0 ( ) ( ) ( )
, , are obtained by the standard five point formula, unless stated
other wise.
(i) 0, 1.75, 1.1875, 3.48438; 0.48438, 2.74219, 1.74219, 3.87110; 0.87110, 2.93555,
1.93555, 3.96778; 0.96778, 2.98389, 1.98389, 3.99195; 0.99195, 2.99598, 1.99598,
3.99799.
(ii) 225.0, 306.25, 106.25, 253.125; 253.125, 376.5625, 176.5625, 288.28125; 288.28125,
394.14063, 194.14063, 297.70315; 297.70315, 398.69337, 198.85158, 299.38624;
299.38624, 399.69312, 199.69312, 299.84656.
(iii) 1.5, 3.375, 0.375, 1.6875; 1.6875, 3.84375, 0.84375, 0.42188; 1.92188, 3.58594, 0.58594,
0.29297; 1.79297, 3.52149, 0.52149, 0.26074; 1.76075, 3.50537, 0.50537, 0.25269.
(iv) 0.41667, 0.10417, 0.10417, 0.28125; 0.45023, 0.13484, 0.08854, 0.20341;
0.45399, 0.15524, 0.10894, 0.19321; 0.46419, 0.16034, 0.11404, 0.19066;
0.46674, 0.16161, 0.11532, 0.19003.
(v) Set all initial approximations as zeros. 1.25, 2.3125, 0.8125, 2.03125; 2.03125,
3.01563, 1.51563, 2.38282; 2.38282, 3.19141, 1.69141, 2.47071; 2.47071,
3.23535, 1.73537, 2.49268. (If we use symmetry, that is, u
1
= u
4
, we get the
fourth iteration as 2.48047, 3.24024, 1.74024).
u
1
u
2
u
3
u
4
Fig. 5.35. Example 5.3.
BOUNDARY VALUE PROBLEMS IN ORDINARY DIFFERENTIAL EQUATIONS... 309
Exercise 5.4
1. 0.09668, 0.13672, 0.09668. 2. 0.12095, 0.17053, 0.12095.
3. 0.125, 0.25, 0.125.
4. (i) 0, 0, 0; (ii) 0.0625, 0, 0.0625; (iii) 0.08779, 0, 0.08779.
5. The given data is discontinuous. The effect of the singularities at (0, 0), (5, 0) is propagated
into the interior when we use finite difference methods. Such problems require special
techniques to deal with singularities. In the present problem, if we take the initial
conditions valid at (0, 0) and (5, 0), that is, u
0, 0
= 20, u
5,0
= 20, we obtain the solutions as
15.0239, 20.0957, 25.3588, 41.3397.
6. 0.7328, | | = 0.0114. 7. 2.2345, 3.8069.
8. 1/9, 0, 1/9; 1/81, 0, 1/81; |
1
| = |
3
| = 0.00695, |
2
| = 0.
9. 0.749665, 0.499943, 0.24999; 0.748856, 0.499723, 0.249941.
10. 0.740683, 1.332299, 0.740683; 0.716668, 1.198160, 0.716668.
Exercise 5.5
1. 0.5, 0.70711, 0.5; 0, 0, 0; 0.5, 0.70711, 0.5.
2. Use explicit method. Assume h = 0.25. 10.1775, 10.24, 10.1775; 8.5491, 10.21, 8.5491;
5.8186, 9.6485, 5.8186; 2.7699, 7.8614, 2.7699; 0.0927, 4.4450, 0.0927.
3. Use explicit method. 0, 0, 0; 1, 0, 1; 0, 0, 0.
4. Use explicit method. Since k is not prescribed, choose k = h such that r = 1. 12.5, 18.75,
12.5.
5. Use explicit method. Period of vibration = [(2l /c)] = 2. Computations are to be done up
to t = 1. Since k is not prescribed, choose k = 0.2 such that r = (k/h) = 1.
0.12, 0.20, 0.20, 0.12; 0.04, 0.08, 0.08, 0.04; 0.04, 0.08, 0.08, 0.04; 0.12, 0.20,
0.20, 0.12; 0.16, 0.24, 0.24, 0.16.
6. Use explicit method. Since k is not prescribed, choose k such that r = (k/h) = 1.
0, 0, 0; 0, 0, 50 2 ; 0, 50 2 , 100; 50 2 , 100, 50 2 .
7. The given data is discontinuous. The effect of the singularity at x = 1/2 is propagated
into the interior when we use finite difference methods. Such problems require special
techniques to deal with singularities. Use explicit method. Since k is not prescribed,
choose k such that r = (k/h) = 1; 1, 1, 1, 1, 0, 0, 1, 1, 1; 0, 1, 1, 0, 0, 0, 0, 1, 0; 0, 0,
0, 0, 0, 0, 0, 1, 0.
8. Use explicit method. Since k is not prescribed, choose k such that r = (k/h) = 1.
0.5, ) 2 2 /( 1 , 0.5; 0, 0, 0; 0.5, ) 2 2 /( 1 , 0.5; ) 2 2 /( 1 , 1, ) 2 2 /( 1 .
9. 0.5, 0, 0.5; 0.5, 0, 0.5.
10. 15.17857, 20.53571, 15.17857; 5.86734, 8.67346, 5.86734.
This page
intentionally left
blank
311
*E>ECH=FDO
The following is a brief list of texts on numerical methods. There are various other texts which
are not reported here.
1. Atkinson, K., Elementary Numerical Analysis, Wiley, New York, 1985.
2. Burden, R.L., and J.D. Faires, Numerical Analysis, 4th edition, PWS-Kent, 1989.
3. Butcher, J.C., The Numerical Analysis of Ordinary Differential Equations: Runge-Kutta
and General Linear Methods, Wiley, New York, 1987.
4. Collatz. L., Numerical Treatment of Differential Equations, 3rd edition, Springer Verlag,
Berlin, 1966.
5. Conte, S.D., and C. deBoor, Elementary Numerical Analysis: An Algorithmic Approach,
3rd edition, McGraw-Hill, New York, 1980.
6. Dahlquist, G., and A. Bjorck, Numerical Methods, Prentice Hall, Englewood Cliffs, N.J,
1974.
7. David Kincaid and W. Cheney, Numerical Analysis, Brooks/ Cole, Calif., 1991.
8. Ferziger, J.H., Numerical Methods for Engineering Application, John Wiley, New York,
1981.
9. Fox, L., Numerical Solution of Ordinary and Partial Differential Equations, Pergamon,
London, 1962.
10. Froberg, C.E., Introduction to Numerical Analysis, Addison-Wesley, Reading, Mass.,
1969.
11. Gear, C.W., Numerical Initial Value Problems in Ordinary Differential Equations,
Prentice-Hall, Englewood Cliffs, N.J., 1971.
12. Gerald, C.F., and P.O. Wheatley, Applied Numerical Analysis, 4th Ed., Addison-Wesley,
Reading, Mass., 1989.
13. Henrici, P., Elements of Numerical Analysis, John Wiley, New York, 1964.
14. Householder, A.S., Principles of Numerical Analysis, McGraw-Hill, New York, 1953.
15. Issacson, E., and H.B. Keller, Analysis of Numerical Methods, John Wiley, New York,
1966.
16. Jain, M.K., Numerical Solution of Differential Equations, 2nd ed., Wiley Eastern Ltd.,
New Delhi, 1984.
17. Jain, M.K., S.R.K. Iyengar., and R.K. Jain, Numerical Methods for Scientific and
Engineering Computation, Sixth Edition, New Age International Publishers, (Formerly
Wiley Eastern Limited), New Delhi, 2008.
312 NUMERICAL METHODS
18. Johnson, L.W., and R.D. Riess., Numerical Analysis, 2nd ed., Addison-Wesley, Read-
ing, Mass., 1982.
19. Lambert, J.D., Computational Methods in Ordinary Differential Equations, John Wiley,
New York, 1973.
20. Lapidus, L., and J. Seinfeld, Numerical Solution of Ordinary Differential Equations,
Academic Press, New York, 1971.
21. Ralston, A., and P. Rabinowitz, A first course in Numerical Analysis, 2nd ed., McGraw-
Hill, New York, 1978.
22. Scheid, F., Numerical Analysis, McGraw-Hill, New York, 1988.
23. Todd, J., Survey of Numerical Analysis, McGraw-Hill, New York, 1962.
313
1@AN
)
abscissas, 128
Adams-Bashforth methods, 217
Adams-Bashforth predictor corrector methods, 227
Adams-Moulton methods, 221
algebraic equation, 1
amplification factor, 238
agumented matrix, 25
*
back substitution method, 27
backward Euler method, 193
Bender-Schmidt method, 277
boundary conditions
Dirichlet, 252
first kind, 242
mixed kind, 242
second kind, 242
third kind, 242
C
characteristic equation, 52
chord method, 6, 11
complete pivoting, 29
condition of convergence, 16
consistent system of equations, 26
convergence of iteration methods, 19
corrector methods, 221
Cotes numbers, 129
Crank-Nicolson method, 283
cubic splines, 99
,
Descartes rule of signs, 4
diagonal system of equations, 26
diagonally dominant, 42, 47
diagonal five point formula, 256, 257
direct methods, 2, 26
Dirichlet boundary value problem, 252
discretization, 253
divided differences, 70
double integration, 169
-
eigen value problem, 52
eigen vector, 53
elementary column transformation, 27
elementary row transformation, 27
error of approximation, 63
error tolerance, 3, 41
Euler method, 185
Euler-Cauchy method, 194
explicit methods, 183, 276, 291
extrapolation, 186
.
finite differences, 80
backward difference operator, 81
314 NUMERICAL METHODS
central difference operator, 83
derivative operator, 87
forward difference operator, 80
mean operator, 85
shift operator, 80
finite difference method, 242, 252
fixed point iteration method, 15
G
Gauss elimination method, 28
Gauss-Jacobi iteration method, 41
Gauss-Jordan method, 35
Gauss-Seidel iteration method, 46
general iteration method, 15
grid points, 182
H
heat equation, 275
Heuns method, 194
1
implicit methods, 183, 275, 282, 301
inconsistent system of equations, 26
initial approximation, 3
initial boundary value problem, 251, 275
initial conditions, 180, 275
initial point, 180
initial value problem, 180
intermediate value theorem, 4
interpolating conditions, 63
interpolating polynomial, 63
inverse interpolation, 76
iteration function, 3, 15
iterative methods, 3, 26, 41, 263
J
Jacobi method, 41
L
Lagrange fundamental polynomials, 65
Lagrange interpolating polynomial, 65
Laplace equation, 252
Liebmann iteration, 263
linear interpolation method, 6
M
mesh points, 182
mesh ratio parameter, 276, 292
method of false position, 6
method of simultaneous displacement, 42
method of successive approximation, 15
mid-point method, 193
Milnes predictor-corrector method, 227
Milne-Simpson method, 225
modified Euler method, 193
multi step methods, 183, 216
multiple root, 2