Math 340 – Homework 4 – Due March 23, 2021Homework submissions will consist of a write-up (with solutions to the hand-written problems and the results to the coding questions) and MATLAB code(for coding problems). Solutions and figures not included in the write-up willNOT be graded. Further, solutions with inadequate explanations will be penal-ized. You should have one main script file called “HW4YourName.m” and therequested function files.
1.Consider the set of points:(−3,4),(−2,6),(−1,7),(0,4),(1,2),(2,0),(3,−1),(4,2).
(a) Write a function for Interpolating Polynomials using Newton’s Divided-Difference For-mula. Have as inputs two vectors,xandy, that give the points (xi, yi), and a vector ofpointswwhere to evaluate the polynomial. OutputQ(w). Include the function file as aseparate file.
(b) Apply your function from part (a) to the set of data points. Give the interpolatingpolynomial in your write-up. Evaluate the function on the interval [−5,5] with step size0.1 between points. Plot the result.
(c) Compare your results from parts (b) and HW 3 problem 3. Should these be the same ordifferent polynomials?
(d) Write a function for Hermite Interpolating Polynomials. Have as inputs two vectors,xandy, that give the points (xi, yi), and a vector of pointswwhere to evaluate the polynomial.OutputP(w).
Include the function file as a separate file.(e) Apply your function from part (d) to the set of data points. Assume thatfhas thefollowing derivatives:f′(−3) = 1, f′(−2) =−1, f′(−1) = 2, f′(0) =−3,f′(1) = 2, f′(2) =−3, f′(3) = 0, f′(4) = 1Evaluate the function on the interval [−3,4] with step size 0.01 between points. Plot theresult.(f) Suppose that|f(16)(x)| ≤Kfor allx∈[−3,4]. Find an error bound for the Hermiteinterpolating polynomial atx= 3.5 in terms ofK.1
2.Consider the set of points:(2,0),(3,−1),(5,3).(a) Write a function for Natural Cubic Spline Interpolating Polynomials with only 3 points.Have as inputs two vectors,xandy, that give the 3 points (xi, yi). Output the polynomialcoefficients for the two splinesS0(x) andS1(x).Note: you do not need to implement thefull algorithm in the book. Instead you can create a system of 8 equations with 8 unknownsand solve the linear system(Ax=b)using the commandx=A/bto get your coefficients.
(b) Apply your function from
(a) to the set of points. Give the cubic splines,S0(x) andS1(x),in your write-up.
(c) Plot your splines found in (b) over the interval [2,5] with step size 0.01 between points.Include the set of data points on the plot as well.3.Letf(x) = lnx, and letx0= 1. Forn= 1,2, . . . ,20, leth= 10−n. For eachn, estimatef′(x0) using
•forward differences,
•backward differences,
•centered differences (i.e., 3-point midpoint formula).Generate a table with your results in MATLAB (using the “table” command) with columns:n,h, forward difference, backward difference, centered difference. Describe the changes inaccuracy asnincreases.
4.The forward-difference formula for the first derivative is given byf′(x0) =1h[f(x0+h)−f(x0)]−h2f′′(x0)−h26f′′′(x0) +O(h3).
(a) Use Richardson’s Extrapolation to derive anO(h3) formula forf′(x0). Be sure theformula is in terms offevaluated at several points.
(b) Apply the formula withh= 0.4 to find an approximation tof′(0) wheref(x) =x+e