% Polinomi di Bernstein
for n=20:20:600
    %n = 200;
    X = linspace(0,1,400);
    clf
    hold on
    %for k=0:10
    %    Y = bern(X,n,k);
    %    plot(X,Y)
    %    title(['Polinomio di Bernstein n = ', num2str(n), ' k = ', num2str(k)])
    %    axis([0 1 0 1])
    %    pause
    %end
    %Y = cauchy(2*X-1);
    Y = abs(X-0.5);
    plot(X,Y);
    Yb = zeros(size(X));
    for k=0:n
    %        Yb = Yb+cauchy(2*k/n-1)*bern(X,n,k);
            Yb = Yb+abs(k/n-0.5)*bern(X,n,k);
    end
    plot(X,Yb,'r')
    pause
end

