function fn = CebysevovaInterpolace(f,a,b,n,x)

if n==0
    poly = 1/2;
else
    i=0:n; poly = (b+a)/2 + ((b-a)/2) * cos((2*i+1)*pi/2/(n+1));
end
% A = zeros(n+1,n+1);
% for i=0:n
%     A(:,i+1) = poly.^i;
% end;
% cond(A)
% b = f(poly)';
% alfa = A\b;
% fn = x; fn(:) = 0;
% for i=0:n
%     fn = fn+alfa(i+1)*x.^i;
% end

fn = x; fn(:) = 0;
for i=0:n
    Li = x; Li(:) = 1;
    for j=0:n
        if j~=i
            Li = Li .* (x-poly(j+1))./(poly(i+1)-poly(j+1));
        end
    end
    fn = fn + f(poly(i+1)) * Li;
end
