Docsity

Homework on Polynomial and Lagrange Interpolation, Assignments of Computer Science

Toggle sidebar
bg1
Homework 7
Due on Thursday, April 3
1 (Problems 3 & 4 on page 166)
a. Find the polynomial of degree 2that interpolates at the datapoints x0= 0, y0= 1, x1= 1, y1= 2, and
x2= 4, y2= 2. You should get p2(t) = −1
4t2+5
4t+ 1.
b. Construct the quadratic polynomial that interpolates y=√xat the nodes x0=1
4, x1=9
16 , and x2= 1.
2 (Problems 6 & 7 on page 166)
a. Find the polynomial of degree 3that interpolates y=x3at the nodes x0= 0.x1= 1, x2= 2, and x3= 3. (This is
an easy problem ...)
b. For each function listed below, construct the Lagrange interpolating polynomial for the set of nodes specified. Plot
both the function and the interpolating polynomial, and also the error, on the interval defined by the nodes.
1. f(x) = √x, xi= 0,1,4;
2. f(x) = log2x, xi= 1,2,4.
3 (Problem 3 on page 172)
In 1973, the horse Secretariat became the first (and, so far, only) winder of the Kentucky Derby to finish the race in
less than two minutes, running the 11
4mile distance in 1 : 59.4seconds. Remarkably, he ran each quarter mile faster
than the previous one, as the following table of data shows. Here tis the elapsed time (in seconds) since the race began
and xis the distance (in miles) that Secretariat has travelled.
x0.0 0.25 0.50 0.75 1.00 1.250
t0.0 25.0 49.4 73.0 96.4 119.4
For this problem, you should write a simple MATLAB code for answering the following problems (You do not need
to turn in the code).
1. Find the cubic polynomial that interpolates this data at x= 0,1
2,3
4,5
4. Plot the polynomial over the domain
[0,1.5]. (You have to hand in the plot and you are not required to write out the polynomial.)1
2. Use this polynomial to estimate Secretariat’s speed at the finish of the race, by finding p0
3(5
4). (The derivative
does not have to be exact. A numerical approximation is sufficient, i.e., compute the derivative using the formula
f0(x)≈f(x+h)−f(x)
h
for small h.)
1Plot with 1501 points. Suppose p(X)is the MATLAB function for the polynomial. The three-line MATLAB commands are X=0:0.001 :
1.5;,Y=p(X), and plot(X, Y, 0
−r0);.
1
pf2

Partial preview of the text

Download Homework on Polynomial and Lagrange Interpolation and more Assignments Computer Science in PDF only on Docsity!

Homework 7

Due on Thursday, April 3

1 (Problems 3 & 4 on page 166)

a. Find the polynomial of degree 2 that interpolates at the datapoints x 0 = 0, y 0 = 1, x 1 = 1, y 1 = 2, and x 2 = 4, y 2 = 2. You should get p 2 (t) = − 14 t^2 + 54 t + 1.

b. Construct the quadratic polynomial that interpolates y =

x at the nodes x 0 = 14 , x 1 = 169 , and x 2 = 1.

2 (Problems 6 & 7 on page 166)

a. Find the polynomial of degree 3 that interpolates y = x^3 at the nodes x 0 = 0.x 1 = 1, x 2 = 2, and x 3 = 3. (This is an easy problem ...)

b. For each function listed below, construct the Lagrange interpolating polynomial for the set of nodes specified. Plot both the function and the interpolating polynomial, and also the error, on the interval defined by the nodes.

  1. f (x) =

x, xi = 0, 1 , 4 ;

  1. f (x) = log 2 x, xi = 1, 2 , 4.

3 (Problem 3 on page 172)

In 1973 , the horse Secretariat became the first (and, so far, only) winder of the Kentucky Derby to finish the race in less than two minutes, running the 1 14 mile distance in 1 : 59. 4 seconds. Remarkably, he ran each quarter mile faster than the previous one, as the following table of data shows. Here t is the elapsed time (in seconds) since the race began and x is the distance (in miles) that Secretariat has travelled.

x 0. 0 0. 25 0. 50 0. 75 1. 00 1. 250 t 0. 0 25. 0 49. 4 73. 0 96. 4 119. 4

For this problem, you should write a simple MATLAB code for answering the following problems (You do not need to turn in the code).

  1. Find the cubic polynomial that interpolates this data at x = 0, 12 , 34 , 54. Plot the polynomial over the domain [0, 1 .5]. (You have to hand in the plot and you are not required to write out the polynomial.)^1
  2. Use this polynomial to estimate Secretariat’s speed at the finish of the race, by finding p′ 3 ( 54 ). (The derivative does not have to be exact. A numerical approximation is sufficient, i.e., compute the derivative using the formula

f ′(x) ≈ f (x + h) − f (x) h for small h.) (^1) Plot with 1501 points. Suppose p(X) is the MATLAB function for the polynomial. The three-line MATLAB commands are X = 0 : 0.001 : 1 .5;, Y = p(X), and plot(X, Y, ′^ − r′);.

  1. Find the quintic polynomial that interpolates the entire dataset. Plot the polynomial over the domain [0, 1 .5]. (You have to hand in the plot and you are not required to write out the polynomial.)
  2. Use the quintic polynomial to estimate Secretariat’s speed at the finish of the race, by finding p′ 5 ( 54 ). (The derivative does not have to be exact. A numerical approximation is sufficient.)

4 (Problem 7 on page 173)

Let f (x) = ex. Define pn(x) to be the Newton interpolating polynomial for f (x) using n + 1 equally spaced nodes on the interval [− 1 , 1]. Thus we are taking higher and higher degree polynomial approximations to the exponential function. Write a MATLAB program that computes pn(x) for n = 2, 4 , 8 , 16 , 32 , and which samples the error f (x) − pn(x) at 501 equally spaced points on [− 1 , 1]. Record the maximum error as found by the sampling as a function of n, that is define En as En = max 0 ≤k≤ 500

|f (tk) − pn(tk)|

where tk = −1 + 5002 k , and plot En versus n.

5 (Problem 4 on page 180)

Show that the error in third degree polynomial interpolation satisfies

||f − p 3 ||∞ ≤

h^4 ||f (4)||∞

if the nodes x 0 , x 1 , x 2 , x 3 are equally spaced, with xi − xi− 1 = h. Hint: Use the change of variable t = x − x 1 − 12 h.