function [x pit] = puleni( fh, a0, b0, prec )
% [x pit] = puleni( fh, a0, b0, prec )

%% testovani argumentu
if( nargin<3 | nargin>4 )
    error('Chybny pocet vstupnich argumentu.')
end
if( nargin==3 )
    prec = 10*eps;
end

%% iterace
maxit = 1000;
pit = 0;

while pit<maxit & (b0-a0)>prec
    pit = pit+1;
    if( fh(1/2*(a0+b0)) < 0 )
        a0 = 1/2*(a0+b0);
    else
        b0 = 1/2*(a0+b0);
    end
end
    
x = 1/2*(a0+b0);
    
    
    
    