
n = 1000;
x = -n:n;
x = x/n;

% generate Runge's function
sc = 3;
y1 = 1./(1 + (sc*x).^2);
plot(x,y1);

% now interpolate it at fewer nodes and plot
k = 30;
m = k/2;
t = -m:m;
t = t/m;
z = 1./(1 + (sc*t).^2);

p = polyfit(t,z,k);

y2 = polyval(p,x);
hold on;
plot(x,y2);