You are on page 1of 9

ASSIGNMENT # 02

Course: Numerical Computing


Submission Status: ONLINE via VLE
Submission Date: Apr 17,2019
Submitted to: Dr. Nadeem Alam Khan

Group Members:
 M. Iftikhar Uddin Khan Sami (13275)
 Raghib Uddin (13273)
 Hamza Arif (14446)
 Azlan Waseem (15096)
 Raja Zaryab (16566)
Assignment#2: (G-4) COURSE TITLE: Numerical Computing
Topic: Polynomial Interpolation and Numerical Integration
Q#1 Using Newton’s forward Formula find the cubic polynomial interpolation
which takes the following values. Evaluate f(1.5).
x 0 1 2 3
f(x) 1 2 1 10

Q#2 Using Newton’s backward Formula find the area of a circle of diameter 88 from
the given table of diameter and area of circle.
Diameter 80 85 90 95 100
Area 5026 5674 6362 7088 7854

Q#3 The specific gravities of Zinc sulphate solutions of different concentration at 15


C 0 are given below.

Concentration(%) 10 12 14 16 18 20 22
Specific Gravity 1.059 1.073 1.085 1.097 1.110 1.124 1.137
0
Find the specific Gravity of 15.8% solution at 15C , using Gauss’s Backward formula.

Q#4 Using Lagrange’s Formula, Evaluate f(8).


X 5 7 11 13 17
Y=xf(x) 150 392 1452 2366 5202

Q#5 Find the equation of the curve passing through the points (1, -21), (1, 15), (2,
12), (3, 3). Evaluate f(0), using Newton’s Divided Difference formula.
X 4 5 7 10 11 13
F(x) 48 100 294 900 1210 2028

Q#6 Evaluate the Approximate value of ∫ Cosx dx taking h= ¿ 6 .


0

Using (i) Trapezoidal Rule (ii) Simpson’s 1/3 Rule.

2
Q#1 Using Newton’s forward Formula find the cubic polynomial interpolation which takes the following
values. Evaluate f(1.5).

x 0 1 2 3
f(x) 1 2 1 10
Solution:

Considering Newto n' s Forward Formula , i. e ,


u u ( u−1 ) 2 u (u−1 ) ( u−2 ) 3
f ( x )= y 0+ . ∆ y0 + . ∆ y0+ . ∆ y0 + …
1! 2! 3!
x−x 0
Where , u=
h
x−0
Here , x 0=0 ,h=1 ,∴ u= =x
1
Now , we form the Forward Difference Table ;
2 3
x y ∆y ∆ y ∆ y
x 0=0 y 0=1
2−1=1
x 1=1 y 1=2 −1−1=−2
1−2=−1 10−(−2 )=12
x 2=2 y 2=1 9−(−1 )=10
10−1=9
x 3=3 y 3=10
So , Now , We have ; y 0=1 , ∆ y 0 =1, ∆ 2 y 0 =−2 , ∆3 y 0=12

u u ( u−1 ) u ( u−1 )( u−2 )


f ( x )=1+ .(1)+ .(−2)+ .(12)
1! 2! 3!
u u (u−1 ) u (u−1 ) ( u−2 )
f ( x )=1+ .( 1)+ .(−2)+ .(12)
1 2 6
f ( x )=1+u+ {u ( u−1 ) . (−1 ) }+{u ( u−1 )( u−2 ) . (2)}

f ( x )=1+u+ {(u 2−u). (−1 ) }+{u .(u2−u−2u+ 2) .(2)}

f ( x )=1+u+ {( u2−u ) . (−1 ) }+ {u . ( u2−3 u+2 ) . ( 2 ) }

f ( x )=1+u+ {(u 2−u). (−1 ) }+{2u .(u 2−3 u+2)}

f ( x )=1+u−(u 2−u)+{2 u .(u2−3 u+2)}

f ( x )=1+u−(u 2−u)+(2 u3−6 u 2+ 4 u)

f ( x )=1+u−u2 +u+2 u3−6 u 2+ 4 u=1+ u+u+ 4 u−u 2−6 u2 +2u 3=1+6 u−7u 2+ 2u3

f ( x )=2 u3 −7u 2+ 6 u+1∨f ( x )=2 x 3−7 x 2+ 6 x+1 ∵u=x (mentioned above )


