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: 665250 • 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?

Explanation / Answer

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]
p = polyval(y,x,[],mu)
[p,delta] = polyval(y,x,S,mu)
f = polyval(p,x);
T = table(x,y,f,y-f,'VariableNames',{'X','Y','Fit','FitError'})
figure
plot(x,y,'o')
// cubic spine
xx = 0:1.5:10;
yy = spline(x,y,xx);
plot(x,y,'o',xx,yy)