function runge_chebyshev_example(n)

x_nodes = -1:2/n:1;% should it be /n?

y_values = f(x_nodes);

t = -1.2:.01:1.2;

%axis([-1.2 1.2 -1.1 1.1])
hold all
%x_nodes = -1:2/(n-1):1;
%y_values = f(x_nodes);
t = -1.:.001:1.;

%axis([-1.1 1.1 -.02 .02])

%figure(1)
%hold all
%plot(t,0)
%plot(0,-1:0.001:2)
%plot(t,p_eval,'Linewidth',2,'Color','red')
%plot(x_nodes,y_values,'o','Color','black')
%plot(t,f(t),'Linewidth',2,'Color','red')
%plot(x_nodes,0,'o','Color','black')

for i = 1:n
    cheb_nodes(i)=cos((2*i-1)*pi/(2*n));
end
%g=1;
%for i=1:n
%g = g.*(t-cheb_nodes(i));
%end

ycheb_values = f(cheb_nodes);
divdif_ycheb = divdif(cheb_nodes,ycheb_values);% divided differences
p_eval = interp(cheb_nodes,divdif_ycheb,t);% Newton interpolation polyomial


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

figure(4)
title('Runge counterexample with Gaussian points')
hold all
axis([-1.2 1.2 m-.1*M M*1.1])
%plot(t,0)
%plot(0,-.02:0.0001:.02)
plot(t,f(t),'-',t,p_eval,'-.',cheb_nodes,ycheb_values,'*')
legend('Runge','interpolation polynomial','nodes')
%yy=max(g);
%plot(-1:.05:1,yy)
%plot(-1:.05:1,-yy)
%text(0,yy,'1/256',...
%     'HorizontalAlignment','left')

end



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