% Script File: RungeEg
% For n = 7:4:31, the Chebyshev interpolants of f(x) = 1/(1+25x^2) 
% on [-1,1] are of plotted.

close all
x = linspace(-1,1,100)'; 
y = ones(100,1)./(1 + 25*x.^2);
for n=7:4:31
   figure
   xCheby = cos(pi*(2*linspace(1,n,n)'-1)/(2*n)); 
   yCheby = ones(n,1)./(1+25*xCheby.^2);
   cCheby=InterpN(xCheby,yCheby);
   pValsCheby = HornerN(cCheby,xCheby,x);
   plot(x,y,x,pValsCheby,xCheby,yCheby,'*')
   title(sprintf('Chebyshev Nodes (n = %2.0f)',n))
end