Numerical-Computational I Note Contd
Numerical-Computational I Note Contd
The symbol is called the difference operator. The differences of the first differences denoted by 2 y0 , 2
y1 y 0
y1 y 0
y 2 2 y 1 y0
...
2 y1 y1
y 3 2 y 2 y1
FINITE DI FFE RENCE S
y3 3y2 3y1 y0
Similarly
r yn r 1 yn 1 r 1 yn
r r r 1 r
ynr 1! yn1 r 2! y
nr
2
... 1 y n
r yn r 1 yn 1 r 1 yn
yn r r y n r r n 1 y nr r n
1 1! 2! 2
... 1 y
Difference Table
It is a convenient method for displaying the successive differences of a function. The following table is
an example to show how the differences are formed.
x y y 2 y 3 y 4 y 5 y
x0 y0
y0
x1 y1 2 y0
y1 3 y0
x2 y2 2 y1 4 y0
y2 3 y1 5 y0
x3 y3 2 y2 4 y1
y3 3 y2
x4 y4 2 y3
y4
x5 y5
The above table is called a diagonal difference table. The first term in the table is y0. It is called
the leading term.
The differences y0 , 2 y 0, 3 y ,0 ..., are called the leading differences. The differences n yn
with a fixed subscript are called forward differences. In forming such a difference table care must be
taken to maintain correct sign.
FINITE DI FFERE NCES
x y y 2 y 3 y
Solution
0 0
0.174
10 0.174 –0.001
0.173 –0.001
20 0.347 –0.002
0.171
30 0.518
Example 2
Construct a difference table for y = f(x) = x3 + 2x + 1 for x = 1, 2, 3, 4, 5.
Solution
x y = f(x) y 2 y 3 y
1 4
9
2 13 12
21 6
3 34 18
39 6
4 73 24
63
5 136
FINITE DI FFE REN CES 67
Example 3. By constructing a difference table and taking the second order differences as constant find the sixth term of
the series 8, 12, 19, 29, 42, ….
Solution Let K be the sixth term of the series. The difference table is
x y
2
1 8
4
2 12 3
7
3 19 3
10
4 29 3
13
5 42 K – 55
K – 42
6 K
The second
differences are constant. K – 55 = 3
K= 3+55
The sixth term of the series is 58. K = 58.
Example 3.4 Find the first term of the series whose second and
subsequent terms are 8, 3, 0, –1, 0, …
Solution Given f(2) = 8, f(3) = 3, f(3) = 0, f(4) = –1, f(5) = 0, we
are to find f(1).
We construct the difference table with the given values.
2 3 4
x f f f
x f x x fx x
2 8
–5
3 3 2
–3 0
4 0 2 0
–1 0
5 –1 2
6 0
We
3 f x 4 f x ... 0.
have
BACKWARD D I F F E R E N C E S
Let y = f(x) be a function given by the values y0, y1, … yn which it takes for the equally spaced values x0, x1, …, xn of the
independent variable x. Then y – y0, y2 – y1, …, yn – yn– 1 are called the first backward differences of y = f(x). They are denoted by
y0 , y1 , ..., yn , respectively. Thus we have
y1 y0 y1
y2 y1 y2
…
yn yn 1 yn ,
x y y 2 y 3 y 4 y
x0 y0
y1
x1 y1 2 y2
y2 3 y3
x2 y2
2 y3 4 y4
y3 3 y4
x3 y3
2 y4
y4
x4 y4
NUMERICAL DIFFERENTIATION
The process of computing the value of the derivative dy/dx for some particular
value of x from the
given data when the actual form of the function is not known is called Numerical differentiation. When the values of the
argument are equally spaced and we are to find the derivative for some given x lying near the beginning of the table, we
can represent the function by Newton–Gregory forward
interpolation formula. When the value of d y/ is required at a point near the end of the table, we use
dx
Newton’s backward interpolation formula and we may use suitable Central difference interpolation formula when the
derivative is to be found at some point lying near the middle of the tabulated values. If the values of argument x are not
equally spaced, we should use Newton’s divided difference formula to approximate the function y = f(x).
DERIVATIVES USING NEWTON’S FORWARD INTERPOLATION FO R M U L A
uu1 u u1u2
y y uy 2 y 3 y
0 0 0 0 ... (1)
12 1
23
x x0 (2)
wher u
e h
and 2 dx for x = 1
dx
x 1 2 3 4 5 6
y 1 8 27 64 125 216
x y y 2 y 3 y 4 y
1 1
7
2 8
12
19 6
3 27
18 0
27 6
4 64
24 0
61
6
5 125 30
91
6 216
dy
d2y
Example From the following table of values of x and y find and
for x =
1.05.
dx
x 1.00 1.05 1.10 1.15 1.20 1.25 dx 1.30 2
x y 2 3 4 5
1.00 1.00000
0.0247
0
1.05 1.02470 –0.00059
0.00241 –0.00002
1
1.10 1.04881 –0.00054 0.00003
0.02357 –0.00001 –0.00006
1.15 1.07238 –0.00051 –0.00003
0.0230 –0.00002
6
1.20 1.09544 –0.00047
0.0225
9
1.25 1.11803 –0.00045
0.0221
4
1.30 1.14017
Interpolation
Forward Difference
Q .1. Construct a forward difference table for the following given data.
x 3.60 3.65 3.70 3.75
y 36.598 38.475 40.447 42.521
Ans.:
x y y 2y 3y
□□□
10
Backward Difference
25 ?
30 0.5000 y30 =?
2y35 =?
3y40 =?
35 0.5736 0.0736
-0.0044
45 0.7071
0.064
Since we know that 3y should be3constant so
3y40 = –0.0005
= -0.0039
Again
2y35 = – 0.0039
– y30 = –0.0039
–y25 = 0.0775
= 0.4225
Hence sin 25 = 0.4225
□□□
12
Newton Gregory Formula for Forward
Interpolation
Q .1. Use Newton formula for interpolation to find the net premium at the age 25
from the table given below :
Age 20 24 28 32
Annual net premium 0.01427 0.01581 0.01772 0.01996
Ans.:
Age (x) ƒ(x) ƒ(x) 2 ƒ(x) 3 ƒ(x)
20 0.01427
0.00154
24 0.01581 0.00037
0.00191 -0.00004
28 0.01772 0.00033
0.00224
32 0.01996
Here a = 20 , h=4 and k=2
x xk
u = 0.25
h
Using following Newton’s Gregory forward interpolation formula :
k
y x yk yk u
2
y u u 1 .....
nk
y 1 .....(u ((n k) 1))
2! k
u
n k !
f(25) 0.00033 u
0.01581+0.00191(0.25) + 2x1 (.75(0.25))
=
= 0.0162543
13
Q .2. From the following table find the number of students who obtained less than
45 marks :
Marks No. of Students
30 – 40 31
40 – 50 42
50 – 60 51
60 – 70 35
70 – 80 31
Ans.:
Marks (x) No. of ƒ(x) 2 ƒ(x) ƒ(x)
3 4 ƒ(x)
Students ƒ(x)
Less than 40 31
42
Less than 50 73 9
51 -25
Less than 60 124 -16 37
35 12
Less than 70 159 -4
31
Less than 80 190
Here a = 40 , h = 10 and k=1
x xk
u =0.5
h
using following
forward interpolation
2 ku u nk
y x
formula y:k yk u y 1 ..... y 1 .....(u ((n k) 1))
2! k
u
=
9
31+ 42(0.5) + 2 0.5( 0.5) + u n 25 k ! 37
6 0.5( 0.5)( 1.5) + 240.5( 0.5)( 1.5)( 2.5)
= 47.8672 = 48 (approximately)
Hence the no. of students who obtained less than 45 marks are 48.
Q .3. Find the cubic polynomial which takes the following values
x 0 1 2 3
ƒ(x) 1 0 1 10
Find ƒ(4)
14
Ans.: Here we know that a = 0, h = 1 then form Newton’s Gregory forward
interpolation formula.
Pn (x) = ƒ(0) + xc1 ƒ(0) + xc2 2ƒ(0) + ___ xcn nƒ(0) ____ (1)
P3 (x) = 1 –x + x2 –x + x3 –3x2 + 2x
Hence the required polynomial of degree three is
=xx33––2x
2x22++11
Again ƒ(4) – 27 = 6
ƒ(4) = 33
□□□
15
Newton’s Formula for Backward
Interpolation
1891 46
20
1901 66 -5
15 2
1911 81 -3 -3
12 -1
1921 93 -4
8
1931 101
Here x = 1925, h = 10 , k=5
x xk
u =1925 – 1931/10 = -0.6
h
Now using Newton’s Backward interpolation formula :
k
y(x) yk yk u
2
y u u 1 .....
k1
y 1 ......(u ((k 1) 1))
2! k
u
u k 1!
Put all the values we get
= 96.6352 thousand (approximately)
16
□□□
Ans.:
x ƒ(x) ƒ(x) 2 ƒ(x) 3 ƒ(x) 4 ƒ(x)
1 22
30 22 = 8
2 1
2 30 26 8
=6
4 1
82 30 ( 3.6 6)
= 26 = -1.6
4 2 7 1
4 82 8 26
=- 0.535 ( 1.6)
3.6 12 1
7 2
= 0.194
17
x ƒ(x) ƒ(x) 2 ƒ(x) 3 ƒ(x) 4 ƒ(x)
7 106 22 8
=
12 4
1.75
216 106
12 7
= 22
12 216
Q .2. By means of Newton’s divided difference formula find the value of ƒ(2), ƒ(8)
and ƒ(15) from the following table :
x 4 5 7 10 11 13
4
+ (x – 4) (x – 5) (x – 7)(x – 10) ƒ(4) + _ _ _ _ _ _ _ ___ (1)
5,7,10,11
4 48
100 48 = 52
5 4
5 100 97 52 = 15
7 4
294 100 21 15
= 97 =1
7 4 10 4
18
x ƒ(x) ƒ(x) 2 ƒ(x) 3 ƒ(x) 4 ƒ(x)
7 294 202 97 0
= 21
10 5
900 294 27 21
= 202 =
1
10 7 11 5
1210 900 33 27
= 310 =1
11 10 13 7
2028 1210
= 409
Substituting the
13values
11 from above table in equation (1)
13 ƒ(x) = 48 + 52 (x – 4) + 15 (x – 4) (x – 5) + (x – 4) (x – 5) (x – 7)
2028
= x2 (x – 1) __ _(2)
Q .3. Find the polynomial of the lowest possible degree which assumes the values 3,
12, 15, -21 when x has values 3, 2, 1, -1 respectively.
19
Ans.: Constructing table according to given data
x ƒ(x) ƒ(x) 2 ƒ(x) ƒ(x)
3
-1 -21
18
1 15 -7
-3 1
2 12 -3
-9
3 3
ƒ(x) = ƒ(x0) + (x –x0) ƒ(x0, x1) + (x –x0) (x –x1) ___(x –xn-1) + ƒ(x0, x1, x2 ..xn)
□□□
20
= 1 y 9
y1
9 1 1 3
16 y 16 y
3
16
16
1
1 y1 y1 y 3- y 1 y -1 y
= 2 16
3
1 1 1
1 y1 y y 3- y 1 y -1 y
= 2 1
8 2 2
3
Hence proved.
□□□
21
Unit 2
Central Difference
22
Gauss Forward Interpolation Formula
(1)
From central difference table we have
23
Gauss Backward Interpolation Formula
We have
Stirling’s Formula
24
Taking the mean of these formula
Ans
U= ( 32- 30)/5 = 0.4
Q.2
25
Ans
Q.3
26
Ans
Q.
Ans
27
Q.2
Ans
28
Q.3
Ans
29
30
Differention
31
32
33
34
35
36
37
38
Q.1
Ans
39
40
Q.2
Ans
41
Q.
Ans
42
43
44
45
46
Q .1. Compute the value of following integral by Trapezoidal rule.
1.4
(sin x log x + ex )
e
dx
0.2
Ans.: Dividing the range of integration in equal intervals in the interval [0.2, 1.4]
47
1.4 0.2 1.2
0.2 h
6 6
x sin x log x ex y = sin x –log +ex
e
h
= 2[(y0 + y6) + 2 (y 1 + y2 + y3 +y4 +y5)]
0.2
= 2 [7.7338 + 2 (16.4907)]
= 4.07152
5.2
1
Q.2. Calculate the value of the integral log x dx by Simpson’s ‘ ’ rule.
4
e 3
4.0 y0 = 1.3862944
4.2 y 1 = 1.4350845
4.4 y2 = 1.4816045
4.6 y3 = 1.5260563
4.8 y4 = 1.5686159
5.0 y 5 = 1.6049379
48
5.2 y6 = 1.6486586
1
Using following Simpson’s ‘ ’
rule : 3
h
I=
[(y0 + y6) + 4 (y 1 + y3 + y5) +2 (y2 +y4)]
3
0.2
= 3 [3.034953 + 18.232315 + 6.1004408]
0.2
= 3 [27.417709] = 1.8278472
1
dx
Q.3. Evaluate 3 using Simpson’s ‘ ’ rule :
0 1 + x2 8
Ans.: Dividing the interval [0, 1] into six equal intervals.
1 0 1
h
6 6
x 1
y= h
(1 x2 )
x0 = 0 y0 = 1.000
x0 + 6h = 1 y6 = (1/2) = 0.50000
49
1
= [1.5 + 9.46632 + = 0.785395
16
1.6]
□□□
Gauss two point
50
Newton Raphson Method
Q .1. Find the root of the equation x2 – 5x + 2 = 0 correct upto 5 decimal places. (use
Newton Raphson Method.)
Ans.: : Given ƒ(x) = x2 – 5x + 2 = 0
Taking x = 0
51
ƒ(0) = 2 (which is positive)
Taking x = 1
ƒ(1) = 1 – 5 + 2 = – 2 (which is negative)
ƒ(0) . ƒ(1) < 0
The root of the given equation lies between 0 and 1
Taking initial approximation as
01
= 0.5
x1 = 2
ƒ(x) = x2 – 5x + 2
f' (x) = 2x – 5
Since x 1 = 0.5
+ 2
= 0.25 – 2.5
+2
= – 0.25
= 1 –( 50.25)
x2 = 0.5=–– 4 4
= 0.19140 – 2.1875 + 2
= 0.003906
= – 4.125
Now finding x3 f (x 2 )
x3 = x2 – f 1 (x2 )
52
= 0.4375 0.003906
– ( 4.125)
= 0.4375 + 0.0009469
= 0.43844
= 0.19222 – 2.1922 + 2
= 0.00002
f'(x3) = 2 x (0.43844) – 5
= – 4.12312
f (x3 )
x4 = x3 – f 1 (x )
3
0.00002
= 0.43844
– ( 4.12312)
= 0.43844 + 0.00000485
= 0.43844
Hence the root of the given equation is 0.43844 which is correct upto five decimal
places.
Q .2. Apply Newton Raphson Method to find the root of the equation 3x – cos x – 1
= 0 correct the result upto five decimal places.
Ans.: Given equation is
ƒ(x) = 3x – cos x – 1
Taking x = 0
ƒ(0) = 3(0) –
cos 0 – 1
=–2
Now taking x = 1
ƒ(1) = 3(1) –
cos (1) – 1
=3–
0.5403 – 1
01 =
= 0.5
x 1 = 1.4597
2
Taking initial
approximation as 53
ƒ(x) = 3x – cos x – 1
f'(x) = 3 + sin x
At x1= 0.5
ƒ(x1) = 3 (0.5) –
cos (0.5) –1
= 1.5 – 0.8775
–1
= – 0.37758
= 1.82556 – 0.820494 – 1
= 0.005066
= 3.57165
= 1.8213 – 0.821305884 – 1
= – 0.00000588
= 3 + 0.57048
= 3.5704
54
Now to find x4 using following formula
f (x3 )
x4 = x3 – f '(x3 )
( 0.00000588)
= 0.60710
– 3.5704
= 0.60710 + 0.00000164
= 0.60710
Which is same as x3
Hence the root of the given equation is x = 0.60710 which is correct upto five
decimal places.
□□□
55
Iterative Method
Q .1. Find a root of the equation x3 + x2 – 1 = 0 in the interval (0,1) with an accuracy of
10-4.
Ans.: Given equation is ƒ(x) = x3 + x2 – 1 = 0
Rewriting above equation in the form
x= (x)
The given equation can be expressed in either of the form : (i)x3 +
x2 – 1 = 0
x3 + x2 = 1 x2 (x + 1)
=1
1
x2 =
1+x
1
x= ___ (1)
(1
x)
(ii) x3 + x2 – 1 = 0
x2 = 1 – x3
(1/2)
x = (1 + x3) ___ (2)
(iii) x3 + x2 – 1 = 0
x3 = 1 – x2
x = (1 – x2) 1/3 ___ (3)
Comparing equation (1) with x – g (x) = 0 we find that
1
g(x) =
(1
x)
g(x) = (1 + x) -1/2
g'(x) = – ½ (1 + x)-3/2
│g'(x)│= ½ (1 + x)3/2
56
1 = <1
2(1 + x) 3/ 2
-3 0 1
=
2 2
3
│g'(x)│= x2
(1 - 2
Which is not less xthan
) one. 2 1/2
1
g'(x) = 3(1 – x2)-2/3 x (– 2x )
2 x
=
3 (1 - x2 ) 1/2
2 x
│g'(x)│= 3 (1 2 2/3
x )
Which is not less than one.
Hence this method is applicable only to equation (1) because it is convergent for
all x (0, 1)
Now taking initial approximation
0 1
x1 = = 0.5
2
1 1
So x2 = (1+ x 1 ) [using iteration scheme x n+1 = (xn ]
1)
1
= =
x2 = 0.51 1 0.81649
1.5
Similarly
1 1
= = 0.7419
x3 = (x2 0.81649 1
1)
57
1 = 1 = 0.7576
x4 =
(x3 1) 0.7419 1
1 1
= = 0.7542
x5 = (x4 1) 0.7576 1
1 1
= = 0.7550
x6 = (x5 1) 0.7542 1
1 1
= = 0.7548
x7 = (x6 1) 0.7550 1
1 1
= =
x8 =
(x7 1) 0.7548
0.7548 1
Hence the approximate root of the given equation is x = 0.7548
Q.2. Find the root of the equation 2x = cos x + 3 correct upto 3 decimal places.
Ans.: Given equation is
ƒ(x) = 2x – cos x – 3 = 0
Rewriting above equation in the form x = g(x)
2x = cos x + 3
cos x + 3 cos x 3
g(x) = =
2 sin x 2 2
g'(x) =
2
sin x
│g'(x)│= 2
For x (1, 2)
│sin x│< 1
cos (x n ) + 3
Hence the iterative scheme xn+1 = 2is convergent.
58
x3 = cos (x2 ) + 3 = cos (1.5353) + 3 = 1.5177
2 2
cos (x3 ) + 3 cos (1.5177) + 3
x4 = 2 = 2 = 1.5265
Which is same as x7
Hence the root of the given equation is x = 1.523 (which is correct upto 3
decimals)
Q.3. Find the root of the equation xex = 1 in the internal (0, 1) (use iterative
Method) Ans.: Given equation is xex – 1 = 0
Rewriting above equation in the form of x = g (x)
xex – 1 = 0
xex = 1 x = e-
x
xn
xn+1 = e
x2 = e x1 = e (0.5)
= 0.60653 x3 = e x2
=e
(0.6065)
= 0.5452
59
x3
x4 = e =e (0.5452)
= 0.5797
x4
x5 = e =e 0.5797
= 0.5600 x6 = e
x5 x6
=e 0.5600
= 0.5712 x7 = e =
e (0.5712)
= 0.5648
x7 (0.5648)
x8 = e =e = 0.5684 x9 = e
x8 (0.5684) x9
=e = 0.5664 x10 = e =e
(0.5664)
= 0.5675
Now
x10
x 11 = e =e 0.5675
= 0.5669 x12 = e
= 0.5671
60
Gauss Elimination Method
3x + 3y + 4z = 24 _ _ _ (1)
x+y +z =7 ___
(2)
2x + y + 3z = 16 ___ (3)
Now eliminating x form equation (2) and equation (3) using equation (1)
-3 equation (2) + equation (1), 3 equation (3) – 2
2
equation (1) we get
-3x - 3y - 3z = -21 6x 3y 9z
3x + 3y + 4z = and 48
24 6x 6 y 8z 48
z 3 3y z
= 3y - z = 0
0
3x + 3y + 4z = 24 _ _ _ (4)
z =3 _ _ _ (5)
3y – z = 0 _ _ _ (6)
Now since the second row cannot be used as the pivot row since a22 = 0 so interchanging
the equation (5) and (6) we get
3x + 3y + 4z = 24 ___ (7)
3y – z = 0 ___ (8)
z =3 ___ (9)
Now it is upper triangular matrix system. So by back substitution we obtain.
z=
3
61
From equation (8)
3y – 3 = 0
3y = 3
y =1
From equation (7)
3x + 3(1) + 4 (3) = 24
3x + 3 + 12 = 24
3x + 15 = 24
3x = 9
x=
3
Hence the solution fo given system of linear equation is
x=3 , y=1 , z =3
Q .2. Solve the following system of linear equation by Gauss Elimination Method :
2x1 + 4x2 + x3 = 3
7x3 = 13 x2 –x3 = -4
8x2 + 7x3 = 13
___
So the system now becomes : (4)
Now eliminating x2 from equation (6) using equation (5) {8 × equation (6) –equation (5)}
x3 = 3
8x2 + 7(3) = 13
8x2 = 13 – 21
8x2 = –8
x2 = –1
From equation
(9)
3x1 +2(–1)
–2 (3) = –
3x1 = –2 +
2+ 6
□□
3x1 = 6
x1 = 2
□
Gauss-Jordan Elimination Method
_ _ _ (1)
10x1 + 2x2 + x3 = 9
_ _ _ (2)
2x1 + 20x2 – 2x3 = – 44
_ _ _ (3)
-2x1 + 3x2 + 10x3 = 22
64
___
98x2 –11x 3 = –229 x3
(8)
it 3reduces to upper triangular system now_ by
Hence = _ _back substitution.
(9)
x3 = 3
From equation (8)
98x2 –1 1 × 3 = – 229
98x2 = –229 + 33
98x2 = –196 x2 = – 2
From equation (7)
49x1 + 6(3) = 67
49x1 = 67 – 18
49x1 = 49
x1 = 1
Thus the solution
of the given
system of linear
equation is
x1 = 1
x2 = – 2
x3 = 3
65