function [root, error_bound] = bisect(a0,b0, ep, max_iterate)
% function [root, error_bound] = bisect(a0,b0, ep, max_iterate)
if a0>= b0
    disp('a0 < b0 is voilated. Stop!')
    return
end    
format short e 
a = a0; b= b0;
fa = f(a); fb = f(b);

if sign(fa)*sign(fb) > 0
    disp('f(a) and f(b) are the same signs. Stop!')
    return
end

c = (a+b)/2
it_count = 0;
fprintf(' \n it_count a b f(c) b-c \n')

while b-c > ep & it_count < max_iterate
    
    it_count = it_count + 1 ;
    fc       = f(c);
    
    iteration = [it_count a b c fc b-c]
    
    if sign(fb)*sign(fc) <=0
        a  =  c;
        fa = fc; 
    else     
        b = c;
       fb = fc;
    end
    
    c = (a+b)/2 ;
    pause
end

format long 

root = c

format short e
error_bound = b-c 
%%%
function value = f(x)
value =x.^6 - x -1;


