format long;
f=inline('x^3-7*x^2+14*x-6');

a=3.2; b=4.0; fa=f(a); fb=f(b);
d=b-a;
epsilon=10^(-8);
n=1;  
fprintf('n        c            d/2             f(c)\n');
fprintf('-------------------------------------------------\n');
while d>=epsilon,
    c=(a+b)/2;
    fc=f(c);
    fprintf('%d     %2.8f    %2.8f   %e\n',n,c,d/2,fc);
    if fa*fc >=0,
       a=c; fa=fc;
    else
       b=c; fb=fc;
    end
    d=b-a;n=n+1;
end