Evaluating f ( 1.5 ) ,
3 2
f ( 1.5 )=2 (1.5 ) −7 ( 1.5 ) + 6 ( 1.5 )+ 1=¿ 2 ( 3.375 )−7 ( 2.25 ) +6 ( 1.5 ) +1
3
f ( 1.5 )=6.75−15.75+ 9+1=¿ 15.75−15.75+ 1=¿≫1 Ans …

4
Q#2 Using Newton’s backward Formula find the area of a circle of diameter 88 from the given table of
diameter and area of circle.

Diameter 80 85 90 95 100
Area 5026 5674 6362 7088 7854
Solution:

Considering Newto n' s Backward Formula ,i . e ,


u u ( u+1 ) 2 u (u +1 )( u+2 ) 3 u (u +1 )( u+2 ) … ( u+n−1 ) n
f ( x )= y n+ . ∇ y n+ . ∇ yn + . ∇ y n +…+ . ∇ y n −−equ(i)
1! 2! 3! n!
x−x n
Where , u=
h
x−90
Here , x n=90 ,h=5 , ∴u= ∵ 88 isnear 90
5
88−90
When x=88 , u= =−0.4
5
Now , we form the Backward Difference Table ;

x y ∆y ∆2 y ∆3 y ∆4 y
x 0=80 y 0=5026
5674−5026=648
x 1=85 y 1=5674 688−648=40
6362−5674=688 38−40=−2
x 2=90 y 2=6362 726−688=38 2+2=4
7088−6362=726 40−38=2
x 3=95 y 3=7088 766−726=40
7854−7088=766
x 4 =100 y 4 =7854
Hence ; y n=7854 , ∇ y n=766 , ∇ 2 y n=40 , ∇ 3 y n=2, ∇ 4 y n=4
¿ When x=88∧u=−0.4
Substituting all the values∈Equ(i)

u u ( u+1 ) 2 u ( u+1 )( u+ 2 ) 3 u ( u+1 ) ( u+2 ) (u+3) 4


y= y n+ . ∇ y n+ . ∇ yn + . ∇ yn + . ∇ yn
1! 2! 3! 4!
−0.4 −0.4 (−0.4+ 1 ) −0.4 (−0.4+ 1 )(−0.4 +2 ) −0.4 (−0.4 +1 )(−0.4+2 ) (−0.4+3)
y=7854 + .766+ .40+ .2+ .4
1! 2! 3! 4!
y=7854−306.4−4.8−0.128−0.1664=¿>7452.5056 Ans …

5
Q#3 The specific gravities of Zinc sulphate solutions of different concentration at 15 C 0 are given below.

Concentration(%) 10 12 14 16 18 20 22
Specific Gravity 1.059 1.073 1.085 1.097 1.110 1.124 1.137
Find the specific Gravity of 15.8% solution at 15C 0, using Gauss’s Backward formula.
Solution:
Cosidering Gaus s ' Backward Formula ; ; ;
u(u+1) 2 u(u−1)(u+ 1) 3 u(u +1)(u−1)( u−2) 4
f ( x )= y 0+¿ u ∆ y 0 + ∆ y −1 + ∆ y−2+ ∆ y−3 +…
2! 3! 4!
x−x 0
Where , u= ∧x 0 is the origin .
h
Here , x 0=16 , h=2 , since x=15.8 lies between x=14∧x=16

x−16 15.8−16 0.2


u= ,=¿When x =15.8=¿ u= =¿− =¿−0.1
2 2 2
Now ,Whe form the Central DifferenceTable ;
x u y ∆y ∆2 y ∆3 y ∆4 y ∆5 y ∆6 y
10 -3 1.059
0.014
12 -2 1.073 −0.002
0.012 0.002
14 -1 1.085 0 −0.001
0.012 0.001 0
16 0 1.097 −−−−¿ 0.001 −−−−¿ −0.001 −−−−¿ −0.001
0.013 0 −0.001
18 1 1.110 0.001 −0.002
0.014 -0.002
20 2 1.124 −0.001
0.013
22 3 1.137
So , Now , We have ; y 0=1.097 , ∆ y−1=0.012 , ∆2 y−1=0.001 , ∆3 y−2=0.001, ∆ 4 y−2=−0.001 , ∆ 5 y −3 =0 , ∆6 y−3=

