%% Puleni intervalu

function final = puleni_PLAST_CYKLOVANI(N,a,b,Rm,sigma_f,err)
    
    x = round((a+b)/2)                             %%vypocet nove souradnice 
    
    fu = ((1-0.056*(log(10)^0.64)*log(360)+0.289*(log(10)^0.53))^(0.1*log(N(x))-0.465))*(0.9022288176^(0.1*log(N(x))-0.465)); %%vypocet fu pro vypoctene sigma_R
    n = (46000/(sigma_f/fu - 0.63*Rm+11.5))^2 %% zpetny vypocet poctu hledanych cyklu n
    
%% Rekurzivni volani funkce    
    if (n < N(x))        
            if abs(a-b) == 1
                final = N(x);
                return;
            end         
            final = puleni_PLAST_CYKLOVANI(N,a,x,Rm,sigma_f,err);
    else        
        if abs(a-b) == 1
                final = N(x);
                return;
        end
        final = puleni_PLAST_CYKLOVANI(N,x,b,Rm,sigma_f,err);        
    end    
end