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

n=12; %number of points
xj=-1:2/(n-1):1; %xj=set of equally spaced points on [-1,1]
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 equally spaced points on [-1,1]')
hold off;

print -depsc lbasis.eps;