u(u+ 1) u(u−1)(u+1) u(u−1)(u+2)(u+1) u ( u−1 )(


f ( x )=1.097+ u X 0.012+ X 0.001+ X 0.001+ X (−0.001 ) +
2! 3! 4!

(−0.1)((−0.1)+1) (−0.1)((−0.1)−1)((−0.1)+ 1) (−0.1)((−


f ( x )=1.097+(−0.1) X 0.012+ X 0.001+ X 0.001+
2! 3!
∵ u=−0.1(mentioned above)
f ( 15.8 )=1.097−0.0012−0.000045+0.0000165−0.00000784+0+ 0.00000159
f ( 15.8 )=¿>1.0957 Ans .

6
Q#4 Using Lagrange’s Formula, Evaluate f(8).

X 5 7 11 13 17
Y=xf(x) 150 392 1452 2366 5202
Solution:
Given the values of x∧ y are x 0 =5 , x 1=7 , x 2=11, x 3=13 , x 4 =17

¿ y 0=150 , y 1=392 , y 2=1452 , y 3 =2366 , y 4=5202

The values arenot equally spaced , So we use Lagrang e' s Formula ¿ find y=f ( x ) .

Considering Lagrang e ' s Formula for 5 pairs .


( x−x 1)( x−x 2 )(x−x 3)(x−x 4 ) ( x−x 0)( x −x2 )( x−x 3)(x −x 4) (x−x 0)(x−x 1 )(x−x 3
y=f ( x )= y0 + y1 +
( x 0−x 1)(x 0−x 2 )(x 0−x 3)( x 0−x 4 ) (x 1−x 0 )(x1 −x2 )( x 1−x 3)(x 1−x 4 ) ( x 2−x 0)( x 2−x 1 )(x2 −x

( x−7 ) ( x −11 ) ( x −13 )( x−17 ) ( x−5 ) ( x −11 ) ( x −13 )( x−17 )


y=f ( x )= .150+ .392
( 5−7 )( 5−11 ) (5−13 ) ( 5−17 ) (7−5 ) ( 7−11 ) (7−13 ) ( 7−17 )
+(x−5)( x−7)(x −13)(x −17) ( x−5)( x−7)( x−11)( x−17)
.1452+ .2366
(11−5)(11−7)(11−13)(11−17) (13−5)(13−7)(13−11)(13−17)
+(x−5)( x−7)(x −11)( x−13)
.5202
(17−5)(17−7)(17−11)(17−13)
When x=8
( 8−7 ) ( 8−11 )( 8−13 ) ( 8−17 ) ( 8−5 )( 8−11 ) ( 8−13 )( 8−17 )
y=f ( 8 )= .150+ .392
(5−7 ) ( 5−11 )( 5−13 ) ( 5−17 ) ( 7−5 )( 7−11 ) ( 7−13 )( 7−17 )
+(8−5)(8−7)(8−13)(8−17) ( 8−5)(8−7)(8−11)(8−17)
.1452+ .2366
(11−5)(11−7)(11−13)(11−17) (13−5)(13−7)(13−11)(13−17)
+(8−5)(8−7)(8−11)(8−13)
.5202
(17−5)(17−7)(17−11)(17−13)
( 1 ) (−3 ) (−5 ) (−9 ) (150 ) ( 3 ) (−3 )(−5 )(−9 )( 392 )
y=f (8)= +
(−2 ) (−6 ) (−8 ) (−12 ) ( 2 )(−5 )(−6 )(−10 )
+(3)(1)(−5)(−9)(1452) (3)(1)(−3)(−9)(2366) (3)(1)(−3)(−5)(5202)
+ +
(6)(4 )(−2)(−6) (8)(6)(2)(−4) (12)(10)(6)(4 )
(−135)(150) (−405)(392) (135)(1452) (81)(2366) (45)(5202)
y=f ( 8 )= + + + +
(1152) (−600) (288) (−384) (2880)
−( 20250 ) (158760 ) ( 196020 ) (191646) (234090)
y=f ( 8 )= + + − +
( 1152 ) ( 600 ) ( 288 ) (384) (2880)
y=f ( 8 )=−17.578+ 264.6+680.625−499.078+81.281
y=f ( 8 )=509.85=¿ ≫ Ans …

7
Q#5 Evaluate f(0), using Newton’s Divided Difference formula.

X 4 5 7 10 11 13
F(x) 48 100 294 900 1210 2028
Solution:

Considering Newto n' s Divided Diffference Formula ,i . e ,


f ( x )=f ( x 0 ) + ( x−x 0 ) f ( x 0 , x 1 ) + ( x−x 0 ) ( x−x 1 ) f ( x 0 , x 1 , x 2 )

+ ( x−x 0 ) ( x−x 1 ) ( x−x 2 ) f ( x 0 , x 1 , x 2 , x 3 ) +…

Now , we form the Divided DifferenceTable ;

x y I DD II DD III DD IV DD V DD
x 0=4 y 0=48
100−48
=52
5−4
x 1=5 y 1=100 97−52
=15
7−4
294−100 21−15
=97 =1
7−5 10−4
x 2=7 y 2=294 202−97 1−1
=21 =0
10−5 11−4
900−294 27−21 0−0
=202 =1 =0
10−7 11−5 13−4
x 3=10 y 3=900 310−202 1−1
=27 =0
11−7 13−5
1210−900 33−27
=310 =1
11−10 13−7
x 4 =11 y 4 =1210 409−310
=33
13−10
2028−1210
=409
13−11
x 5=13 y 5=2028
So , Now , We have ;
f ( x )=48+ ( x−4 ) ( 52 )+ ( x−4 )( x−5 )( 15 ) + ( x−4 )( x−5 ) ( x−7 ) ( 1 ) +0
When f ( 0 ) ,
f ( 0 )=48+ ( 0−4 )( 52 ) + ( 0−4 )( 0−5 ) ( 15 ) + ( 0−4 )( 0−5 ) ( 0−7 )( 1 ) +0
f ( 0 )=48+ (−4 )( 52 ) + (−4 ) (−5 ) ( 15 ) + (−4 ) (−5 ) (−7 ) (1 )+ 0
f ( 0 )=48−( 4 ) ( 52 )+ ( 20 )( 15 )−(140) ( 1 )+ 0
f ( 0 )=48−208+300−140+0=¿=¿ 0 Ans …

8

Q#6 Evaluate the Approximate value of ∫ Cosx dx taking h= π /6 .
0

Using (i) Trapezoidal Rule (ii) Simpson’s 1/3 Rule.

Solution:

π 2 π 2 π .6 12 π
Given that ; ∫ Cosx dx , h= , n= = = =12
0 6 π π π
6
Here , y =cos x dx . The intervalis[ 0,2 π ]
We shall find the values of y∧they are givenby thetable below .
π π π 2π 5π 7π 4π 3π 5π 11π
x 0 π 2π
6 3 2 3 6 6 3 2 3 6
0.86
y=f ( x ) 1 0.5 0 -0.5 -0.866 -1 -0.866 -0.5 0 0.5 0.866 1
6
¿> cos( x ) y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 y 10 y 11 y 12
By Trapezoidal Rule ,

y 0 + y 12
∫ Cosx dx=h
0
[ 2
+ y1 + y 2 + y 3 + y 4 + y5 + y 6 + y 7 + y 8+ y 9+ y10 + y 11 ]

∫ Cosx dx= π6 . [ 1+ 1
2
+0.866+ 0.5+0−0.5−0.866−1−0.866−0.5+ 0+0.5+0.866 ]
0

∫ Cosx dx= π6 . [ 1+ 1
2 ]
−1 =0=¿> Ans …
0

1
By Simpso n' s Rule ,
3

∫ Cosx dx= h3 [( y 0 + y 12)+ 4( y 1 + y 3 + y 5 + y 7 + y 9 + y 11)+2( y 2 + y 4 + y 6 + y 8 + y 10 )]


0

π

6
∫ Cosx dx= 3 [ (1+ 1)+ 4(0.866+ 0−0.866−0.866+ 0+0.866)+2(0.5−0.5−1−0.5+0.5)]
0

∫ Cosx dx= π2 . [(2)+4 (0)+2(−1)]= π2 . [ 2−2 ] =0=¿> Ans …


0

You might also like