Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

2 Homework Set No. 2: Problem 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

2 Homework Set No.

2
NB! If a problem is not specified to use Matlab, then you should not use Matlab.

Preparation for Matlab home works: Read chapter 3 in the notes of Gockenbach.

Problem 1

(a). The Taylor series for (1 + x)n is also known as the binomial series. It states
that
n(n − 1) 2 n(n − 1)(n − 2) 3
(1 + x)n = 1 + nx + x + x + · · · (x2 < 1)
2! 3!
Derive the series and for n√= 2, n = 3 and n = 1/2, give its particular form. Then use
the last form to compute 1.0001 correct to 15 decimal places (rounded).

(b). (continuation) Use the previous problem to obtain a series for (1 + x2 )−1 .

Problem 2

(a). Use the Lagrange interpolation process to obtain a polynomial of least degree that
assumes these values:
x 0 2 3 4
y 7 11 28 63

(b). (Continuation) For the points in the table of (a), find the Newton form of the in-
terpolating polynomial. Show that the two polynomials obtained are identical, although
their forms may differ.

(c). The polynomial p(x) = x4 − x3 + x2 − x + 1 has the values shown.


x -2 -1 0 1 2 3
p(x) 31 5 1 1 11 61
Find a polynomial q(x) that takes these values (you don’t need expand it):
x -2 -1 0 1 2 3
q(x) 31 5 1 1 11 30
(Hint: This can be done with little work.)

Problem 3

(a). Show directly that the maximum error associated with linear interpolation is
bounded by 18 (x1 − x0 )2 M , where M = maxx0 ≤x≤x1 |f 00 (x)|.

1
(b). An interpolating polynomial of degree 20 is to be used to approximate e−x on the
interval [0, 2]. How accurate will it be?

Problem 4

(a). Derive the approximation formula


1
f 0 (x) ≈ [4f (x + h) − 3f (x) − f (x + 2h)]
2h
and show that its local truncation error is of the form 31 h2 f 000 (ξ).
(Hints: Consider the polynomial that interpolates the function at the following 3 points:
x, x + h, x + 2h.)

(b). Then, use the formula to find the derivative of f (x) = tan(x) at x = 1.0 for
h = 0.1, 0.01 and 0.001. Compare the error with the error bound for this formula.

(c). Use Matlab to compute the approximation to tan(x) at x = 1.0, with this formula,
with smaller and smaller values of h. Plot the error as a function of h, use log scale
(loglog). What is the best result you manage to get? What is your comments to the
result?
What to hand in for part c): Hand in the Matlab script file, the plot of error, and
your comments.

Problem 5: Divided difference in Matlab.

Part (A): Write two functions in Matlab. The first one should read in two vectors x
and y, and return a table (a matrix) of the divided difference values. This means, the
first line of your divdiff.m file should be:

function a=divdiff(x,y)

The second function should read in the table of divided difference values, the x-vector,
and a vector t, and return the polynomial values computed at points given in the vector
t. This means, your file polyvalue.m should start with the following line:

function v=polyvalue(a,x,t)

What to hand in: Hand in the files divdiff.m and polyvalue.m.

Part (B) : Here you can test your Matlab functions in (A). Using 21 equally spaced
nodes on the interval [−5, 5], find the interpolating polynomial p of degree 20 for the
function f (x) = (x2 + 1)−1 . Plot the functions f (x) and p(x) together at 41 equally

2
spaced points, including the nodes. Plot the error e(x) = |f (x) − p(x)| also. Give your
comments.
What to hand in: Hand in your Matlab script file, and the plots of f (x) with p(x),
and the error, and your comments.

Part (C): With the same problems in (B), now using Chebyshev nodes xi = 5 cos(iπ/20),
where 0 ≤ i ≤ 20, and nodes xi = 5 cos[(2i + 1)π/42], where 0 ≤ i ≤ 20. Plot f (x) with
p(x) for both cases, and the errors. Give your comments.
What to hand in: Hand in your Matlab script file, and the plots of f (x) with p(x),
and the error, and your comments.

You might also like