$29
1. The polynomial p(x) = x4 x3 + x2 x + 1 has the values shown below.
x
-2
-1
0
1
2
3
p(x)
31
5
1
1
11
61
Using as little work as possible to nd a polynomial q which has values
x
-2
-1
0
1
2
3
q(x)
31
5
1
1
11
30
2. Prove that a polynomial interpolantion of degree at most n through the (n + 1) points
f(x0; y0); (x1; y1); : : : ; (xn; yn)g must be unique. (Hint: Assume that there are two such polynomials,
P and Q, and argue that they must be identical, that is R(x) = P (x) Q(x) must be zero.)
3. (a) Verify that the polynomials
p(x) = 5x3 27x2 + 45x 21; q(x) = x4 5x3 + 8x2 5x + 3
both interpolate the points in the below table.
x
1
2
3
4
y
2
1
6
47
You showed that interpolation polynomials are unique. Does this problem contradict that? Why? (b) Verify that the polynomials
p(x) = 3 + 2(x 1) + 4(x 1)(x + 2);
q(x) = 3
(x + 2)x
3
(x 1)x
7
(x 1)(x + 2)
3
6
2
both interpolate the points in the below table.
x
1
-2
0
y
3
-3
-7
You showed that interpolation polynomials are unique. Does this problem contradict that? Why?
4. Prove the recursion formula for computing Newton divided di erences.
f[x0; x1; : : : ; xk] =
f[x1; x2; : : : ; xk]
f[x0; x1; : : : ; xk 1]
xk
x0
To do this, let P be the interpolating polynomial for f(x0; y0); (x1; y1); : : : ; (xk 1; yk 1)g and Q the
interpolating polynomial for f(x1; y1); (x2; y2); : : : ; (xk; yk)g and consider the polynomial
R(x) =
xk
x
P (x) +
x x0
Q(x):
xk
x0
xk x0
(a) Prove R is the unique polynomial of at most degree k which interpolates points f(x0; y0); (x1; y1); : : : ; (xk; yk)g.
(b) Determine the coe cient of xk on each side of the equation.
1
5. Consider y = sin x on [0; 2 ] with ve equally spaced interpolation points. Find the interpolation polynomial by hand via the following method
(a) Vandermonde matrix.
(b) Newton’s form using direct computing of the coe cients.
(c) Newton’s form via Newton divided di erence (attach your Newton divided di erence matrix.)
(d) Lagrange interpolation.
6. Write a Matlab function p = NewtonInt(x,y) for polynomial interpolation using Newton form and direct computing of the coe cients. The input for this function should be an array x with (n + 1) distinct points x0; x1; x2; : : : ; xn and also an array of function values y, with (n + 1) function values y0; y1; y2; : : : ; yn. Your function should return to a vector which contains the coe cients (in descend order) of your interpolation polynomial p such that p(xi) = f(xi) for i = 0; 1; : : : ; n.
7. Write a Matlab function p = NewtonDiv(x,y) for polynomial interpolation using Newton form and Newton divided di erence. The input for this function should be an array x with (n+1) distinct points x0; x1; x2; : : : ; xn and also an array of function values y, with (n + 1) function values y0; y1; y2; : : : ; yn. Your function should return to a vector which contains the coe cients (in descend order) of your interpolation polynomial p such that p(xi) = f(xi) for i = 0; 1; : : : ; n.
8. Write a Matlab function p = LagrangeInt(x,y) for polynomial interpolation using Lagrange form. The input for this function should be an array x with (n + 1) distinct points x0; x1; x2; : : : ; xn and also an array of function values y, with (n + 1) function values y0; y1; y2; : : : ; yn. Your function should return to a vector which contains the coe cients (in descend order) of your interpolation polynomial p such that p(xi) = f(xi) for i = 0; 1; : : : ; n.
9. Compare the e ciency of NewtonInt(x,y), NewtonDiv(x,y) and LagrangeInt(x,y). Try with large amount of sample points until you see a signi cant di erence.
10. To see the accuracy of an interpolation polynomial p(x), we evaluate the interpolation polynomial on evaluation points. To avoid machine error, instead of direct computing, we apply the Horner’s method. Check
https://en.wikipedia.org/wiki/Horner%27s_method
Let (xi; yi), q i m be the points to be evaluated, De ne ~x := (x1; x2; :::; xm)T and ~y := (y1; y2; :::; ym)T . The residual are then de ned by the average error
residual =
kp(~x) ~yk
; where m is the number of evaluation points:
m
In real life application, you may use di erent vector norms depending on the problem. Three popular vector norms are
n
Xi
L1 norm: k~xk1 :=
jxij
=1
n
Xi
L2 norm: k~xk2 :=
jxij2
=1
L
~x
:=
1
max
j
x
ij
1 norm: k k1
i
n+1
(a) Read and understand the Horner’s method
2
(b) Write a Matlab script residual = eval(p,x,y,k) which evaluates the polynomial p at sample points x using Horner’s method with one of the norm above. Here p is a vector containing all the coe cients of the interpolation polynomial, x is a vector containing the evaluation points, y is the true value at sample points and k = 0; 1; 2 indicates which norm your are going to use (0 for L1, 1 for L1 and 2 for L2).
11. For each function below, do
(a) f(x) = sin(x); 0 x 2
(b) g(x) = cos(x); 0 x 2
(c) h(x) = ln(x); 0:5 x 2
(d) i(x) = ex; 0 x 2
(a) Apply your code to nd the coe cients of Newton’s interpolation polynomial and Lagrange’s interpolation polynomial. Use 201 equally spaced sample points of the give interval.
(b) Matlab has a built in polynomial tting function \poly t". Use this command to t your sample points using an appropriate degree n.
(c) Evaluate your result in (a) and (b) by computing the evaluation error residual = eval(p,x,y,k) with 1001 equally spaced evaluation points of the given interval. Use the three di erent norms and list your result for each method.
(d) Based on what you see in (c), discuss which vector norm is better.
(e) Read the help le of \poly t", discuss when to use \poly t" and when to use interpolation polynomial. Think about real life applications.
1
12. Consider the Runge function f(x) = 1 + 25x2 on [ 1; 1]. Graph the following all on the same plot.
Label your graph and include a legend.
(a) Graph y = f(x) on [ 1; 1] using 100 uniformly distributed data points.
(b) Find the degree 10 polynomial interpolant of function f through 11 equally spaced nodes in [ 1; 1]. Graph it using the same data points as in (a).
(c) Repeat (b) with 11 non-equally spaced Chebyshev points xj = cos
j
; j = 0; 1; : : : ; 10. Graph
10
your polynomial using the same data points as in (a).
(d) (Challenge) Research on Chebyshev points and explain why it will solve the Runge phenomenon.
3