%%Matlab code for answering question 4a. and 4b.
clear all
close all
%function for which interpolation have to do
f=@(x) 1./(1+x.^2);
%13 equally spaced points between -5 to 5
xx=[-5:5/6:5];
yy=f(xx);
%12th degree polynomial coefficients
p = polyfit(xx,yy,12);
%polyval code
x1 = linspace(-5,5,1001);
y1 = polyval(p,x1);
figure(1)
plot(xx,yy,'ro')
hold on
plot(x1,y1,'linewidth',2)
hold off
title('Plotting for Runge function equally spaced point')
xlabel('x')
ylabel('f(x)')
legend('Actual data','polynomial fit')
%13 Chebyshev points between -5 to 5
for j=1:13
xx(j)=5*cos(pi*(j-1)/12);
end
yy=f(xx);
%12th degree polynomial coefficients
p = polyfit(xx,yy,12);
%polyval code
x1 = linspace(-5,5,1001);
y1 = polyval(p,x1);
figure(2)
plot(xx,yy,'ro')
hold on
plot(x1,y1,'linewidth',2)
hold off
title('Plotting for Runge function Chebyshev points')
xlabel('x')
ylabel('f(x)')
legend('Actual data','polynomial fit')
%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%%
Eilymai retine, or you m yur ova rodinT ur pl nda listing of your code. (b) Repeat part (a) with ...