Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Problem 1:

x 1=1 ; x 2=2 ; x 3=3 ; x 4 =4

y 1=f (x 1)=f (1)=


e−1 e 2−4 e3−19
; y 2=f (x 2)=f ( 2)= ; y 3=f (x 3)=f (3)= ;
2 2 2
e 4 −52
y 4 =f ( x 4)=f (4)=
2
The Lagrange interpolating polynomial is given by:
( x−x 2)( x −x3 )(x−x 4 ) (x −x1 )(x−x 3)(x−x 4 ) ( x−x 1)( x−x 2 )(x−x 4 ) ( x−x 1 )(x−
p3 ( x)= y1 + y 2+ y3 +
(x 1−x 2)( x 1−x 3)(x 1−x 4 ) ( x 2−x 1)( x 2−x 3 )( x 2−x 4 ) ( x3 −x1 )( x 3−x 2)(x 3−x 4 ) ( x 4 −x1 )( x 4−

Plugging in the values for x and y, we get:

p3 ( x)=0.649 x3 −4.8888 x 2+10.9574 x −5.8586

So f (3.5)= p3 (3.5)=0.430375

Problem 2:
a) We want to obtain the Lagrange linear interpolation in the following intervals:
[-3;-1] ; [-1;0] ; [0;3] ; [3;5]
For each interval, we can use the following formula to obtain the piecewise
polynomial:
( x −x) y 0+( x−x 0 ) y 1
p1 ( x)= 1
( x 1−x 0)
Therefore,
On [-3;-1], p1 ( x )=−2.5 x −5.5
On [-1;0], p1 ( x )=4 x +1
5
On [0;3], p1 ( x )= x+1
3
−3
On [3;5], p1 ( x )= x+10.5
2

b) Let us construct the divided differences table:


i xi yi 1st order 2nd order 3rd order 4th order
0 -3 2 -- -- -- --
1 -1 -3 -2.5 -- -- --
2 0 1 4 2.16667 -- --
3 3 6 1.66667 -0.58333 -0.45833 --
4 5 3 -1.5 -0.63333 -0.00833 0.05625

p4 ( x)= y 0 +( x−x 0)[ x 0 , x 1 ]+( x −x0 )(x−x 1)[ x 0 , x 1 , x 2 ]+( x−x 0)(x−x 1)(x −x2 )[ x0 , x 1 , x 2 , x 3 ]+( x−x 0 )(

Plugging in the values from the table above and simplifying, we obtain the following:
p4 ( x )=0.05625 x 4 −0.40208 x 3−0.17292 x 2+ 4.28542 x+1
6 y 1− y 0
c) 2 M 0+ M 1=
h1( h1
−0
)
6 y n− y n−1
M n−1+ 2 M n=
hn (
0−
hn )
hi h +h h y − y y − y i−1
6 ( 3 i
)
M i−1+ i i +1 M + i+1 M i+1 = i +1 i − i
6 h i+1 hi
For i =1, 2 M 0+ 6 M 1 + M 2=39
For i =2, M 1+ 8 M 2 +3 M 3=−14
For i = 3, 3 M 2+10 M 3 +2 M 4=−19

Solving those equations, we obtain the following:


S1 ( x ) =1.5319 x 3−4.3137 x2 +2.0000
S2 ( x ) =−2.0049 x3 + 4.8775 x 2 +1.1275 x−3 .0000
S3 ( x ) =0.0234 x 3−1.1373+ 4.8676 x +1 .0000
S4 ( x )=0.04191 x 3−0.9265 x 2−1.3235 x +6 .0000
d) Let us construct the table containing all needed elements for the least squares method
x y x2 xy
-3 2 9 -6
-1 -3 1 3
0 1 0 0
3 6 9 18
5 3 25 15

^y =a0 +a1 x

n ∑ xy −∑ x ∑ y
a 1= 2
=0.5588
n ∑ x 2− ( ∑ x )

∑ x2 ∑ y−∑ x ∑ x y
a 0= 2
=1.353
n ∑ x 2−( ∑ x )

Therefore, the linear interpolation of the given data points, using the least squares
method, is given by ^y =1. 353+0. 5588 x.

You might also like