In: Computer Science
X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Y = [-1.5, 16, 44, 90, 141, 207, 292, 398.4, 522, 670]
%Matalb Code for given question
X=[1,2,3,4,5,6,7,8,9,10]
Y=[-1.5,16,44,90,141,207,292,398.4,522,670]
syms x
p=polyfit(X,Y,1) % This fit data X,Y eith 1st order polynomial
y1=p(1)+p(2)*x %This is linear function y1=f(x)
p2=polyfit(X,Y,2) % This fit data X,Y eith 2nd order polynomial
y2=p2(1)+p2(2)*x+p2(3)*x^2 %This is function y2=f(x)
Y1=polyval(p,X) %This evaluate the polynomial function obtained from(a)at X
Y2=polyval(p2,X)%This evaluate the polynomial function obtained from(a)at X
plot(X,Y,'k') %This plot the graph of original data points X,Y
hold on
plot(X,Y1,'r') %This plot the fitted curve obtained by linear polynomial
plot(X,Y2,'c') %This plot the fitted curve obtained by quadratic polynomial
title('Graph of data points')
xlabel('X-Axis')
ylabel('Y-Axis')
legend(' Original data curve',' linear Y1','Quadratic Y2')
Output