Numerical Methods
Numerical Methods
Numerical Methods
Module 5
NUMERICAL METHOD
CONTENTS:
Finite difference:
Forward and Backward difference
Newtons forward and backward interpolation formula
Newtons divided difference formula
Lagranges interpolation formula
Numerical integration
Newton Raphson,s Method
Regular Falsi Method
Finite Differences
y r y r 1 y r , r 0,1, 2,..., n 1
y 0 y1 y 0
y1 y 2 y1
. first forward differences
.
y n 1 y n y n 1
The difference of the first difference are called the second differences,they are
symbolically denoted as
Now 2 y 0 (y 0 ) ( y1 y 0 )
y1 y 0 ( y 2 y1 ) ( y1 y 0 )
y 2 2y1 y 0
||| ly 2 y1 y 3 2 y 2 y1
2 y r y r 2 2y r 1 y r
Note : 3 y 0 y 3 3y 2 3y1 y 0
k y r y r k k C1 y r k 1 k C 2 y r k 2 .... (1) k C r
Ex: The following table gives a set of values of x and the corresponding values of
y = f(x)
x: 10 15 20 25 30 35
y: 19.97 21.51 22.47 23.52 24.65 25.89
Form the difference table and find f (10), 2 f (10), 3f (20), 4 f (15) .
x Y 2 3 4 5
10 19.97
1.54
15 21.51 -0.58
0.96 0.67
20 22.47 0.09 -0.68
Note:
1. f(x + h) = f(x + h) - f(x) = ∆ f(x)
2. 2 f(x + 2h) = (f(x + 2h))
= {f(x + 2h) - f(x + h)}
= f(x + 2h) - f(x + h)
= f(x + 2h) - f(x + h) - f(x + h) + f(x)
= f(x + 2h) -2f(x + h) + f(x)
Department of Mathematics/ACSCE Page 4
= ∆2 f(x)
|||ly n f(x + nh) = ∆n f(x)
Backward difference table
x Y y 2y 3y
X0 y0
y1
X1 y1 2y2
y2 3y3
X2 y2 2y3
y3
X3 y3
We carryout upto the stage where we get two entries ( 2 unknowns) and equate
each of those entries to zero. (Assuming) to be a polynomial of degree 2.
b + 3a - 200 = 0
-3b - a + 408 = 0 We get a = 24 b = 128
u (u 1) (u 2) ...( u n 1) n
y0
n!
Note :
1. Newton forward interpolation is generally used to interpolate the values of y
near the beginning of a set of tabular values for a better accuracy,.
Problems:
1) The 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
y = 10.63 13.03 15.04 16.81 18.42 19.90 21.27
distance
Choose x0 = 100
120 100
i) x 120, u 0.4
50
0.4 (0.4)(0.4 1)
f (120) 10.63 (2.40) (0.39)
1! 2!
218 200 18
ii) Let x = 218, x0 = 200, u 0.36
50 50
= 15.7
(0.5)(0.5)
f (1.85) 6.049 (0.5) (0.637) (0.066)
2
(0.5)(0.5) (1.5)
(0.008)
6
= 6.359
4) From the following data find the number of students who have obtained 45
marks. Also find the number of students who have scored between 41 and 45
marks.
Marks 0 - 40 41 - 50 51 - 60 61 -70 71 - 80
No. of 31 42 51 35 31
students
x Y 2 3 4
40 31
f(45) - f(40) = 70 = Number of students who have scored between 41 and 45.
x y 2 3 4
0 3
3
1 6 2
5 0
2 11 2 0
7 0
3 18 2
9
4 27
x0
u x
1
x ( x 1) x(x 1)
f ( x ) 3 x (3) (2) (0) 3 2x x 2
2 x!
u (u 1) 2 u (u 1) (u 2) 3
y y n u y n yn y n ....
2! 3!
x xn
where u
h
x y 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
0.26 0.3
u 0.8
0.05
(0.8) (0.8) (0.2) (1.2)
f (0.26 ) 0.3093 (0.8)(0.054 ) (0.2) (0.0014) (0.0004) 0.2659
2 6
x d 2 3 4 5
0 0
0.0347
0.2 0.0347 0.0479
0.0826 -
0.0318
0.4 0.1173 0.0161 0.0003
Department of Mathematics/ACSCE Page 14
0.0987 - -
0.0321 0.0003
0.6 0.2160 -0.016 0
0.0827 -0.032
0.8 0.2987 -
0.0481
0.0346
1.0 0.3333
Answer:
x xn
u 0.4
n
y = 7542
4) Find the interpolating polynomial which approximates the following data.
x 0 1 2 3 4
x y 2 3 4
0 -5
-5
1 -10 6
1 6
2 -9 12 0
13 6
3 4 18
31
4 35
x4
u
1
18 (x 4) (x 3) (x 2) (6)
f (x) 35 (x 4) (31) (x 4) (x 3)
2! 3!
f(x) x 3 2x 2 6x - 5
( x x 0 ) ( x x1 ) ( x x 3 )...( x x n )
f ( x 2 ) ....
( x 2 x 0 ) ( x 2 x1 ) ( x 2 x 3 )...( x 2 x n )
interpolation formula
y 2 y1
y1 [x 2 , x1 ]
x 2 x1
y n y n 1
y n 1 [ x n 1 , x n ]
x n x n 1
[x 2 , x1 ] [x1 , x 0 ]
[x 0 , x1 , x 2 ]
x2 x0
y 2 y1 [ x 3 , x 2 ] [ x 2 , x1 ]
|| ly 2 y1 [x1 , x 2 , x 3 ]
x 3 x1 x 3 x1
... ( x x 0 ) ( x x 1 ) ...( x x n ) n y 0
.
Department of Mathematics/ACSCE Page 17
Inverse interpolation: Finding the value of y given the value of x is called
interpolation where as finding the value of x for a given y is called inverse
interpolation.
Since Lagrange's formula is only a relation between x and y we can obtain the
inverse interpolation formula just by interchanging x and y.
( y y1 ) ( y y 2 )....( y y n )
x .x 0
( y 0 y1 ) ( y 0 y 2 )...( y 0 y n )
( y y 0 ) ( y y 0 ) ( y y 2 ) ( y y 3 )...( y y n )
x1 ...
( y1 y 0 ) ( y1 y 2 ) ( y1 y 3 ) ...( y1 y n )
( y y 0 ) ( y y1 )...( y y n 1 )
... .x n
( y n y 0 ) ( y n y1 )...( y n y n 1 )
( y y 0 ) ( y y1 ) ( y y 2 ) ( y y 3 ) ( y y 4 )
.... x4
( y 5 y 0 ) ( y 5 y1 ) ( y 5 y 2 )...( y 5 y 4 )
= 3.55
Evaluate f(9) using (i) Lagrange's formula (ii) Newton's divided difference
formula.
i) Lagranges formula
(9 7) (9 11) (9 13) (9 17) (9 5) (9 11) (9 13) (9 17)
f (9) (150) .392
(5 7) (5 11) (5 13) (5 17) (7 5) (7 11) (7 13) (7 17)
(9 5) (9 7) (9 11) (9 13)
(5202) 810
(17 5) (17 7) (17 11) (17 13)
f(9) = 810
ii)
5 150
121
7 392 24
265 1
11 1452 32 0
457 1
13 2366 42
709
17 5202
3) Using i) Langranges interpolation and ii) divided difference formula. Find the
value of y when x = 10.
x: 5 6 9 11
y: 12 13 14 16
i) Lagranges formula
(10 6) (10 9) (10 11) (10 5)(10 9)(10 11)
y f (10) 12 13
(5 6) (5 9) (5 11) (6 5)(6 9)(6 11)
11 16
4) If y(1) = -3, y(3) = 9, y(4) =30, y(6) = 132 find the lagranges interpolating
polynomial that takes the same values as y at the given points.
Given:
X 1 3 4 6
Y -3 9 30 132
( x 3) ( x 4) ( x 6) ( x 1)(x 4)(x 6)
f (x) . (3) .9
(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 3)(6 4)
= x3 - 3x2 + 5x - 6
5) Find the interpolating polynomial using Newton divided difference formula for
the following data:
X 0 1 2 5
Y 2 3 12 147
X y 2 3
0 2
1
1 3 4
9 1
Numerical Integration:-
b
Evaluating the value of I y dx numerically, given the set of values ( xi , yi ) ,
a
I
3h
y0 y n 3 y1 y 2 y 4 y5 .... y n1 2 y3 y6 ..... y n3
8
when n is a multiple of 3.
Problems:
rd 1
by dividing the interval 0 , 1 into
1 dx
1) Using Simpson’s
3
rule evaluate 1 x
0
2
4 equal sub intervals and hence find the value of correct to four decimal
places.
Department of Mathematics/ACSCE Page 22
Solution: Let us divide [0,1] into 4 equal strips (n = 4)
1 0 1
length of each strip: h
4 4
1 2 1 3 4
The points of division are x 0, , , , 1
4 4 2 4 4
1
By data y
1 x2
Now we have the following table
x 0 1/4 ½ 3/4 1
1
y
1 x2 1 16/17 4/5 16/25 ½
y0 y1 y2 y3 y4
rd
1
Simpson’s rule for n = 4 is given by
3
b
h
ydx 3 y
a
0 y4 4 y1 y3 2 y2
1/ 4 1 16 16 4
1
1
dx 1 4 2. 0.7854
0
1 x 2
3 2 17 25 5
1
1
Thus 1 x
0
2
dx 0.7854
2) Given that
x 4 4.2 4.4 4.6 4.8 5 5.2
log x 1.3863 1.4351 1.4816 1.5261 1.5686 1.6094 1.6487
5.2 th
3
Evaluate log x dx using Simpson’s rule
4
8
th
3
Solution: Simpson’s rule for n = 6 is given by
8
log
4
e xdx 1.8279
1
xdx
3) Using Weddle’s rule evaluate 1 x
0
2
by taking seven ordinates and hence
find loge2
Solution: Let us divide [0,1] into 6 equal strips ( since seven ordinates)
1 0 1
length of each strip: h
6 6
1 2 1 3 1 4 2 5 6
The points of division are x 0, , , , , , 1
6 6 3 6 2 6 3 6 6
1
By data y
1 x2
Now we have the following table
1
x 3(1/ 6)
1 x 2
dx 0 5(6 / 37) 3/10 6(2 / 5) 6 /13 5(30 / 61) 1/ 2
0
10
1
x
1 x
0
2
dx 0.3466
To deduce the value of loge2: We perform theoretical integration and equate the
resulting value to the numerical value obtained.
Poblems:
2. Find the root of the equation xex = cos x using Regula falsi method correct to
three decimal places.
Solution:
Let f(x) = cosx - xex
Observe
f(0) = 1
f(1) =cos1 - e = -2.17798
root lies between 0 and 1
Taking x0 = 0, x1 = 1
f(x0) = 1, f(x1) = -2.17798
x1 x 0
x2 x0 .f ( x 0 )
f (x1 ) f (x 0 )
1
0 (1) 0.31467
3.17798
f(x2) = f(0.31467) = 0.51987 +ve
Root lies between 0.31467 and 1
x0 = 0.31467, x1 = 1
f(x0) = 0.51987, f(x1) = -2.17798
1 0.31467
x 3 0.31467 (0.51987) 0.44673
2.17798 0.51987
This method is used to find the isolated roots of an equation f(x) = 0, when the
derivative of f(x) is a simple expression.
2.Using Newton's Method, find the real root of xex = 2. Correct to 3 decimal
places.
Answer:
Let f(x) = xex - 2
f(0) = -2
f(1) = e - 2 = 0.7182
Let x0 = 1
f' (x) = (x + 1) ex
We have
x k e xk 2
x k 1 x k
( x k 1) e x k
e2
x1 1 0.8678
2e
(0.8678) e 0.8678 2
x 2 0.8678 0.8527
(1.8678) e 0.8678
(0.8527) e 0.8527 2
x 3 0.8527 0.8526
(1.8527) e 0.8527
3. Find by Newton's Method the real root of 3x = cosx + 1 near 0.6, x is in radians.
Correct for four decimal places.
Answer:
Let f(x) = 3x - cosx - 1
f'(x) = 3 + sinx
3x k cos x k 1
x k 1 x k
3 sin x k
3 (0.6) cos (0.6) 1
When x 0 0.6 x 1 0.6 0.6071
3 sin (0.6)
3 (0.6071) cos (0.6071) 1
x 2 0.6071 0.6071
3 sin (0.6071)
Since x1 = x2
The desired root is 0.6071
4. Obtain the iterative formula for finding the square root of N and find 41
Answer:
Let x N
or x2 - N = 0
f(x) = x2 - N
f'(x) = 2x
Now
x 2k N
x k 1 x k
2x k
x N
xk k
2 2x k
1 N
i.e. x k 1 x k
2 xk
To find 41
Observe that 36 41
Choose x 0 6
1 41
x 1 6 6.4166
2 6
1 41
x 2 6.4166 6.4031
2 6.4166
5. Obtain an iterative formula for finding the p-th root of N and hence find (10)1/3
correct to 3 decimal places.
Answer:
Let xp = N
or xp - N = 0
Let f(x) = xp - N
f ' ( x ) px p1
x pk N
Now x k 1 x k
px pk1
Observe that 8 < 10
81 / 3 101 / 3
i.e. 2 (10)1 / 3
Use x0 = 2, p = 3, N=10
2 3 10
x1 2 2.1666
3 (2 2 )
(2.1666) 3 10
x 2 2.1666 2.1545
3(2.1666) 2
(2.1545) 3 10
x 3 2.1545 2.1544
3 (2.1545) 2
(10)1 / 3 2.1544
6. Obtain an iterative formula for finding the reciprocal of p-th root of N. Find
(30)-1/5 correct to 3 decimal places.
Answer:
Let x -p = N
or x -p - N = 0
f(x) = x -p - N
f'(x) = -px -p - 1
Now
p
xk N
x k 1 x k
p 1
p xk