Docsity

Numerical Analysis - Solutions to Homework 10 | MATH 433, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Math 433 - Numerical Analysis - Spring 2008
Homework 10: SOLUTIONS
Assigned: Saturday, April 5, 2008.
Due: Friday, April 18, 2008.
1. (Interpolation).
We want to study the effect of different choices of interpolation points {x0, x1, . . . , xn}
on the function wn(x) = (x−x0)(x−x1). . . (x−xn) in the formula for the error
in interpolating polynomials. In particular, we want to study evenly spaced
points and Chebyshev points in the interval [−1,1]. Consider the following
choices:
(a) xi=−1 + 2i
ni= 0, . . . , n
(b) xi=−cos π
n+ 1 1
2+i i= 0, . . . , n.
In each case, plot w10(x) in the interval [-1,1]. Discuss the results.
2. Write a computer program to perform polynomial interpolation using equally
spaced points and the Chebyshev points on the interval [-1, 1] for the function
f(x). Investigate the convergence of pnto fby running the program for n=
8,16,32 in the following cases
f1(x) = |x|,and f2(x) = (−1 if x < 0,
0 if x= 0,
1 if x > 0.
Discuss the results. As ngets larger, is there pointwise convergence? Is conver-
gence uniform in x?
(in MATLAB |x|=abs(x) and the second function is sign(x), you can use the
library function ”polyfit” in MATLAB. Use ”help polyfit” to find how to use
it).
3. (Hermite Interpolation).
(a) The theorem describing the error in using Hermite interpolation is as fol-
lows.
Theorem: If f∈C2n+2[a, b], then
f(x) = H(x) + (x−x0)2. . . (x−xn)2
(2n+ 2)! f(2n+2)(ξ)
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Numerical Analysis - Solutions to Homework 10 | MATH 433 and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Math 433 - Numerical Analysis - Spring 2008 Homework 10: SOLUTIONS Assigned: Saturday, April 5, 2008. Due: Friday, April 18, 2008.

  1. (Interpolation).

We want to study the effect of different choices of interpolation points {x 0 , x 1 ,... , xn} on the function wn(x) = (x − x 0 )(x − x 1 )... (x − xn) in the formula for the error in interpolating polynomials. In particular, we want to study evenly spaced points and Chebyshev points in the interval [− 1 , 1]. Consider the following choices:

(a) xi = −1 +

2 i n

i = 0,... , n

(b) xi = − cos

[

π n + 1

  • i

)]

i = 0,... , n.

In each case, plot w 10 (x) in the interval [-1, 1]. Discuss the results.

  1. Write a computer program to perform polynomial interpolation using equally spaced points and the Chebyshev points on the interval [-1, 1] for the function f (x). Investigate the convergence of pn to f by running the program for n = 8 , 16 , 32 in the following cases

f 1 (x) = |x| , and f 2 (x) =

{ (^) − 1 if x < 0, 0 if x = 0, 1 if x > 0. Discuss the results. As n gets larger, is there pointwise convergence? Is conver- gence uniform in x?

(in MATLAB |x| = abs(x) and the second function is sign(x), you can use the library function ”polyfit” in MATLAB. Use ”help polyfit” to find how to use it).

  1. (Hermite Interpolation).

(a) The theorem describing the error in using Hermite interpolation is as fol- lows. Theorem: If f ∈ C 2 n+2[a, b], then

f (x) = H(x) +

(x − x 0 )^2... (x − xn)^2 (2n + 2)!

f (2n+2)(ξ)

for some ξ with a < ξ < b.

Now, consider f (x) = x ln x, n = 1, x 0 = 1, and x 1 = 3 (from problem # 3 on page 414). (b) Use linear interpolation and Hermite interpolation to approximate the value of f (1.5). Which estimate is more accurate? (c) Verify that the error bound for Hermite interpolation holds for the Hermite polynomial found in (3a).

  1. Find a polynomial of least degree satisfying:

p(1) = − 1 , p′(1) = 2 , p′′(1) = 0 , p(2) = 1 , p′(2) = − 2

  1. (Splines).

(a) Find the natural cubic spline S(x) satisfying S(0) = 0, S(1/2) = 1, S(1) = 0. Your answer will be 2 cubic polynomials, S 0 (x), S 1 (x). Verify that your answer satisfies all the necessary conditions (interpolation, continuity of 1st and 2nd derivatives, boundary conditions). (b) In the case of the clamped spline, the column vector of unknowns is m = (a 0 , a 1 ,... , an− 1 , an)T^. Note that the equations for a 0 and an are no longer a 0 = 0 and an = 0, so that the tridiagonal matrix B will change slightly. One can write down the matrix and right hand side for the linear system Bm = f which determines m. The matrix B is invertible, and hence the clamped cubic spline exits and is unique. (Matrix B is strictly diagonal dominant, hence, it is non-singular.) Determine the clamped cubic spline S(x) that interpolates the data f (0) = 0, f (1) = 1, f (2) = 2 and satisfies S′(0) = S′(2) = 1. Again, your answer will consist of 2 cubic polynomials, S 0 (x), S 1 (x). Verify all the necessary conditions and note that the boundary conditions for the clamped spline are different from those for the natural spline. Plot the spline over the interval [0, 2].

Problem 2

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

Interpolating polynomial using n=4 equidistant points

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=8, f(x)=abs(x)

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=

Figure 2: f 1 (x) = |x| using equispaced points

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

Interpolating polynomial using n=4 Chebyshev points

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=8, f(x)=abs(x)

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=

Figure 3: f 1 (x) = |x| using Chebyshev points

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

Interpolating polynomial using n=4 Chebyshev points

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=8, f(x)=abs(x)

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=

! 2! 1 0 1 2

! 2

! 1

0

1

2

x

f(x) and P(x)

n=

Figure 5: f 2 (x) = sgn x using Chebyshev points

For f 1 (x) using equispaced interpolation points, there is no convergence as n → ∞ (since oscillations occupy larger area as n increases) but there is uniform convergence if Chebyshev points are used. For f 2 (x), again, no convergence if equispaced points are used but there is point- wise convergence with Chebyshev points since oscillations grow as n increases but get more localized around x = 0.

O (7)

O

O

(8)

(2)

(1)

O

(10)

O

(4)

(9)

O

O

(3)

(5)

O

(6)

O

O

O

f:=xln(x);* f := x ln x eval(f,x=1.5);

p1:=3ln(3)/2(x-1);** p1 := 32 ln 3 x K 1 eval(p1,x=1.5); 0.7500000000 ln 3 evalf(%);

H:=(x-1)+(3ln(3)-2)/4(x-1)^2+(1-ln(3))/2(x-1)^2(x-3);** H := x K 1 C 14 3 ln 3 K 2 x K 1 2 C 12 1 K ln 3 x K 1 2 x K 3 eval(H,x=1.5); 0.1875000000 C 0.3750000000 ln 3 evalf(%);

0.6081976622-0.8239592168; K0. 0.6081976622-0.5994796084;

Figure 6: Maple file to evaluate function, linear interpolating and Hermite polynomi- als