Numerical Methods I PDF
Numerical Methods I PDF
Numerical Methods I PDF
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.
Interpolation
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.
Note: 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),,(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 differencesy1 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 yn1 .Thus
2y0= y1y0 = y2 2y1 + y0,2y1= y2y1 = 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 2y0
y1 3y0
x2 y2 2y1 4y0
y2 3 y1
x3 y3 2y2
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 rthorder backward differences,
r yk r -1 yk r -1 yk -1 , r = 1, 2,
The relation between and is given byyr= 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
Explain why the result differs from the actual value 33 = 27.
Solution: There are 4 tabulated values, that is, (0, 1), (1, 3), (2, 9) and (4, 81) are
given, therefore its 4th forward difference must be zero.
By constructing difference table.
x y y 2 y 3 y 4 y
0 1
2
1 3 4
6 a19
2 9
a15 124 4a
a9 1053a
3 a (say)
902a
4 81 81 a
Exercise
1. Find the missing points in the following table:
x 45 50 55 60 65
y 3 - 2 - -2.4
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.
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(0) = 1,
y(1) = 0, y(2) = 1 and y(3) = 10. Hence or otherwise, obtain y (0.5).
Here x0 = 0, x1 = 1, x2 = 2, x3 = 3
and y0 = 1, y1 = 0, y2 = 1 y3 = 10
Ans:
We form the difference table
x y 2 3
x0 = 0 y0 = 1
y0= 1
x1 = 1 y1 = 0 2y0= 2
y1= 1 3y0= 6
y1= 8
2
x2 = 2 y2 = 1
y2= 9
x3 = 3 y3 = 10
Here h = 1, x0 = 0, therefore p = x
x (x 1) x (x 1) (x 2)
y (x) = 1 + x (1) + 2 6
1.2 1.2.3
= 1 x + (x2 x) + (x3 3x2 + 2x)
y (x) = x3 2x2 + 1
which is the polynomial from which we obtained the above tabular values.
To compute y (0.5)
Here x0 + ph = x = 0.5
p = 0.5 since x0 = 0 and h = 1
p(p 1) 2 p(p 1)(p 2) 3
y (0.5) = y0 + p y0 + y0 y0
2! 3!
(0.5) (0.5 1) (0.5) (0.5 1) (0.5 2)
= 1 + 0.5 (1) + 2 + 6
2 6
= 6.25
which is the same value as that obtained by substituting x = 0.5 in the cubic
polynomial.
Example 2: Using Newtons forward difference formula, find the sum
Sn 13 23 33 ... n3.
Ans:
First we prepare the cumulative frequency table, as follows,
Marks less than (x) 40 50 60 70 80
No. of students y 31 73 124 159 190
40 31
42
50 73 9
25
51
60 124 37
16
12
35
70 159
4
31
80 190
We shall find the number of students with marks less than 45.
From the above table we have,
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.
Exercise
1 2
x
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 .
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]
8. The population of a town in the decennial census was as given below.
Estimate the population for the year 1895 and 1925.
Example1: Find Lagranges interpolation polynomial fitting the points y(1) = -3,
y(3) = 0, y(4) = 30, y(6) = 132. Hence find y(5).
x 1 3 4 6
y= f(x) 3 0 30 132
1
On simplification, we get y(x) = ( x 3 27x 2 92x 60) , which is the required
2
Lagranges interpolation polynomial. Now y(5) = 75.
Example 2: Use Lagranges interpolation formula to fit a polynomial for the data :
x 0 1 3 4
y 12 0 6 12
Hence estimate y at x = 2
Solution:
By data x0 = 0, x1 = 1, x2 = 3 x3 = 4
y0 = 12, y1 = 0 y2 = 6 y3 = 12
(x x1 ) (x x 2 )(x x 3 ) (x x 0 ) (x x 2 ) (x x 3 )
We have y = f (x) = y0 y1
(x 0 x1 ) (x 0 x 2 ) (x 0 x 3 ) (x1 x 0 ) (x1 x 2 ) (x1 x 3 )
(x x 0 ) (x x1 )(x x 3 ) (x x 0 ) (x x1 ) (x x 2 )
+ y2 y3
(x 2 x 0 ) (x 2 x1 ) (x 2 x 3 ) (x 3 x 0 ) (x 3 x1 ) (x 3 x 2 )
(x 1) (x 3) (x 4)
that is, y = f (x) = (12) + 0
(1) (3) (4)
x (x 1) (x 4) x (x 1) (x 3)
+ 6 12
(3) (2) (1) (4) (3) (1)
y = f (x) = x3 7x2 + 18 x 12
x 5 7 11 13 17
Put x = 9 we get
(9 7) (9 11) (9 13) (9 17)
y(9) = 150
(5 7) (5 11) (5 13) (5 17)
(9 5) (9 7) (9 13) (9 17)
= 1452
(11 5) (11 17) (11 13) (11 17)
(9 5) (9 7) (9 11) (9 17)
= 2366
(13 5) (13 7) (13 11) (13 17)
(9 5) (9 7) (9 11) (9 13)
= 5202 = 810
(17 5) (17 7) (17 11) (17 13)
x
y y1 y y2 ... y yn x y y0 y y2 ... y yn x .....
y0 y1 y0 y2 ... y0 yn 0 y1 y0 y1 y2 ... y1 yn 1
Example 1: If y1 4, y3 12, y4 19 and yx 7, find x.
Solution:
(5)(12) (3)(12) (3)( 5)
x (1) (3) (4)
(8)(15) (8)(7) (15)(7)
1.86.
Exercise
1. Applying Lagranges formula, find a cubic polynomial which approximates
the following data:
x -2 -1 2 3
y(x) -12 -8 3 5
2. Given the data points (1,-3),(3,9),(4,30) and (6,132) satisfying the function
y = f(x), compute f(5) .
3. Given the table values
x 50 52 54 56
3
x 3.684 3.732 3.779 3.825
y1 y0
x0 , x1
x1 x0
Similarly,
y2 y1 y y2 y yn1
x1, x2 , x2 , x3 3 , , xn1, xn n .
x2 x1 x3 x2 xn xn1
The second order divided differences are defined as
x1, x2 x0 , x1 x , x x1, x2 , ,
x0 , x1, x2 , x1, x2 , x3 2 3
x2 x0 x3 x1
x0 , x1
x1 y1
x0 , x1, x2
x1, x2
x2 y2
x1, x2 , x3
x2 , x3
x3 y3
. .
. . x0 , x1,, xn
. .
. .
. .
. .
xn2 , xn1 xn3 , xn2 , xn1
xn1 yn1
x, x0 , x1 x0 , x1, x2 ( x - x2 ) x, x0 , x1, x2
Using this in (2), we get
y y0 ( x x0 ) x0 , x1 + x x0 x x1 x0 , x1, x2
x x0 x x1 x x2 x, x0 , x1, x2 .
Proceeding in this manner, we arrive at
y y0 ( x x0 ) x0 , x1 + x x0 x x1 x0 , x1, x2
x x0 x x1 x x2 x, x0 , x1, x2
+ x-x 0 x-x1 x-x 2 x-x n-1 x 0 , x1, , x n
x-x 0 x-x1 x-x 2 x-x n x, x 0 , x1, , x n
This is called Newtons divided difference interpolation formula, the last term
being the remainder term after (n + 1) terms.
Example 1: Given the values
x 4 5 7 10 11 13
f(x) 48 100 294 900 1210 2028
Evaluate f (8) using Newtons divided difference formula.
Solution:
x f(x) First Order Second Third order Fourth
Differences Order Differences order
Differences Differences
4 48
52
15
5 100
97 1
21 0
7 294 1
202
10 900 27 0
310 1
11 1210 33
409
13 2028
Using divided difference formula, we get
f x 48 52 x 4 15 x 4 x 5 1 x 4 x 5 x 7
f (8) 448
Example 2: From the following table find f(x) and hence f(6) using Newtons
interpolation formula:
x 1 2 7 8
f(x) 1 5 5 4
Solution:
x y First Order Second Third order
Differences Order Differences
Differences
1 1
4
2 5 -2/3
0 1/14
7 5 -1/6
-1
8 4
f (6) 6.2380.
Example 3: Find the equation y=f(x) of least degree and passing through the
points (-1, -21), (1, 15), (2, 12), (3, 3). Find also y at x=0.
Solution:
x y First Order Second Third order
Differences Order Differences
Differences
-1 -21
18
1 15 -7
-3 1
2 12 -3
-9
3 3
Example 4: Find the Newtons divided differences polynomials for the data and
also find f(2.5).
x 3 1 0 3 5
f(x) 30 22 12 330 3458
x f(x) First Order Second Third order Fourth
Differences Order Differences order
Differences Differences
3 30
1 22 2
10 4
0 12 26 5
114
3 330 44
290
1564
5 3458
Exercise
1. Fit an interpolating polynomial for the data
u10 355,u0 -5,u8 -21,u1 -14,u4 -125 by using Newtons interpolation
formula and hence evaluate u 2 .
2. Construct the interpolation polynomial for the data given below using
Newtons general interpolation formula for the divided differences
x 2 4 5 6 8 10
y 10 96 196 350 868 1746
4. Fit a polynomial to the data (-4, 1245), (-1, 33), (0, 5), (2, 9), (5, 1335). Hence
find f(1) and f(7)
Numerical Differentiation:
Let y0 , y1,, yn be the values of a function y f ( x) corresponding to
x0 , x1,, xn , the process of computing successive derivatives at some
particular value of independent variable x is known as numerical
differentiation.
The approximate values of these derivatives are obtained by differentiating
dy dy dp
dx dp dx
1 2 p -1 2 3 p2 - 6 p 2 3 4 p3 -18 p 2 22 p - 6 4
y0 y0 y0 y0
h 2 6 24
.(1)
Differentiating again,
d2y 1 2 6 p 2 18 p 11 4
y0 ( p 1) 3
y0 y0
dx2 h2 12
(2)
In a similar way the higher order derivatives can be computed. The
expressions (1) and (2) take a simpler form when the derivative is required at
x = x0, because at this point p = 0. Hence we get
dy 1 1 1 1
dx y0 2 y0 3 y0 4 y0
x x h 2 3 4
0
and
d2y 1 2 11 4 5 5
2 2 y0 y0 y0 y0
3
dx x x h 12 6
0
The given values of x are equidistant and the given x is near to xn , we use
the backward difference table and consider Newtons backward interpolation
formula.
p( p 1) 2 p( p 1)( p 2) 3
y f xn ph yn pyn yn yn
2 3!
Differentiating with respect to p, we obtain
dy 1 2 p 1 2 3 p2 6 p 2 3
yn yn yn (3)
dx h 2 3!
2 yn ( p 1)3 yn
d2y 1
.(4)
dx2 h2
The expressions (3) and (4) take a simpler form when the derivative is
required at x = xn, because at this point p = 0. Hence we get
dy 1 1 1 1
dx yn 2 yn 3 yn 4 yn
x xn h 2 3 4
and
d2y 1 2 11 4 5 5
2 2 yn yn yn yn
3
dx x xn h 12 6
Example 1:
Given that
50 51 52 53 54 55 56
3.684 3.7084 3.7325 3.7563 3.7798 3.803 3.8259
d2y
find and at = 50 and = 56.
dx 2
2 3
50 3.684
0.0244
51 3.7084 0.0003
0.0241 0
52 3.7325 0.0003
0.0238 0
53 3.7563
0.0003
0.0235
54 3.7798 0
0.0003
0.0232
55 3.803 0
0.0003
0.0229
56 3.8259
(a) At x = 50, h = 1,
1 1 1
= {0.0244 (0.0003) + (0)} = 0.02455.
1 2 3
d2y
= 1[-0.0003]= -0.0003
dx 2
(b) At x = 56, h = 1,
1
= {0.0229 + 0.5 (0.0003) + 0} = 0.02275.
1
d2y
= 1[-0.0003] = -0.0003
dx 2
dy d 2y
Compute and at x = 1.2 and x = 2.0.
dx dx 2
2 3 4 5 6
1.0 2.7183
0.6018
1.2 3.3201 0.1333
0.7351 0.0294
1.4 4.0552 0.1627 0.0067
1 1 1 1 1
= {1.3395 + (0.2429) + (0.0441) + (0.0080) + (0.0013)}
0.2 2 3 4 5
= 7.3896
2 1 11 5
= {0.2429 + 0.0441 + (0.0080) (0.0013)} = 7.3854.
2 (0.2)2 12 6
Example 3: The population of a certain town is given below. Find the rate of
growth of population in 1931 and 1971:
2 3 4
1931 40.62
20.18
1941 60.8 1.03
19.15 5.49
1951 79.95 4.46 4.47
23.61 1.02
1971 132.65
(i) At x=1931, h = 10,
1 1 1 1
= {20.18 (1.03) + (5.49) (4.47)} = 2.36425
10 2 3 4
(ii) At x=1971, h = 10,
1 1 1 1
= {29.09 + (5.48) + (1.02) + (4.47)} = 3.10525
10 2 3 4
Exercise
1. A rod is rotating in a plane. The following table gives the angle in radians
through which the rod has turned for various values of the time t seconds.
t 0 0.2 0.4 0.6 0.8 1.0 1.2
0 0.12 0.49 1.12 2.02 3.2 4.67
Calculate the angular velocity and angular acceleration of the rod when
t = 0.2 sec and t = 1.2 sec.
1. The following data gives corresponding values of pressure and specific
volume of a superheated steam
v 2 4 6 8 10
p 105 42.7 25.3 16.7 13
Find the rate of change of pressure with respect to volume when v 2.
2. Given the following table of values of x and y
x 1.00 1.05 1.10 1.15 1.20 1.25 1.30
y 1.0000 1.0247 1.0488 1.0723 1.0954 1.1180 1.1401
dy d2y
Find and at x 1.00 .
dx dx 2
4. A function is given according to the table below.
1.5 2.0 2.5 3.0 3.5 4.0
3.375 7.000 13.625 24.000 38.875 59.000
2
Find and at = 1.5 and = 3.5.
5. Given that
1.96 1.98 2.00 2.02 2.04
0.7825 0.7739 0.7651 0.7563 0.7473
2
Find and at = 1.98 and = 2.04.
2
Find and at = 1.00 and = 1.25.
NUMERICAL INTEGRATION
Consider the definite integral
b
I y dx
a
p p -1 2 p p -1 p - 2 3
b xn
I y dx y0 py0 y0 y0 ... dx
x0
a
2 6
Geometrical significance
The curve y = f(x) is replaced by n straight line segments joining the points
x0 , y0 and x1, y1 ; x1, y1 and x2 , y2 ;...; xn-1, yn-1 and xn , yn . Then the area
bounded by the curve y = f (x), the ordinates x = x0 and x = xn and the X-axis is
approximately equal to the sum of the areas of the n trapeziums thus obtained.
Note: The error in the trapezoidal formula is
b - a h2 y
E x O(h 2 )
12
where y x denotes the largest value of the second derivative.
Simpsons 1/3 rule:
Put n =2 in (1), we get
x2
1 h
ydx2h y0 y0 6
2
y0 y0 4 y1 y2
x0 3
x4
h
Similarly, ydx y2 4 y3 y4
x2
3
xn
h
and finally ydx yn-2 4 yn-1 yn
xn -2
3
xn
3h
and finally, ydx yn-3 3 yn-2 3 yn-1 yn
xn-3
8
Examples:
6
dx
1. Evaluate 1 x2 by using
0
(i) Trapezoidal rule (ii) Simpsons 1/3 rule (iii) Simpsons 3/8 rule
by dividing the interval into six equal subintervals.
Solution:
ba 60
Given n = 6, hence h 1.
n 6
x 0 1 2 3 4 5 6
y 1 0.5 0.2 0.1 0.0588 0.0385 0.027
y0 y1 y2 y3 y4 y5 y6
approximate value of .
x 0 0.2 0.4 0.6 0.8 1
y 1 0.96154 0.86207 0.73529 0.60976 0.5000
y0 y1 y2 y3 y4 y5
By Trapezoidal rule
1
dx h
1 x 2 2 y0 y5 2 y`1 y2 y3 y4
0
0.2
1 0.5 2 0.96154 0.86207 0.73529 0.60976 0.783732
2
By actual integration,
1
dx 1
1 x 2 = (tan x)10
4
0
0.783732
Hence 4
3.13493
3. A solid of revolution is formed by rotating about the x-axis the area between
X-axis, the lines x=0 and x = 1 and a curve through the points with the
following coordinates:
x 0.00 0.25 0.50 0.75 1.00
y 1.0000 0.9896 0.9589 0.9089 0.8415
Solution:
1
Volume V= y 2 dx
0
h = 0.25.
Using Simpsons 1/3 rule,
0.25
V= 1 4 0.9793 0.8261 2 0.9195 0.7081 2.8192 .
3
4. A curve passes through the points (1, 2), (1.5, 2.4), (2, 2.7), (2.5, 2.8), (3, 3),
(3.5, 2.6), (4, 2.1). Obtain the area bounded by the curve, X-axis, x=1 and
x=4. Also find the volume of solid of revolution obtained by revolving this
area about the X-axis.
4
Soln: Area = ydx where h = 0.5
1
0.5
= 2 2.1 2 2.7 3 4 2.4 2.8 2.6 7.7833 sq.units
3
Volume =
0.5
3
22 (2.1)2 2 2.72 32 4 2.42 2.82 2.62 64.13 cub.units
1.4
Solution:
Let y sin x log x e x and h 0.2, n 6
The values of y are as given below:
x 0.2 0.4 0.6 0.8 1.00 1.2 1.4
y 3.0295 2.7975 2.8976 3.1660 3.5597 4.0698 4.4042
1.4
sin 3h
x log x e x dx y0 y6 3 y`1 y2 y4 y5 2 y3
0.2
8
3 0.2
3.0295 4.4042 3 2.7975 2.8976 3.5597 4.0698
8
2 3.1660
4.0304
Exercise
1. Given that
x 4.0 4.2 4.4 4.6 4.8 5.00 5.2
y=log x 1.3863 1.4351 1.4816 1.5261 1.5686 1.6094 1.6487
5.2
Evaluate ydx by
4
(i) Trapezoidal rule (ii) Simpsons 1/3 rule (iii) Simpsons 3/8 rule
2
2. Evaluate cos d using Simpsons 1/3 rule by taking 9 ordinates.
0