%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Université de Lille 1
%MAO 2004/2005
%
%                      Approximation au sens des moindres carrés
%                                                   
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function insthilb(NMAX)

N=1;
a=0,b=1
for N=1:NMAX
dx=(b-a)/N;
x=a:dx:b;
xr=a:0.1*dx:b;
fx=exp(x).*sin(pi*x);
fxp=exp(xr).*sin(pi*xr);
%fx=1;
s=zeros(N,1);
%calcul des contributions de f
for i=1:N
    s(i)=sum(fx.*(x.^(i-1)))*dx;
end
%résolution du système
P1=invhilb(N)*s;
for i=1:N
P(i)=P1(N-i+1);
end
pmc=polyval(P,xr);
%calcul avec matlab via polyfit
polyfit(x,fx,length(x)-1)
plot(xr,pmc,x,fx)
titre=N;
title('titre')
drawnow
pause(1)
end

