
function demobisezione_2018(test)

if nargin < 1
test=1;
end

switch test
    case 1 % flat
        f=inline('exp(x)-2+x'); a=0; b=1;
        sol=0.4428544010023885;
    case 2
        f=inline('sin(x)-x'); a=-2; b=3;
        sol=0;
end

tolintv=10^(-5);maxit=10000;
[aa,bb]=bisezione_step(a,b,tolintv,maxit,f);



for ii=1:length(aa)
          ee=(bb(ii)-aa(ii))/2;
fprintf('\n \t $%4.0f$ & $%1.8e$ & $%1.8e$ & $%1.8e$ &$%1.1e$ &$%1.0f$',ii-1,aa(ii),bb(ii),...
    (aa(ii)+bb(ii))/2, ee,sign(f((aa(ii)+bb(ii))/2)));
end

figure(1)
xx=linspace(a,b,10000);
yy=feval(f,xx);
axis tight;
plot(xx,yy,xx,zeros(size(xx)));

figure(2)
ee=(bb-aa)/2;
errs=abs(ee-sol);
errs(1:end-1)./errs(2:end)
semilogy(1:length(ee),errs)

format long e
ee