Assignment 2 - 1 TR2103
Assignment 2 - 1 TR2103
Tutorial 2 _1
1 The following values of the function f(x) = sin x + cos x, are given
x 10 20 30
f(x 1.1585 1.2817 1.3660
)
Construct the quadratic Lagrange interpolating polynomial that fits the data. Hence, find f(π/12).
Compare with the exact value.
P1 ( x )=l0 ( x ) f ( x 0 )+ l 1 ( x ) f ( x1 ) +l 2 ( x ) f ( x2 )
x 2−50 x+ 600 2 2
P1 ( x )= [ 1.1585 ] + x −40 x +300 [ 1.2817 ] + x −30 x+200 [ 1.366 ]
200 −100 200
π
Hence f ( )
12
f ( 12π )= p( 12π )
π 2 π π 2 π π 2 π
π 12 ( ) ( )
−50
12
+ 600
12
−40
12
+300 ( ) ( )
( ) −30
12 12
+ 200 ( )
p
12( )
=
200
[ 1.1585 ] +
−100
[ 1.2817 ] +
200
[1.366]
Hence, interpolate at x = 5.
P1 ( x )=l0 ( x ) f ( x 0 )+ l 1 ( x ) f ( x1 ) +l 2 ( x ) f ( x2 ) +l 3 ( x ) f ( x 3 )
( x−x 1)( x −x2 )(x−x 3) ( x−x 0)(x −x2 )(x−x 3) (x−x 0)(x−x 1 )( x−x3 )
P1 ( x )= [f ( x0 ) ]+ [f ( x 1 ) ]+ [ f ( x 2 ) ]+
(x0 −x 1)( x 0−x 2)(x 0− x3 ) (x 1−x 0)( x 1−x 2)(x 1−x 3 ) ( x 2−x 0 )(x 2−x 1)(x 2−x 3)
( x−1)( x −4)( x−7) ( x− (−1 ))( x−4)( x−7) ( x−(−1 ) )( x−1)(x −7) (x−(−1 ) )( x
P1 ( x )= [−2 ] + [0 ]+ [ 63 ] +
(−1−1)(−1−4)(−1−7) (1−(−1 ) )( 1−4 )(1−7) ( 4−(−1 ))(4−1)(4−7) (7−(−1 ))(7
Hence x = 5
P1 ( x )=−0.2+67.2+38
P1 ( x )=105
3 Find the second divided difference of f(x) = 1/x, using the points a, b, c.
4 Find f(x) as a polynomial in x for the following data by Newton’s divided difference formula
x 1 3 4 5 7 10
f(x 3 31 69 13 351 1011
) 1
Hence, interpolate at x = 3.5 and x = 8.0. Also find, f ′ (3) and f ″ (1.5).
x f(x) First d.d Second d.d Third d.d Fourth d.d Fifth d.d
1 3 14 8 1 0 0
3 31 38 12 1 0
4 69 62 16 1
5 131 110 22
7 351 220
10 1011
f ( x )=3+ 14 x−14+( x ¿¿ 2−3 x−x+ 3)( 8)+(x 3−8 x 2−5 x−12)( 1)¿
f ( x )=x 3−23 x +1
f ( 3.5 )=−36.63
f ( 3.5 )=329
' 1 ∇2 f x ∇ 3 f x ∇4 f x ∇5 f x
f ( 3 )= ( ∇ f x + + + + )
h 2 3 4 5
1 22 1 0 0
f ' ( 3 )= (220+ + + + )
2 2 3 4 5
f ' ( 3 )=115.67
5 Using Newton’s backward difference interpolation, interpolate at x = 1.0 from the following data.
x 0.1 0.3 0.5 0.7 0.9 1.1
f(x -1.699 -1.073 -0.375 0.443 1.429 2.631
)
x f(x) ∇f ∇2 f ∇3 f ∇4 f ∇5 f
0.1 -1.699 0.626 0.072 0.048 0 0
0.3 -1.073 0.698 0.12 0.048 0
0.5 -0.375 0.818 0.168 0.048
0.7 0.443 0.986 0.216
0.9 1.429 1.202
1.1 2.631
∇f n ∇2 f n ∇3 f n
f ( x )=f ( x n ) + ( x−x n ) + ( x−x n ) ( x−x n−1 ) + ( x−x n )( x−x n−1) ( x−x n−2 )
h 2! h 2 3 ! h3
f ( x )=x 3 +3 x−2
Interpolate x = 1.0
f ( x )=(1.0)3+ 3(1.0)−2
f ( x )=2
6 Obtain the linear spline and quadratic spline approximation for the following data.
x 0 1 2
f(x -1 3 29
)
Linear spline
i x f(x)
0 0 -1
1 1 3
2 2 29
x 1< x< x 2
f ( x )=f ( x 1) + m1 ( x− x1 )
f ( x )=f ( 1 )+ m1 (x−1)
f ( x i )−f ( x i−1)
m i−1=
xi −xi−1
f ( x 2 )−f ( x 1)
m 1=
x2 −x1
29−3
m 1=
2−1
m1=26
f ( x )=f ( 1 )+ m1 (x−1)
f ( x )=3+ 26(x−1)
f ( x )=26 x−23
f ( 1.5 )=16
x 0 < x< x1
f ( x )=f ( x 0 ) +m 0 (x−x 0)
f ( x i )−f ( x i−1)
m i−1=
xi −xi−1
f ( x 1 )−f ( x 0)
m 1=
x1 −x0
3−(−1)
m 1=
1−0
m 1=4
f ( x )=(−1)+ 4 ( x−0)
f ( x )=4 x−1
f ( 0.5 )=1
QUADRATIC SPLINE
a 1 x 2+ b1 x +c 1 0 ≤ x <1
a 2 x 2+ b2 x +c 2 1≤ x< 2
So,
E 1=c1=−1
E 2=a1+ b1 +c 1=¿ 3
Then,
c 1 +1=a 1+ b1 +c 1−3
a 1+b 1+ 2=0
a 2+b 2+ c 2−3=4 a 2+ 2b 2+ c2 −4 9
3 a2 +b 2−26=0