Sie sind auf Seite 1von 4

CZ2105 Numerical Methods I, Tutorial 2

Department of Computational Science


National University of Singapore
TA: Dr. Zhao Yibao
1. For the given function f (x), let x0 = 0, x1 = 0.6, and x2 = 0.9. Construct the Lagrange
interpolation polynomial of degree (i) at most 1 and (ii) at most 2 to approximate f (0.45),
and find the actual error:

f (x) = 1 + x.
Answer:
Given
f (x) =

1.9.

1 + x, we have y0 = f (x0 ) = 1, y1 = f (x1 ) =

1.6 and y2 = f (x2 ) =

(a) The Lagrange interpolation polynomial of degree at most 1 is constructed as follows:


x1 x
y0 +
x1 x0
L1 (x) =
x2 x

y1 +
x2 x1

x x0
y1 , for x [x0 , x1 ],
x1 x0
x x1
y2 , for x [x1 , x2 ],
x2 x1

where x0 = 0, x1 = 0.6, x2 = 0.9, y0 = 1, y1 = 1.6 and y2 = 1.9.


f (0.45)
1.2042 is approximated through the linear Lagrange polynomial L1 (0.45) =
1
3
+ 4 1.6 1.1987, the absolute error is approximately |1.1987 1.2042| = 0.0055.
4

(b) The Lagrange interpolation polynomial of degree at most 2 is constructed as follows:


L2 (x) = l0 (x)y0 + l1 (x)y1 + l2 (x)y2 ,

x [x0 , x2 ],

where
(x x1 )(x x2 )
,
(x0 x1 )(x0 x2 )
(x x0 )(x x2 )
,
l1 (x) =
(x1 x0 )(x1 x2 )
(x x0 )(x x1 )
.
l2 (x) =
(x2 x0 )(x2 x1 )

l0 (x) =

L2 (0.45) 1.2034, the absolute error is approximately |1.2034 1.2042| = 0.0008.

2. Use Nevilles method to approximate 3 with the function f (x) = x and the values
x0 = 0, x1 = 1, x2 = 2, x3 = 4, and x4 = 5.
Answer:
To approximate

3 using Nevilles method, we have


P0 = f (x0 ) = 0,
P1 = f (x1 ) = 1,
1


P2 = f (x2 ) = 2,
P3 = f (x3 ) = 2,

P4 = f (x4 ) = 5;
3 x0
3 x1
P0,1 =
P1 +
P0 = 3,
x1 x0
x0 x1
3 x2
3 x1
P2 +
P1 1.828,
P1,2 =
x2 x1
x1 x2
3 x2
3 x3
P2,3 =
P3 +
P2 1.707,
x3 x2
x2 x3
3 x3
3 x4
P3,4 =
P4 +
P3 1.764;
x4 x3
x3 x4
3 x0
3 x2
P0,1,2 =
P1,2 +
P0,1 1.242,
x2 x0
x0 x2
3 x3
3 x1
P2,3 +
P1,2 1.747,
P1,2,3 =
x3 x1
x1 x3
3 x2
3 x4
P2,3,4 =
P3,4 +
P2,3 1.726;
x4 x2
x2 x4
3 x3
3 x0
P1,2,3 +
P0,1,2 1.621,
P0,1,2,3 =
x3 x0
x0 x3
3 x1
3 x4
P1,2,3,4 =
P2,3,4 +
P1,2,3 1.737;
x4 x1
x1 x4
x x4
x x0
P1,2,3,4 +
P0,1,2,3 1.691.
P0,1,2,3,4 =
x4 x0
x0 x4
We summarize the
x0 = 0 P0 = 0
x1 = 1 P1 =
1
x2 = 2 P2 = 2
x3 = 4 P3 =
2
x4 = 5 P4 = 5

above calculation results into the following table


P0,1
P1,2
P2,3
P3,4

=3
1.828 P0,1,2 1.242
1.707 P1,2,3 1.747 P0,1,2,3 1.621
1.764 P2,3,4 1.726 P1,2,3,4 1.737 P0,1,2,3,4 1.691

3. Let L3 (x) be the interpolation polynomial for the data (0, 0), (0.5, y), (1, 3) and (2, 2).
Find y if the coefficient of x3 in L3 (x) is 6.
Answer:
Assume that

L3 (x) = 6x3 + c2 x2 + c1 x + c0 .

