function runge_example(n)

x_nodes = -1:2/n:1;

y_values = f(x_nodes);
t = -1.2:.01:1.2;

n = length(x_nodes);

divdif_y = divdif(x_nodes,y_values);% divided differences

p_eval = interp(x_nodes,divdif_y,t);% Newton interpolation polyomial

m1=min(p_eval);
m2=min(y_values);
m=min(m1,m2);
M1=max(p_eval);
M2=max(y_values);
M=max(M1,M2);

figure(1)
title('Runge counterexample')
axis([-1.2 1.2 m-.1*M M*1.1])
hold all
plot(t,f(t),'-',t,p_eval,'-.',x_nodes,y_values,'*')
legend('Runge','interpolation polynomial','nodes')
end

function f = f(x)
    f = 1./(1+12*x.^2);
end