Spring 2023, CMPSC/MATH 455 Homework Assignment #4
The homework is due April 3rd. All questions carry equal weight. Please submit the code (.m
files) for problems 1 and 2 on Canvas.
1
Joe had decided to buy stocks of a particularly promising Internet company. The price per share
was $100, and Joe subsequently recorded the stock price at the end of each week. With the abscissae
measured in days, the following data were acquired: (0, 100), (7, 98), (14, 101), (21, 50), (28, 51),
(35, 50). In attempting to analyze what happened, it was desired to approximately evaluate the
stock price a few days before the crash.
(a) Pass a linear interpolant through the points with abscissae 7 and 14. Then add to this data set
the value at 0 and (separately) the value at 21 to obtain two quadratic interpolants. Evaluate
all three interpolants at x = 12. Which one do you think is the most accurate? Explain.
(b) Plot the two quadratic interpolants above, together with the data (without a broken line
passing through the data) over the interval [0, 21]. What are your observations?
2
The gamma function is defined by Γ(x) =
∫∞
0 t
x?1xtdt, x > 0. It is known that for integer numbers
the function has the value Γ(n) = (n?1)! = 1 ·2 ·3 · · ·(n?1). (We define 0! = 1.) Thus, for example,
(1, 1), (2, 1), (3, 2), (4, 6), (5, 24) can be used as data points for an interpolating polynomial.
(a) Write a MATLAB script that computes the polynomial interpolant of degree four that passes
through the above five data points.
(b) Write a program that computes a cubic spline to interpolate the same data. (You may use
MATLAB’s spline.)
(c) Plot the two interpolants you found on the same graph, along with a plot of the gamma
function itself, which can be produced using the MATLAB command gamma.
(d) Plot the errors in the two interpolants on the same graph. What are your observations?
3
Given the four data points (?1, 1), (0, 1), (1, 2), (2, 0), determine the interpolating cubic polynomial
? using the monomial basis;
? using the Lagrange basis;
? using the Newton basis.
Show that the three representations give the same polynomial.
4
A secret formula for eternal youth, f(x), was discovered by Dr. Quick, who has been working in
our biotech company. However, Dr. Quick has disappeared and is rumored to be negotiating with
a rival organization. From the notes that Dr. Quick left behind in his hasty exit it is clear that
f(0) = 0, f(1) = 2, and that f [x0, x1, x2] = 1 for any three points x0, x1, x2. Find f(x).
1
5How does Hermite interpolation differ from ordinary interpolation? How does a cubic spline inter-
polant differ from a Hermite cubic interpolant?
WX:codehelp mailto: [email protected]
标签:cubic,455,same,two,interpolants,points,matlab,data,MATH From: https://www.cnblogs.com/hopepython/p/17278231.html