function P2(n)
% Set up and solve the linear system for alfa...
x = linspace(-1,1,n+1)';
A = MakeMatrix(x,n);
y = exp(-x).*sin(10*x);
alfa = A\y;
% Display the interpolant...
z = linspace(-1,1)';
f = exp(-z).*sin(10*z);
p = MakeMatrix(z,n)*alfa;


plot(z,f,z,p,x,y,'o',[-1 1],[0 0],'-r')
legend('f(x)','p(x)')
title(sprintf('Degree = %1d',n),'fontsize',14) 
shg

function A = MakeMatrix(x,n)
m = length(x);
A = zeros(m,n+1);
A(:,1) = ones(m,1);
A(:,2) = x;
for j=3:n+1
    A(:,j) = 2*x.*A(:,j-1) - A(:,j-2);
end




