clear all;

% set interval limits
a = -1;
b =  1;

% interpolation points and corresponding samples
n = 16;
x = linspace(a,b,n);         % equispaced points
y = 1./(1+25*x.^2);

% x points to plot at
xx = linspace(a,b,1000);

% corresponding y values
p = polyfit(x,y,n-1);
yy = polyval(p,xx);
% yy = spline(x,y,xx);

% plot the interpolant
plot(xx,yy,'b','linewidth',2)

% and the interpolation points
hold on
plot(x,y,'kx','markersize',12,'linewidth',2)
hold off

% it's good to label the axes and give a title
xlabel('$x$','interpreter','latex','fontsize',16)
ylabel('$y$','interpreter','latex','fontsize',16)
title(['Interpolant of Runge function, n=',num2str(n)],'fontsize',16)
