Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the data points In MATLAB a) Find a single polynomial that interpolates

ID: 665338 • Letter: C

Question

Consider the data points

In MATLAB

a) Find a single polynomial that interpolates the data points
b) Check with a plot that your polynomial does indeed interpolate the data. You
can use matlab commad polyval to evaluate a polynomial given the coecients.
c) Would this interpolating polynomial likely give a good prediction of what is
happening at x = 1.5? Why or why not?
d) Create a cubic spline function for the same data, and plot it on the same graph
as the single polynomial interpolant. Does it do a better job describing the data?

x=[1 2 3 4 5 6 7 8 9 10] y=[1.1 4.1 8.9 16.1 26 36 52 63 78 105]

Explanation / Answer

load census; f = fit(cdate, pop, 'linearinterp') plot(f,cdate,pop) load carbon12alpha f1 = fit(angle, counts, 'nearestinterp') f2 = fit(angle, counts, 'pchip') p1 = plot(f1, angle, counts) xlim( [min(angle), max(angle)]) hold on p2 = plot(f2, 'b') hold off legend([p1; p2], 'Counts per Angle','Nearest', 'pchip')