3.
NUMERICAL METHODS-I
Introduction:
Most of the problems of engineering, physical and economical sciences can be
formulated in terms of system of equations, ordinary or partial differential
equations. In majority of the cases, the solutions to these problems in analytical
form are non-existent or difficult. In all such cases, numerical methods provide
approximate solutions, practical for analysis. Numerical methods do not strive for
exactness. Instead, they yield approximations with specified degree of accuracy.
The early disadvantage of the several numbers of computations involved has been
removed through high speed computation using computers, giving results which
are accurate, reliable and fast.
3.1 Interpolation with evenly spaced points
Introduction:
Suppose that a function y = f(x) is given. For a set of values of x in the domain, we
can tabulate the corresponding values of y. The central problem of interpolation is
the converse of this:
Given a set of tabular values ( x0 , y0 ), ( x1 , y1 ), ..., ( xn , yn ) satisfying the relation
y = f(x) where the explicit nature of f(x) is not known, it is required to find a
simpler function, say ( x ) , which approximates f(x), such that f(x) and ( x ) agree
at the set of tabulated points. Such a process of approximation of an unknown
function by a known function within the range where it is defined, such that both
functions assume same values at the given set of tabulated points is called
interpolation. The extrapolation is the process of approximating the unknown
function by a function at a point outside the range of definition. If ( x ) is a
polynomial, then the process is called polynomial interpolation and ( x ) is called
the interpolating polynomial.
Weierstrass Theorem: If f(x) is continuous in x0 x xn , then given any ε > 0,
there exists a polynomial P(x) such that f ( x) - P( x) for all x in ( x0 , xn ).
This approximation theorem justifies the polynomial approximation.
There are two main uses of these approximating polynomials. The first use is to
reconstruct the function f(x) when it is not given explicitly and only values of f(x)
and/ or its certain order derivatives are given at a set of distinct points called nodes
or tabular points. The second use is to perform the required operations which were
intended for f(x), like determination of roots, differentiation and integration etc.
can be carried out using the approximating polynomial P(x). The approximating
polynomial P(x) can be used to predict the value of f(x) at a non-tabular point.
Remark: Through two distinct points, we can construct a unique polynomial of
degree 1(straight line). Through three distinct points, we can construct a unique
polynomial of degree atmost two (a parabola or a straight line). In general, through
n 1 distinct points, we can construct a unique polynomial of degree atmost n. The
interpolation polynomial fitting a given data is unique.
We consider x to be an independent variable and y = f(x) as a function of x where
the explicit nature of y is not known, but a set of values (x0, y0), (x1, y1),
(x2, y2),…,(xn, yn) satisfying yi = f(xi), i = 0, 1, 2, …, n are given.
Interpolation with equally spaced points:
To obtain interpolating polynomials, we use finite differences.
Finite differences
Suppose that
xi = x0 + ih, h > 0, i = 1, 2, …,n.
i.e., the values of x are equally spaced.
The following are the three types of finite differences
1. Forward Differences
2. Backward Differences
3. Central Differences
Forward Differences:
The differences y1 – y0, y2 – y1,…,yn – yn-1 are called first order forward
differences of y and are respectively denoted by y0 , y1 , y2 ,..., yn . We call ‘’,
the forward difference operator. The differences of the first order forward
differences are called second order forward differences and are denoted by
2 y0 , 2 y1 , 2 y2 , ... , 2 yn 1 . Thus
2y0= y1 y0 = y2 – 2y1 + y0, 2y1= y2 y1 = y3 – 2y2 + y1
and so on. Similarly, one can find the rth order forward differences recursively as,
r yk r -1 yk 1 r -1 yk , r = 1, 2, …
These differences can be tabulated and the table so obtained is called forward
difference table and it is read diagonally downwards.
x y 2 3 4
x0 y0
y0
x1 y1 2 y0
y1 3y0
x2 y2 2 y1 4 y0
y2 3 y1
x3 y3 2 y2
y3
x4 y4
Backward differences:
The differences y1 – y0, y2 – y1,…,yn – yn-1 when denoted by y1, y2,…, yn,
are called first order backward differences of y. The operator is called the
backward difference operator. The differences of the first order differences are
called second order differences and are denoted by 2y2, 2y3, …,2yn.
Similarly one can define the rth order backward differences,
r yk r -1 yk r -1 yk -1 , r = 1, 2, …
The relation between and is given by yr = yr-1.
The backward difference table is as shown below and it is read diagonally
upwards.
x y 2 3 4
x0 y0
y1
x1 y1 2 y2
y2 3y3
x2 y2 2 y3 4 y4
y3 3 y4
x3 y3 2 y4
y4
x4 y4
Other notations for y = f(x) are
1. yx = f(x + h) – f(x),
2. yx = f(x) – f(x –h)
where h is the difference between two consecutive x values.
Shift Operator:
The shift operator, denoted by E, is defined by the equation Eyk = yk+1. The
operator shifts the functional value yk to the next higher value yk+1.
Again operating by E, we get E2yk = E(Eyk) = E(yk+1) = yk+2. In general
Eryk = yk + r.
The inverse shift operator, denoted by E-1, is defined by the equation E-1yk = yk-1.
In general
E-ryk= ykr.
Properties of finite differences:
1. Linearity Property:
For any two constants a and b and for any two functions f(x) and g(x), we
have, (a f(x) b g(x)) = a f(x) b g(x)
2. Differences of Polynomial: The first order difference of a polynomial of degree
n is a polynomial of degree n 1. Hence nth difference of a polynomial of degree n
is a constant.
Proof:
Consider
f(x) = a0xn + a1xn-1 + a2xn-2 +…+ an-1x + an, a0 0.
Then,
f ( x) f ( x h) - f ( x)
a0 x h n
xn
a1 x h x n-1
n -1
a2 x h n -2
x n-2 ...
a0 nhx n-1 lower deg ree terms
which is a polynomial of degree n1. Similarly,
2 f ( x) a0 n(n 1) h 2 x n 2 lower deg ree terms
which is a polynomial of degree n2.
Continuing in this manner, we arrive at
nf(x) = a0n!hn,
which is a constant. Hence nth difference is a constant.
Remark: (n + 1)th and higher order differences of a polynomial of degree n are
zero.
Remark: Converse of the above is also true. i.e., if for a function f(x) the nth order
finite difference is a constant and (n +1)th ordered finite difference is zero then f(x)
is a polynomial of degree n.
3. 1+ = E.
4. 1 = E-1.
4. = E = E
k k
5. yr (1)i 1 yk i
k
…….(1)
i 1 i
Proof: Since
E 1 , wehave E 1
k k
k (1 E )k (1)i E i
i 1 i
k k k k k k
k yr (1)i E i yr (1)i E i yr (1)i yk i
i 1 i i 1 i i 1 i
6. k yr k yk r
Example : Making suitable assumptions find the missing terms in the following
table:
x 1 2 3 4 5 6 7
y 103.4 97.6 122.9 ? 179.0 ? 195.8
Solution:
Let y0 =103.4, y1 = 97.6, y2 = 122.9, y3= ?, y4 = 179.0, y5 = ?, y6 = 195.8. Since 5
values of y are known, we assume that y is a polynomial of degree 4, so that the 4 th
order differences are constants and 5th order differences are zero, from which we
obtain (use equation 1)
5y0 = 0 y5 – 5y4 +10y3 10y2 + 5y1 y0 = 0 y5 + 10y3 = 1739.4
5y1 = 0 y6 – 5y5 +10y4 10y3 + 5y2 y1 = 0 5y5 + 10y3 = 2502.7
Solving,
y3 = 154.8575, y5 = 190.825
Exercises 4.1
1. Find the missing values in the table
x 0 1 2 3 4
y 1 3 9 ? 81
Explain why the result differs from the actual value 33 = 27. (Ans: 31)
2. Find the missing points in the following table:
x 45 50 55 60 65
y 3 - 2 - -2.4
(Ans: y(50) = 2.925, y(60) = 0.225)
3. Find the missing values in the following table:
x 0 1 2 3 4 5 6
y 5 11 22 40 - 140 -
4. Given u0 = 10, u1 = 6, u3 = 26 and u5 = 130. Find u2 and u4.
Newton-Gregory Forward Difference Interpolation Formula
Statement: Given a set of points (x0, y0), (x1, y1), (x2, y2),…,(xn, yn) satisfying
y = f(x), where explicit nature of y is not known and values of x are equally
spaced, the nth degree polynomial yn(x) such that f(x) and yn(x) agree at the
tabulated points is given by
p( p 1) 2 p ( p 1)( p 2)...( p n 1) n
yn ( x) y0 py0 y0 ... y0 ........(2)
2! n!
where x = x0 + ph.
Proof: Since yn(x) is a polynomial of degree n, it can be written as
yn ( x ) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) ... an ( x x0 )( x x1 )...( x xn-1 ) ....(3)
yn (x0) = y0 gives a0 = y0.
y0
yn (x1) = y1 gives a1 = .
h
2 y0
yn (x2) = y2 gives a2 = .
2! h 2
M
n y0
yn (xn) = yn gives an = .
n!h n
Set x x0 ph . Then,
x – x0 = ph, x – x1 = (p – 1) h, …, x xn-1 = (p n +1)h.
Substituting in (3) and simplifying we get (2).
The formula,
p( p 1) 2 p( p 1)...( p n 1) n
yn ( x) y0 py0 y0 ... y0 ,
2! n!
is called Newton- Gregory forward difference interpolation formula and it is
useful for interpolating near the beginning of a set of tabular values.
Newton-Gregory Backward Difference Interpolation Formula
Statement: Given a set of points (x0, y0), (x1, y1), (x2, y2),…,(xn, yn) satisfying
y = f(x), where explicit nature of y is not known and values of x are equally
spaced, the nth degree polynomial yn(x) such that f(x) and yn(x) agree at the
tabulated points is given by
p( p 1) 2 p( p 1)( p 2)...( p n 1) n
yn ( x) yn pyn yn ... yn .......(4)
2! n!
where x = xn + ph.
Proof: Since yn(x) is a polynomial of degree n, it can be written as
yn ( x) a0 a1 ( x xn ) a2 ( x xn )( x xn-1 ) ... an ( x xn )( x xn-1 )...( x x1 ) ....(5)
yn (xn) = yn gives a0 = yn.
y n
yn (xn-1) = yn-1 gives a1 = .
h
2 yn
yn (xn-2) = yn-2 gives a2 = .
2! h 2
M
n y0
yn (x1) = y1 gives an = .
n!h n
Set x xn ph . Then,
x – xn = ph, x – xn-1 = (p + 1) h, …, x x1 = (p + n 1)h.
Substituting in (5) and simplifying we get (4).
The formula,
p( p 1) 2 p( p 1)...( p n 1) n
yn ( x) yn pyn yn ... yn ,
2! n!
is called Newton- Gregory backward difference interpolation formula and it is
useful for interpolating near the end of a set of tabular values.
Example 1: Find the cubic polynomial which takes the following values:
y (1) 24, y (3) 120, y (5) 336,and y (7) 720. Hence, or otherwise, obtain the
value of y (8).
Solution: We form the difference table:
x y 2 3
1 24
96
3 120 120
216 48
5 336 168
384
7 720
Here h = 2, x0 = 1. Hence p = (x1)/2.
Using forward difference formula, we get,
x 1 x 1 x 1 x 1 x 1
1 1 2
x 1
(96)
2 2 (120) 2 2 2 (48)
y ( x ) 24
2 2 6
x 3 6 x 2 11x 6.
y(8) = 83 + 6(82) + 11(8) + 6 = 990.
Example 2: Using Newton’s forward difference formula, find the sum
S n 13 23 33 ... n3 .
Solution: S n ( n 1)3 , 2 S n 3n 2 9n 7, 3S n 6n 12, 4 Sn 6.
Thus Sn is a polynomial of degree 4 in ‘n’.
Further, S1 1, S1 8, 2 S1 19, 3 S1 18, 4 S1 6. Hence,
2
( n 1)( n 2)( n 3)( n 4) n( n 1)
S n 1 ( n 1)(8) ... (6) .
24 2
Example 3: Values of x (in degrees) and sin x are given in the following table:
x 15 20 25 30 35 40
sin x 0.2588190 0.3420201 0.4226183 0.5 0.5735764 0.6427876
Determine the value of sin380.
Solution: The difference table is
x sin x 2 3 4 5
15 0.2588190
0.0832011
20 0.3420201 -0.0026029
0.0805982 -0.0006136
25 0.4226183 -0.0032165 0.0000248
0.0773817 -0.0005838 0.0000041
30 0.5 -0.0038053 0.00002879
0.0735764 -0.0005599
35 0.5735764 -0.0043652
0.0692112
40 0.6427876
Here x = 38 and h = 5. Therefore p = -0.4.
Hence,
y (38) = 0.6427876-0.02768448+0.00052382+0.00003583-0.00000120
= 0.6156614.
Example 4: The table below gives the values of tan x for 0.10 x 0.30 :
x 0.10 0.15 0.20 0.25 0.30
y = tan x 0.1003 0.1511 0.2027 0.2553 0.3093
Find: (i) tan 0.12 (ii) tan 0.26 (iii) tan 0.40 and (iv) tan 0.50.
Solution: The difference table is
x tan x 2 3 4
0.10 0.1003
0.0508
0.15 0.1511 0.0008
0.0516 0.0002
0.20 0.2027 0.0010 0.0002
0.0526 0.0004
0.25 0.2553 0.0014
0.0540
0.30 0.3093
(i) p = 0.4, tan (0.12) = 0.1205. (Actual Value : 0.1205)
(ii) p = -0.8, tan (0.26) = 0.2662. (Actual Value : 0.2660)
(iii) p = 2, tan (0.40) = 0.4241. (Extrapolation, Actual Value: 0.4227).
(iv) p = 4, tan (0.50) = 0.5543. (Extrapolation, Actual Value : 0.5463).
Remark: Comparison of the computed and actual values shows that in the first
two cases (i.e., in interpolation) the results obtained are fairly accurate whereas in
the last-two cases (i.e., in extrapolation) the errors are quite considerable. The
example therefore demonstrates the important result that if a tabulated function is
other than a polynomial, then extrapolation very far from the table limits.
Exercises 4.2
1. The population in decennial census was as under. Estimate the population
for the year 1955:
Year 1921 1931 1941 1951 1961
Population 46 66 81 93 101
x
2 1 2
0
2. The probability integral p exp t dt has the following values:
2
x 1.00 1.05 1.10 1.15 1.20 1.25
p 0.682689 0.706282 0.728668 0.749856 0.769861 0.788700
Calculate p for x = 1.235 .
2
The values of the elliptic integral K (m) 1 m sin 2
-1/ 2
3. d for certain
0
equidistant values of m are given below. Determine K(0.25).
m 0.20 0.22 0.24 0.26 0.28 0.30
K(m) 1.659624 1.669850 1.680373 1.691208 1.702374 1.713889
4. From the following table, find y when x = 1.45.
x 1.0 1.2 1.4 1.6 1.8 2.0
y 0.0 -0.112 -0.016 0.336 0.992 2.0
5. Evaluate sin (0.197) from the following table:
x 0.15 0.17 0.19 0.21 0.23
sinx 0.14944 0.16918 0.18886 0.20846 0.22798
6. Given the table of values:
x 150 152 154 156
y= x 12.247 12.329 12.410 12.490
Evaluate 155 .
7. From the following table find the number of students who obtained less than
45 marks.
Marks < 40 40 - 50 50 - 60 60 – 70 70 - 80
No. of
31 42 51 35 31
students
[Hint: Apply NFIF for cumulative frequency]