function [ P ] = Bern_pol( n,f )
% function [ P ] = Bern_pol( n,f )
% Bernsejn polynomial of f
% n - degree
% f - inline or annonymous function

b=[1 zeros(1,n)]; % x^n
P=f(1)*b;
for k=n-1:-1:0
    b(end)=[];
    b=conv(b,[-1 1]); %x^k*(1-x)^(n-k)
    P=P+f(k/n)*nchoosek(n,k)*b;
end


end