Data (0, 0), (1, 3) and (2, 2) lead to the following equations:
c0 = 0,
c + c1 + c2 + 6 = 3,
c0 + 2c
0
1 + 4c2 + 48 = 2.

Solution of the above equation system is


c0 = 0,
c = 17,
c1 = 20.
2

So,
L3 (x) = 6x3 20x2 + 17x.
Therefore, y = L3 (0.5) = 4.25.
4. Use Newtons forward-difference formula to construct interpolation polynomials of degrees
1, 2 and 3 for the following data. Approximate the specified value using each of the
polynomials.
f (0.25) if f (0.1) = 0.6205, f (0.2) = 0.2839, f (0.3) = 0.0066, f (0.4) = 0.2484.
Answer:
Denote x0 = 0.1, x1 = 0.2, x2 = 0.3 and x3 = 0.4. From the following formulas,
f [x0 ] = f (x0 ),
f [x1 ] = f (x1 ),
f [x2 ] = f (x2 ),
f [x3 ] = f (x3 );
f [x1 ] f [x0 ]
f [x0 , x1 ] =
,
x1 x0
f [x2 ] f [x1 ]
,
f [x1 , x2 ] =
x2 x1
f [x3 ] f [x2 ]
;
f [x2 , x3 ] =
x3 x2
f [x1 , x2 ] f [x0 , x1 ]
f [x0 , x1 , x2 ] =
,
x2 x0
f [x2 , x3 ] f [x1 , x2 ]
,
f [x1 , x2 , x3 ] =
x3 x1
f [x1 , x2 , x3 ] f [x0 , x1 , x2 ]
f [x0 , x1 , x2 , x3 ] =
.
x3 x0
we obtain
x0
x1
x2
x3

= 0.1
= 0.2
= 0.3
= 0.4

f (x0 ) = 0.6205
f (x1 ) = 0.2839
f (x2 ) = 0.0066
f (x3 ) = 0.2484

f [x0 , x1 ] = 3.366
f [x1 , x2 ] = 2.905
f [x2 , x3 ] = 2.418

f [x0 , x1 , x2 ] = 2.305
f [x1 , x2 , x3 ] = 2.435

f [x0 , x1 , x2 , x3 ] 0.4333

Using points (x1 , f (x1 )) and (x2 , f (x2 )), we can construct the interpolation polynomial of
degree 1 as
N1 (x) = f [x1 ] + f [x1 , x2 ](x x1 ).
Using points (x0 , f (x0 )), (x1 , f (x1 )) and (x2 , f (x2 )), we construct the interpolation polynomial of degree 2 as
N2 (x) = f [x0 ] + f [x0 , x1 ](x x0 ) + f [x0 , x1 , x2 ](x x0 )(x x1 ).
(Note: we can also use points (x1 , f (x1 )), (x2 , f (x2 )) and (x3 , f (x3 )) to construct the
interpolation polynomial of degree 2.)

The interpolation polynomial of degree 3 is as follows:


N3 (x) = f [x0 ] + f [x0 , x1 ](x x0 ) + f [x0 , x1 , x2 ](x x0 )(x x1 )
+f [x0 , x1 , x2 , x3 ](x x0 )(x x1 )(x x2 ).
So, substituting x = 0.25 in N1 (x), N2 (x) and N3 (x), respectively, we obtain
N1 (0.25) 0.1387,
N2 (0.25) 0.1329,
N3 (0.25) 0.1327.
5. A fourth-degree polynomial P (x) satisfies 44 P (0) = 24, 43 P (0) = 6, and 42 P (0) = 0,
where 4P (x) = P (x + 1) P (x). Compute 42 P (10).
Answer:
If P (x) is a fourth-degree polynomial, it can be easily proved that 4P (x) is a third-degree
polynomial. Furthermore, we can prove that 42 P (x) is a second-degree polynomial.
Denote Q(x) = 42 P (x) = c2 x2 + c1 x + c0 , we have

43 P (x) = 42 P (x + 1) 42 P (x) = 2c2 x + c2 + c1 ,


44 P (x) = 43 P (x + 1) 43 P (x) = 2c2 .
From 44 P (0) = 24, 43 P (0) = 6, and 42 P (0) = 0,, we obtain
c0 = 0,
c2 + c1 = 6,
2c2 = 24.
Therefore, we have c0 = 0, c1 = 6, c2 = 12 and 42 P (10) = Q(10) = 1140.
(Remark: If you find any problem with the sample answer, please bring to my
notice. Thank you.)

Das könnte Ihnen auch gefallen