[go: up one dir, main page]

0% found this document useful (0 votes)
115 views6 pages

Assignment 2 - 1 TR2103

1. Construct a quadratic Lagrange interpolation polynomial to interpolate the function f(x) = sin(x) + cos(x) at the points 10°, 20°, 30°. Interpolate to find f(π/12) and compare to the exact value. 2. Construct a Lagrange interpolation polynomial to interpolate the function at the points -1, 1, 4, 7. Interpolate to find f(5). 3. Explain how to find the second divided difference of a function f(x) = 1/x using points a, b, c. [DOCUMENT]

Uploaded by

farah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views6 pages

Assignment 2 - 1 TR2103

1. Construct a quadratic Lagrange interpolation polynomial to interpolate the function f(x) = sin(x) + cos(x) at the points 10°, 20°, 30°. Interpolate to find f(π/12) and compare to the exact value. 2. Construct a Lagrange interpolation polynomial to interpolate the function at the points -1, 1, 4, 7. Interpolate to find f(5). 3. Explain how to find the second divided difference of a function f(x) = 1/x using points a, b, c. [DOCUMENT]

Uploaded by

farah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

TR2013 Introduction to Numerical Methods

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−x 1)( x−x 2) ( x−x 0 )( x−x 2) ( x−x 0 )( x −x1 )


P1 ( x )= [f ( x 0 ) ]+ [ f ( x 1 ) ]+ [f ( x 2 ) ]
(x0 −x 1)( x 0−x 2) ( x 1−x 0 )( x1− x2 ) ( x 2−x 0 )( x 2−x 1 )

( x−20)(x−30) ( x−10 ) ( x−30 ) ( x −10 )( x−20 )


P1 ( x )= [1.1585]+ [1.2817]+ [1.3660 ]
(10−20)(10−30) ( 20−10 ) ( 20−30 ) ( 30−10 )( 30−20 )

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]

p ( 12π )=3.400+ (−3.712 )+1.3128


p ( 12π )=1.0008
2 Construct the Lagrange interpolation polynomial for the data
x -1 1 4 7
f(x -2 0 63 342
)

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

x 3−12 x 2+39 x−28 x 3−7 x 2−x+ 7 x3 −4 x 2−x−4


P1 ( x )= [−2 ] + [ 63 ] + [ 342 ]
−80 −45 144

Hence x = 5

53 −12 ( 5 )2 +39(5)−28 53 −7(5)2−5+7 53 −4 (5)2−5−4


P1 ( x )= [ −2 ] + [ 63 ] + [ 342 ]
−80 −45 144

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.

x f(x) First d.d Second d.d


a 1 f (a , b) f (a , b , c)
a
b 1 f (b , c)
b
c 1
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 )=f ( x 0 ) + ( x−x 0 ) f [ x 0 , x 1 ]+ ( x−x 0 )( x−x1 ) f [ x 0 , x1 , x2 ] + ( x−x 0 ) ( x−x 1 ) ( x−x 2 ) f [ x0 , x 1 , x 2 , x 3 ]+ ( x−x 0 )( x −x1


f ( x )=3+ ( x−1 ) (14)+ ( x−1 ) ( x −3 ) (8)+ ( x−1 ) ( x −3 )( x−4 ) (1)+ ( x−1 ) ( x−3 ) ( x−4 ) ( x−5 ) (0)+ ( x−1 )( x−3 )( x−

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

Interpolate x = 3.5 and x = 8.0

f ( 3.5 )=x 3−23 x+1

f ( 3.5 )=(3.5)3−23 (3.5)+1

f ( 3.5 )=−36.63

f ( 8.0 )=( 8.0)3 −23(8.0)+1

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

1.202 0.216 0.048


f ( x )=2.631+ ( x−1.1 ) + ( x−1.1 ) ( x−0.9 ) + ( x −1.1 )( x−0.9 )( x−0.7 )
0.2 2 !(0.2)2
3 !(0.2)3
f ( x )=2.631+ ( x−1.1 ) ( 6.01 ) + ( x 2−2 x+ 0.99 ) (2.7 ) +(x 3−2.7 x 2 +2.39 x−0.693)

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
)

Hence, interpolate at x = 0.5 and x = 1.5.

Linear spline

i x f(x)
0 0 -1
1 1 3
2 2 29

x 1< x< x 2

f ( x )=f ( x n−1) + m n−1 ( x− xn−1 )

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 )=26 ( 1.5 )−23

f ( 1.5 )=16

x 0 < x< x1

f ( x )=f ( x n−1) + mn−1 ( x− xn−1 )

f ( x )=f ( x 0 ) +m 0 (x−x 0)

f ( x )=f ( 0 ) +m1 (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 )=f ( 0 ) +m1 (x−0)

f ( x )=(−1)+ 4 ( x−0)

f ( x )=4 x−1

f ( 0.5 )=4 ( 0.5 )−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

E 1=a1 (0)2+ b1 ( 0 )+ c 1=−1


E 2=a1 (1)2 +b 1 ( 1 ) +c 1=3

E 3=a2 (1)2+b 2 ( 1 ) +c 2=3

E 4=a2 (2)2 +b 2 ( 2 ) +c 2=29

So,

E 1=c1=−1

E 2=a1+ b1 +c 1=¿ 3

E 3=a2 +b2 +c 2=3

E 4=4 a 2+2 b2 x+ c 2=29

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

You might also like