xbasc()
n=evstr(x_dialog('nombre de points ?','5'))
x=1:n+1;r=rand(1,n+1,'n');
p=max(zeros(1,n+1),x.*x+x.*r);d=p;
b(1)=d(1);
for k=1:n
   for j=1:n+1-k
   d(j)=(d(j+1)-d(j))/k;
   end 
  b(k+1)=d(1);
end
deff('y=po(x)',['y=b(1);s=1;for k=1:n;s=s*(x-k)';
                'y=y+b(k+1)*s;end'])
x2=1:0.1:(2*n);
plot2d(x,p,-2,'151','population',[1,-n,2*n,4*n^ 2+n])
fplot2d(x2,po,1,'000');
//plot2d(x2,x2.*x2,2,'000');
V=[ones(n+1,1),x',x'.*x'];
b=p'\V;
deff('y=p1(x)',['y=b(1);s=1;for k=2:3;s=s*x';
                'y=y+b(k)*s;end']);
fplot2d(x2,p1,3,'100','parabole moindres carres');
//
