%script to plot lagrange basis functions for 12 Chebychev points
%on [-1,1].
%Brad Nelson 1/22/11

n=12; %number of points
%xj=set of chebychev points on [-1,1]
xj=zeros(1,n);
for i=1:n
   xj(i)=-cos(pi*(i-1)/(n-1)); 
end
xs=-1:0.001:1;
ys=zeros(numel(xs),n);
for i=1:numel(xs);
    ys(i,:)=lagrange(xs(i),xj);
end
figure;
hold on;
plot(xs,ys,'-');
plot(xj,zeros(numel(xj)),'*k');
title('lagrange basis functions for 12 Chebychev points on [-1,1]')
hold off;

print -depsc lbasis_cheb.eps;