Professional Documents
Culture Documents
VI SEMESTER
CORE COURSE
B Sc MATHEMATICS
(2011 Admission)
UNIVERSITY OF CALICUT
SCHOOL OF DISTANCE EDUCATION
Calicut university P.O, Malappuram Kerala, India 673 635.
359
UNIVERSITY OF CALICUT
SCHOOL OF DISTANCE EDUCATION
STUDY MATERIAL
Core Course
B Sc Mathematics
VI Semester
NUMERICAL METHODS
Prepared by:
Sri.Nandakumar M.,
Assistant Prof essor
Dept. of Mathematics,
N.A.M. Coll ege, Kal likkandy.
Kannur.
Scrutinized by:
Layout:
Reserved
Numerical Methods
Page 2
Contents
MODULE I
MODULE II
18
32
51
Numerical Interpolation
71
87
100
Interpolation by Iteration
114
Numerical Differentiaton
119
10 Numerical Integration
11
MODULE III
MODULE IV
Numerical Methods
Page No.
128
140
12 Solution by Iterations
161
13 Eigen Values
169
179
187
16 Euler Methods
195
203
214
Page 3
SYLLABUS
B.Sc. DEGREE PROGRAMME
MATHEMATICS
M M 6B11 : NUMERICAL METHODS
4 credits
30 weightage
Text :
S.S. Sastry : Introductory Methods of Numerical Analysis, Fourth Edition, PHI.
Module I : Solution of Algebraic and Transcendental Equation
2.1
Introduction
2.2
Bisection Method
2.3
2.4
Iteration method
2.5
Newton-Raphson Method
2.6
Ramanujan's method
2.7
Finite Differences
3.1
Introduction
Differences of a polynomial
Module II : Interpolation
3.6
3.7
Page 4
3.11
Inverse interpolation
Introduction
5.2
5.4
Numerical Integration
6.5
Introduction
7.2
7.3
7.4
Euler's method
Runge-Kutta method
7.6
Predictor-Corrector Methods
S. Sankara Rao : Numerical Methods of Scientists and Engineer, 3rd ed., PHI.
2.
3.
Numerical Methods
Page 5
1
FIXED POINT ITERATION METHOD
Nature of numerical problems
Solving mathematical equations is an important requirement for various branches of
science. The field of numerical analysis explores the techniques that give approximate
solutions to such problems with the desired accuracy.
Computer based solutions
The major steps involved to solve a given problem using a computer are:
1. Modeling: Setting up a mathematical model, i.e., formulating the problem in
mathematical terms, taking into account the type of computer one wants to use.
2. Choosing an appropriate numerical method (algorithm) together with a preliminary
procedures to be performed by the computer and then writing, say, a C++ program.
4. Operation or computer execution.
5. Interpretation of results, which may include decisions to rerun if further data are
needed.
Errors
Numerically computed solutions are subject to certain errors. Mainly there are three
types of errors. They are inherent errors, truncation errors and errors due to rounding.
1. Inherent errors or experimental errors arise due to the assumptions made in the
mathematical modeling of problem. It can also arise when the data is obtained from
certain physical measurements of the parameters of the problem. i.e., errors arising
from measurements.
2. Truncation errors are those errors corresponding to the fact that a finite (or infinite)
sequence of computational steps necessary to produce an exact result is truncated
prematurely after a certain number of steps.
3. Round of errors are errors arising from the process of rounding off during
computation. These are also called chopping, i.e. discarding all decimals from some
decimals on.
Numerical Methods
Page 6
Error
Truevalue
2 1 .4142 Error .
0.00001
1.4142
We note that
r ~
a
We may also introduce the quantity = a a~ = and call it the correction, thus, a = a~
+ , i.e.
True value = Approximate value + Correction.
Error bound for a~ is a number such that a~ a i.e., .
Number representations
Integer representation
Numerical Methods
Page 7
0.1714 E 13
0.2000 E01
0.1714 13
0.2000 +01
Significant digits
Significant digit of a number c is any given digit of c, except possibly for zeros to the
left of the first nonzero digit that serve only to fix the position of the decimal point. (Thus,
any other zero is a significant digit of c). For example, each of the number 1360, 1.360,
0.01360 has 4 significant digits.
Round off rule to discard the k + 1th and all subsequent decimals
(a) Rounding down If the number at (k + 1)th decimal to be discarded is less than half a
unit in the k th place, leave the k th decimal unchanged. For example, rounding of 8.43
to 1 decimal gives 8.4 and rounding of 6.281 to 2 decimal places gives 6.28.
(b) Rounding up If the number at (k + 1)th decimal to be discarded is greater than half a
unit in the k th place, add 1 to the k th decimal. For example, rounding of 8.48 to 1
decimal gives 8.5 and rounding of 6.277 to 2 decimals gives 6.28.
(c) If it is exactly half a unit, round off to the nearest even decimal. For example, rounding
off 8.45 and 8.55 to 1 decimal gives 8.4 and 8.6 respectively. Rounding off 6.265 and
6.275 to 2 decimals gives 6.26 and 6.28 respectively.
Exa mp le Find the roots of the following equations using 4 significant figures in the
calculation.
(a) x2 4x + 2 = 0
Numerical Methods
and
(b) x2 40x + 2 = 0.
Page 8
Solution
A formula for the roots x1, x2 of a quadratic equation ax2 + bx + c = 0 is
(i)
x1
1
( b b 2 4 ac ) and
2a
x2
1
( b b 2 4ac ) .
2a
x1
1
(b b2 4ac ) , and
2a
x2
c
ax1
2 = 2 + 1.414 = 3.414,
2 = 2 1.414 = 0.586
Numerical Methods
Page 9
Remainder
0.5 2
40
20
10
1.0
81
Integer
part
Product
Page 10
as the roots of the equation f(x) = 0, or the zeroes of the function f (x). The roots of
equations may be real or complex.
In general, an equation may have any number of (real) roots, or no roots at all. For
example, sin x x = 0 has a single root, namely, x = 0, whereas tan x x = 0 has infinite
number of roots (x = 0, 4.493, 7.725, ).
Algebraic and Transcendental Equations
f(x) = 0 is called an algebraic equation if the corresponding f ( x) is a polynomial. An
example is 7x2 + x - 8 = 0. f ( x) 0 is called transcendental equation if the f ( x) contains
trigonometric, or exponential or logarithmic functions. Examples of transcendental
equations are sin x x = 0, tan x x 0 and 7 x 3 log(3 x 6) 3e x cos x tan x 0.
There are two types of methods available to find the roots of algebraic and
transcendental equations of the form f (x) = 0.
1. Direct Methods: Direct methods give the exact value of the roots in a finite number of
steps. We assume here that there are no round off errors. Direct methods determine all the
roots at the same time.
2. Indirect or Iterative Methods: Indirect or iterative methods are based on the concept of
successive approximations. The general procedure is to start with one or more initial
approximation to the root and obtain a sequence of iterates xk which in the limit
converges to the actual or true solution to the root. Indirect or iterative methods
determine one or two roots at a time. The indirect or iterative methods are further
divided into two categories: bracketing and open methods. The bracketing methods
require the limits between which the root lies, whereas the open methods require the
initial estimation of the solution. Bisection and False position methods are two known
examples of the bracketing methods. Among the open methods, the Newton-Raphson is
most commonly used. The most popular method for solving a non-linear equation is the
Newton-Raphson method and this method has a high rate of convergence to a solution.
In this chapter and in the coming chapters, we present the following indirect or iterative
methods with illustrative examples:
1. Fixed Point Iteration Method
2. Bisection Method
3. Method of False Position (Regula Falsi Method)
4. Newton-Raphson Method (Newtons method)
Numerical Methods
Page 11
f ( x) 0
x ( x).
Take an arbitrary x0 and then compute a sequence x1, x2, x3, . . . recursively from a
relation of the form
xn 1 ( xn )
(n 0, 1, )
(3)
To a given equation (1) there may
correspond several equations (2) and the behaviour, especially, as regards speed of
convergence of iterative sequences x0, x1, x2, x3, . . . may differ accordingly.
Example Solve f ( x) x 2 3x 1 0, by fixed point iteration method.
Solution
Write the given equation as
or
x 2 3x 1
x 3 1/ x .
Choose ( x) 3 1 . Then ( x)
x
1
and ( x) 1 on the interval (1, 2).
x2
(n = 0, 1, 2, . . . )
Page 12
xn1 (xn)
(n 0, 1, )
1
x 1
Take
1 . Then
( x) 1
2
x 1
( x)
1
3
( x 1) 2
Choose ( x) 3 1 . Then ( x)
x
1
and ( x) 1 on the interval (1, 2).
x2
xn 1
x n 1 1/ x n 1
1.3228756 0.7559289
At this stage,
| xn 1 xn | 0.7549263 0.7546517 0.0002746,
which is less than 0.0004. The iteration is therefore terminated and the root to the
required accuracy is 0.7549.
Example Use the method of iteration to find a positive root, between 0 and 1, of the
equation xe x 1.
Writing the equation in the form
x e x
Numerical Methods
Page 13
1
e xn
(n 0, 1, )
x3 0.5004735,
x 4 0.6062435,
x5 0.5453957,
x6 0.5796123,
so that
1 (cos x 3),
2
and
| ( x ) |
sin x
1.
2
Hence the iteration method can be applied to the eq. (3) and we start with x0 / 2. The
successive iterates are
x1 1.5,
x2 1.535,
x3 1.518,
Numerical Methods
Page 14
x3 + x 1 = 0 can be written as x x 2 1 1 , or x
1
.
x 1
2
Note that
( x)
2| x|
1 x
2 2
so by the Theorem we can expect a solution for any real number x0 as the starting point.
Choosing x0 = 1, and undergoing calculations in the iterative formula
xn1 (xn )
1
2
1 xn
(n = 0, 1, . . .),
(4)
x1=0.500,
x2=0.800,
x4= 0.729,
x5=0.653,
x6=0.701, ...
x3 =0.610 ,
x2 0.93215560685805
x3 0.92944074461587 ;
x4 0.92881472066057
When ( x)
sin x
, we have:
x2
x1 0.84147098480790;
x2 1.05303224555943
x3 0.78361086350974 ;
x4 1.14949345383611
Numerical Methods
Page 15
sin x
, the iteration doesnt converge.
x2
x2 0.99127188988250
x3 0.85395152069647 ;
x4 0.98510419085185
When ( x) x
sin x x3
, we have:
cos x 3x 2
x1 0.93554939065467;
x2 0.92989141894368
x3 0.92886679103170 ;
x4 0.92867234089417
x 1 ( x ) x x 3 4 x 2 10,
x 2 ( x )
10
4x,
x
1
10 x 3
2
10
x 4 ( x )
4 x
x 3 ( x )
x 3 4 x 2 10
x 5 ( x ) x
3x2 8x
For x 1 ( x) x x3 4 x 2 10, numerical results are:
x0 1.5;
x2 0.875
x3 6.732;
x4 469.7
x0 1.5;
10
4 x , numerical results are:
x
x2 0.8165
x3 2.9969; x4 (8.65)1/ 2
Numerical Methods
;
Page 16
For x 3 ( x)
1
10 x3 , numerical results are:
2
x0 1.5;
x2 1.2869
x3 1.4025;
x4 1.3454
Exercises
Solve the following equations by iteration method:
sin x
x 1
x 1
x4 = x + 0.15
3 x cos x 2 0
x 3 5 x 3 0,
x3 x 1 0
x 1 x 3
6
3 x 6 log10 x
x 1 x 3
5
2 x log10 x 7
x3 2 x 2 10 x 20
2sin x x
cos x 3 x 1
3 x sin x e x
x3 x 2 100
Numerical Methods
Page 17
2
BISECTION AND REGULA FALSI METHODS
B isectio n Met ho d
The bisection method is one of the bracketing methods for finding roots of an equation.
For a given a function f(x), guess an interval which might contain a root and perform a
number of iterations, where, in each iteration the interval containing the root is get halved.
The bisection method is based on the intermediate value theorem for continuous
functions.
Intermediate
value
continuous functions:
continuous function and
theorem
for
If f
is a
f (a) and f (b)
between a and b.
Algorithm : Bisection Method
Suppose we want to find the solution to the equation f ( x) 0 , where f is continuous.
Given a function f ( x) continuous on an interval [a0 , b0] and satisfying f ( a0 ) f (b0 ) 0.
For n = 0, 1, 2, until termination do:
Compute
1
xn (an bn ) .
2
Page 18
Else continue.
If f ( an ) f ( xn ) 0 , a root lies in the interval ( an , xn ) .
Set an 1 an , bn 1 xn .
If f ( an ) f ( xn ) 0, a root lies in the interval ( xn , bn ) .
Set an 1 xn , bn 1 bn .
Then f ( x) 0 for some x in [ an 1 , bn 1 ] .
Test for termination.
Criterion for termination
A convenient criterion is to compute the percentage error r defined by
r
xr xr
100%.
xr
where xr is the new value of xr . The computations can be terminated when r becomes
less than a prescribed tolerance, say p . In addition, the maximum number of iterations
may also be specified in advance.
Some other termination criteria are as follows:
In this chapter our criterion for termination is terminate the iteration process after
some finite steps. However, we note that this is generally not advisable, as the steps may
not be sufficient to get an approximate solution.
Example Solve x3 9x+1 = 0 for the root between x = 2 and x = 4, by bisection method.
Given f ( x) x 3 9 x 1 . Now f (2) 9, f (4) 29 so that f (2) f (4) 0 and hence a root lies
between 2 and 4.
Set a0 = 2 and b0 = 4. Then
Numerical Methods
Page 19
x0
(a0 b0 )
2
2 4 3 and
2
f ( x0 ) f (3) 1 .
Since f (2) f (3) 0 , a root lies between 2 and 3, hence we set a1 = a0 = 2 and b1 x0 3 . Then
x1
(a1 b1 ) 2 3
Since f (2) f (2.5) 0, a root lies between 2.5 and 3, hence we set a2 x1 2.5 and b2 b1 3 .
Then x2
(a2 b2 ) 2.5 3
xn
f ( xn )
1.0000
2.5
5.875
2.75
2.875
2.9375
2.9531
1.1113
0.0901
Numerical Methods
Page 20
x5 1.328125, etc.
Example Find a positive root of the equation xe x 1, which lies between 0 and 1.
Let f ( x ) xe x 1. Since f (0) 1 and f (1) 1.718, it follows that a root lies between 0 and 1.
Thus,
x0 0 1 0.5 .
2
Since f (0.5) is negative, it follows that a root lies between 0.5 and 1. Hence the new root is
0.75, i.e.,
x1 .5 1 0.75.
2
x2
.5 .75
0.625
2
x3
.5 .625
0.5625.
2
Numerical Methods
Page 21
2. x3 1.2 x 2 4 x 48
3. e x 3x
4. x3 4 x 9 0
5. x3 3 x 1 0
6. 3 x cos x 1
7. x3 x 2 1 0
8. 2 x 3 cos x
9. x 4 3
10. x3 5x = 6
11. cos x x
12. x 3 x 2 x 3 0,
Numerical Methods
Page 22
Algorithm:
f ( a0 ) f (b0 ) 0.
xn
an
f (an )
bn
f (bn )
f (bn ) f (an )
Numerical Methods
Page 23
theorem a root lies in between 0 and 1. We search for that root by regula falsi method and
we will get an approximate root.
Set a0 = 0 and b0 = 1. Then
a0
b0
f b 01 11 0.5
f b f a 1 1
f a0
x0
and
f ( x0 ) f (0.5) 0.375 .
Since f (0) f (0.5) 0 , a root lies between 0.5 and 1. Set a1 x0 0.5 and b1 b0 1 .
Then
a1
b1
0.5 1
f b
0.375 1
x
0.6364
f b f a 1 0.375
f a1
a2
x2
b2
1
f b 0.6364
0.1058 1
0.6712
f b f a 1 0.1058
f a2
and
f ( x2 ) f (0.6712) 0.0264
Since f (0.6712) f (0.6364) 0, a root lies between x2 and 1, and hence we set a3 x2 0.6364
and b3 b1 1.
a3
Then x3
1
f b 0.6712
0.0264 1
0.6796
f b f a 1 0.0264
f a3
3
and
b3
f ( x3 ) f (0.6796) 0.0063 0 .
Numerical Methods
Page 24
5
x1
f (5) f (8)
5(28.00586026) 8( 34.50675846)
f (8) f (5)
28.00586026 34.50675846)
6.655990062 .
Now, f ( x1 ) 4.275625415 and therefore, f (5) f ( x1 ) 0 and hence the root lies between
6.655990062 and 8.0. Proceeding similarly,
x 2 6.83400179, x3 6.850669653,
Page 25
Ans: (i) The bisection and regula-falsi method is always convergent. Since the
method brackets the root, the method is guaranteed to converge. The main
disadvantage is, if it is not possible to bracket the roots, the methods cannot
applicable. For example, if f ( x) is such that it always takes the values with same
sign, say, always positive or always negative, then we cannot work with bisection
method. Some examples of such functions are
Exercises
Find a real root of the following equations by false position method:
1. x3 5 x 6
2. 4 x e x
3. x log10 x 1.2
4. tan x tanh x 0
5. e x sin x
6. x3 5 x 7 0
7. x3 2 x 2 10 x 20 0
8. 2 x log10 x 7
9. xe x cos x
10. x3 5 x 1 0
11. e x 3x
12. x 2 log e x 12
13. 3 x cos x 1
14. 2 x 3sin x 5
15. 2 x cos x 3
16. xe x 3
17. cos x x
18. x3 5 x 3 0
Ramanujans Method
We need the following Theorem:
If n is any rational number and x 1 , then
Binomial Theorem:
1 x
Numerical Methods
n(n 1) . . . (n (r 1)) r
n(n 1) 2
1 n x
x . . .
x . . .
1
1 2
1 2 . . . r
Page 26
In particular,
1 x
and
1 x
1 x x2 x3 . . . 1 xn . . .
n
1 x x2 x3 . . . xn . . .
where
f ( x ) is of the form
bn a1bn 1 a2 bn 2 an 1b1
n 2,3,
Solution
The given equation can be written as f ( x )
f ( x ) 1 1 (11x 6 x 2 x 3 )
6
Numerical Methods
Page 27
Comparing,
a1 11 , a2 1,
6
a3 1 ,
6
a4 a5 0
1 11x 6 x x
6
b1 b2 x b3 x 2
Hence,
b1 1;
b2 a1 11 ;
6
b3 a1b2 a2 b1 121 1 85 ;
36
36
b4 a1b3 a2 b2 a3b1 575 ;
216
b5 a1b4 a2 b3 a3b2 a4 b1 3661 ;
1296
b6 a1b5 a2 b4 a3b3 a4 b2 a5b1 22631 ;
7776
Therefore,
b1 6
0.54545 ;
b2 11
b2 66
0.7764705
b3 85
b3 102
0.8869565 ;
b4 115
b4 3450
0.9423654
b5 3661
b5 3138
0.9706155
b6 3233
By inspection, a root of the given equation is unity and it can be seen that the successive
convergents
bn
approach this root.
bn 1
Page 28
Recall
ex 1 x
x 2 x3
2! 3!
Hence,
3
4
5
f ( x) 1 x x 2 x x x 0
2
6 24
a1 1,
a2 1,
a3 1 ,
2
a4 1 ,
6
a5 1 ,
24
We then have
b1 1;
b2 a2 1;
b3 a1b2 a2 b1 1 1 2;
b4 a1b3 a2 b2 a3b1 2 1 1 7 ;
2 2
b5 a1b4 a2 b3 a3b2 a4 b1 7 2 1 1 37 ;
2
2 6 6
b6 a1b5 a2 b4 a3b3 a4 b2 a5b1 37 ; 7 1 1 1 261 ;
6 2
6 24 24
Therefore,
b2 1
0.5 ;
b3 2
b3 4
0.5714 ;
b4 7
b4 21
0.56756756 ;
b5 37
b5 148
0.56704980 .
b6 261
Solution
2
3
4
f ( x ) 1 x x 2 x 2 x 2 0.
(2!)
(3!)
(4!)
Let
Here
a1 1,
Numerical Methods
a2 1 2 ,
(2!)
a3 1 2 ,
(3!)
a4 1 2 ,
(4!)
Page 29
a5 1 2 ,
(5!)
a6 1 2 ,
(6!)
Writing
1
x2
x 3 x 4 b b x b x 2 ,
1 x (2!)
1
2
3
(3!)2 (4!)2
we obtain
b1 1,
b2 a1 1,
b3 a1b2 a2 b1 1 1 2 3 ;
4
(2!)
b4 a1b3 a2 b2 a3b1 3 1 2 1 2 3 1 1 19 ,
4 (2!)
4 4 36 36
(3!)
b5 a1b4 a2 b3 a3b2 a4 b1
19 1 3 1 1 1 211 .
36 4 4 36
576 576
It follows
b1
1;
b2
b2 4
1.333;
b3 3
b3 3 36 27
1.4210 ,
b4 4 19 19
b4 19 576
1.4408,
b5 36 211
f ( x ) 1 x x x x x 0.
3! 5! 7!
Here
Numerical Methods
Page 30
a1 2,
a2 0,
a5 1 ,
120
a6 0,
a3 1 ,
6
a4 0,
a7 1 ,
5040
we write
x 3 x 5 x 7
1
2
x
6 120 5040
b1 b2 x b3 x 2
We then obtain
b1 1;
b2 a1 2;
b3 a1b2 a2 b1 4;
b4 a1b3 a2 b2 a3b1 8 1 47 ;
6 6
b5 a1b4 a2 b3 a3b2 a4 b1 46 ;
3
b6 a1b5 a2 b4 a3b3 a4 b2 a5b1 3601 ;
120
Therefore,
b1 1
;
b2 2
b2 1
;
b3 2
b3 24
0.5106382
b4 27
b4 47
0.5108695
b5 92
b5 1840
0.5109691 .
b6 3601
x2
x3
x4
0
(2!) 2 (3!) 2 (4!) 2
x x3 1.
Page 31
3
NEWTON RAPHSON ETC..
The Newton-Raphson method, or Newton Method, is a powerful technique for solving
equations numerically. Like so much of the differential calculus, it is based on the simple
idea of linear approximation.
Newton Raphson Method
Consider f ( x) 0 , where f
has continuous
f ( x0 ) f ( x1 )
,
x0 x1
f ( x0 )
f ( x0 )
f ( x1 )
,
f ( x1 )
and so on.
f ( x2 )
f ( x2 )
f ( xn )
f ( xn )
Page 32
The refinement on the value of the root xn is terminated by any of the following conditions.
(i) Termination after a pre-fixed number of steps
(ii) After n iterations where, xn 1 xn for a given 0 , or
(iii) After n iterations, where f ( xn )
for a given 0 .
Termination after a fixed number of steps is not advisable, because a fine approximation cannot be
ensured by a fixed number of steps.
Algorithm: The steps of the Newton-Raphson method to find the root of an equation f x 0 are
1. Evaluate f x
2. Use an initial guess of the root, xi , to estimate the new value of the root, xi 1 , as
xi 1 = xi
f xi
f xi
a =
xi 1 xi
100
xi 1
4. Compare the absolute relative approximate error with the pre-specified relative error
tolerance,
s . If a > s then go to Step 2, else stop the algorithm. Also, check if the
number of iterations has exceeded the maximum number of iterations allowed. If so, one
needs to terminate the algorithm and notify the user.
The method can be used for both algebraic and transcendental equations, and it also works
when coefficients or roots are complex. It should be noted, however, that in the case of an
algebraic equation with real coefficients, a complex root cannot be reached with a real starting
value.
Example Set up a Newton iteration for computing the square root of a given positive
number. Using the same find the square root of 2 exact to six decimal places.
Let c be a given positive number and let x be its positive square root, so that x c . Then
x 2 c or
Numerical Methods
Page 33
f ( x) x c 0
f ( x ) 2 x
xn 1 xn
or
xn 1
xn c
2 xn
xn
c
2 2 xn
xn 1 1 xn c , n 0. 1, 2, ,
2
xn
or
xn 1 1 x n 2
2
xn
, n 0, 1, 2,
Choose x0 1 . Then
x1 = 1.500000, x2 = 1.416667, x3 = 1.414216, x4 = 1.414214,
and accept 1.414214 as the square root of 2 exact to 6D.
Historical Note: Heron of Alexandria (60 CE?) used a pre-algebra version of the above
recurrence. It is still at the heart of computer algorithms for finding square roots.
5 is the only zero of f(x) = x2 - 5 on the interval [1, 3]. See the
Picture.
Numerical Methods
Page 34
Numerical Methods
Page 35
This solution is also the only zero of the function f ( x) x cos x . So now we see how
Newton's method may be used to approximate r. Since r is between 0 and / 2 , we
set x1 = 1. The rest of the sequence is generated through the formula
We have
f ( x ) 3 x 1
2
xn 1 xn
xn xn 1
2
3xn 1
or xn 1
2 xn 1
2
3xn 1
, n= 0,1,2,.
Solution
Take
f ( x ) x log10 x 1.2.
Numerical Methods
Page 36
Noting that
we obtain
1 log x 0.4343
10
x
and hence the Newtons iterative formula for the given equation is
xn 1 xn
f ( xn )
0.4343 x log e xn 1.2
xn
.
f ( xn )
log10 x 0.4343
Here
f ( x ) x 2 sin x ,
so that
f ( x) 1 2 cos x
xn 1 x n
xn 1
xn 2sin xn
1 2cos xn
, n 0. 1, 2,
2(sin xn xn cos xn )
1 2cos xn
Nn
Dn
or
, n 0. 1, 2,
where we take N n 2(sin xn xn cos xn ) and Dn 1 2cos xn , to easy our calculation. Values
calculated at each step are indicated in the following table (Starting with x0 2 ).
n
xn
Nn
Dn
xn+1
2.000
3.483
1.832
1.901
1.901
3.125
1.648
1.896
1.896
3.107
1.639
1.896
Page 37
x n 1 x n
x n3` 2 x n 5
3 x n2 2
x1 2 1 2.1
10
f ( x1 ) (2.1)3 2(2.1) 5 0.06,
and
f ( x1 ) 3(2.1)2 2 11.23.
x n sin x n cos x n
x n cos x n
f ( xn )
n xn
0 3.1416 1.0
xn1
2.8233
2.7984
Example Find a real root of the equation x e x , using the Newton Raphson method.
f ( x ) xe x 1 0
Let x0 1. Then
x1 1 e 1 1 1 1 0.6839397
2e 2
e
Numerical Methods
Page 38
Now
Example f(x) = x2+lnx has a root near x = 1.5. Use the Newton -Raphson formula to
obtain a better estimate.
Here x0 = 1.5, f(1.5)= 0.5 + ln(1.5)= 0.0945
(0.0945)
f ( x) 1 1 ; f (1.5) 5 ; x1 1.5
1.5567
x
3
1.6667
The Newton-Raphson formula can be used again: this time beginning with 1.5567 as our
initial
x 2 1.5567
( 0.0007)
1.5571
1.6424
f ( xn )
,
f ( x n )
f ( x0 )
f ( x 0 )
f ( x 0 )
, x 0 ( p 1)
, x 0 ( p 2)
f ( x0 )
f ( x0 )
f ( x 0 )
must have the same value if there is a root with multiplicity p, provided that the initial
approximation x0 is chosen sufficiently close to the root.
Example Find a double root of the equation
f ( x ) x 3 x 2 x 1 0.
Page 39
x0 2
f ( x0 )
0.8 2 0.072 1.012,
f ( x0 )
(0.68)
and
x0
f ( x0 )
(0.68)
0.8
1.043,
f ( x0 )
2.8
The closeness of these values indicates that there is a doublel root near to unity. For the
next approximation, we choose x1 1.01 and obtain
x1 2
and
x1
f ( x1 )
1.01 0.0099 1.0001,
f ( x1 )
f ( x1 )
1.01 0.0099 1.0001,
f ( x1 )
Hence we conclude that there is a double root at x 1.0001 which is sufficiently close to the
actual root unity.
On the other hand, if we apply Newton-Raphson method with x0 0.8, we obtain
x1 0.8 0.106 0.91, and x 2 0.91 0.046 0.96.
Exercises
1.
2.
3.
4.
5.
6.
Use the Newton-Raphson method, with 3 as starting point, to find a fraction that is
within 10 8 of 10 .
7.
8.
Design Newton iteration for the cube root. Calculate 3 7 , starting from x0 = 2 and
performing 3 steps.
Calculate
7 2.645751
Page 40
10.
Find all real solutions of the following equations by Newtons iteration method.
(a) sin x =
11.
12.
x
.
2
(b) ln x = 1 2x
(c) cos x x
x 5x 3 0
x x 2 x 34 0
Ramanujans Method
We need the following Theorem:
Binomial Theorem:
1 x
In particular,
1 x
and
1 x
1 x x2 x3 . . . 1 xn . . .
n
1 x x2 x3 . . . xn . . .
Page 41
f ( x ) 0,
where
f ( x ) is of the form
bn a1bn 1 a2 bn 2 an 1b1
n 2,3,
Solution
The given equation can be written as f ( x )
f ( x ) 1 1 (11x 6 x 2 x 3 )
6
Comparing,
a1 11 , a2 1,
6
a3 1 ,
6
a4 a5 0
1 11x 6 x x
6
Numerical Methods
b1 b2 x b3 x 2
Page 42
Hence,
b1 1;
b2 a1 11 ;
6
b3 a1b2 a2 b1 121 1 85 ;
36
36
b4 a1b3 a2 b2 a3b1 575 ;
216
b5 a1b4 a2 b3 a3b2 a4 b1 3661 ;
1296
b2 66
0.7764705
b3 85
b3 102
0.8869565 ;
b4 115
b4 3450
0.9423654
b5 3661
b5 3138
0.9706155
b6 3233
By inspection, a root of the given equation is unity and it can be seen that the successive
convergents
bn
approach this root.
bn 1
ex 1 x
x2 x3
2! 3!
Hence,
3
4
5
f ( x) 1 x x2 x x x 0
2 6 24
a1 1,
Numerical Methods
a2 1,
a3 1 ,
2
a4 1 ,
6
a5 1 ,
24
Page 43
We then have
b1 1;
b2 a2 1;
b3 a1b2 a2b1 11 2;
b4 a1b3 a2b2 a3b1 2 1 1 7;
2 2
b5 a1b4 a2b3 a3b2 a4b1 7 2 1 1 37 ;
2
2 6 6
b3 4
0.5714 ;
b4 7
b4 21
0.56756756 ;
b5 37
b5 148
0.56704980 .
b6 261
Solution
2
3
4
f (x) 1 x x 2 x 2 x 2 0.
(2!) (3!) (4!)
Let
Here
a1 1,
a2 1 2 ,
(2!)
a5 1 2 ,
(5!)
a3 1 2 ,
(3!)
a4 1 2 ,
(4!)
a6 1 2 ,
(6!)
Writing
Numerical Methods
Page 44
x2 x3 x4 b b x b x2
1
(2!)
,
1
2
3
(3!)2 (4!)2
we obtain
b1 1,
b2 a1 1,
b3 a1b2 a2b1 1 1 2 3 ;
(2!) 4
It follows
b1
1;
b2
b2 4
1.333;
b3 3
b3 3 36 27
1.4210 ,
b4 4 19 19
b4 19 576
1.4408,
b5 36 211
f ( x ) 1 x x x x x 0.
3!
5!
7!
Here
a1 2,
a5 1 ,
120
a2 0,
a6 0,
a3 1 ,
6
a4 0,
a7 1 ,
5040
we write
Numerical Methods
Page 45
x 3 x 5 x 7
1
2
x
6 120 5040
b1 b2 x b3 x 2
We then obtain
b1 1;
b2 a1 2;
b3 a1b2 a2 b1 4;
b4 a1b3 a2 b2 a3b1 8 1 47 ;
6 6
b5 a1b4 a2 b3 a3b2 a4 b1 46 ;
3
b6 a1b5 a2 b4 a3b3 a4 b2 a5b1 3601 ;
120
Therefore,
b1 1
;
b2 2
b2 1
;
b3 2
b3 24
0.5106382
b4 27
b4 47
0.5108695
b5 92
b5 1840
0.5109691 .
b6 3601
x2
x3
x4
0
2
2
(2!)
(3!)
(4!) 2
x x3 1.
Page 46
f ( x n )
f ( x n ) f ( x n 1 )
,
x n x n 1
f n ( x n x n 1 x n 1 f n x n f n 1
.
f n f n 1
f n f n 1
It should be noted that this formula requires two initial approximations to the root.
Example Find a real root of the equation x 3 2 x 5 0 using secant method.
Let the two initial approximations be given by x 1 2 and x0 3.
We have
f ( x 1 ) f1 8 9 1, and f ( x0 ) f0 27 11 16.
x1
2(16) 3(1) 35
2.058823529.
17
17
Also,
f ( x1 ) f1 0.390799923.
x2
x0 f1 x1 f 0 3( 0.390799923) 2.058823529(16)
2.08126366.
f1 f0
16.390799923
Again
f ( x 2 ) f 2 0.147204057.
x3 2.094824145.
Numerical Methods
Page 47
Let us assume the initial approximation to the roots as 1 and 2. That is consider x1 1
and x0 2
f ( x1 ) f 1 1 e 1 1 0.367879441=0.632120559 and
f ( x0 ) f 0 2 e 2 2 0.135335283=1.864664717.
x1 f 0 x0 f 1
f 0 f 1
0.487142.
1.864664717 0.632120559
1.232544158
Also,
f ( x1 ) f1 0.487142 e 0.487142 -0.12724.
0.58378
f1 f 0
-0.12724 1.864664717
-1.99190
Again
0.56738
f 2 f1
0.15323
0.02599 -0.12724
f ( x3 ) f3 0.56738 e 0.56738 0.00037.
Page 48
x4
0.5671
f3 f 2
0.00037 0.02599
-0.02562
xn
2
(ii)
xn 1
3 xn
2
(iii)
1
C
xn 1 xn (iv) None of these
2
xn
(b) The next iterative value of the root of 2 x 2 3 0 using the Newton-Raphson
method, if the initial guess is 2, is
(i) 1.275
(ii) 1.375
(c) The next iterative value of the root of 2 x 2 3 0 using the secant method, if the
initial guesses are 2 and 3, is
(i) 1
(ii) 1.25
(iii)
xn 1
xn 1 f n xn f n 1
f n f n 1
(ii) xn 1
xn f n xn 1 f n 1
(iii)
f n f n 1
xn 1
xn 1 f n 1 xn f n
f n 1 f n
1
C
(a) (iii) xn 1 xn
2
xn
(b) (ii) 1.375
(c) (iii) 1.5
Numerical Methods
Page 49
(d) (i) xn 1
xn 1 f n xn f n 1
f n f n 1
Numerical Methods
Page 50
4
FINITE DIFFERENCES OPERATORS
to
the
equidistant
x1 x0 h, x2 x0 2h, x3 x0 3h,..., xn x0 nh .
where
divided difference interpolation polynomials can be used for interpolation, some simpler
interpolation formulas can be derived. For this, we have to be familiar with some finite
difference operators and finite differences, which were introduced by Sir Isaac Newton.
Finite differences deal with the changes that take place in the value of a function f(x) due
to finite changes in x. Finite difference operators include, forward difference operator,
backward difference operator, shift operator, central difference operator and mean
operator.
For the values y0 , y1 ,..., yn of a function y=f(x), for the equidistant values x0 , x1 , x2 ,..., xn ,
where x1 x0 h, x2 x0 2h, x3 x0 3h,..., xn x0 nh , the forward difference operator is
defined on the function f(x) as,
f xi f xi h f xi f xi 1 f xi
That is,
yi yi1 yi
Then, in particular
f x0 f x0 h f x0 f x1 f x0
y0 y1 y0
f x1 f x1 h f x1 f x2 f x1
y1 y2 y1
etc.,
y0 , y1 ,..., yi ,... are known as the first forward differences.
Numerical Methods
Page 51
2 f xi
f xi f xi h f xi
f xi h f xi
f xi 2h f xi h f xi h f xi
f xi 2h 2 f xi h f xi
yi 2 2 yi 1 yi
In particular,
2 f x0 y2 2 y1 y0 or 2 y0 y2 2 y1 y0
3 f xi 2 f xi
f xi 2h 2 f xi h f xi
y
3y
3 y yi
i 3
i2
i 1
In particular,
3 f x0 y3 3 y2 3 y1 y0
or
3 y0 y3 3 y2 3 y1 y0
x0
y0 f ( xo )
2 y
3 y
y0 y1 y0
x1
y1 f ( x1 )
2 y0 y1 y0
y1 y2 y1
x2
y 2 f ( x2 )
3 y0 2 y1 2 y0
2 y1 y2 y1
y2 y3 y2
x3
Numerical Methods
y3 f ( x3 )
Page 52
Example Construct the forward difference table for the following x values and its
corresponding f values.
x
0.1
0.3
f 0.003
x
0.1
0.003
0.3
0.067
0.5
0.148
0.7
0.248
0.9
0.370
1.1
0.518
1.3
0.697
0.067
f
0.064
0.081
0.100
0.122
0.148
0.179
0.5
0.7
0.9
0.017
0.019
0.022
0.026
0.031
3f
4f
0.002
0.003
0.004
0.005
0.001
0.001
0.001
f ( x)
1
x
1.0
1.000
1.2
0.8333
1.4
0.7143
1.6
0.6250
1.8
0.5556
2.0
0.5000
Numerical Methods
2f
first
differe
nce
second
differe
nce
-0.1667
-0.1190
-0.0893
-0.0694
-0.0556
0.0477
0.0297
0.0199
0.0138
3f
-0.0180
-0.0098
-0.0061
1.1
1.3
0.518
0.697
5f
0.000
0.000
f ( x)
1
, x = 1(0.2)2, 4D.
x
4f
5f
0.0082
-0.0045
0.0037
Page 53
y f ( x) : 4 9 17
22
y=f(x)
-2
2 y
3 y
4
y0 =5
17
22
2 y0 =3
3 y0 =-6
y1 =8
2 y1 =-3
y2 =5
Numerical Methods
Page 54
Proof:
f ( x) g ( x) ( fg )( x)
( fg )( x h) ( fg )( x)
f ( x h) g ( x h) f ( x ) g ( x )
f ( x h) g ( x h) g ( x ) g ( x ) f ( x h) f ( x )
f ( x h)g ( x) g ( x)f ( x)
g ( x h) g ( x )
g ( x)
Proof:
f ( x) f ( x h) f ( x)
g ( x) g ( x h) g ( x)
f ( x h) g ( x) f ( x) g ( x h)
g ( x h) g ( x)
f ( x h) g ( x) f ( x) g ( x) f ( x) g ( x) f ( x) g ( x h)
g ( x h) g ( x)
g ( x ) f ( x h) f ( x ) f ( x ) g ( x h) g ( x )
g ( x h) g ( x )
g ( x)f ( x) f ( x)g ( x)
g ( x h) g ( x )
Numerical Methods
Page 55
Result 2: If n is an integer,
f (a nh) f (a) nC1f (a) nC2 2 f (a) n f (a)
x0
f0
x1
2f
f1
f0
2f0
x2
f2
f1
2f2
x3
f3
f2
2f2
x4
f4
f3
2f3
x5
f5
f4
2f4
x6
f6
3f
3f0
3f1
3f2
3f3
4f
4f0
4f1
4f2
5f
5f0
5f1
6f
6f0
f5
2 f 0 f1 f 0 f 2 f1 f1 f 0 f 2 2 f1 f 0
3 f 0 2 f1 2 f 0 f 2 f1 f1 f 0
f f f f f f f f
3 2
2 1
2 1
1 0
f 3f 3f f
3
2
1 0
In general,
n f
f nC f
nC f
nC f
... ( 1) n f .
n
1 n 1
2 n2
3 n3
0
Page 56
Show that the value of yn can be expressed in terms of the leading value y0
Exa mp le
or
f1 f 0 f 0
f1 f 2 f1
or
f 2 f1 f1
f 2 f 3 f 2 or
f 3 f 2 f 2
3 f1 2 f 2 2 f1 or 2 f 2 2 f1 3 f1
Hence
f3 f 2 f 2
f1 f1 f 0 2 2 f 0 3 f 0
f 0 3f 0 32 f 0 3 f 0
1 f 0
3
Page 57
f n f 0 nC1f 0 n C 2 2 f 0 . . . n f 0
Thus
n
f n nCi i f 0 .
i0
2 y
3 y
x
xo
y0 f ( xo )
y1 y1 y0
x1
2 y2 y2 y1
y1 f ( x1 )
3 y3 2 y3 2 y2
y2 y2 y1
x2
y 2 f ( x2 )
2 y3 y3 y2
y3 y3 y2
x3
y3 f ( x3 )
Page 58
2.
Proof: Consider the function f(x).
f ( x) f ( x h) f ( x)
f ( x) f ( x) f ( x h)
( f ( x)) f ( x) f ( x)
f ( x h) f ( x ) f ( x ) f ( x h)
f ( x) f ( x h)
f ( x ) f ( x h)
f ( x )
3. E 1
Proof: Consider the function f(x).
f ( x) f ( x) f ( x h) f ( x h) E 1 f ( x) E 1
4. 1 E 1
Proof: Consider the function f(x).
f ( x) f ( x) f ( x h) f ( x) E 1 f ( x) 1 E 1 f ( x) 1 E 1
y f ( x) : 8
12
Y=f(x)
-2
-8
2 y
3 y
y1 =3-(-8)=11
2 y2 =-2-11= -13
3 y3 =13-(-13)=26
y2 =1-3=-2
2 y3 =11-(2)=13
y3 =12-1=11
Numerical Methods
12
Page 59
x0
f0
x1
2f
f1
f1
2f2
x2
f2
f2
2f3
x3
f3
f3
2f4
x4
f4
f4
2f5
x5
f5
x6
f6
f5
f6
3f
3f3
3f4
3f5
3f6
4f
5f
4f4
5f
4f5
4f6
6f
6f6
5f
6
2f6
Example Show that any value of f (or y) can be expressed in terms of fn (or yn ) and its
backward differences.
Solution
f n f n f n1 implies f n 1 f n f n
and f n 1 f n 1 f n 2 implies f n 2 f n1 f n1
2 f n f n f n 1 implies f n 1 f n 2 f n
i.e., f n r f n r C1 f n r C2 2 f n . . . (1) r r f n
If we write yn to denote fn the above result is:
yn r yn r C1 yn r C2 2 yn . . . (1) r r yn
Numerical Methods
Page 60
Centr al Dif f er en c es
Central difference operator for a function f(x) at xi is defined as,
h
f ( xi ) f xi
2
h
f xi , where h being the interval of differencing.
2
Let y 1 f x0 h . Then,
2
h
h h
h h
y 1 f x0 f x0 f x0
2
2
2
2 2
2
f x0 h f x0 f x1 f x0 y1 y0
y 1 y0
2
xo
y0 f ( xo )
2y
3y
y 1 y1 y0
2
x1
2 y1 y 3 y 1
y1 f ( x1 )
x2
y 2 f ( x2 )
y3 f ( x3 )
3 y 3 2 y2 2 y1
y 3 y2 y1
2 y2 y 5 y 3
2
x3
y 5 y3 y2
2
Numerical Methods
x0
f0
x1
2f
f1
f1/2
2f1
x2
f2
f3/2
2f2
x3
f3
f5/2
2f3
x4
f4
3f
3f3/2
3f5/2
4f
4f2
f7/2
Page 61
(b) 3 f
m1
2
m2
3f
m1
3f
m 1
2
(a) fmfm1/2 fm1/2 ( fm1 fm)( fm fm1)
f
m 1
2 fm f
m 1
(1)
Thus, when E operates on f (x), the result is the next value of the function. If we apply the
operator twice on f (x), we get
E2 f (x) = E [E f (x)] = f (x+ 2h).
Thus, in general, if we apply the shift operator n times on f (x), we arrive at
E n f (x) = f (x+ nh)
(2)
Page 62
E1 f(x) = f (x h)
(3)
En f(x) = f (x nh)
(4)
and similarly
Average Operator
The average operator is defined as
f x 1 f ( x h2 ) f ( x h2 )
2
Differential operator D
The differential operator D has the property
Df ( x) d f ( x) f ( x)
dx
2
D 2 f ( x) d 2 f ( x) f ( x)
dx
E 1
.
E
Page 63
Therefore,
= E 1/2 E 1/2
The definition of the operators and E yields
1
h
f x f x
2
2
h 1
f x E1/ 2 E 1/ 2 f x .
2 2
Therefore,
1 1/ 2
E E 1/ 2 .
2
It is known that
E f (x) = f (x + h).
Using the Taylor series expansion, we have
2
h
Ef x f x h f x
f x . . .
2!
f x h Df x
h2 2
D x . . .
2!
h D h2 D2
. . . f x e hD f x .
1!
2!
Thus
E e hD . Or,
hD = log E.
Example If , , denote forward, backward and central difference operators, E and
respectively the shift operator and average operators, in the analysis of data with equal
spacing h, prove the following:
2
2
(i ) 1 2 2 1
2
2
iii 1 2 / 4
2
iv E2
ii E1/ 2
v 2 .
Solution
(i) From the definition of operators, we have
Numerical Methods
Page 64
1 1/ 2
E E 1/ 2 E1/ 2 E 1/ 2 12 E E 1 .
2
Therefore
1 2 2 1
2
1 2
1
E 2 E 2 E E 1
4
4
Also,
1
2
2
1
1
1 E1/ 2 E 1/ 2 E E 1
2
2
2
2
1 2 2 1 .
2
E
2
1 2 / 4
2
1/ 2
E 1/ 2
2
E1/ 2 E 1/ 2 1
E 2 E 1 1 1/ 2
E E 1/ 2 E1/ 2 E 1/ 2
2
2
E 2 E 1 E E 1
2
2
2
1 1/ 2
E E 1/ 2
=E 1
=
(iv) We write
1 1/ 2
E E 1/ 2 E1/ 2 E 1/ 2 12 E E 1
2
1
1 E 1 2 12 1 E 1 2 12 EE 1 2 2E .
2
1 1/ 2
E E 1/ 2 E1/ 2 E 1/ 2 12 E E 1
2
1
1 1 12 .
2
Numerical Methods
Page 65
Using the standard relations given in boxes in the last section, we have
hD log E log 1 log E log E 1 log 1
Also,
1 1/ 2
E E 1/ 2 E1/ 2 E 1/ 2 12 E E 1
2
1 hD
e e hD sin hD
2
Therefore
hD sinh 1 .
Example Show that the operations and E commute.
Solution
From the definition of operators and E , we have
Ef 0 f1
1
f f
2 3/ 2 1/ 2
and also
Ef 0
1
1
E f1/ 2 f 1/ 2 f 3/ 2 f1/ 2
2
2
Hence
E E .
x2
x2
ex u0 xu0 2u0 ... u0 u1x u2 ...
2!
2!
x2 2
x22
e u0 xu0 u0 ... e 1 x
... u0
2!
2!
exexu0 ex(1)u0
exEu0
Numerical Methods
Page 66
x2 E 2
1 xE
... u0
2!
u0 xu1
x2
u ...,
2! 2
as desired.
Example Using the method of separation of symbols, show that
nu x n u x nu x 1
n(n 1)
u x 2 (1) n u x n .
2
u x nu x 1
n(n 1)
u x 2 (1) n u x n .
2
u x nE 1u x
n(n 1) 2
E u x (1) n E nu x
2
n(n 1) 2
1 nE 1
E (1) n E n u x
2
1 E 1 u x
n
1
1 u x
E
E 1
ux
E
n
n
ux
En
n E nu x
nu x n ,
= L.H.S
Differences of a Polynomial
Let us consider the polynomial of degree n in the form
f ( x ) a0 x n a1 x n 1 a2 x n 2 . . . an 1 x an ,
where a0 0 and
Then
Numerical Methods
Page 67
f ( x h ) a0 ( x h ) n a1 ( x h ) n 1 a2 ( x h ) n 2 ... an 1 ( x h) an
an 1 ( x h x )
f x a 0 x n n C1 x n 1h n C 2 x n 2 h 2 . . . h n x n
a1[ x n 1
n 1
C1 x n 2 h
n 1
C2 x n 3 h 2
. . . h n 1 x n 1 ] . . . an 1h
a 0 nhx n 1 a 0 n C 2 h 2 a1 n 1C1h x n 2 . . . a n 1h .
Therefore,
f x a 0 nhx n 1 b x n 2 c x n 3 . . . k x l ,
where b, c, . . . , k, l are constants involving h but not x. Thus, the first difference of
a polynomial of degree n is another polynomial of degree (n 1). Similarly,
2 f x f x f x h f x
a0 nh x h
n 1
n2
x n 1 b x h x n 2
. . . k x h x
Page 68
Conversely, if the n th differences of a tabulated function are constant and the (n 1)th ,
(n 2)th,..., differences all vanish, then the tabulated function represents a polynomial of
degree n. It should be noted that these results hold good only if the values of x are equally
spaced. The converse is important in numerical analysis since it enables us to approximate
a function by a polynomial if its differences of some order become nearly constant.
Theorem (Differences of a polynomial)The nth differences of a polynomial of degree n is a
constant, when the values of the independent variable are given at equal intervals.
Exercises
1.
Calculate f ( x)
1
, x 0(0.2)1 to (a) 2 decimal places, (b) 3 decimal places and (c)4
x 1
decimal places. Then compare the effect of rounding errors in the corresponding
difference tables.
2.
3.
Express 2y1 (i.e. 2f1 ) and 4y0 (i.e. 4f0 ) in terms of the values of the function y =
f(x).
Set up a difference table of f ( x) x 2 for x 0(1)10 . Do the same with the calculated
value 25 of f (5) replaced by 26. Observe the spread of the error.
4.
Calculate f ( x)
1
, x 0(0.2)1 to (a)2 decimal places, (b)3 decimal places and (c)4
x 1
decimal places. Then compare the effect of rounding errors in the corresponding
difference tables.
5.
6.
7.
8.
Set up a forward difference table of f(x) = x2 for x = 0(1)10. Do the same with the
calculated value 25 of f(5) replaced by 26. Observe the spread of the error.
Construct the difference table based on the following table.
x
0.0
0.1
0.2
0.3
0.4
0.5
cosx
1.000 00
0.995 00
0.980 07
0.955 34
0.921 06
0.877 58
0.0
0.1
0.2
0.3
0.4
sinx
0.000 00
0.099
83
0.198
67
0.295
52
0.389
42
0.5
0.479
Numerical Methods
Page 69
9.
Show that E E 1 / 2 .
10.
Prove that
11.
12.
2 sinhhD / 2
ii 2 coshhD / 2.
and
13. Construct
0.0
0.1
0.2
0.3
0.4
0.5
cos x
1.000
00
0.995
00
0.980
07
0.955
34
0.921
06
0.877
58
0.0
0.1
0.000
00
0.099
83
0.2
0.198
67
0.3
0.4
0.5
0.295
52
0.389 0.479
42
43
yn
2 yn
Numerical Methods
1
4
13
18
24
Page 70
5
NUMERICAL INTERPOLATION
Consider a single valued continuous function y f ( x) defined over [a,b] where
f ( x) is known explicitly. It is easy to find the values of y for a given set of values of x in
differentiation or integration.
Now we have first to find a simpler function, say g ( x) , such that f ( x) and g ( x) agree
at the given set of points and accept the value of g ( x) as the required value of f ( x) at some
point x in between a and b.
If g ( x) is a
distinct points are given, a polynomial of degree not greater than two can be fitted
uniquely. In general, if n+ 1 distinct points are given, a polynomial of degree not greater
than n can be fitted uniquely.
Interpolation ts a real function to discrete data.
given values of x in between x0 and xn . To do this we have first to find a simpler function,
say g ( x) , such that f ( x) and g ( x) agree at the set of tabulated points and accept the value
of g ( x) as the required value of f ( x) at some point x in between x0 and xn . Such a process
is called interpolation. If g ( x) is a polynomial, then the process is called polynomial
interpolation.
In interpolation, we have to determine the function g ( x) , in the case that f ( x) is
difficult to be obtained, using the pivotal values f 0 f ( x 0 ), f 1 f ( x1 ) ,. . . , f n f ( x n ) .
Linear interpolation
In linear interpolation, we are given with two pivotal values f 0 f ( x0 ) and f1 f ( x1 ),
and we approximate the curve of f by a chord (straight line) P1 passing through the points
( x0 , f 0 ) and ( x1 , f1 ) . Hence the approximate value of f at the intermediate point x x 0 rh
is given by the linear interpolation formula
f ( x ) P1 ( x ) f 0 r ( f1 f 0 ) f 0 r f 0
where r
x x0
h
and 0 r 1 .
Exa mp le Evaluate ln 9.2 , given that ln 9.0 2.197 and ln 9.5 2.251.
Here x0 = 9.0 , x1 = 9.5, h = x1 x0 =9.5 9.0 = 0.5, f0 = f(x0) = ln 9.0 2.197 and
f1 f ( x1 ) ln 9.5 2.251. Now to calculate ln 9.2 f (9.2), take x 9.2, so that
r
x x0
h
x x0
h
15 10 5 0.5
10
10
1.24
Numerical Methods
1.4
Page 72
1.24
x x0
h
hence
1.24
1.24
is
3.4947.
Quadr atic I n ter po latio n
In quadratic interpolation we are given with three pivotal values f 0 f ( x0 ), f1 f ( x1 )
and f 2 f ( x2 ) and we approximate the curve of the function f between x0 and x2 = x0 +2h
by the quadratic parabola P2 , which passes through the points ( x0 , f 0 ), ( x1 , f1 ), ( x2 , f 2 ) and
obtain the quadratic interpolation formula
f ( x) P2 ( x) f 0 r f 0
where r
x x0
h
r ( r 1) 2
f0
2
and 0 r 2 .
Here x0 = 9.0 , x1 = 9.5, x1 = 10.0, h = x1 x0 =9.5 9.0 = 0.5, f0 = f(x0) = ln9.0 = 2.197,
f1 = f(x1) = ln9.5 = 2.251 and f2 = f(x2) = ln10.0 = 2.3026. Now to calculate ln9.2=f(9.2), take
x = 9.2, so that r
x x0
h
ln 9.2 f (9.2) P2 ( x) f 0 r f 0
r ( r 1) 2
f0
2
9.0
2.1972
9.5
2.2513
2f
0.0541
0.0028
0.0513
10.0
2.3026
Hence,
Numerical Methods
Page 73
0.4(0.4 1)
( 0.0028)
2
f ( x) cos x
0.0
1.00000
0.2
0.98007
0.4
0.92106
First
difference
-0.01993
-0.05901
Second
difference
-0.03908
x x0
h
= 0.95647, correct to 5 D.
In quadratic interpolation, we need three consecutive (equally spaced) x values and
their corresponding f values, first differences and second difference. Here x0 = 0.0 , x1 =
0.2, x1 = 0.4, h = x1 x0 =0.2 0.0 = 02,
f0 = 1.00000, f1 = 0.98007 and f2 = 0.92106,
f0=-0.01993, 2f0=-0.03908
cos 0.28 P2 (0.28) f 0 r f 0
x x0
h
r ( r 1) 2
f0
2
1.4(1.4 1)
0.03908 0.96116 to 5D.
2
Page 74
From the above, it can be seen that quadratic interpolation gives more accurate value.
Newtons Forward Difference Interpolation Formula
Using Newtons forward difference interpolation formula we find the n degree
polynomial Pn which approximates the function f(x) in such a way that Pn and f agrees at
n+1 equally spaced x values, so that Pn ( x0 ) f 0 , Pn ( x1 ) f1 , , Pn ( xn ) f n , where f 0 f ( x0 ),
f1 f ( x1 ), , f n f ( xn ) are the values of f in the table.
r ( r 1). . .( r n 1) n
r ( r 1) 2
f0 . . .
f0
2!
n!
where x x0 rh, r
x x0
h
, 0r n.
r 0,1, 2,..., n
a3 ( x x0 )( x x1 )( x x2 ) ...
an ( x x0 )( x x1 )( x x2 )...( x xn1 )
Imposing now the condition that f ( x) and pn ( x ) should agree at the set of tabulated
points, we obtain
a0 f0 ; a1
f1 f0 f0
2 f
3 f
n f
; a2 2 0 ; a3 3 0 ;...; an n 0 ;
x1 x0 h
h 2!
h 3!
h n!
Interpolation Formula with the already given values will be added with a new term at the
end, x x0 x x1 ..... x xn
1
n 1 y0 to get the new interpolation formula with the
n 1
n 1!h
Exa mp le Using Newtons forward difference interpolation formula and the following
table evaluate f(15) .
x
f(x)
10
46
20
66
30
81
40
93
50
101
f
20
15
12
8
2f
3f
-5
-3
-1
4f
-3
-4
r (r 1) . . . (r 4 1) 4
r (r 1) 2
f0 . . .
f0 ,
2!
4!
so that
f (15) 46 (0.5)(20)
(0.5)(0.5 1)
(0.5)(0.5 1)(0.5 2)
(5)
(2)
2!
3!
Page 76
Exa mp le Find a cubic polynomial in x which takes on the values -3, 3, 11, 27, 57 and
107, when x=0, 1, 2, 3, 4 and 5 respectively.
x
f(x)
-3
11
27
57
107
16
14
30
20
50
Now the required cubic polynomial (polynomial of degree 3) is obtained from Newtons
forward difference interpolation formula
f ( x) P3 ( x) f 0 r f 0
r ( r 1) 2
r ( r 1)( r 3 1) 3
f0
f0 ,
2!
3!
x( x 1)
x( x 1)( x 3 1)
(2)
(6)
2!
3!
or f ( x) x 2 x 7 x 3
3
Exa mp le Using the Newtons forward difference interpolation formula evaluate f(2.05)
where f ( x) x , using the values:
x
x
Numerical Methods
2.0
2.1
2.2
2.3
1.414 214
1.449 138
2.4
1.549 193
Page 77
Here r
2.0
1.414 214
2.1
1.449 138
2.2
1.483 240
2.3
1.516 575
2.4
1.549 193
0.034 924
0.034 102
0.033 335
0.032 618
-0.000 822
-0.000 767
-0.000 717
0.000055
0.000050
0.000 005
x x0
=(2.052.00)/0.1=0.5, so by substituting the values in Newtons formula (for
h
(0.5)(0.5 1)(0.5 2)
(0.000055)
3!
the
(0.5)(0.5 1)
( 0.000822)
2!
Example
Find
cubic
y
24
96
3 120
120
216
5 336
48
168
384
7 720
x 1
(120)
f ( x) 24
(96)
2
2
Numerical Methods
Page 78
x 1 x 1 1 x 1 2
2 2
2
(48) x3 6 x 2 11x 6.
xr x0 9 1
4 . Hence
h
2
r (r 1) 2
r (r 1) (r 2) 3
f0
f0
2!
3!
43
4 3 2
120
48 1320
2
3 2
Solution
Sn 1 13 23 33 ... n3 (n 1)3
and hence
Sn 1 Sn (n 1)3 ,
or
Sn (n 1)3 .
it follows that
2 Sn Sn 1 Sn (n 2)3 (n 1)3 3n 2 9n 7
3 Sn 3(n 1) 9n 7 (3n 2 9n 7) 6n 12
4 Sn 6(n 1) 12 (6n 12) 6
S1 (1 1)3 8,
3 S1 6 12 18,
2 S1 3 9 7 19,
4 S1 8.
( n 1)( n 2)
( n 1)( n 2)( n 3)
(19)
(18)
2
6
Page 79
1
1
1
n 4 n3 n 2
4
2
4
n( n 1)
Problem: The population of a country for various years in millions is provided. Estimate the
population for the year 1898.
Year x:
Population y:
46
66
81
93
101
Solution: Here the interval of difference among the arguments h=10. Since 1898 is at the
beginning of the table values, we use Newtons forward difference interpolation formula for finding
the population of the year 1898.
The forward differences for the given values are as shown here.
x
1891
46
2 y
3 y
4 y
y0 20
1901
2 y0 5
66
3 y0 2
y1 15
1911
81
y2 12
1921
93
1931
101
4 y0 3
2 y1 3
3 y1 1
2 y2 4
y3 8
f ( x) y0 x x0
Numerical Methods
Page 80
1
3
4!104
21 91 18837
61.178
40 500 40000
Example Values of x (in degrees) and sin x are given in the following table:
x (in degrees)
15
20
25
30
35
40
sin x
0.2588190
0.3420201
0.4226183
0.5
0.5735764
0.6427876
sin x
15 0.2588190
0.0832011
0.0026029
20 0.3420201
0.0006136
0.0805982
0.0032165
25 0.4226183
0.0000248
0.0005888
0.0773817
0.0038053
30 0.5
0.0692112
0.0000289
0.0005599
0.0735764
35 0.5735764
0.0000041
0.0043652
40 0.6427876
Page 81
x xn 38 40
2
0.4
h
5
5
0.4( 0.4 1)
( 0.0043652)
2
0.00000120
0.6156614
y f ( x)
1
3
9
81
Numerical Methods
Page 82
By inspection it can be seen that the tabulated function is 3x and the exact value of f (3) is
27. The error is due to the fact that the exponential function 3x is approximated by means
of a polynomial in x of degree 3.
ExampleThe table below gives the values of tan x for 0.10 x 0.30
0
0
0
0
0
x
.1
.1
.2
.2
.3
y ta n x
0 .1 0 0 3
0 .1 5 1 1
0 .2 0 2 7
0 .2 5 5 3
0 .3 0 9 3
0
5
0
5
0
Find: (a) tan 0.12 (b) tan 0.26 . (c) tan 0.40 (d) tan 0.50
The table difference is
x
0 .1 0
y f (x)
0 .1 0 0 3
0 .0 5 0 8
0 .1 5
0 .1 5 1 1
0 .0 0 0 8
0 .0 5 1 6
0 .2 0
0 .2 0 2 7
0 .0 0 0 2
0 .0 0 1 0
0 .0 5 2 6
0 .2 5
0 .2 5 5 3
0 .0 0 0 2
0 .0 0 0 4
0 .0 0 1 4
0 .0 5 4 0
0 .3 0
0 .3 0 9 3
a) To find tan (0.12), we have r 0.4 Hence Newtons forward difference interpolation
formula gives
tan (0.12) 0.1003 0.4(0.0508)
0.4(0.4 1)
(0.0008)
2
0.4(0.4 1)(0.4 2)
(0.0002)
6
0.1205
b)
Numerical Methods
Page 83
x xn
n
0.26 03
0.05
0.8
which gives
tan (0.26) 0.3093 0.8(0.0540)
0.8(0.8 1)
(0.0014)
2
Exercises
1.
Using the difference table in exercise 1, compute cos0.75 by Newtons forward difference
interpolating formula with n 1, 2, 3, 4 and compare with the 5D-value 0.731 69.
2.
Using the difference table in exercise 1, compute cos0.28 by Newtons forward difference
interpolating formula with n 1, 2, 3, 4 and compare with the 5D-value
3.
Using the values given in the table, find cos0.28 (in radian measure) by linear interpolation and
by quadratic interpolation and compare the results with the value 0.961 06 (exact to 5D).
Numerical Methods
Page 84
f(x)=cosx
0.0
1.000 00
0.2
0.980 07
First
difference
Second
difference
-0.019 93
-0.03908
-0.059 01
0.4
0.921 06
-0.03671
-0.095 72
0.6
0.825 34
-0.03291
-0.128 63
0.8
0.696 71
-0.02778
-0.156 41
1.0
0.540 30
4.
5.
The sales in a particular shop for the last ten years is given in the table:
Year
1996
Sales (in
lakhs)
40
function f
1998
2000
2002
2004
43
48
52
57
having
Estimate the sales for the year 2001 using Newtons backward difference interpolating formula.
6.
Find
having
f ( x)
8.
10
Compute sin0.3 and sin0.5 by Everett formula and the following table.
sinx
Numerical Methods
0.
2
0.198 67
-0.007 92
0.
4
0.389 42
-0.015 53
.6
0.564 64
-0.022 50
Page 85
9. The following table gives the distances in nautical miles of the visible horizon for the given
heights in feet above the earths surface:
x =height
: 100
y = distance :
150
200
250
300
350
400
Numerical Methods
Page 86
6
NEWTON S AND LAGRANGIAN FORMULAE - PART I
Newtons Backward Difference Interpolation Formula
Newtons backward difference interpolation formula is
f ( x) Pn ( x) f n rf n
where x xn rh, r
r (r 1). . .(r n 1) n
r (r 1) 2
fn . . .
fn
2!
n!
x xn
h
, n r 0.
r 0,1, 2,..., n
pn ( x) a0 a1 ( x xn ) a2 ( x xn )(x xn1 )
a3 ( x xn )( x xn1 )( x xn2 ) ...
an ( x xn )( x xn1 )...(x x1 )
Imposing the condition that f ( x) and pn ( x ) should agree at the set of tabulated points
we obtain (after some simplification) the above formula.
Remark 1:
If the values of the kth forward/backward differences are same, then (k+1)th or higher differences
are zero. Hence the given data represents a kth degree polynomial.
Remark 2:
The Backward difference Interpolation Formula is commonly used for interpolation near the end of
a set of tabular values and for extrapolating values of y a short distance forward that is right from yn
.
Problem: For the following table of values, estimate f(7.5), using Newtons backward difference
interpolation formula.
Numerical Methods
Page 87
27
2f
3f
4f
7
12
19
6
18
37
4
64
24
61
125
216
343
512
0
6
30
91
0
6
0
6
36
127
0
6
42
169
Solution:
Since the fourth and higher order differences are 0, the Newtons backward interpolation
formula is
u u 1 2
y
2! n
,
u u 1u 2 3
u u 1u 2....(u n 1) n
yn ....
yn
3!
n!
f ( xn uh) yn u yn
Where, u
x xn
h
and
yn 169 , 2 yn 42 , 3 yn 6 and 4 yn 0 .
Hence,
f (7.5) 512 (0.5)(169)
(0.5)(0.5 1)
(0.5)(0.5 1)(0.5 2)
(42)
6
2!
3!
= 421.875.
Example For the following table of values, estimate f(7.5), using Newtons backward
difference interpolation formula.
Numerical Methods
Page 88
27
64
125
216
343
512
f
7
19
37
61
91
127
169
2f
12
18
24
30
36
42
3f
6
6
6
6
6
4f
0
0
0
0
Since the fourth and higher order differences are 0, the Newtons backward
interpolation formula is
f (x) Pn (x) fn rfn
r
x xn
h
r(r 1) 2
r(r 1)(r 2) 3
fn
fn , where
2!
3!
(0.5)(0.5 1)
(0.5)(0.5 1)(0.5 2)
(42)
6
2!
3!
= 421.875
Page 89
G1 p
G2
p ( p 1)
2!
G3
( p 1) p ( p 1)
,
3!
G4
( p 1) p ( p 1)( p 2)
,
4!
x 3
y 3
y 3
x 2
2 y 3
y 2
y 2
x 1
3 y 3
2 y 2
y 1
y 1
x0
2 y 1
y0
3 y 1
6 y 3
5 y 2
4 y 1
3 y0
y1
x2
4 y 2
2 y0
y1
5 y 3
3 y 2
y0
x1
4 y 3
2 y1
y2
y2
x3
y3
3!
n!
f ( x0 uh) y0 u y0
where, u
x x0
h
we have,
2 y0 2 Ey1 2 1 y1 2 y1 3 y1
3 y0 3 Ey1 3 1 y1 3 y1 4 y1 ,
Numerical Methods
Page 90
3!
4!
f ( x0 uh) y0 u y0
C3 3 y1
u 1
C4 4 y2
u 1
C5 5 y2 ....
u2
p ( p 1)
,
2!
G3
( p 1) p ( p 1)
,
3!
G4
( p 2)( p 1) p ( p 1)
,
4!
Example From the following table, find the value of e1.17 using Gauss forward formula.
1.00
1.05
1.10
1.15
1.20
1.25
1.30
ex
2.7183
2.8577
3.0042
3.1582
3.3201
3.4903
3.6693
Solution
Here we take x0 1.15, h 0.05 .
Also, x p x0 ph
1.17 1.15 p (0.05),
Numerical Methods
Page 91
which gives
p
0.02 1
0.05 4
ex
2 .7 1 8 3
0 .1 3 9 4
1 .0 5
2 .8 5 7 7
0 .0 0 7 1
0 .1 4 6 5
1 .1 0
3 .0 0 4 2
0 .0 0 0 4
0 .0 0 7 5
0 .1 5 4 0
1 .1 5
3 .1 5 8 2
0 .0 0 0 4
0 .0 0 7 9
0 .1 6 1 9
1 .2 0
3 .3 2 0 1
0
0 .0 0 0 4
0 .0 0 8 3
0 .1 7 0 2
1 .2 5
3 .4 9 0 3
0 .0 0 0 1
0 .0 0 0 5
0 .0 0 8 8
0 .1 7 9 0
1 .3 0
3 .6 6 9 3
(2 / 5 1)(2 / 5)(2 / 5 1)
(0.0004)
6
3!
4!
f ( x0 uh) y0 u y1 2 y1
C2 2 y1
u 1
C3 3 y2
u 1
C4 4 y2
u2
C5 5 y3 .... .
u2
Page 92
x0 3h
y3
2 y
3 y
4 y
5 y
6 y
y3
x0 2h
2 y3
y 2
y1
x0 h
y0
y1
5 y2
4 y1
2 y0
y2
6 y3
4 y2
3 y1
y1
x0 h
5 y3
3 y2
2 y1
y0
x0
4 y3
2 y2
y1
3 y0
2 y1
y2
x0 2h
x0 3h
3 y3
y2
y3
Numerical Methods
Page 93
The above table can also be written in terms of central differences using the operator as
follows:
x
x0 3 h
y 3
2y
3y
4y
5y
6y
y 5
x0 2 h
y 2
y 3
3 y 3
y 1
y 1
x0 h
y0
y1
x0
y1
x0 h
y3
y2
x0 2 h
x0 3h
2 y 2
4 y 1
2 y 1
5 y 1
3 y 1
2
4 y0
2 y1
y1
y1
2 y2
3 y3
2 y0
6 y0
5 y1
2
y5
y3
The difference given in both the tables are same can be established as follows:
We have E 2 . Then, y 5 E 2 y 5 y 5 1 y3 ;
1
2 y2 E 2
y2
2 2
2 y21 2 y3 ;
3y
3
2
1
E 2 y 3 3 3 y3 and so on.
2 2
We use the central differences as found in the first table for interpolation near the central
value. Among the various formulae for Central Difference Interpolation, first we consider Gausss
forward interpolation formula.
INTERPOLATION - Arbitrarily Spaced x values
In the previous sections we have discussed interpolations when the x-values are
equally spaced. These interpolation formulae cannot be used when the x-values are not
equally spaced. In the following sections, we consider formulae that can be used even if
the x-values are not equally spaced.
Numerical Methods
Page 94
f x1 f x0
,
x1 x0
f x0 , x1 , x2
f x1 , x2 f x0 , x1
,
x2 x0
f x0 , . . . , x k
f x1 , . . . , x k f x0 , . . . , x k 1
x k x0
Also, f [ x, x0 , x1 , , xn ]
Note
f [ x p x1 , , xn ] f ( x, x0 ,] xn
x0 x
k f 0
k ! hk
and Newtons divided difference interpolation formula takes the form of Newtons
forward difference interpolation formula.
Derivation of the formula:
For
function y f x ,
let
us
x , f x , x , f x , x , f x ,..., x , f x .
0
variable
are
given
the
set
of
(n 1)
points,
called
the first divided difference of f x between two consecutive arguments xi and xi 1 as,
f xi , xi 1
Numerical Methods
f xi 1 f xi
for i 0,1,..., n 1
xi 1 xi
Page 95
f xi 1 , xi 2 f xi , xi 1
for i 0,1,..., n 2
xi 2 xi
In general the nth divided difference (or divided difference of order n) between
x1 , x2 ,..., xn is,
f x0 , x1 ,..., xn
f x1 , x2 ,..., xn f x0 , x1 ,..., xn 1
xn x0
f x1 f x0
x1 x0
f x1 , x2 f x0 , x1
x2 x0
1 f x2 f x1 f x1 f x0
x2 x0
x2 x1
x1 x0
f x2
f x1
f x0
1
1
x2 x0 x2 x1 x2 x0 x2 x1 x1 x0 x2 x0 x1 x0
f x2
f x1
f x0
x2 x0 x2 x1 x2 x1 x1 x0 x2 x0 x1 x0
f x0 , x1 , x2
f x0
f x1
f x2
x0 x2 x0 x1 x1 x0 x1 x2 x2 x0 x2 x1
f x0
f x1
...
x
x
x
x
...
x
x
x
x
x
0 1 0 2 0 n 1 0 1 x2 ... x1 xn
Numerical Methods
f xn
x
x
x
n 0 n x1 ... xn xn 1
Page 96
f x1 f x0
x1 x0
f x0 f x1
f x1 , x0
x0 x1
When we are considering the nth divided difference also, we can write, f x0 , x1 ,..., xn as
f x0 , x1 ,..., xn
f x0
f x1
f xn
...
x0 x1 x0 x2 ... x0 xn x1 x0 x1 x2 ... x1 xn
xn x0 xn x1 ... xn xn1
From this expression it is clear that, whatever be the order of the arguments, the expression is
same.
Hence the divided differences are symmetrical about their arguments.
2. Divided difference operator is linear.
For example, consider two polynomials f x and g ( x) . Let
h( x) af x b g ( x) ,
where a and b are any two real constants. The first divided difference of h( x) corresponding to
the arguments x0 and x1 is,
h x0 , x1
h x1 h x0 af x1 b g ( x1 ) af x0 b g ( x0 )
x1 x0
x1 x0
a f x1 f x0 b g ( x1 ) g ( x0 )
x1 x0
f x1 f x0
g ( x1 ) g ( x0 )
b
x1 x0
x1 x0
a f x0 , x1 bg x0 , x1
f x1 f x0 x1n x0 n
x1 x0
x1 x0
Page 97
f x1 , x2 f x0 , x1
x2 x0
n 1
which
Since the divided difference operator is linear, we get nth divided difference of g x as a0 , which is
the leading coefficient of g x .
Example Using the following table find f ( x ) as a polynomial in x
x
f ( x)
39
822
1611
Numerical Methods
f [ xk , xk 1 ]
39
822
1611
15
261
789
6
41
132
5
13
Page 98
Hence
f ( x ) 3 ( x 1) (9) x ( x 1) (6) x ( x 1) ( x 3)(5)
x ( x 1) ( x 3)( x 6)
x 4 3 x 3 5 x 2 6.
Example Find the interpolating polynomial by Newtons divided difference formula for
the following table and then calculate f(2.1).
x
f(x)
x f(x)
Now
substituting
First
divided
Second
divided
difference
difference
Third divided
difference
f[xk -1, xk, xk+1, xk+2]
f ( x0 , x1 ) 0
f ( x1 , x2 ) 1
f ( x2 , x3 ) 3/ 2
the
values
1/ 2
1/ 6
in
1
2
the
formula,
we
get
1
1
f ( x) 1 ( x 0)(0) ( x 0)( x 1) ( x 0)( x 1)( x 2)
2
12
3
2
1 x 3 x 2 x 1
12
4
3
Numerical Methods
Page 99
7
NEWTON S AND LAGRANGIAN FORMULAE - PART II
Obtain Newtons divided difference interpolating polynomial satisfied by
4,1245 , 1,33 , 0,5 , 2,9 and 5,1335 .
Problem:
f (x) f x0 x x0 f x0 , x1 x x0 x x1 f x0 , x1, x2
x x0 x x1 x x2 f x0 , x1, x2 , x3 ....
First divided
differences
Second divided
differences
Third
divided
differences
Fourth
divided
differences
-4
-404
-1
94
-28
-14
10
2
2
3
13
88
442
Page 100
f x0 f x f x f x0
x0 x
x x0
f x f x0 x x0 f x, x0 ---- (1)
Consider x , x0 and x1 . Then,
f x, x0 , x1
f x0 , x1 f x, x0 f x, x0 f x0 , x1
x1 x
x x1
f x, x0 f x0, x1 x x1 f x, x0, x1
Put it in (1), we get,
f x f x0 x x0 f x0 , x1 x x1 f x, x0 , x1
That is,
f x f x0 x x0 f x0 , x1 x x0 x x1 f x, x0 , x1 --- (2)
Again, for x , x0 , x1 and x2
f x, x0 , x1, x2
f x, x0 , x1 f x0 , x1, x2 f x0 , x1, x2 f x, x0 , x1
x2 x
x x2
Page 101
x x0 x x1 ..... x xn f x, x0 , x1,..., xn
If f(x) is a polynomial of degree n, then f x, x0 , x1 ,..., xn 0 , because it is the (n+1)th
difference.
Hence we get,
f ( x) f x0 x x0 f x0 , x1 x x0 x x1 f x0 , x1 , x2
x x0 x x1 x x2 f x0 , x1 , x2 , x3 ....
Problem 2: The following table gives the relation between steam pressure and
temperature. Find the pressure at temperature 3750.
Temp. :
3610
3670
3780
Pressure:
154.9
167.9
191
Numerical Methods
3870
212.5
3990
244.2
Page 102
Solution:
To find the pressure at temperature 3750, it is to establish the relation giving
pressure in terms of temperature. Let us consider temperature as x values and pressure a
s corresponding f(x) values.
The given x values are 3610, 3670, 3780, 3870 and 3990. Corresponding f(x) values
are 154.9, 167.9, 191,212.5 and 244.2.
f(x) is obtained by Newtons divided difference interpolating polynomial as,
f ( x) f x0 x x0 f x0 , x1 x x0 x x1 f x0 , x1 , x2
x x0 x x1 x x2 f x0 , x1 , x2 , x3 ....
x x0 x x1 ..... x xn f x, x0 , x1,..., xn
Given f x0 f (3610 ) 154.9 .
First divided
differences
361
367
378
387
399
Second divided
differences
2.01666
0.00971
2.18181
2.38888
2.64166
Third
divided
differences
0.01035
0.01204
0.0000246
0.0000528
Fourth
divided
differences
0.00000074
Numerical Methods
Page 103
31
69
131
351
1011
Also find f(4.5), f(8) and the second derivative of f(x) at x=3.2.
Solution:
To obtain the Newtons divided difference interpolating polynomial f(x), we need
the divided difference using the given values.
It is calculated and listed in the following table
X
First divided
differences
14
38
62
110
220
Second divided
differences
Third
divided
differences
Fourth
divided
differences
12
16
22
0
0
Since the fourth divided differences are zeroes, f(x) is of degree 3 and it is obtained as,
f (x) f x0 x x0 f x0 , x1 x x0 x x1 f x0 , x1, x2
x x0 x x1 x x2 f x0 , x1, x2 , x3
f x0 f (1) 3; f x0 , x1 14; f x0 , x1 , x2 8 and f x0 , x1 , x2 , x3 1
f ( x) 3 x 1 14 x 1 x 3 8 x 1 x 3 x 4 1
That is,
f ( x) x 3 x 1
Hence,
Numerical Methods
Page 104
Lagrangian Interpolation
Another method of interpolation in the case of arbitrarily spaced pivotal values x0, x1, . . .
, xn is Lagrangian interpolation. This method is based on Lagranges n+1 point
interpolation formula given by
f x Ln x
l x
lkkxk fk ,
k0
where
l0 ( x ) ( x x1 )( x x2 ) . . . . ( x xn ) ,
lk ( x) ( x x 0 ) ( x xk 1 )( x xk 1 ) ( x xn ) ,
0 < k < n.
ln ( x ) ( x x0 )( x x1 ) . . ..( x xn 1 )
Remark: Lk ( xk ) f k . For, lk ( x j ) 0, when j k , so that for x xk , the sum on the RHS of the
formula reduces to the single term f k , which indicates that f and Lk agrees at n+1
tabulated points.
Derivation of the formula:
Given the set of (n 1) points, x0 , f x0 , x1 , f x1 , x2 , f x2 ,..., xn , f xn of x and f(x), it is
required to fit the unique polynomial pn ( x ) of maximum degree n, such that f ( x) and pn ( x ) agree
at the given set of points. The values x0 , x1 ,..., xn may not be equidistant.
Since the interpolating polynomial must use all the ordinates f x0 , f x1 ,..., f xn , it can be
written as a linear combination of these ordinates. That is, we can write the polynomial as
pn ( x) l0 ( x) f x0 l1 ( x) f x1 ln ( x) f xn .
Page 105
Hence, C
xi x0 xi x1 ... xi xi 1 xi xi 1 ... xi xn
Therefore,
li ( x)
x x0 x x1 ... x xi 1 x xi 1 ... x xn
xi x0 xi x1 ... xi xi 1 xi xi 1 ... xi xn
with
li ( x)
x x0 x x1 ... x xi 1 x xi 1 ... x xn
xi x0 xi x1 ... xi xi 1 xi xi 1 ... xi xn
is
called
Lagrange
interpolating
Let
x , f x , x , f x , x , f x
0
x x1 and
x0 x1
l1 ( x)
x x0 .
x1 x0
Page 106
p2 ( x) l0 ( x) f x0 l1 ( x) f x1 l2 ( x) f x2 , where,
x x1 x x2 ,
x0 x1 x0 x2
l0 ( x )
l1 ( x)
x x0 x x2 and
x1 x0 x1 x2
l2 ( x )
x x0 x x1 .
x2 x0 x2 x1
x x0 x x2 x x3 ,
x1 x0 x1 x2 x1 x3
l3 ( x)
x x0 x x1 x x2 and so on.
x3 x0 x3 x1 x3 x2
l2 ( x )
where,
l0 ( x)
x x1 x x2 x x3
x0 x1 x0 x2 x0 x3
x x0 x x1 x x3 and
x2 x0 x2 x1 x2 x3
Problem : Given f(2) = 9, and f(6) = 17. Find an approximate value for f(5) by the method of
Lagranges interpolation.
Solution:
For the given two points (2,9) and (6,17), the Lagrangian polynomial of degree 1
p1 ( x) l0 ( x) f x0 l1 ( x) f x1 , where, l0 ( x)
p1 ( x)
x x1 and
x0 x1
l1 ( x)
x x0 . That is,
x1 x0
x x1 f x x x0 f x
x0 x1 0 x1 x0 1
p1 ( x)
x 6 9 x 2 17
2 6
6 2
Hence,
f (5) P1 (5)
5 6 9 5 2 17
2 6
6 2
1
3
9 17
4
4
15
Problem: Use Lagranges formula, to find the quadratic polynomial that takes the values
x
Numerical Methods
: 0
f ( x) : 0
Page 107
is
For the given three points (0,0) , (1,1) and (3,0), the quadratic polynomial by Lagranges
interpolation is p2 ( x)
x x1 x x2 f x x x0 x x2 f x x x0 x x1 f x
x0 x1 x0 x2 0 x1 x0 x1 x2 1 x2 x0 x2 x1 2
We are considering the given x values 0,1, and 3 as x0 , x1 and x2 . Given, f x0 and f ( x2 )
are zeroes. Hence the polynomial is,
p2 ( x )
x x0 x x2 f x
x1 x0 x1 x2 1
Then,
p2 ( x )
x 0 x 3 1
1 0 1 3
p2 ( x)
x x 3
1
1 3x x 2 .
2
2
Example Find Lagranges interpolation polynomial fitting the points f(1) = 3, f(3) = 0,
f(4) = 30, f(6) = 132. Hence find f(5).
Here 4 tabulated points are given. Hence we need Lagranges polynomial for (n + = 3
+ 1 = 4 points) and is given by
l (x)
f (x) L3(x) k
f
l (x ) k .
k0 k k
3
( x 3)( x 4)( x 6)
( x 1)( x 4)( x 6)
(3)
(0)
(1 3)(1 4)(1 6)
(3 1)(3 4)(3 6)
( x 1)( x 3)( x 6)
( x 1)( x 3)( x 4)
(30)
(132)
(4 1)(4 3)(4 6)
(6 1)(6 4)(6 4)
1 ( x 27 x 92 x 60), on simplification.
2
3
Find ln 9.2 with n 3 , using Lagranges interpolation formula with the given
Numerical Methods
9.0
9.5
10.0
11.0
ln x
2.197
2.251
2.302
2.397
Page 108
22
29
59
90
3 l (9.2)
ln(9.2) f (9.2) L3 9.2 k
f .
l (x ) k
k 0 k k
Example
corresponding
values
of
and
log10 x
are
(300, 2.4771), (304, 2.4829), (305, 2.4843) and (307, 2.4871). Find log10 301.
log10 301
lk ( y )
xk .
k 0 lk ( yk )
x Ln ( y )
lk (7)
xk
k 0 lk ( yk )
x Ln (7)
where x0 1, y0 k ,
Numerical Methods
x y 3, y1 12
x2 4, y2 19 and y 7
Page 109
i.e., x
(7 y0 ) (7 y2 )
(7 y1 ) (7 y2 )
x0
( y0 y1 ) ( y0 y2 )
( y1 y0 ) ( y1 y2 )
x1
i.e.,
(7 y0 ) (7 y1 )
x2
( y2 y0 ) ( y2 y1 )
(5) (12)
(3) (12)
(3) (5)
(1)
(3)
(4)
(8) (15)
(8) (7)
(15) (7)
1 27 4
2 14 7
= 1.86
The actual value is 2.0 since the above values were obtained from the polynomial
y( x ) x 2 3.
y ln x
0.69315
0.91629
1.09861
Similarly,
l1 ( x ) (4 x 2 20 x 24) and l2 ( x ) 2 x 2 9 x 10.
Hence
L2 ( x )
l0 ( x )
l ( x)
l ( x)
f 1
f 2
f
l0 ( x k ) 0 l1 ( x k ) 1 l0 ( x k ) 2
( x 2) ( x 3)
( x 2) ( x 2.5)
( x 2.5) ( x 3.0)
f0
f1
f2
(0.5) (1.0)
(2.5 2) (3.0 2.5)
(3 2) (3 2.5)
(2 x 2 11x 15) (0.69315) (4 x 2 20 x 24) (0.91629)
(2 x 2 9 x 10) (1.09861)
0.08164 x 2 0.81366 x 0.60761.
Page 110
x
0
/4
/2
8 (0.70711) 1
9
9
4.65688 0.51743.
9
Example Using Lagranges interpolation formula, find the form of the function y( x ) from
the following table.
x
12
12
24
so on.
x
0
3
4
R(0)
12
12, and
0 1
R( x )
12
6
8
( x 3)( x 4)
( x 0)( x 4)
( x 0)( x 3)
(12)
(6)
(8)
(3) (4)
(3 0) (3 4)
(4 0) (4 3)
Numerical Methods
Page 111
( x 3)( x 4) 2 x ( x 4) 2 x ( x 3)
= x 2 5 x 12.
Hence the required polynomial approximation to y( x ) is given by
y( x ) ( x 1)( x 2 5 x 12).
Example With the use of Newtons divided difference formula, find log 10301. Given the
following divided difference table
x
f ( x ) log 10 x
300
2.47714
304
2.4829
305
2.4843
307
2.4871
f [ xk 1 , xk ]
0.00145
0.00140
f [ xk 2 , xk , xk 1 ]
0.00001
0
0.00140
It is clear that the arithmetic in this method is much simpler when compare to that in
Lagranges method.
Exercises
9.
10.
11.
Numerical Methods
f(x)=cosx
First
difference
Second
difference
0.0
1.000 00
-0.019 93
-0.03908
0.2
0.980 07
-0.059 01
-0.03671
0.4
0.921 06
-0.095 72
-0.03291
Page 112
12.
13.
0.6
0.825 34
-0.128 63
0.8
0.696 71
-0.156 41
1.0
0.540 30
-0.02778
function f
having
The sales in a particular shop for the last ten years is given in the table:
Year
1996
Sales (in
lakhs)
40
1998
2000
2002
2004
43
48
52
57
Estimate the sales for the year 2001 using Newtons backward difference interpolating
formula.
14.
having
f ( x)
16.
10
Compute sin0.3 and sin0.5 by Everett formula and the following table.
sinx
0.2
0.198 67
-0.007 92
0.4
0.389 42
-0.015 53
.6
0.564 64
-0.022 50
9. The following table gives the distances in nautical miles of the visible horizon for the
given heights in feet above the earths surface:
x =height
: 100
150
200
250
300
350
400
Page 113
8
INTERPOLATION BY ITERATION
Interpolation by Iteration
Given the (n 1) points ( x0 , f0 ), ( x1 , f1 ), , ( xn , f n ), where the values of x need not
necessarily be equally spaced, then to find the value of f corresponding to any given value
of x we proceed iteratively as follows: obtain a first approximation to f by considering the
first-two points only; then obtain its second approximation by considering the first-three
points, and so on. We denote the different interpolation polynomials by ( x ), with
suitable subscripts, so that at the first stage of approximation, we have
01 ( x ) f0 ( x x0 ) f [ x0 , x1 ]
1
x1 x0
f0
f1
x0
x1
x
.
x
01 ( x )
1
x 2 x1 02 ( x )
x1
x2
x
.
x
Similarly we obtain 013 ( x ), 014 ( x ), etc. At the nth stage of approximation, we obtain
012n (x)
012n1(x) xn1 x
1
xn xn1 012n2n (x) xn x .
x0
f0
x1
f1
x2
f2
x3
f3
x4
f4
Numerical Methods
01 ( x )
02 ( x )
03 ( x )
04 ( x )
012 ( x )
013 ( x )
014 ( x )
0123 ( x )
0124 ( x )
01234 ( x )
Page 114
A modification of this scheme, due to Neville, is given in the following Table. Nevilles
scheme is particularly suited for iterated inverse interpolation.
Table 2 Nevilles Scheme
f
x0
x1
f0
f1
x2
f2
x3
f3
x4
f4
01 ( x)
12(x)
23(x)
34 (x)
012 (x)
123(x)
234(x)
0123(x)
1234 (x)
01234 (x)
Example 26 Using Aitkens scheme and the following values evaluate log10 301.
x
log10 x
300
2.4771
304
2.4829
305
2.4843
307
2.4871
2.47855
2.47854
2.47853
2.47858
2.47857
2.47860
Solution
log10 301 2.4786.
Inverse Interpolation
Given a set of values of x and y, the process of finding the value of x for a certain value of y
is called inverse interpolation. When the values of x are at unequal intervals, the most
obvious way of performing this process is by interchanging x and y in Lagranges or
Aitkens methods.
Example If y1 4, y3 12, y4 19 and yx 7, find x. Compare with the actual value.
Solution
Aitkens scheme (see Table 1) is
Numerical Methods
Page 115
12
19
1.750
1.600
1.857
12
19
1.750
2.286
1.857
u(u 1)(u 2) 3
u(u 1) 2
y0
y0
2
6
u 1 yu y0
y0
y0 .
y0
2
6
Neglecting the second and higher differences, we obtain the first approximation to u as
follows
u1 1 ( yu y0 ).
y0
Next, we obtain the second approximation to u by including the term containing the
second differences. Thus,
u (u 1) 2
u2 1 yu y0 1 1
y0
y0
2
where we have used the value of u1 for u in the coefficient of 2 y0 . Similarly, we obtain
u (u 1) 2
u (u 1)(u2 2) 3
u3 1 yu y0 2 2
y0 2 2
y0
y0
2
6
Numerical Methods
Page 116
and so on. This process should be continued till two successive approximations to u agree
with each other to the required accuracy. The method is illustrated in the following
example.
ExampleTabulate y x 3 for x 2, 3, 4 and 5, and calculate the cube root of 10 correct to
three decimal places.
Solution
x
y x3
27
64
125
19
18
37
24
61
0.15(0.15 1) (0.15 2)
0.15(0.15 1)
u3 1 2
(18)
(6) 0.1532
19
2
6
0.1541(0.1541 1) (0.1541 2)
0.1541(0.1541 1)
u4 1 2
(18)
(6)
19
2
6
0.1542.
We take u 0.154 correct to three decimal places. Hence the value of x (which corresponds
to y 10), i.e., the cube root of 10 is given by x0 uh 2 (0.154)1 2.154.
Exercises
1. The values of x and ux are given in the following Table.
x
ux
113
286
613
Numerical Methods
Page 117
2. Using Lagrange inverse formula, find the value of x corresponding to y 100 from the
following Table.
x
11
24
58 108 174
11
f ( x)
12
13
14
16
ux
16.35
10
15
Find correct to one decimal place the value of x for which ux 14.
Numerical Methods
Page 118
9
NUMERICAL DIFFERENTIATION AND INTEGRATION
Numerical differentiation
The problem of numerical differentiation is the determination of approximate value
of the derivative of a function at a given point.
Differentiation using Difference Operators
We assume that the function y = f(x) is given for the equally spaced x values xn =
x0 + nh, for n = 0, 1, 2, To find the derivatives of such a tabular function, we proceed as
follows:
Using Forward Difference Operator
hD log E log1
Hence
D
1
1
2 3 4 5
log1
. . .
h
h
2
3
4
5
Also,
1
2 3 4 5
D 2
...
2
3
4
5
h
1 2
11
5
3 4 5 . . .
2
12
6
h
Therefore,
f ( x)
d
1
2 f ( x) 3 f ( x) 4 f ( x) 5 f ( x)
f ( x) Df ( x) f ( x)
...
dx
h
2
3
4
5
1
11
5
f ( x ) D 2 f ( x ) 2 2 f ( x ) 3 f ( x ) 4 f ( x ) 5 f ( x ) . . .
12
6
h
Recall that
hD log1 .
Numerical Methods
Page 119
On expansion, we have
1
2 3 4
...
h
2
3
4
Also,
1
2 3 4
D 2
...
2
3
4
h
1 2
11
5
3 4 5 . . .
2
12
6
h
Hence,
f ( x)
d
f ( x) Df ( x)
dx
1
2 f ( x) 3 f ( x) 4 f ( x)
f ( x )
...
h
2
3
4
f ( x) D 2 f ( x)
1 2
11
5
f ( x) 3 f ( x) 4 f ( x) 5 f ( x) . . .
2
12
6
h
Example Compute f (0.2) and f (0) from the following tabular data.
x
0.0
0.2
0.4
0.6
0.8
1.0
Since x = 0 and 0.2 appear at and near beginning of the table, it is appropriate to use
formulae based on forward differences to find the derivatives. The forward difference
table for the given data is:
x
f(x)
0.0
1.00
0.2
1.16
0.4
3.56
0.6
13.96
0.8
41.96
1.0 101.00
Numerical Methods
2.24
8.00
17.60
31.04
5.76
9.60
13.44
3.84
3.84
0.00
Page 120
Using
f x Df x
2 f x 3 f x 4 f x
1
f x
.
.
.
h
2
3
4
we obtain
f 0.2
1
8.00 9.60 3.84
2.40
3 .2
0 .2
2
3
4
Using
f x D 2 f x
1 2
11 4
3
f x f x f x . . .
2
12
h
we obtain
f 0
11
5
12
6
0.2
1
Example Compute f (2.2) and f (2.2) from the following tabular data.
x
1.4
1.6
1.8
2.0
2.2
f(x)
1.4 4.0552
1.6 4.9530
1.8 6.0496
2.0 7.3891
2.2 9.0250
f(x)
0.8978
1.0966
1.3395
1.6359
0.1988
0.2429
0.2964
0.0441
0.0535
0.0094
2 f x 3 f x 4 f x
1
f x
...
h
2
3
4
we obtain
f 2.2
1
0.2964 0.0535 0.0094
1.6359
9.0215
0 .2
2
3
4
Numerical Methods
Page 121
1 2
11 4
3
f x f x f x . . .
2
12
h
we obtain
f 2.2
0.2
11
1.0
1.2
1.4
1.6
1.8
2.0
d2y
dy
and 2 for x 1.2 :
dx
dx
2.2
1.0
2.7183
1.2
3.3201
1.4
4.0552
1.6
4.9530
1.8
6.0496
2.0
7.3891
2.2
9.0250
0.6018
0.7351
0.8978
1.0966
1.3395
1.6359
0.133
0.1627
0.1988
0.2429
0.2964
0.0294
0.0067
0.0361
0.0080
0.0441
0.0094
0.0535
0.0013
0.001
0.0014
1
1
1
1
1
0.7351 (0.1627) (0.0361) (0.0080) (0.0014)
0.2
2
3
4
5
3.3205 .
2
Similarly, d 2y
dx x 1.2
1
11
5
0.1627 0.0361 (0.0080) (0.0014) 3.318.
0.04
12
6
ExampleCalculate the first and second derivatives of the function tabulated in the
preceding example at the point x 2.2 and also
Numerical Methods
dy
at x 2.0 .
dx
Page 122
We use the table of differences of Example 1. Here xn 2.2, yn 9.0250 and h 0.2.
Hence backward difference for derivative gives
1
dy
f (2.2)
dx
0.2
x 2.2
1.6359 1 (0.2964) 1 (0.0535) 1 (0.0094) 1 (0.0014)
2
3
4
5
= 9.0228.
d2 y
1
f (2.2)
dx2
0.04
x2.2
0.2964 0.0535 11 (0.0094) 5 (0.0014) 8.992.
12
6
Also,
1
dy
f (2.2)
dx
0.2
x 2.0
1.3395 1 (0.2429) 1 (0.0441) 1 (0.0080) 1 (0.0013) 1 (0.0001)
2
3
4
5
6
= 7.3896.
Derivative using Newtons Forward difference Formula
For finding the derivative at a point near to the beginning of the tabular values,
Newtons Forward difference Formula is used. For the values y0 , y1 ,..., yn of a function
y=f(x),
corresponding
to
the
equidistant
values x0 , x1 , x2 ,..., xn ,
where
x1 x0 h, x2 x0 2h, x3 x0 3h,..., xn x0 nh , Newtons Forward difference Formula is,
u u 1 2
y0
2!
u u 1 u 2 3
u u 1 u 2 ....(u n 1) n
y0 ....
y0
3!
n!
f ( x) f ( x0 uh) y0 u y0
where, u
x x0
.
h
f ( x)
f ( x)
du
dx h du
h
Numerical Methods
Page 123
d
1
2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
f ( x) y0
y0
y0
y0 .....
dx
h
2!
3!
24
dx
1
d 1
2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
y0
y0
y0 .....
du h
2!
3!
24
h
1 2 2 6u 6 3 12u 2 36u 22 4
y0
y0
y0 .....
2
3!
24
h 2!
1 2
6u 2 18u 11 4
y0 u 1 3 y0
y0 .....
2
12
h
In similar way,
du 1
d3
d d2
12u 18 4
f
(
x
)
f ( x) 3 3 y0
y0 .....
3
2
du dx
12
dx
dx h
When x x0 , and u 0, we have
d2
1
11
f ( x) 2 2 y0 3 y0 4 y0 .....
2
12
dx
h
and
d3
1
3
f (x) 3 3 y0 4 y0 .....
3
2
dx
h
To find the derivative at a point near to the end of the tabular values, Newtons
backward difference Formula is used. For the equidistant arguments, Newtons backward
difference Formula is,
u u 1 2
yn
2!
u u 1 u 2 3
u u 1 u 2 ....(u n 1) n
yn ....
yn
3!
n!
f ( x) f ( xn uh) yn u yn
where u
x xn
h
Numerical Methods
Page 124
d
d x xn
d
1
f ( x)
du f ( x ) h
du
dx
h
d
1
2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
f ( x ) yn
yn
yn
yn ...
dx
h
2!
3!
24
d2
d d
du 1
f ( x)
f ( x)
du
dx
dx
dx h 2
6u 2 18u 11 4
3
n
n
yn ... , and
12
du 1
d3
d d2
f
(
x
)
f ( x)
3
3
2
du
dx
dx
dx h
3 y 12u 18 4 y ...
n
n
12
d
1
1
1
1
f ( x) yn 2 yn 3 yn 4 yn ...
dx
h
2
3
4
d2
1
11
f ( x) 2 2 yn 3 yn 4 yn ... and
2
12
dx
h
d3
1
3
f ( x) 3 3 yn 4 yn ... .
2
dx3
h
Problem: Compute f (0) and f (0.2) from the following tabular data.
x
0.0
0.2
0.4
0.6
0.8
1.0
y=f(x)
0.0
1.00
0.2
1.16
0.4
3.56
0.6
13.96
0.8
41.96
1.0 101.00
Numerical Methods
y
0.16
2.40
10.40
28.00
59.04
2 y
2.24
8.00
17.60
31.04
3 y
5.76
9.60
13.44
4 y 5 y
3.84
3.84
0.00
Page 125
x x0 0
h
f "(0)
For x=0.2, u
1
2
0.2
24
6
0.2 0.0 1
0.2
d
1
2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
f ( x) y0
y0
y0
y0 .....
dx
h
2!
3!
24
Hence,
d
1
2 1 1
3 12 6 1 2
4 13 18 12 22 1 6
f ( x)
0.16
2.24
5.76
3.84
dx
0.2
2!
3!
24
x 0.2
= 3.2, on simplification.
If the arguments are not equidistant, the approximating polynomial for the given
tabular points is found by Newtons divided difference formula or Lagranges
interpolation formula. Then the derivative of the function can get at any x in the range.
For example: We find the first derivative of a function at 0, using the points
4,1245 , 1,33 , 0,5 , 2,9 and 5,1335 where x values are not equidistant. We can get the
approximating polynomial by Newtons divided difference formula.
The table of divided differences is,
x
-4
1245
-1
33
1335
Numerical Methods
First divided
differences
Second divided
differences
Third divided
differences
Fourth divided
differences
-404
-28
94
-14
2
442
10
3
13
88
Page 126
On simplification, we get
f ( x) 3x 4 5 x3 6 x 2 14 x 5 .
Then,
f '( x) 12 x3 15 x 2 12 x 14
Hence,
f '(0) 14 .
Exercises
1.
1.00
1.10
1.15
1.20
1.25
1.30
f ( x)
2.
1.05
Find the first derivative of f(x) at x = 0.4 from the following table:
x
0.1
0.2
0.3
0.4
A slider in a machine moves along a fixed straight rod. Its distance x cm along the
rod is given below for various values of time t (seconds). Find the velocity of the
slider and its acceleration at time t = 0.3 sec.
t
0.0
0.1
0.2
0.3
0.4
0.5
0.6
1.3
1.5
1.7
1.9
2.1
2.3
Page 127
10
NUMERICAL INTEGRATION
THE TRAPEZOIDAL RULE
In this method to evaluate
and replace f by a straight line segment on each subinterval. The vertical lines from the
ends of the segments to the partition points create a collection of trapezoids that
approximate the region between the curve and the x-axis. We add the areas of the
trapezoids counting area above the x-axis as positive and area below the axis as negative
and denote the sum by T . Then
1
1
1
1
T (y0 y1 )h (y1 y2 )h (yn2 yn1 )h (yn1 yn )h
2
2
2
2
h y0 y1 y2 ... yn1 yn
1
2
1
2
where
y 0 f ( a ), y1 f ( x1 ), ... , y n 1 f ( x n 1 ),
y n f (b ) .
To approximate a f ( x)dx ,
(for n subintervals of length h b a
n
and y j f ( x j )).
use
h
( y 0 2 y1 2 y 2 ... 2 y n 1 y n )
2
h
T [ y 0 y n 2( y1 y 2 ... y n 1 )]
2
T
or
x 2 dx .
Numerical Methods
Page 128
To find the trapezoidal approximation, we divide the interval of integration into four
subintervals of equal length and list the values of y x 2 at the endpoints and partition
points.
j
xj
1.0
1.25
1.5625
1.50
2.2500
1.75
3.0625
2.00
4.0000
Sum
5.0000
y j x j2
1.0000
6.8750
With n 4 and h b a 2 1 1 :
n
h
T [ y 0 y 4 2( y1 y 2 y 3 )]
2
1 1.4 2 6.875
8
= 2.34375
The exact value of the integral is
x 2 dx x 8 1 7 2.33334
3 1 3 3 3
The approximation is a slight overestimate. Each trapezoid contains slightly more than the
corresponding strip under the curve.
Problem: Using Trapezoidal rule solve the integral,
x
0
1
dx
6 x 10
with four
subintervals.
Solution:
is,
For n subintervals, the trapezoidal rule for the integral of a function in the range [a,b]
b
f ( x)dx 2 y
2 y1 2 y2 ... 2 yn 1 yn
Page 129
f ( x)dx 2 y
Now,
2 y1 2 y2 2 y3 y4
In our integral,
x
0
1
dx , the range of integral [0,1] is divided into four equal
6 x 10
Hence,
1
x
0
1
0.25
dx
0.10 2 0.08649 2 0.07547 2 0.06639 0.05882
6 x 10
2
= 0.07694.
Example Use the trapezoidal rule with n 4 to estimate
2
x dx .
1
xj
1.0
1.25
0.80000
1.50
0.66667
1.75
0.57143
2.00
0.50000
Sum
1.50000
1.00000
2.0381
Numerical Methods
Page 130
h
T [ y 0 y 4 2( y1 y 2 y 3 )]
2
1 dx ln x ln 2 ln1 0.69315
x
1
Here h
b a 1 0
0.1 and
n
1
1 x2
0.1
dx T
y y10 2 ( y1 y2 y9 )
e
2 0
0
xj
xj2
0.0
0.00
0.1
0.01
0.960 789
0.2
0.04
0.913 931
0.3
0.09
0.852 144
0.4
0.16
0.778 801
0.5
0.25
0697 676
0.6
0.36
0.612 626
0.7
0.49
0.612 626
0.8
0.64
0.527 292
0.9
0.81
0.444 858
1
0
1.0
1.00
Sums
1
x2
j
f (x ) e
j
1.000 000
0.990 050
0.367 879
1.367 879
6.778 167
Numerical Methods
Page 131
f ( x ) dx is based on approximating
with
( Ax 2 Bx C ) dx h ( y 0 4 y1 y 2 )
3
f ( x ) dx , use
S h ( y 0 4 y1 2 y 2 4 y 3 ... 2 y n 2 4 y n 1 y n ).
3
where
(5A)
dx
0 4x 5
, by Simpsons 1/3
rule of integration.
We note that
5
5 dx
25
1 log 4 x 5 1 log25 log5 1 log 1 log5.
4
0 4
4
x
5
4
5 4
0
5 dx
, by Simpsons rule of integration, divide the interval
0 4x 5
Numerical Methods
b a 50
0.5.
n
10
Page 132
xj
0.0
0.5
1.0
1.5
11
2.0
13
2.5
15
3.0
17
3.5
19
4.0
21
4.5
23
10
5.0
25
f j f (x j )
4 xj+5
0.20
0.1429
0.1111
0.0909
0.0769
0.6666
0.0588
0.0526
0.0476
0.0434
0.04
s0=0.24
Sums
1
4x j 5
s1=0.3963
s2=0.2944
Hence,
5 dx
0 .5
0.24 4(0.3963) 2(0.2944) 0.4023.
S
3
0 4x 5
and
Problem: Find
10
1 x
Solution:
By Simpsons one third rule,
f ( x)dx 3 y
4 y1 y3 ... 2 y2 y4 .... yn
10
1
dx , let the range [0,10] is subdivided into 10 equal interval of
1 x2
0
In our integral,
10
0.5 0.2 0.1 0.0588 0.0385 0.0270 0.02 0.0154 0.0122 0.0099
Thus,
Numerical Methods
Page 133
1 x
1
dx 1 4 0.5 0.1 0.0385 0.02 0.0122 2 0.2 0.0588 0.027 0.0154 0.0099
3
1
1.0099 4 0.6707 2 0.3012
3
1
4.2951 1.4317 .
3
6
1
dx using Simpsons three eight rule.
2
3
x
0
Problem: Evaluate
Solution:
a f ( x)dx
3h
y0 3 y1 y2 y4 .... yn 1 2 y3 y6 y9 ... yn
8
Let the limit of integral [0,6] be divided into six equal parts with interval h=1, using the
1
x values 0,1,2,3,4,5 and 6. Corresponding y values of the given integrand function
3 x2
are,
x
Thus,
6
3 x
dx
3 1
y0 3 y1 y2 y4 .... yn 1 2 y3 y6 y9 ... yn
8
For n=6,
6
3 x
3 x
dx
3 x
3 1
y0 3 y1 y2 y4 y5 2 y3 y6
8
3 1
0.333 3 0.25 0.1429 0.0526 0.0357 2 0.1 0.0256
8
dx
3
3
0.333 1.4436 0.2 0.0256 2.0022
8
8
dx 0.7508 .
Numerical Methods
Page 134
Here h b a 1 0 0.1
n
10
xj
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
10
1.0
Sums
y f ( x ) x 2j
j
j
0.00
0.01
0.04
0.09
0.16
0.25
0.36
0.49
0.64
0.81
1.00
s0=1.00
s1 =1.65
s2=1.20
Hence ,
1
2
x dx S
0.1
1.00 4 (1.65 ) 2 (1.20 ) 0.3333.
3
Example 11 A town wants to drain and fill a small-polluted swamp (See the adjacent
figure). The swamp averages 5 ft deep. About how many cubic yards of dirt will it take to
fill the area after the swamp is drained?
Solution To calculate the volume of the swamp, we estimate the surface area and multiply
by 5. To estimate the area, we use Simpsons rule with h 20 ft and the ys equal to the
distances measured across the swamp, as shown in the adjacent figure.
Numerical Methods
Page 135
S h ( y 0 4 y1 2 y 2 4 y 3 2 y 4 4 y 5 y 6 )
3
20 (146 488 152 216 80 120 13) 8100
3
ex
/2
dx using
xj
0.000
0.125
0.250
0.375
0.500
0.625
0.750
0.875
1.000
2 x j2 / 2
e
0.7979
0.7917
0.7733
0.7437
0.7041
0.6563
0.6023
0.5441
0.4839
s0=1.2818
Sums
Hence I
f f (x )
j
j
s1=2.7358
s2=2.0797
2 1 x2 / 2
0.125
e
dx S
1.2818 4(2.7358) 2(2.0797)
0
3
0.6827
f ( x) dx
Numerical Methods
Ln ( x) dx
fk
l ( xk )
k 0 k
l (x) dx
b
Page 136
For n = 1, we have only one interval [x0, x1] such that a = x0 and b = x1 and then the
above integration formula gives trapezoidal rule.
For n = 2 , we have two subintervals [x0, x1] and [x1, x2] of equal width h such that a
= x0 and b = x2 and then the above integration formula becomes
b
f ( x) dx
x2
x0
f ( x) dx h f 0 4 f1 f 2 ,
3
f ( x) dx
x3
x0
f ( x) dx 3 h f 0 3 f1 3 f 2 f 3 ,
8
x0
32
1 33 32
1 34
f ( x)dx h 3 y0 y0 2 y0 33 32 3 y0 0
2
23 2
6 4
9
1 27 9
1 81
h 3 y0 y1 y0 y2 2 y1 y0 27 9 y3 3 y2 3 y1 y0
2
2 3 2
6 4
h
72 y0 108 y1 y0 54 y2 2 y1 y0 9 y3 3 y2 3 y1 y0
24
h
9 y0 27 y1 27 y2 9 y3
24
x3 x0 3 h
f ( x)dx
x0
Similarly,
x6 x0 6 h
x3
3h
y0 3 y1 3 y2 y3
8
f ( x)dx
3h
y3 3 y4 3 y5 y6
8
Page 137
f ( x)dx
xn3
3h
yn3 3yn2 3yn1 yn
8
f ( x)dx
x0
3h
y0 3 y1 3 y2 y3 y3 3 y4 3 y5 y6 ... yn 3 3 yn 2 3 yn 1 yn
8
That is,
b
a f ( x)dx
3h
y0 3 y1 3 y2 y3 y3 3 y4 3 y5 y6 ... yn 3 3 yn 2 3 yn 1 yn
8
3h
a f ( x)dx 8 y
3 y1 3 y2 2 y3 3 y4 3 y5 2 y6 3 y7 ... 3 yn 1 yn
a f ( x)dx
3h
y0 3 y1 y2 y4 .... yn 1 2 y3 y6 y9 ... yn
8
Exercises
Estimate the integral using
(a) trapezoidal rule
1.
4.
7.
and
sin t dt
3.
( x 2 1) dx
6.
1 ds
2
2.
x dx
5.
8.
sin x
dx
0 x
1
dx
10. ln 2
x
0
Numerical Methods
1
dx
1 x
x 3dx
9.
(t 3 t ) dt
1 x
6
dx
11.
1
dx
x
12.
(2 x 1) dx
Page 138
13.
14.
1 x 2 dx
x 1 x2
0.0
0.125
0.12402
0.25
0.24206
0.375
0.34763
0.5
0.43301
0.625
0.48789
0.75
0.49608
0.875
0.42361
1.0
15.
18.
sin t dt
3cos
(2 sin )
( x 2 1) dx
16.
17.
(t 3 1) dt
1 ds
(S 1) 2
3cos
(2 sin ) 2
1.57080
0.0
1.17810
0.99138
0.78540
1.26906
0.39270
1.05961
0.75
0.39270
0.48821
0.78540
0.28946
1.17810
0.13429
1.57080
19. The following table gives values of x and f ( x ) . Find the area bounded by the curve
y f ( x), the x -axis and the ordinates x = 7.47 and 7.52.
x
7.47
7.48
7.49
7.50
7.51 7.52
F ( x)
1.93
1.95
1.98
2.01
2.03 2.06
1.6
1.2
f x e x
21.
1.2
1.3
1.4
0.237
0.185 0.141
1.5
1.6
0.106 0.077
dx
1 x
by
Page 139
11
SOLUTION OF SYSTEMS OF LINEAR EQUATIONS
Solution of system of linear equations
A system of m linear equations in n unknowns x1, x2, . . . , xn is a set of equations of
the form
a1 1 x1 + a1 2 x2 +
. . .
+ a1 n x n = b1
a2 1 x1 + a2 2 x2 +
. . .
+ a2 n x n = b2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
a m 1 x1 + a m 2 x2 + . . .
+ amn xn = bm
where the coefficients a j k and the b j are given numbers. The system is said to be
homogeneous if all the b j are zero; otherwise, it is said to be non-homogeneous.
The system of linear equations is equivalent to the matrix equation (or the single vector
equation)
Ax b
where the coefficient matrix A [a i j ] is the m n matrix and x and b are the column
matrices (vectors) given by:
a11
A a 21
.
a
m1
a12
a 22
.
am2
... a1n
... a 2 n ,
... .
... a mn
x1
x
2
x .
.
x
n
and
b1
b
2
b .
.
b
m
A solution of the system is a set of numbers x1, x2, . . . , xn which satisfy all the m
equations, and a solution vector of (1) is a column matrix whose components constitute a
solution of system. The method of solving such a system using methods like Cramers
rule is impracticable for large systems. Hence, we use other methods like Gauss
elimination.
Gauss Elimination Method
In the Gauss elimination method, the solution to the system of equations is obtained
in two stages. In the first stage, the given system of equations is reduced to an equivalent
upper triangular form using elementary transformations. In the second stage, the upper
triangular system is solved using back substitution procedure by which we obtain the
solution in the order xn , xn 1 , xn 2 , , x2 , x1 .
Numerical Methods
Page 140
2x1 x2 2x3 x4 6
(1)
(2)
(3)
2x1 2x2 x3 x4 10
(4)
To eliminate x1 from equations (2), (3) and (4), we subtract suitable multiples of equation
(1) and we get the following system of equations:
(2) 3 (1)
(5)
(3) 2 (1)
x2 x3 5x4 = 13
(6)
(4) 1 (1)
x2 3x3 +0x4 =
(7)
To eliminate x2 from equations (6) and (7), subtract suitable multiples of equation (5) and
get the following system of equations:
(6) (-1/9)(5) x3 4x4 = 11
(8)
(9)
To eliminate x2 from equation (9), subtract 3(8) and get the following equation:
13 x4 = 39
(10)
From equation (10), x4 = 39/13 = 3; using this value of x4, (9) gives x3 = -1; using these
values of x4 and x3, (7) gives x2 = 1; using all these values (1) gives x1 = 2. Hence the
solution to the system is x1 = 2, x2 = 1, x3 = 1, x4 = 3.
Note: The above method can be simplified using the matrix notation. The given system of
equations can be written as
Ax b
and the augmented matrix is
1 2
1 6
2
6 6 6 12 36
4
3 3 3 1
2 2 1 1 10
Numerical Methods
Page 141
1 2
1
6
2
0 9 0 9 18
.
0 0 1 4 11
0 0 0 13 39
Hence
1 2
1 x1 6
2
0 9 0 9 x 18
2
0 0 1 4 x3 11
0 0 0 13 x4 39
x2 1 ,
x3 1 , x4 3
In the example, we had a11 0. Otherwise we would not have been able to eliminate x1 by
using the equations in the given order. Hence if a11 0 in the system of equations we
have to reorder the equations (and perhaps even the unknowns in each equation) in a
suitable fashion; similarly, in the further steps. Such a situation can be seen in the
following Example.
Example Using Gauss elimination solve:
y 3z 9
2x 2 y
z 8
x 5z
Here the leading coefficient (i.e., coefficient of x) is 0. Hence to proceed further we have to
interchange rows 1 and 2, so that
2x + 2 y
y
z = 8
(1)
+ 3z = 9
(2)
x + 5z
= 8
(3)
1
(1)
2
+ 3z
y +
9
z
2
= 9
= 12
(4)
+ 3z
= 9
Page 142
3
z
2
(4) (2)
= 3
z = 2, y = 9 6 = 3,
Hence
(5)
x = 2.
Hence
x 2
y 3 .
z 2
In total pivoting, we look for an absolutely largest coefficient in the entire system
and start the elimination with the corresponding variable, using this coefficient as the
pivotal coefficient (for this we have to interchange rows and columns, if necessary);
similarly in the further steps. Total pivoting, in fact, is more complicated than the partial
pivoting. Partial pivoting is preferred for hand calculation.
Example Solve the system
0.0004 x1 1.402 x2 1.406
(1)
(2)
(2)
0.40031
(1a )
0.0001
and so
(1a)
1405 x2 1404
(2a)
x2
1404
0.9993
1405
Numerical Methods
Page 143
x1
1
0.005
1.406 1.402 0.9993 0.0004 12.5.
0.0004
a21 as the
pivotal coefficient (i.e. second equation becomes the pivotal equation). To start with we
rearrange the given system as follows:
0.4003 x1 1.502 x2 2.501
(3)
(4)
(4)
0004
(3) 1.404 x2 1.404
4003
(3a)
(4a)
and so
x2
1.404
1
1.404
x1
1
(2.501 1.502 1) 10.
0.4003
Example Solve the following system (i) without pivoting (ii) with pivoting
0.0002 x 0.3003 y 0.1002
. . . (1)
. . . (2)
(2)
2
0.3003 2
0.1002 2
(1) 3.000
y 2.0000 0.0002
0.0002
0002
i.e.,
1498.5 y 499.
Now by back substitution, the solution to the system is given by y 0.3330 and x 0.5005 ;
(ii) With pivoting:
Since a11 is small and is nearer to zero as compared with a21 , we accept
a21 as the
pivotal coefficient (i.e. second equation becomes the pivotal equation). To start with we
rearrange the given system as follows:
Numerical Methods
. . . (3)
. . . (4)
Page 144
(4)
0002
3.0000 0.0002
2 0.0002
(3) 0.3003
y 0.1002
2
2
2
which simplifies to
0.3000 y 0.1000.
1
3
and
1
x .
2
A 2 3 4
3 4 1
R2 R2 (2) R1
m21 2
R3 R3 (3) R1
m31 3
1 2 3
~ 0 1 2
0 2 8
1 2 3
~ 0 1 2
0 0 4
R3 R3 ( 2) R2
m32 3
L m21 1 0 2 1 0 .
3 2 1
m31 m32 1
Page 145
2
3 2 1 0 0 4 x3 14
. . . (1)
2
3 2 1 y3 14
. . . (2)
3 x1 y1
1 2
0 1 2 x = y
2 2
0 0 4 x3 y3
. . . (3)
where
y3 12
With these values of y1 , y2 , y3 , Eq. (3) can now be solved by back substitution and we
obtain
x1 1
x = 2
2
x3 3
by LU decomposition.
(LU decomposition of the coefficient matrix A)
Proceeding as in the above example,
2 3 1
1
1
1 5
U 0
and L
2 2
2
0 0 18
3
2
Numerical Methods
1 0
7 1
Page 146
3/ 2 7 1 0 0
18 z 8
(iv)
or, as
0 0 y1 9
1
1/ 2 1 0 y 6 ,
2
3/ 2 7 1 y3 8
(v)
where
1 x y1
2 3
0 1/ 2 5 / 2 y y .
2
0 0
18 z y3
(vi)
y1 9,
y3 5 .
With these values of y1 , y2 , y3 , eq. (vi) can now be solved by the back substitution process
and we obtain
x
35
,
18
29
,
18
5
.
18
a12
a22
a32
a13 x1 b1
a23 x2 b2 (*)
a33 x3 b3
Numerical Methods
Page 147
1 0 0 x1 d1
0 1 0 x d
2 2
0 0 1 x3 d3
(**)
To obtain the system as given in (**), first we augment the matrices given is (*) as,
a11
a
21
a31
a12
a22
a32
a13 b1
a23 b2 and after some elementary operations, it
a33 b3
is written as,
1 0 0 d1
0 1 0 d (***) , this helps us to write the given
2
0 0 1 d3
Elimination procedure: The first step is same as in Gauss elimination method, which is, we
make the elements below the first pivot in the augmented matrix 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 matrix is of the form (***). Partial pivoting
can also be used in the solution. We may also make the pivots as 1 before performing the
elimination.
Problem: Solve the following system of equations
x1 x2 x3 1
4 x1 3x2 x3 6
3x1 5 x2 3x3 4
2
3 5 3 x3 4
1 1 1 1
4 3 1 6
3 5 3 4
Page 148
0 2 0 1
0 0 10 5
0
1 0
0 1 0 1
2
0 0 10 5
Now, making the pivots as 1, R2= (( R2) and R3= (R3/( 10))), we get
1 0 0 1
1
0 1 0 2
0 0 1 12
1 0 0 x1 1
Hence, 0 1 0 x2 12
0 0 1 x3 12
Note: 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 nonsingular matrix. To obtain inverse of a matrix, 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 obtain, the matrix A
augmented with I, A I in the form I A1 , since AA1 I .
Numerical Methods
Page 149
(1)
2x + 3y + 4z = 20
(2)
4x + 3y + 2z = 16
(3)
(1a)
(2a)
5y 2z = 16
(3a)
+ 5z = 16
y + 2z =
12z = 36
(1b)
(2b)
(3b)
(1c)
y = 2
(2c)
12z = 36
(3c)
Hence, x = 1, y = 2, z = 3.
Assignments
1. Apply Gauss elimination method to solve the equations:
2x 3y z 5
4 x 4 y 3z 3
2 x 3 y z 1
20 y 2 z
2 x 3 y
Numerical Methods
9
44
10 z 22
Page 150
x3 x 4 4
x1
7 x 2 x 3 x 4 12
x1
x2
6 x3 x 4 5
x1
x2
x3 4 x 4 6
x y 6 z 12
3x y z
12
2 x 10 y
13
2 x 2 y 10 z 14
4 x 4 y 3z 3
2 x 3 y z
y 2z 8
Numerical Methods
Page 151
11. Find the inverse of the following matrix using Cholesky method:
1 1 1
1 2 4 .
1 2 2
(1)
a12
a22
a32
a13 x11
a23 x21
a33 x31
x12
x22
x32
x13 1 0 0
x23 0 1 0 .
x33 0 0 1
Numerical Methods
a11
a
21
a31
a12
a22
a32
a13 x11 1
a23 x21 0
a33 x31 0
a11
a
21
a31
a12
a22
a32
a13 x12 0
a23 x22 1
a33 x32 0
Page 152
a11
a
21
a31
a12
a22
a32
a13 x13 0
a23 x23 0
a33 x33 1
We can therefore solve each of these systems using Gaussian elimination method and the
result in each case will be the corresponding column of X A1 . We solve all the three
equations simultaneously as illustrated in the following examples.
Example Using Gaussian elimination, find the inverse of the matrix
2 1 1
A 3 2 3 .
1 4 9
In this method, we place an identity matrix, whose order is same as that of A, adjacent to
A which we call augmented matrix. Then the inverse of A is computed in two stages. In the
first stage, A is converted into an upper triangular form, using Gaussian elimination
method.
We write the augmented system first and then apply low transformations:
2 1
2 1 1 1 0 0
3 2 3 0 1 0 0 1
2
0 72
1 4 9 0 0 1
1
3
2
17
2
1 0 0
by R2 R2 32 R1
23 1 0
by R3 R3 12 R1
12 0 1
1 0 0
2 1 1
3
1
0 2
23
1 0 by R3 R3 7 R21
2
0 0 2 10 7 1
0 0 2 10
(1)
2 1 1 0
0 1
3
1
2
2
0 0 2 7
(2)
2 1 1 0
0 1
3
1
2
2
0 0 2 1
(3)
2
0 0 2 x31 10
Numerical Methods
Page 153
x12
x22
x32
x13 3 52
x23 12 172
x33 5 72
12
3
.
2
1
2
All these operations are also performed on the adjacently placed identity matrix.
Example Use the Gaussian elimination method to find the inverse of the matrix
1 1 1
A 4 3 1 .
3 5 3
At first, we place an identity matrix of the same order adjacent to the given matrix. Thus,
the augmented matrix can be written as
1 1 1 1 0 0
4 3 1 0 1 0
3 5 3 0 0 1
. . . (1)
In order to increase the accuracy of the result, it is essential to employ partial pivoting.
We look for an absolutely largest coefficient in the first column and we use this coefficient
as the pivotal coefficient (for this we have to interchange rows if necessary)
In first column of matrix (1), 4 is the largest element, and hence is the pivotal element.
In order to bring 4 in the first row we interchange the first and second rows and obtain the
augmented matrix in the form
4 3 1 0 1 0
1 1 1 1 0 0
3 5 3 0 0 1
. . . (2)
1 34 14 0 14 0
1 1
1 1 0 0
1
by R1 R1
3 5
3
0
0
1
4
~ 0
0
3
4
1
4
11
4
14
5
4
15
4
1
0
4
1 14
0 43
0
by R2 R2 R1
0
by R3 R3 3R1
1
We now search for an absolutely largest coefficient in the second column (and not in
the first row) and we use this coefficient as the pivotal coefficient. The pivot element is
the max (1/4, 11/4) and is 11/4. Therefore, we interchange second and third rows of the
above.
Numerical Methods
Page 154
0
0
3
4
11
4
1
4
14 0 14 0
15
0 43 1
4
5
1 14 0
4
15
3
0
1
0
11
11
5
0 14
1 14
4
4
11
15
3
4
11
0 1 11 0 11
0 0 10 1 2 1
11
11
11
15
0 1 11 0 ;
0 0 10 1
11
1
1 34 14
15
3
0 1 10 11 ;
0 0 10 2
11
11
1 34 14
0
15
4
11
0 1 11
0 0 10 1
11
11
Thus we have
x11
A x21
x31
1
x12
x22
x32
1
7
5
5
x13
3
x23
0
2
x33 11
1
5
10
2
5
1
2
1
10
Numerical Methods
Page 155
1 1 1 1 0 0
4 3 1 0 1 0
3 5 3 0 0 1
1 1 1 1 0 0
by R2 R2 4 R1
~ 0 1 5 4 1 0
by R3 R3 3R1
0 2 0 3 0 1
1 1 1 1 0 0
by R2 R2
~ 0 1 5 4 1 0
0 2 0 3 0 1
1 0 4 3 1 0
by R1 R1 R2
~ 0 1
5
4 1 0
by R3 R3 2 R2
0 0 10 11 2 1
3
1
0
1 0 4
~ 0 1 5
4
1
0
1
by R3 R3
0 0
1 11/10 1/ 5 1/10
10
7 / 5 1/ 5 2 / 5
1 0 0
by R1 R1 4 R3
~ 0 1 0 3/ 2
0
1/ 2
by R2 R2 5 R1
0 0 1 11/10 1/ 5 1/10
Thus we have
1
7
5
5
3
A1
0
2
11
1
5
10
2
5
1
.
2
1
10
where L is a lower triangular matrix and U is an upper triangular matrix. This means that
L has only zeros above the diagonal and U has only zeros below the diagonal. For
example, for a 3-by-3 matrix A, its LU decomposition looks like this:
Numerical Methods
Page 156
21 22 23 21 1 0 0 u22 u23
a31 a32 a33 l31 l32 1 0 0 u33
Consider a system of linear equations,
a11x1 a12 x2 a13 x3 b1
a21x1 a22 x2 a23 x3 b2
a31x1 a32 x2 a33 x3 b3
where
a12
a22
a32
x1
x
2
x .
.
x
n
a13
a23 ,
a33
and
b1
b
2
b .
.
b
m
1 0 0
L l21 1 0
l31 l32 1
and
This gives,
LUx = b.
Let Ux=y. This implies, Ly=b.
That is,
1 0 0 y1 b1
l
21 1 0 y2 b2
l31 l32 1 y3 b3
Thus,
y1 b1
l21 y1 y2 b2
l31 y1 l32 y2 y3 b3
Numerical Methods
Page 157
This gives the y values by forward substitution, which means, substitute the value
of y1 given by the first equation in the second and solve y2 , then use these values of
y1 and y2 in the third and solve y3 .
Then the system of equations
1 0 0
On multiplying l21 1 0
l31 l32 1
and
0 0 u33
u12
u13
u11
l u
l21u13 u23
21 11 l21u12 u22
u12 a12 ;
u13 a13
a21
;
u11
a31
u11
Numerical Methods
Page 158
3 1 2 z
9
6
8
2 3 1
To decompose the matrix 1 2 3 in the form of LU, we equate the corresponding
3 1 2
u12 3;
a21 1
;
u11 2
u13 1
l31
a31 3
u11 2
1
1
u22 a22 l21u12 2 3 ;
2
2
1
5
u23 a23 l21u13 3 1 ;
2
2
3
a32 l31u12 1 2 3
l32
7 and
u22
1
2
5
3
3 35
u33 u33 a33 l31u13 l32u23 2 1 7 2 18
2
2
2 2
Hence,
2 3 1 1 0 0 2 3 1
1 2 3 1 1 0 0 1 5
2
2
2
3 1 2 32 7 1 0 0 18
This implies,
1 0 0 2 3 1 x
1
5
1
2 1 0 0 2 2 y
32 7 1 0 0 18 z
9
6
8
Consider
Numerical Methods
Page 159
1 0 0 y1 9
2 3 1 x y1
0 1 5 y y , then 1 1 0 y 6 ,
2
2
2
2
2
0 0 18 z y3
2 7 1 y3 8
y1 9
y 3
2 2
y3 5
That is,
2 3 1 x 9
0 1 5 y 3
2
2
2
0 0 18 z 5
Now, solving the above expression we obtain the values of x, y and z as a solution
of the given system of equations as,
35
x 18
y 29
18 .
z 185
Assignments
1.
(i) A 1
3 3
2 4 4
2.
1 1 2
(ii) B 1 2 4
2 4 7
Using Gaussian elimination method, find the inverse of the following matrices:
(i)
0 1 2
A 1 2 3
3 1 1
Numerical Methods
2 0 1
(ii) B 3 2 5
1 1 0
Page 160
12
SOLUTION BY ITERATIONS
SOLUTION BY ITERATION: Jacobis iteration method and Gauss Seidel iteration method
The methods discussed in the previous section belong to the direct methods for
solving systems of linear equations; these are methods that yield solutions after an
amount of computations that can be specified in advance.
In this section, we discuss indirect or iterative methods in which we start from an
initial value and obtain better and better approximations from a computational cycle
repeated as often as may be necessary, for achieving a required accuracy, so that the
amount of arithmetic depends upon the accuracy required.
Jacobis iteration method and Gauss Seidel iteration method
Consider a linear system of n linear equations in n unknowns x1 , x2 , , xn of the form
a11 x1 a12 x2 a13 x3 a1n xn
a21 x1 a22 x2 a23 x3 a2n xn
b1
b2
b3
. . . (1)
a23
a2n
b2 a21
x2
x
x
x
b3 a31
a32
a2n
x3
x
x
x
an, n1
bn an1
an2
xn
x
x
x
ann ann 1 ann 2
ann n1
x1
a
a
b1 a12
x 13 x 1n xn
a11 a11 2 a11 3
a11
(2)
Suppose we start with x1(0) , x2(0) , , xn(0) as initial values to the variables x1 , x2 , , xn . Then
we can find better approximations to x1 , x2 , , xn using the following two iterative
methods:
(i) Jacobis iteration method
Jacobis iteration method, also called the method of simultaneous displacements, is as follows:
Numerical Methods
Page 161
Step 1: Determination of first approximation x1(1) , x2(1) , , xn(1) using x1(0) , x2(0) , , xn(0) .
a2n (0)
b2 a21 (0) a23 (0)
(1)
x2
x
x
x
a22 a22 1
a22 3
a22 n
x
x
x
a33 a33 1
a33 2
a33 n
an, n1 (0)
bn an1 (0) an2 (0)
(1)
xn
x
x
x
ann ann 1
ann 2
ann n1
x1(1)
a
b1 a12 (0) a13 (0)
x2 x3 1n xn(0)
a11 a11
a11
a11
(3)
Step 2: Similarly, x1(2) , x2(2) , , xn(2) are evaluated by just replacing xr(0) in the right hand
sides equations in (3) by xr(1) .
Step n 1: In general, if x1( n ) , x2( n ) , , xn( n ) are a system of n th approximations, then the next
approximation is given by the formula
a2n (n)
b2 a21 (n) a23 (n)
(n1)
x2
x x
x
a22 a22 1 a22 3
a22 n
a33 a33
a33
a22 n
an, n1 (n)
bn an1 (n) an2 (n)
(n1)
xn
x
x
x
ann ann 1 ann 2
ann n1
x1(n1)
a
b1 a12 (n) a13 (n)
x2 x3 1n xn(n)
a11 a11
a11
a11
(4)
xi(r1)
bi n aij (r)
xj
aii
a
ii
j1
r 0,1,2,,
i 1, 2, , n
ji
A sufficient condition for obtaining a solution by Jacobis iteration method is the diagonal
dominance,
i.e.,
a aij , i 1, 2, , n.
ii j 1
j i
i.e., in each row of A the modulus of the diagonal element exceeds the sum of the off
diagonal elements and also the diagonal elements aii 0 . If any diagonal element is 0, the
equations can always be re-arranged to satisfy this condition.
Numerical Methods
Page 162
a2n (0)
b2 a21 (1) a23 (0)
(1)
x2
x
x
x
a22 a22 1 a22 3
a22 n
x
x
x
an, n1 (1)
bn an1 (1) an2 (1)
(1)
xn
x
x
x
ann ann 1 ann 2
ann n1
x1(1)
a
b1 a12 (0) a13 (0)
x
x 1n xn(0)
a11 a11 2
a11 3
a11
(5)
Step n 1: In general, if x1( n ) , x2( n ) , , xn( n ) are a system of n th approximations, then the next
approximation is given by the formula
a2n (n)
b2 a21 (n1) a23 (n)
( n1)
x2
x1
x3
xn
a22 a22
a22
a22
( n1)
x3
x1
x2
xn
a33 a33
a33
a33
an, n1 (n1)
bn an1 (n1) an2 (n1)
( n1)
xn
x
x
ann ann 1
ann 2
ann n1
x1(n1)
a
b1 a12 (n) a13 (n)
x2 x3 1n xn(n)
a11 a11
a11
a11
(6)
xi(r1)
xj xj (r 0,1,2,, i 1, 2, , n).
aii
a
a
ii
j 1
j i1 ii
Remark We note the difference between Jacobis method and Gauss-Seidel method.
(Attention! In the following the bold face letters must be carefully noted):
Jacobis method: In the first equation of (3), we substitute the initial approximations
x2(0) , x3(0) , , xn(0) into the right-hand side and denote the result as x1(1) . In the second
equation, we substitute x1( 0) , x3( 0) , , xn(0) and denote the result as
x2(1) . In third, we
substitute x1(0) , x2(0) , , xn(0) and call the result as x3(1) . The process is repeated in this
manner.
Numerical Methods
Page 163
Gauss-Seidel method: In the first equation of (3), we substitute the initial approximation
x2(0) , , xn(0) into the right-hand side and denote the result as x1(1) . In the second equation,
we substitute x1(1) , x3(0) , , xn(0) and denote the result as
x1(1) , x2(1) , , xn(0) and call the result as x3(1) . The process is repeated in this manner and
illustrated below:
Example 11 Solve the following system of equations using (a) Jacobis iteration method
and (b) Gauss-Seidel iteration method.
10 x1 2 x2 x3 x4 3
2 x1 10 x2 x3 x4 15
x1 x2 10 x3 2 x4 27
x1 x2 2 x3 10 x4 9 .
Solution
To solve these equations by the iterative methods, we re-write them as follows:
x1 0.3 0.2 x2 0.1x3 0.1x4
x2 1.5 0.2 x1 0.1x3 0.1x4
x3 2.7 0.1x1 0.1x2 0.2 x4
x4 0.9 0.1x1 0.1x2 0.2 x3
It can be verified that these equations satisfy the diagonal dominance condition. The
process and given in the following Tables.
Table 1. Jacobis Method
Numerical Methods
x1
x2
x3
x4
0 .3
1 .5 6
2 .8 8 6
0 .1 3 6 8
0 .8 8 6 9
1 .9 5 2 3
2 .9 5 6 6
0 .0 2 4 8
0 .9 8 3 6
1 .9 8 9 9
2 .9 9 2 4
0 .0 0 4 2
0 .9 9 6 8
1 .9 9 8 2
2 .9 9 8 7
0 .0 0 0 8
0 .9 9 9 4
1 .9 9 9 7
2 .9 9 9 8
0 .0 0 0 1
6
7
0 .9 9 9 9
1 .0
1 .9 9 9 9
2 .0
3 .0
3 .0
0 .0
0 .0
Page 164
x1
0 .3
1 .5
2 .7
0 .9
0 .7 8
1 .7 4
2 .7
0 .1 8
0 .9
1 .9 0 8
2 .9 1 6
0 .1 0 8
0 .9 6 2 4
1 .9 6 0 8
2 .9 5 9 2
0 .0 3 6
0 .9 8 4 5
1 .9 8 4 8
2 .9 8 5 1
0 .0 1 5 8
0 .9 9 3 9
1 .9 9 3 8
2 .9 9 3 8
0 .0 0 6
0 .9 9 7 5
1 .9 9 7 5
2 .9 9 7 6
0 .0 0 2 5
0 .9 9 9 0
1 .9 9 9 0
2 .9 9 9 0
0 .0 0 1 0
0 .9 9 9 6
1 .9 9 9 6
2 .9 9 9 6
0 .0 0 0 4
1 0
0 .9 9 9 8
1 .9 9 9 8
2 .9 9 9 8
0 .0 0 0 2
1 1
1 2
0 .9 9 9 9
1 .0
1 .9 9 9 9
2 .0
2 .9 9 9 9
3 .0
0 .0 0 0 1
0 .0
From Tables 1 and 2, it is clear that twelve iterations are required by Jacobis method to
achieve the same accuracy as seven Gauss-Seidel iterations.
Example 12 Solve by Jacobis iteration method, the system of equations
20x1 x2 7 x3 17
3x1 20x2 x3 18
2x1 3x2 20x3 25
x1 17 1 x2 7 x3
20 20
20
x2 18 3 x1 1 x3
20 20 20
(3)
x3 25 2 x1 3 x2
20 20 20
Numerical Methods
Page 165
(0)
(0)
these values on the right sides of equations in (3), we get the first approximation values
(1)
(1)
(1)
x1 17 0.85 , x2 18 0.90 and x3 25 1.25
20
20
20
Putting these values on the right side of the equations in (2), we obtain the second
approximation values, x 1.02 , x 0.965 and x3(2) 1.03 . Similarly, third approximation
values are
x1 1.00125 ,
(3)
(2)
(2)
(3)
(4)
(4)
exact solution x1 1 , x2 1 , x3 1 .
Example 13 Solve, using Gauss-Seidel iteration method, the system:
x1 - 0.25x2 - 0.25x3
-0.25x1 +
x2
= 50
- 0.25x4 = 50
x3
-0.25x1 +
- 0.25x4 = 25
-0.25x2 - 0.25x3 +
x4 =
25
Solution
The given system of equations can be written as
x1 50 0.25 x2 0.25 x3
(2)
x 2 50 0.25 x1 0.25 x4
x3 25 0.25 x1 0.25 x4
x4 25 0.25 x2 0.25 x3
(0)
(0)
(0)
(0)
(1)
(0)
(1)
(0)
(1)
(1)
(1)
(1)
(2)
(1)
(2)
(1)
Numerical Methods
(2)
(2)
Page 166
Example 14 Using Gauss Siedel iteration solve the following system of equations, in three
steps starting from 1, 1, 1.
10 x y z 6
x 10 y z 6
x y 10 z 6
Solution
x 5, y 5,
Numerical Methods
Exercises
1.
2.
3.
4.
Answers
1. x 1.013, y 1.996, z 3.001
2. x 2, y 3, z 4 (Approximately)
3. x 13.223, y 16.766, z 2.306
4. x 2.556, y 1.722, z 1.005
5. x 1.08, y 1.95, z 3.16
Numerical Methods
Page 168
13
EIGEN VALUES
Eigen Values
Definitions Suppose be an indeterminate. Consider the n n matrix
a11 a12
a
a
A 21 22
.
.
an1 an2
... a1n
... a2n
[ai j ]n n
... .
... an n
. . . (1)
.
.
.
an2 . . . ann
an1
. . . (2)
The determinant A I of the characteristic matrix of A given in (2) can be found out
to be
b0 + b1 + b2 2 + . . . + bn 1n 1 + bn n
. . . (3)
. . . (3)
The equation
A I = 0
. . . (4)
an2
. . .
. . .
.
. . .
a1n
a2n
.
(4)
ann
Numerical Methods
Page 169
The roots of the characteristic equation (4) are called the characteristic roots or latent
roots or eigen values of the matrix A. If is an eigen value, then column vector X such
that AX X is called an eigen vector associated with the eigen value .
Example Find the eigen values and the corresponding eigen vectors of the matrix
2
8 6
A 6
7 4.
2 4
3
Solution
The characteristic equation of A is A I = 0.
8
6
2
6 7
4 0
2
4 3
i.e.,
On simplification we get
- 3 + 18 2 45 = 0,
which gives the eigen values = 0;
= 3;
= 15.
AX 0 X
i.e., by solving
x1
8 6 2 x1
6 7 4 x 0 x
2
2
x3
2 4
3 x3
i.e., by solving
2 x1 0
8 6
6
7 4 x 2 0.
2 4
3 x3 0
6 x2
7 x2
4 x2
2 x3
4 x3
3 x3
0
0
0
1
2
3
Page 170
4 x1 3 x2 x3 0
and
2 x1 4 x 2 3 x3 0.
3 3 1 4 1 2 4 3 4 4 3 2
or
x
x1
x
2 3 .
5 10 10
or
x1 x 2 x3
.
1
2
2
x1 x2 x3
k,
1 2
2
Hence
where k is arbitrary.
x1 k , x2 2k , x3 2k .
. . . (4)
2 4
0 x3 0
2 2
0 0 0 x3 0
Page 171
k
X 12 k
k
Hence
2
2 4 12 x3 0
2a
X 2a
a
Hence
Solution
It can be seen that the eigen values are 2, 2 and 8.
Now we determine the eigen vector corresponding to the largest eigen value 8:
The eigen vector X corresponding to = 8 is obtained by solving AX 8 X i.e., by
solving [A 8 I ] X = 0
i.e., by solving
2 x1 0
6 8 2
2 3 8 1 x 0.
2
2
1 3 8 x3 0
Numerical Methods
Page 172
i.e., by solving
2 x1 0
2 2
2 4 1 x 0.
2
2 1 5 x3 0
2 x2
5 x2
x2
2 x3
x3
5 x3
0
0
0
1
2
3
and
2 x1 x 2 5 x3 0.
1 5 1 1 1 2 1 5 1 1 1 2
or
x
x1 x 2
3.
6 3 3
or
x1 x 2 x3
.
2 1 1
Hence
x1 x 2 x3
k.
2 1 1
x1 2k , x 2 k , x3 k .
. . . (4)
A 0
1
Numerical Methods
1
2 0
0 5
Page 173
0
1
2 0
0
5
Then we have:
x1
x1
A x2 2 x2 ,
x3
x3
and 6 x2 0
from which we obtain
x1 x3 and x2 0.
Numerical Methods
Page 174
The
.
1
2
1
2
X3 0
1/
Example Determine the largest eigen value and the corresponding eigenvector of the
matrix
1 6 1
A 1 2 0
0 0 3
Then we have
AX (0)
Numerical Methods
1 6 1 1 1
1 2 0 0 1
0 0 3 0 0
Page 175
Let X
(1)
1
1 . Then we have AX (0) X (1) and we have an approximate eigen value is 1 and
0
AX
(1)
1 6 1 1 7
2.3
1 2 0 1 3 3 9
0 0 3 0 0
0
2.3
1
0
2.2
4 1.1 ;
0
2
4.4 1 ;
0
2
4 1 ;
0
2
4 1 .
0
It follows that the largest eigen value is 4 and the corresponding eigenvector is
2
1 .
0
a12
a22
a23
0
a23 .
a33
a12
a22
a23
0
a23 0.
a33
. . . (1)
Page 176
a11
a12
a12
a 0
a23 11
a23
a22
a12
where 2 ( )
a11
a12
a12
a22
( a11 )0 ( )
a11
a12
2 ( )
a12
a22
2
( a11 ) ( a22 ) a12
2
1 ( )(a22 ) a12
0 ( )
2
3 ( ) 2 ( )( a33 ) a23
1 ( ) .
In general, if
k ( )
a11
a12
a12
a22
0
a23
0
0
...
...
...
...
...
...
...
ak 1 , k
0
0
, (2 k n),
...
akk
The equation k ( ) 0 is the characteristic equation and can be solved using the methods
discussed in Chapter 2. When the eigen values are known its eigen vectors can be
calculated.
Exercises
1. Find the eigen values and the corresponding eigen vectors of the following matrices:
3
(a)
5
0
1
Numerical Methods
1 2
2 4
(b)
Page 177
2 1 0
(c) 0 2 1
0 0 2
5
3 10
(d) 2 3 4
3
5
7
3 0 0
(e) 5 4 0
3 6 1
5 1 1
(f) 1 3 1
1 1 3
5 6 6
g 1 4 2
3 6 4
2
h 2
7
2 0
1 1
2 3
2
i 1
1
2
3
2
3
j 1
1
1
3
1
2
k 0
2
1
3
4
2
l 1
1
1
2
1
1
1
2
1
2
3
1
1
3
1
1
2
1 2
the
characteristic
roots
of
1 0 2
A 0 2 1 .
2 0 1
the matrix A 6 1 4.
2 4
3
5. Obtain the eigen values and the corresponding eigen vector of matrix
6 2 2
A 2
3 1.
2 1 3
6. Use the iterative method to find the largest eigen value and the corresponding eigen
vector of the matrix
2 1 2
5
2 6 3 4
.
A
1
3 19 2
2 4 2 1
Numerical Methods
Page 178
14
TAYLOR SERIES METHOD
METHODS FOR NUMERCIAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
There are differential equations that cannot be solved using the standard methods
even though they possess solutions. In such situations, we apply numerical methods for
obtaining approximate solutions, where the accuracy is sufficient. These methods yield
the solution in one of the following forms:
(i) Single-step method: A series for y in terms of powers of x, from which the value
of y at a particular value of x can be obtained by direct substitution.
(ii) Multi-step method: In multi step methods, the solution at any point x is obtained
using the solution at a number of previous points.
Taylors, Picards, Eulers and Modified Eulers methods are coming under singlestep method of solving an ordinary differential equation.
The need for finding the solution of the initial value problems occur frequently in
Engineering and Physics. There are some first order differential equations that cannot be
solved using the standard methods. In such situations we apply numerical methods.
These methods yield the solution in one of the two forms:
(iii)A series for y in terms of powers of x, from which the value of y can be obtained
by direct substitution.
(iv)A set of tabulated values of x and y.
The methods of Taylor and Picard belong to class (i), whereas those of Euler, RungeKutta, etc., belong to the class (ii). In this chapter we consider Taylor series method.
Taylor Series
We recall the following (Ref. Fourth Semester Core Text):
k 0
( x a) 2
f ( k ) (a)
f (a) . . .
( x a ) k = f ( a) ( x a ) f ( a )
k!
2!
( x a ) n 1 ( n 1)
( x a)n ( n)
f
(a)
f (a)
( n 1)!
n!
In most of the cases, the Taylors series converges to f ( x ) at every x and we often write
the Taylors series at x a as
Numerical Methods
Page 179
f ( x ) f ( a) ( x a ) f ( a )
( x a) 2
f (a) . . .
2!
(1)
( x x0 ) 2
y ( x0 ) . . .
2!
... (2)
y f ( x, y ), y ( x0 ) y0 .
y ( x) y0 ( x x0 ) y0
( x x0 ) 2
y0 . . .
2!
(4)
If the values of y0 , y0, are known, then (4) gives a power series for y. From (3) we
have y f , which on differentiation with respect to x (using chain rule) gives
y f
df f f
y
dx x x
(5)
x
x3
x3
x 4 (4) x5 (5)
y0 y0 y0
y y0
1!
2!
3!
4! 0
5!
(6)
We have
y x y 2 ,
y0 y( x x0 , y y0 ) x0 y02 0 12 1.
y 1 2 yy ,
y0 y ( x x0 , y y0 ) 1 2 y0 y0 1 2(1)(1) 3.
y 2 yy 2( y)2 ,
y0 y( x x0 , y y0 ) 2 y0 y0 2 y0 8.
2
y (4) 2 yy 6 yy,
y0(4) y (4) ( x x0 , y y0 ) 2 y0 y0 6 y0 y0 34.
y (5) 2 yy (4) 8 yy 6( y)2 ,
y0(5) y (5) ( x x0 , y y0 ) 2 y0 y0(4) 8 y0 y0 6( y0 )2 186.
Numerical Methods
Page 180
3 2 4 3 17 4 31 5
x x x x . . .
2
3
12
20
(7)
To obtain y (0.1) correct to four decimal places, we consider the terms upto x 4 and putting
x 0.1, we obtain
y (0.1) 0.9138.
Remark to the Example (Truncation and range of x) Suppose that we wish to find the
range of values of x for which the above series, truncated after the term containing x 4 ,
can be used to compute the values of y correct to four decimal places. We need only to
write
31 5
x 0.00005,
20
so that
x 0.126.
dy
x y numerically starting with x 1, y 0 .
dx
( x 1) 2
( x 1)3
( x 1) 4 (4)
y0
y0
y0 . . .
2!
3!
4!
(7)
Here
d
y 0 y ( x x 0 , y y 0 ) x 0 y 0 1 0 1 y ( x y ) 1 y ;
dx
y 0 y ( x x 0 , y y 0 ) 1 y 0 1 1 2
y x y ;
y y ;
y 0 y ( x x 0 , y y 0 ) y 0 2.
y (4) y
; y 0(4) y( x x 0 , y y 0 ) y0 2.
( x 1)3 ( x 1) 4
...
3
12
Now to find y (1.1), we put x 1.1 in the above series (considering terms upto 4th power of
x ) we get
y (1.1) 0.1 (0.1) 2
(0.1) 3 (0.1) 4
3
12
= 0.11.
Page 181
( x 4) 2
( x 4)3
( x 4) 4 (4)
y0
y0
y0 . . .
2!
3!
4!
(8)
5 xy y 2 2 0
(10)
(12)
5 xy + 20 y + 2 yy + 8 y y + 6 (y )2 = 0(13)
Using x0 4; y0 1, (9) gives 5 x0 y0 y0 2 2 0
. (10) gives
5 x0 y0 5 y0 2 y0 y0 0
or
or 5 4 y0 5 0.05 2 1 0.05 0
Numerical Methods
Page 182
y ( x) 1 x 4 0.05
x 4
2!
0.0175
x 4
3!
0.01025
x 4
4!
0.00845
x 4
5!
0.008998125
0.1
2!
0.0175
0.1
3!
0.01025
0.1
4!
0.00845
0.1
5!
0.008998125
= 1.0049
Solution of Second Order IVP by Taylor Series Method
Consider the second order initial value problem
y f ( x, y , y ), y ( x0 ) y0 , y ( x0 ) l0 .
(14)
p f ( x, y , p )
y ( x0 ) y0
(16)
p ( x0 ) p0 l0 .
(17)
( x x0 ) 2
y0 . . .
2!
.....(18)
where y0 , y0 , are determined using (16) and (17) and successive differentiation. The
method is illustrated in the following example.
Example Using Taylor series method, prove that the solution of
d2y
xy 0
dx 2
with the initial conditions y (0) d and y (0) 0 is given by
Set
1
4
28
y ( x) d 1 x 3 x 6 x 9 . . .
3!
6!
9!
y p.
Then,
Numerical Methods
.......(19)
y p,
Page 183
p xy 0.
Here x0 0,
(21)
y0 y ( x0 ) y (0) 0.
y0 y ( x0 ) y (0) d ,
From (20),
so
( x x0 ) 2
y0 . . .
2!
p xy ,
y p xy ,
y0 x0 y0 0;
y p y xy ,
y0 y0 x0 y0 d ;
y (4) 2 y xy,
y0(4) 2 y0 x0 y0 0;
y (5) 3 y xy,
y0(5) 3 y0 x0 y0 0;
y (6) 4 y xy (4) ,
y0(6) 4 y0 x0 y0(4) 4d ;
Solution
Set
y p.
Then,
y p,
(22)
y ( x) y0 ( x x0 ) y0
Here x0 0,
p xp 2 y 2 ,
From (22),
so y p xp 2 y 2 ,
y p p 2 2 xpp 2 yy,
Numerical Methods
y0 x0 p0 2 y0 2 0 1 1;
y0 p0 2 2 x0 p0 p0 2 y0 y0 0;
Page 184
y p p 2 2 xpp 2 yy,
y0 p0 2 2 x0 p0 p0 2 y0 y0 0;
x2
...
2!
(24)
(0.1)2
1 0.005 0.995.
2!
Exercises
In Exercises 1 12 , solve the given initial value problem using Taylor series method. Also
find the value of y for the given x .
1.
dy
1 xy , y (0) 1. Also find y (0.1).
dx
2.
dy
x 2 y 2 2, y 1 at x 0. Also find y (0.1).
dx
3.
dy
y 2 1, y (0) 0. Also find y (0.1) and y (0.2).
dx
4.
dy
x y 2 , y (0) 1. Obtain numerical values for x 0.2(0.2)0.6.
dx
5.
x = 0.0(0.2)0.4.
6.
dy
1
2
, y (4) 4. Also find y (4.1) and y (4.2).
dx x y
9. Solve
dy
1 2 xy, y (0) 0. Also find y (0.2) and y (0.4).
dx
10. Solve
dy
xy1/ 3 , y (1) 1. Also find y (1.1) and y (1.2).
dx
11. Solve
dy
x 2 y, y (0) 1. Also find y at x 0.1(0.1)0.4.
dx
Numerical Methods
x 1.0(0.1)1.2.
Page 185
12. Solve
dy
2 y 3e x , y (0) 0. Also find y (0.1) and y (0.2).
dx
In Exercises 13 15, solve the given second order initial value problem using Taylor series
method. Also find the value of y for the given x .
13.
d2y
dy
y x , y (0) 1, y (0) 0. Also find y (0.1).
dx 2
dx
14.
d2y
xy 0, y (0) 1, y (0) 0.5. Also find y (0.1) and y (0.2).
dx 2
15.
d2y
x 2 xy, y (0) 1, y (0) 0. Also find y (0.1) and y (0.2).
2
dx
Numerical Methods
Page 186
15
PICARDS ITERATION METHOD
Consider the initial value problem
y f ( x, y ) , y ( x0 ) y0 .
(1*)
Also, assume (1*) have a unique solution on some interval containing x0 . By separating
variables, the differential equation in (1) becomes
dy f ( x, y ) dx.
...(1**)
Integrating (1**) from x0 to x with respect to x, (at the same time y changes from y0 to
y ) we get
y
y0
x0
dy f (x, y)dx
or
or
x
y(x) y0 f (x, y)dx
x0
x
y(x) y0 f (x, y)dx
x0
(2)
It can be verified, by substituting x x0 and y y0 in (2), that (2) satisfies the initial
condition in (1).
To find the approximations to the solution y ( x) of (2) we proceed as follows:
We substitute the first approximation y y0 on the right side of (2), and obtain the better
approximation
x
y (1) ( x) y0 f ( x, y0 )dx
x0
(3)
In the next step we substitute the function y (1) ( x) on the right side of (2) and obtain
x
y (2) ( x) y0 f ( x, y (1) ( x))dx ,
x0
(4)
(5)
Page 187
Working Rule
Consider the initial value problem
y f ( x, y ) , y ( x0 ) y0 .
(n 1, 2, 3, )
...(6)
with y (0) y0 .
Example Find approximate solutions by Picards iteration method to the initial value
problem y 1 y 2 with the initial condition y (0) 0. Hence find the approximate value
of y at x 0.1 and x 0.2 .
Picards iterations nth step is given by (6).
In this problem
f ( x, y ) 1 y 2 ; x0 0, y (0) y0 y ( x0 ) y (0) 0,
and hence
f ( x, y ( n 1) ) 1 y ( n 1) .
2
i.e.,
x
2
y ( n ) x y ( n 1) dx
(n 1, 2, 3, )
x
2
y (1) x y (0) dx
0
Putting y (0) 0,
x
y (1) x 02 dx x.
0
x
2
y (2) x y (1) dx
0
Putting y (1) x,
x
1
y (2) x x 2 dx x x 3 .
3
0
Numerical Methods
Page 188
x
2
y (3) x y (2) dx
0
1
3
Putting y (2) x x 3 ,
2
x
1
y (3) x x x 3 dx
3
0
1
2
1
x x3 x5 x7 .
3
15
63
We can continue the process. But we take the above as an approximate solution to the
given initial value problem. That is,
y y ( x) x
1 3 2 5 1 7
x x
x .
3
15
63
(7)
and
y (0.2) 0.202709 .
The above are not exact values for y at the given x points, but the approximate values.
dy
x y with the initial condition y (0) 1. Find approximately the value
dx
of y for x 0.2 and x 1.
Example Given
i.e.,
y (n) 1
y (1) 1
x 2 x ( n 1)
y dx
2 0
x 2 x (0)
y dx
2 0
x2 x
x2
dx 1 x .
2 0
2
y (2) 1
Putting y (1) 1 x
Numerical Methods
x 2 x (1)
y dx
2 0
x2
, we obtain
2
Page 189
x2 x
x2
1 x dx
2 0
2
y (2) 1
1 x x2
x 2 x (2)
y dx
2 0
y (3) 1
Putting y (2) 1 x x 2
x3
6
x3
, we obtain
6
y (3) 1
x2 x
x3
1 x x 2 dx
2 0
6
1 x x2
x3 x 4
3 24
We accept
y 1 x x2
x3 x 4
3 24
as an approximate solution.
When x = 0.2, we have
y (0.2) 1 0.2 (0.2)2
(0.2)3 (0.2)4
1.2427.
3
24
1 1
3.3751.
3 24
y 1 xy.
Hence
f ( x, y ) 1 xy ; x0 2, y (0) y0 y ( x0 ) y (2) 0,
and hence
f ( x, y ( n 1) ) 1 xy ( n 1) .
Numerical Methods
Page 190
x
y ( n ) x 2 xy ( n1) dx (n 1, 2, 3, )
i.e.,
x
y(1) x 2 xy(0) dx
2
i.e.,
y (1) x 2.
x
y (2) x 2 xy (1) dx
2
2
x3
x x2 .
3
3
x
y (3) x 2 xy (2) dx
2
2
3
Putting y (2) x x 2
x3
, we obtain
3
x 2
x3
y (3) x 2 x x x 2 dx
3
3
2
22
x 2 x3 x 4 x5
x .
15
3
3 4 15
We consider
y
22
x 2 x3 x 4 x5
x
15
3
3 4 15
dy y x
, y(0) =1 using Picards method. Find the value of y at x =
dx y x
0.1 approximately.
Here f ( x, y )
Numerical Methods
yx
; x0 0, y (0) y0 y ( x0 ) y (0) 1, and hence by (6),
yx
Page 191
x y(n1) x
y 1 (n1) dx
x
0 y
(n)
x y(0) x
y(1) 1 (0)
dx
x
0 y
Putting y (0) = 1, we obtain
x 1 x
y(1) 1
dx
0 1 x
By actual division,
1 x
2
1
1 x
1 x
and hence the above can be written as
x
2
y(1) 1 1
dx
1 x
0
1 x 2ln(1 x).
with the initial condition y 0 when x 0, use Picards method to obtain y for x 0.25, 0.5
and 1.0 correct to three decimal places.
Here f ( x, y )
x2
; x0 0, y (0) y0 y ( x0 ) y (0) 0, and hence by (6),
y2 1
x
y( n)
0
x
y
(1)
x2
y(n1) 1
2
x2
(0) 2
dx
dx
Numerical Methods
Page 192
(1)
x 2 dx 1 x 3
3
0
x
y (2)
x2
(1) 2
dx
x
d ( 13 x3 )
x2
dx
( 1 x3 )2 1 dx
6
0 (1/ 9) x 1
0 3
x
y (2)
tan 1 1 x 3 1 x 3 1 x 9
3
3
81
so that y(1) and y(2) agree to the first term, viz., (1/ 3) x 3 . To find the range of values of x so
that the series with the term (1/ 3)x 3 alone will give the result correct to three decimal
places, we put
1 x 9 0.0005
81
which yields
x 0.7
Hence
y(0.25) 1 (0.25)3 0.005
3
y(0.5) 1 (0.5)3 0.042
3
When x 1.0 ( x 0.7 is not true) so we have to consider the second term 1 x9 also into
81
Exercises
In Exercises 1-7, solve the initial value problem by Piacrds iteration method (Do three
steps).
1. y y , y (0) 1.
2. y x y , y (0) 1.
3. y xy 2 x x3 , y(0) 0.
4. y y y 2 , y (0) .
5. y y 2 , y (0) 1.
6. y 2 y , y (1) 0.
Numerical Methods
1
2
Page 193
7. y
3y
, y (1) 1.
x
In Exercises 8-16, solve the initial value problem by Piacrds iteration method (Do four
steps). Also find the value of y at the given points of x.
8. y 2 x y , y (1) 3. Also find y (1.1).
9. y x y , y (0) 1. Also find y (0.2).
10. y x 2 y, y (1) 2. Also find y (1.2).
11. y 3x y 2 , y (0) 1. Also find y (0.1).
12. y 2 x 3 y , y (0) 1. Also find y (0.25).
13. 2
dy
x y , y (0) 2. Also find y (0.1).
dx
14.
dy y 1
, y (1) 1. Also find y (1.1).
dx x x 2
15.
dy
1 xy , y (0) 1. Also find y (0.1).
dx
16.
dy
x (1 x 3 y ), y (0) 3. Also find y (0.1) and y (0.2).
dx
Numerical Methods
Page 194
16
EULER METHODS
Consider the initial value problem of first order
(1)
x1 x0 h, x2 x1 h,
dy f (x, y)dx.
...(1A)
Integrating (1A) from x0 to x1 with respect to x, (at the same time y changes from y0 to
y1 ) we get
y1
x1
y0
x0
dy f (x, y)dx
or
or
x1
y1 y0 f ( x, y)dx
x0
x1
y1 y0 f (x, y)dx
x0
(2)
y1 y0 f (x0 , y0 )(x1 x0 )
or
y1 y0 h f (x0, y0 ).
x2
y2 y1 f (x, y)dx
x1
(3)
y2 y1 h f (x1, y1).
Numerical Methods
Page 195
yn1 yn hf (xn, yn )
( n 0, 1, )
(4)
Example
( n 0, 1, )
(5)
Use Eulers method with h = 0.1 to solve the initial value problem
dy
x 2 y 2 with y (0) 0 in the range 0 x 0.5.
dx
Here f ( x, y ) x 2 y 2 , x0 0, y0 0, h 0.1.
Hence
x1 x0 h 0.2,
x2 x1 h 0.2, x3 x2 h 0.3,
x4 x3 h 0.4,
x5 x4 h 0.5.
We determine y1 , y2 , y3 , y4 , y5 using the Euler formula (5). Substituting the given value in
yn1 yn hf (xn , yn )
we obtain
yn 1 yn 0.1( xn2 yn2 )
( n 0, 1, )
Hence
y (0) 0
y (0.1) 0
y (0.2) 0.001
y (0.3) 0.005
y (0.4) 0.014
y (0.5) 0.0300196.
Numerical Methods
Page 196
Example
Using Euler method solve the equation y 2 xy 1 with y (0) 0, h 0.02 for
x 0.1.
x2 x1 h 0.04, x3 x2 h 0.06,
x4 x3 h 0.08,
x5 x4 h 0.1.
We determine y1, y2, y3, y4, y5 using the Euler formula (5). Substituting the given value in
yn1 yn hf (xn , yn )
we obtain
yn1 yn 0.02(2xn yn 1)
( n 0, 1, )
y (0.02) 0.02
y (0.04) 0.04
y (0.06) 0.06
y (0.08) 0.08
y (0.1) 0.1.
Here
f ( x, y ) x y , x0 0, y0 y ( x0 ) y (0) 0.
xn x0 1 0
0.2. Hence
n
5
x2 x1 h 0.4, x3 x2 h 0.6,
x4 x3 h 0.8,
x5 x4 h 1.0.
We determine y1, y2 , y3, y4 , y5 using the Euler formula (5). Substituting the given value in
(5), we obtain
yn1 yn 0.2(xn yn )
Numerical Methods
( n 0, 1, )
Page 197
y e x x 1.
The exact values of y can be evaluated from (6) by substituting the corresponding x
values, in particular,
y1 y ( x1 ) e x1 x1 1 e0.2 0.2 1 0.000, approximately.
The other exact values are also shown in the following table.
xn
approxi
mate
value of
0.2( xn yn )
Exact
values
yn
Absolute
value
of Error
0.0
0.000
0.000
0.000
0.000
0.2
0.000
0.040
0.021
0.021
0.4
0.040
0.088
0.092
0.052
0.6
0.128
0.146
0.222
0.094
0.8
0.274
0.215
0.426
0.152
1.0
0.489
0.718
0.229
The approximate value of y (1.0) by Eulers method is 0.489, while exact value is 0.718.
Exercises
In Exercises 1-11, solve the initial value problem using Eulers method for value of y at
the given point of x with given ( h is given in brackets)
1.
dy
1 y , y (0) 0 at the point x 0.2 ( h 0.1).
dx
2.
dy y x
dy
1
3 x y , y (0) 1 at the point x 0.2 ( h 0.05).
dx
2
Page 198
6.
dy
1 y 2 , y (0) 0 at the point x 0.4 ( h 0.2).
dx
7.
dy
xy , y (0) 1 at the point x 0.4 ( h 0.2).
dx
8.
dy
1 ln( x y ), y (0) 1 at the point x 0.2 ( h 0.1).
dx
2x
with y 1 at x 0 for h 0.5 on the interval
y
[0, 1].
18. Using Eulers method find y (0.2) of the initial value problem y x 2 y , y (0) 1,
taking h 0.1.
19. Using Eulers method find the value of y at the point x 2 in steps of 0.2 of the initial
value problem
dy
2 xy , y (1) 1 .
dx
where y1( n) is the nth approximation to y1 . The iteration formula can be started by
choosing y1(0) from Eulers formula
y1(0) y0 hf ( x 0 , y0 ).
Numerical Methods
Page 199
Example
that
Using modified Eulers method, determine the value of y when x 0.1 given
y x 2 y; y(0) 1.
(Take h 0.05)
Here f ( x, y ) x 2 y; x0 0, y0 1.
y1(0) y0 hf ( x0 , y0 ) 1 0.05(1) 1.05
y1(1) y0 h [ f ( x0 , y0 ) f ( x1 , y1(0) )]
2
1 0.05 [ f (0, 1) f (0.05, 1.05)]
2
1 0.025[1 (0.05)2 1.05]
1.0513
y1(2) y0 h [ f ( x0 , y0 ) f ( x1 , y1(1) )]
2
1 0.05 [ f (0, 1) f (0.05, 1.0513)]
2
1 0.025[1 (0.05)2 1.0513]
1.0513
y2(1) y1 h [ f ( x1 , y1 ) f ( x2 , y2(0) )]
2
Numerical Methods
Page 200
y2(2) y1 h [ f ( x1 , y1 ) f ( x2 , y2(1) )]
2
Using modified Eulers method, determine the value of y when x 0.2 given
dy
x
dx
y ; y (0) 1.
(Take h 0.2)
Here f ( x, y ) x y ; x0 0, y0 1.
y1(0) y0 hf ( x0 , y0 ) 1 0.2(0 1) 1.2
y1(1) y0 h [ f ( x0 , y0 ) f ( x1 , y1(0) )]
2
1 0.2 [1 (0.2 1.2] 1.2295.
2
y1(2) y0 h [ f ( x0 , y0 ) f ( x1 , y1(1) )]
2
1 0.2 [1 (0.2 1.2295] 1.2309.
2
y1(3) y0 h [ f ( x0 , y0 ) f ( x1 , y1(2) )]
2
1 0.2 [1 (0.2 1.2309] 1.2309.
2
dy
1 y , y (0) 0 at the point x 0.2 ( h 0.1).
dx
2.
dy y x
Numerical Methods
Page 201
dy
1
3 x y , y (0) 1 at the point x 0.2 ( h 0.05).
dx
2
dy
1 y 2 , y (0) 0 at the point x 0.4 ( h 0.2).
dx
7.
dy
xy , y (0) 1 at the point x 0.4 ( h 0.2).
dx
8.
dy
1 ln( x y ), y (0) 1 at the point x 0.2 ( h 0.1).
dx
Numerical Methods
Page 202
17
RUNGE KUTTA METHODS
The Taylor series method has desirable features, particularly in its ability to keep the
errors small, but that it also has the strong disadvantage of requiring the evaluation of
higher derivatives of the function f(x,y). In the Taylor series method, each of these higher
order derivatives is evaluated at the point xi at the beginning of the step, in order to
evaluate y ( xi ) at the end of the step. We observed that the Euler method could be
improved by computing the function f(x,y) at a predicted point at the far end of the step in
x. The Runge-Kutta approach is to aim for the desirable features of the Taylor series
method, but with the replacement of the requirement for the evaluation of higher order
derivatives with the requirement to evaluate f(x,y) at some points within the step xi to xi 1
. Since it is not initially known at which points in the interval these evaluations should be
done, it is possible to choose these points in such a way that the result is consistent with
the Taylor series solution to some particular, which we shall call the order of the RungeKutta method. The Runge-Kutta method of order N = 4 is most popular. It is a good
choice for common purposes because it is quite accurate, stable, and easy to program.
Most authorities proclaim that it is not necessary to go to a higher-order method because
the increased accuracy is offset by additional computational effort. If more accuracy is
required, then either a smaller step size or an adaptive method should be used.
We use the fact that Runge-Kutta method of rth order agree with Taylors series solution
up to the terms of h r .
Second Order Runge-Kutta Method
Computationally, most efficient methods in terms of accuracy were developed by two
German mathematicians, Carl Runge and Wilhelm Kutta. These methods are well known
as Runge-Kutta methods (R-K methods). In this and the coming section we consider
second and fourth order R-K methods.
There are several second order Runge-Kutta formulas and we consider one among
them.
Working Method (Second Order Runge-Kutta Method)
Given the initial value problem (1).
x1 x0 h, x2 x1 h,
Numerical Methods
Page 203
Also denote
xn1 xn h
kn hf (xn , yn )
(8)
ln hf (xn1, yn kn )
(9)
1
yn1 yn (kn ln )
2
(10)
Remark Modified Euler method is a special case of second order Runge-Kutta method
given by (10).
Example Use second order Runge-Kutta method with h 0.1 to find y (0.2), given
dy
x 2 y 2 with y (0) 0.
dx
x2 x1 h 0.2.
To determine y1 , y2 we use second order Runge-Kutta method and using (8) (10),
kn hf ( xn , yn ) 0.1( xn2 yn2 )
ln hf (xn1, yn kn ) 0.1[xn21 ( yn kn )2 ]
and
1
yn1 yn (kn ln )
2
k0 0.2( x02 y02 ) 0.1(02 02 ) 0.
l0 0.2( x12 ( y0 k0 ) 2 ) 0.1 (0.1) 2 (0 0) 2 ) 0.001
and
1
1
y1 y0 ( k0 k0 ) 0 (0 0.001) 0.0005.
2
2
k1 0.2( x12 y12 ) 0.1 (0.1) 2 (0.0005)2 0.001, correct to three places of decimals.
l1 0.2( x22 ( y1 k1 ) 2 ) 0.1 (0.2) 2 (0.0015) 2 ) 0.004
and
1
1
y2 y1 ( k1 l1 ) 0.0005 (0.001 0.004) 0.003.
2
2
Numerical Methods
Page 204
y (0.2) 0.003.
Example
Given the initial value problem y x y , y (0) 0. Find the value of y
approximately for x 1 by second order Runge-Kutta method in five steps. Compare the
result with the exact value.
Here f ( x, y ) x y , x0 0, y0 0. As we have to calculate the value of y when x 1 in five
steps, we have to take h
x1 x0 h 0.2,
xn x0 1 0
0.2. Hence
n
5
x2 x1 h 0.4, x3 x2 h 0.6,
x4 x3 h 0.8,
x5 x4 h 1.0.
yn
1
yn 1 yn ( kn ln )
2
1
0.2(xn yn ) 0.2 xn 0.2 yn 0.2(xn yn )
2
yn 0.22( xn yn ) 0.02
The successive steps and calculations are plotted in the following table.
approximate
y n 1
value of yn
xn yn
0.22( xn yn ) 0.02
0 0.0
0.0000
0.0000
0.0200
0.0200
1 0.2
0.0200
0.2200
0.0684
0.0884
2 0.4
0.0884
0.4884
0.1274
0.2158
3 0.6
0.2158
0.8158
0.1995
0.4153
4 0.8
0.4153
1.2153
0.2874
0.7027
5 1.0
0.7027
xn
Hence y (1) 0.7027. In an earlier example we have noted that the exact value is 0.718.
Numerical Methods
Page 205
Exercises
In Exercises 1-10, solve the initial value problem using second order Runge-Kutta method
for value of y at the given point of x with given h.
1.
dy
1 y , y (0) 0 at the point x 0.2 (Take h 0.1).
dx
2.
dy y x
dy
x y , y (0) 1 at the point x 0.2 (Take h 0.1).
dx
dy
1 y 2 , y (0) 0 at the point x 0.4 (Take h 0.2).
dx
7.
dy
xy , y (0) 1 at the point x 0.4 (Take h 0.2).
dx
8.
dy
1 ln( x y ), y (0) 1 at the point x 0.2 (Take h 0.1).
dx
2x
with y 1 at x 0 for
y
Numerical Methods
Page 206
17. Using second order Runge-Kutta method find y (0.2) of the initial value problem
y x 2 y , y (0) 1, taking h 0.1.
18. Using second order Runge-Kutta method find the value of y at the point x 2 in
steps of 0.2 of the initial value problem
dy
2 xy , y (1) 1 .
dx
Also denote
y0 y ( x0 ), y1 y ( x1 ), y2 y ( x2 ),
(11)
Bn hf ( xn 12 h, yn 12 An )
(12)
Cn hf ( xn 12 h, yn 12 Bn )
(13)
Dn hf ( xn h, yn Cn )
(14)
1
yn 1 yn ( An 2 Bn 2Cn Dn )
6
(15)
y (0.2) given
dy
x 2 y 2 with
dx
y (0) 0.
x2 x1 h 0.2.
Page 207
2
Cn hf ( xn 12 h, yn 12 Bn ) 0.1 ( xn 0.05) 2 yn 12 Bn
2
Dn hf ( xn h, yn Cn ) 0.1 xn21 yn Cn
1
yn 1 yn ( An 2 Bn 2Cn Dn )
6
x1 x0 0.1 0 0.1 0.1
Page 208
Example Use Runge-Kutta method with h 0.2 to find the value of y at x 0.2, x 0.4,
and x 0.6, given
dy
1 y 2 , y (0) 0.
dx
x2 x1 h 0.4.
An hf ( xn , yn ) 0.2(1 yn2 )
2
Bn hf ( xn 12 h, yn 12 An ) 0.2 1 yn 12 An
2
Cn hf ( xn 12 h, yn 12 Bn ) 0.2 1 yn 12 Bn
2
Dn hf ( xn h, yn Cn ) 0.2 1 yn Cn
1
yn 1 yn ( An 2 Bn 2Cn Dn )
6
x1 x0 0.2 0 0.2 0.2
2
C0 0.2 1 y0 12 B0 0.2 1 (0.101) 2 0.20204.
2
D0 0.2 1 y0 C0
Numerical Methods
Page 209
1
y1 y0 ( A0 2 B0 2C0 D0 )
6
1
0 (0.2 2 0.202 2 0.20204 0.20816) 0.2027.
6
2
2
C1 0.2 1 y1 12 B1 0.2 1 (0.3121) 2 0.2195. D1 0.2 1 y1 C1
i.e.,
A2 0.2(1 y22 );
2
C2 0.2 1 y2 12 B2 ;
2
D2 0.2 1 y2 C2 .
xn x0 1 0
0.2. Hence
n
5
Page 210
x1 x0 h 0.2,
x2 x1 h 0.4, x3 x2 h 0.6,
x4 x3 h 0.8,
x5 x4 h 1.0.
xn1 xn h xn 0.2
An hf (xn , yn ) 0.2(xn yn )
Bn hf ( xn 12 h, yn 12 An ) 0.2 xn 0.1 yn 0.1( xn yn )
0.22( xn yn ) 0.02
Cn hf ( xn 12 h, yn 12 Bn )
0.2 xn 0.1 yn 0.11( xn yn ) 0.01
0.222( xn yn ) 0.022
Dn hf ( xn h, yn Cn )
1
yn 1 yn ( An 2 Bn 2Cn Dn )
6
i.e.,
yn 1 yn 0.2214( xn yn ) 0.0214.
The successive steps and calculations are plotted in the following table.
approximate
xn yn
0.2214( xn yn ) 0.0214
xn
0.0
0.0000
0.0000
0.0000
0.021 400
0.2
0.021 400
0.221 400
0.049 018
0.070 418
0.4
0.091 818
0.491 818
0.108 889
0.130 289
0.6
0.222 107
0.822 107
0.182 014
0.203 414
0.8
0.425 521
1.225 521
0.271 330
0.292 730
1.0
0.718 251
Numerical Methods
value of yn
0.2214( xn yn )
Page 211
Table:
Comparison of the accuracy of three methods discussed in earlier sections in the case of
the initial value problem y x y , y (0) 0.
Approximate values to y
obtained by
Exact
value
xn
Euler
method
R-K
Second
Order
R-K
Fourth
Order
R-K
Second
Order
R-K
Fourth
Order
0.2
0.021403
0.000
0.0200
0.021400
0.021
0.0014
0.000003
0.4
0.091825
0.040
0.0884
0.091818
0.052
0.0034
0.000007
0.6
0.222119
0.128
0.2158
0.222107
0.094
0.0063
0.000011
0.8
0.425541
0.274
0.4153
0.425521
0.152
0.0102
0.000020
1.0
0.718282
0.489
0.7027
0.718251
0.229
0.0156
0.000031
Exercises
In Exercises 1-10, solve the initial value problem using fourth order Runge-Kutta method
for value of y at the given point of x (with h. given in brackets)
1.
dy
y, y (0) 1 at the point x 1 ( h 0.5)
dx
2.
dy
1 y , y (0) 0 at the point x 0.2 ( h 0.1).
dx
3.
dy
y x, y (0) 2 at the point x 0.2 ( h 0.1).
dx
dy
x y , y (1) 0.4 at the point x 1.6 (e h 0.6).
dx
dy y x
8.
dy
xy , y (1) 2 at the point x 1.6 ( h 0.2).
dx
Numerical Methods
Page 212
9.
dy
1 ln( x y ), y (0) 1 at the point x 0.2 ( h 0.1).
dx
the range
0.00(0.02)0.06.
14. Using Runge-Kutta method find y (0.2) of the initial value problem y x 2 2 y, y (0) 0,
taking h 0.2.
15. Using Runge-Kutta method find the value of y at the point x 2 in steps of 0.2 of the
initial value problem
dy
2 xy , y (1) 1 .
dx
16. Using Runge-Kutta method find y (1.3), given y x 2 y and y (1) 2. Take h 0.3 .
17. Solve using Runge-Kutta method y y
2x
with y 1 at x 0 for h 0.5 on the
y
Numerical Methods
Page 213
18
PREDICTOR CORRECTOR METHODS
Introduction
Euler method and fourth order Runge-Kutta methods are called single-step methods,
where we have seen that the computation of yn 1 requires the knowledge of yn only. But
modified Euler method is a multi-step method since for the computation of yn 1 the
knowledge of yn is not enough. It is a predictor-corrector method, in which a predictor
formula is used to predict the value yn 1 of y at xn 1 and then a corrector formula is used to
improve the value of yn 1 .
For example, consider the initial value problem
dy
f x, y , y ( x0 ) y0 .
dx
Using simple Eulers and modified Eulers method, we can write down a simple
predictor-corrector pair (P-C) as
P:
yn1(0) yn hf (xn , yn ).
h
(1)
(0)
C : yn1 yn f (xn , yn ) f (xn1, yn1).
2
Here, yn 1(1) is the first corrected value of yn 1. . The corrector formula may be used
iteratively as defined below:
r 1, 2,
The iteration terminate when two successive iterates agree to the desired accuracy. We
have considered modified Euler method in the previous chapter.
In this chapter we consider two methods: Adams-Moulton and Milnes Methods.
They require function values at xn , xn 1 , xn 2 , for the computation of the function value at
xn 1 .
Adams-Moulton Method
Consider the initial value problem
y f ( x, y ), y ( x0 ) y0 .
Numerical Methods
(1)
Page 214
Starting
with
given
x0
and
given
the
and
x1 x 0 h , x 1 x 0 h , x 2 x 0 2 h ,
step
size
x3 x0 3h .
h,
We
we
have
denote
f 2 f ( x2 , y2 ), and f 3 f ( x3 , y3 ).
f 0 f ( x0 , y0 ), f1 f ( x1 , y1 ), f 1 f ( x1 , y1 ),
h
(55 f 0 59 f 1 37 f 2 9 f 3 )
24
(1)
h
(9 f1 p 19 f 0 5 f 1 f 2 ),
24
(2)
and correct by
y1C y0
where f1 p f ( x1 , y1P ).
The general forms for formulae (1) and (2) are given by
ynP1 yn
h
(55 f n 59 f n 1 37 f n 2 9 f n 3 )
24
(1)
h
(9 f np1 19 f n 5 f n 1 f n 2 ),
24
(2)
with correction
ynC1 yn
The formulae given above are example of explicit predictor corrector formulae as they are
expressed in ordinate form.
Example Given
dy
1 y 2 ; y (0) 0. Compute y (0.8) using Adams-Moulton Method.
dx
The starter values are y (0.6), y (0.4) and y (0.2) . Using fourth-order Runge-Kutta method
(Ref. Example 7 in the previous chapter), the values are found to be:
y (0.6) 0.6841,
y (0.4) 0.4228,
Also,
y (0.2) 0.2027.
y1 y ( x1 ) y (0.4) 0.4228,
and y3 y ( x3 ) y (0) 0.
f 0 f ( x0 , y0 ) 1 y02 1 (0.6841)2 ;
Numerical Methods
Page 215
f 1 f ( x1 , y1 ) 1 y21 1 (0.4228)2 ;
f ( x) 1 y 2
x3 0.0
y3 0.000
f 3 1.0000
x2 0.2
y2 0.2027
f 2 1.0411
x1 0.4
y1 0.4228
f 1 1.1787
x0 0.6
y0 0.6841
f 0 1.4681
0.2
55[1 (0.6841)2 ] 59[1 (0.4228)2 ]
24
37[1 (0.4228)2 ] 9
1.0233, on simplification.
0.2
9[1 (0.0233)2 ] 19[1 (0.6841)2 ]
24
5[1 (0.4228) 2 ] [1 (0.2027) 2 ]
1.0296, on simplification.
Exercises
1. Using Adams-Moulton predictor-corrector method, find the value of y at x 4.4 from
the differential equation
5x
dy
y 2 2,
dx
given that
x 4.0
4.1
4.2
4.3
y 1.0000 1.0049 1.0097 1.0143
y (0) 1
Page 216
(Take h 0.2.)
3. Using Adams-Moulton predictor-corrector method, find the value of y at x 1.4 of the
initial value problem
x 2 y xy 1,
y (1) 1.0
y (0) 1
using Adams-Moulton predictor-corrector method, in the interval (0.2, 0.5) given that
y (0.05) 1.00125, y (0.1) 1.00502, y (0.15) 1.01136.
Milnes Method
Consider the initial value problem
(1)
y f ( x, y ), y ( x0 ) y0 .
Starting
with
given
x0
and
x1 x0 h, x1 x0 h, x2 x0 2h,
given
and
f 0 f ( x0 , y0 ), f1 f ( x1 , y1 ), f 1 f ( x1 , y1 ),
the
step
x3 x0 3h .
size
h,
We
we
have
denote
f 2 f ( x2 , y2 ), and f 3 f ( x3 , y3 ).
4h
(2 f 2 f 1 2 f 0 )
3
(1)
and correct by
h
y1C y1 ( f 1 4 f 0 f1P ),
3
(2)
4h
(2 f n 2 f n 1 2 f n )
3
(3)
and correct by
h
ynC1 yn1 ( fn1 4 fn fnP1 ),
3
Numerical Methods
(4)
Page 217
dy
1 y 2 ; y (0) 0. Compute y (0.8) and y (1.0) using Milnes Method.
dx
Example Given
Solution
Determination of y (0.8) :
Here take x1 0.8, h 0.2. Hence
x0 x1 h 0.8 0.2 0.6, x1 0.4, x2 0.2, x3 0.
The starter values are y (0.6), y (0.4) and y (0.2) . Using fourth-order Runge-Kutta method,
the valued are found to be:
y (0.6) 0.6841,
y (0.4) 0.4228,
y (0.2) 0.2027.
Hence
y0 0.6841,
y2 0.2027 and
y1 0.4228,
y3 y ( x3 ) y (0) 0.
Also,
f 0 f ( x0 , y0 ) 1 y02 1 (0.6841)2 ;
f 1 1 y21 1 (0.4228)2 ;
f ( x) 1 y 2
x3 0.0
y3 0.000
f 3 1.0000
x2 0.2
y2 0.2027
f 2 1.0411
x1 0.4
y1 0.4228
f 1 1.1787
x0 0.6
y0 0.6841
f 0 1.4681
Hence
0.8
2(1.0411) 1.1787 2(1.4681) 1.0239
3
Numerical Methods
Page 218
and hence the corrected value of y1 at x1 0.8 is obtained using (2) as below:
y1C 0.4228
0.2
1.1787 4(1.4681) 2.0480 1.0294.
3
The starter values are y (0.8), y (0.6), and y (0.4) . We have the values
y (0.8) 1.0294, y (0.6) 0.6841,
y (0.4) 0.4228.
Hence
y0 1.0294,
y1 0.6841,
y2 0.4228 and y3 0.
f ( x) 1 y 2
x3 0.2
y3 0.2027
f 3 1.0411
x2 0.4
y2 0.4228
f 2 1.1787
x1 0.6
y1 0.6841
f 1 1.4681
x0 0.8
y0 1.0294
f 0 2.0597
Hence
f1 1 y1P 3.3667
2
dx
2
Numerical Methods
Page 219
As f ( x, y )
y1 3.595,
y2 2.636 and y3 2.
x y
, we have
2
f 0 f ( x0 , y0 )
x0 y0 1.5 4.968
3.2340. ;
2
2
f 1 f ( x1 , y1 )
x1 y1 1.0 3.595
2.2975. ;
2
2
f 2 f ( x2 , y2 )
x2 y2 0.5 2.636
1.5680. ;
2
2
4h
2 f 2 f 1 2 f0
3
4 0.5
3
Using the predicted value, we shall compute the corrected value of y1 from the corrector
formula
h
y1C y1 ( f 1 4 f 0 f1P ),
3
(2)
x1 y1P 2 6.871
4.4355.
2
2
0.5
2.2975 4 3.234 4.4355 6.8731667.
3
Page 220
y 0 1
y1 y ( x1 ) y (0.2) 1.2428,
y2 y ( x2 ) y (0.1) 1.1103.
4h
2 f 2 f 1 2 f0
3
4 0.5
2 1.2103 1.4428 2 1.6997 1.58363
3
(2)
we compute
f1P f ( x1 , y1P ) x1 y1P 0.4 1.5836 1.9836.
Hence
y1C 1.2428
Numerical Methods
0.1
1.4428 4 1.6997 1.9836 1.5836.
3
Page 221
0.1
0.2
0.3
0.4
dx
2
Here take x1 2.0, h 0.5. Hence
y0 4.968, y1 3.595,
As f ( x, y )
y2 2.636 and
y3 2.
x y
, we have
2
f 0 f ( x0 , y0 )
x0 y0 1.5 4.968
3.2340. ;
2
2
f 1 f ( x1 , y1 )
x1 y1 1.0 3.595
2.2975. ;
2
2
f 2 f ( x2 , y2 )
x2 y2 0.5 2.636
1.5680. ;
2
2
4h
2 f 2 f 1 2 f0
3
4 0.5
3
Using the predicted value, we shall compute the corrected value of y1 from the corrector
formula
h
y1C y1 ( f 1 4 f 0 f1P ),
3
Page 222
f1P f ( x1 , y1P )
x1 y1P 2 6.871
4.4355.
2
2
0.5
2.2975 4 3.234 4.4355 6.8731667.
3
y (0.3) 1.50412.
*********
Numerical Methods
Page 223