
function demobisezione_2018(test)

if nargin < 1
test=3;
end

switch test
    case 1 % flat
        f=inline('10^(-8)*(x.^2-2)');
    case 2 % steep
        f=inline('10^(8)*(x.^2-2)');
    case 3
        f=inline('(x.^2-2)');
end

a=1; b=2;
tolres=10^(-10);tolintv=10^(-10);maxit=10000;
[aar,bbr,ir]=bisezione_res(a,b,tolres,maxit,f);
[aarw,bbrw,irw]=bisezione_resw(a,b,tolres,maxit,f);
[aas,bbs,is]=bisezione_step(a,b,tolintv,maxit,f);

xr=(bbr(end)+aar(end))/2;
xrs=(bbrw(end)+aarw(end))/2;
xs=(bbs(end)+aas(end))/2;
sol=sqrt(2);

fprintf('\n \t  $%1.15e$ & $%1.3e$ & $%1.3e$ & $%4.0f$ %%[res ]',xr,abs(xr-sol),abs(f(xr)),ir);
fprintf('\n \t  $%1.15e$ & $%1.3e$ & $%1.3e$ & $%4.0f$ %%[resw]',xrs,abs(xrs-sol),abs(f(xrs)),irw);
fprintf('\n \t  $%1.15e$ & $%1.3e$ & $%1.3e$ & $%4.0f$ %%[step]  \n',xs,abs(xs-sol),abs(f(xs)),is);
xx=linspace(a,b,10000);
yy=feval(f,xx);

plot(xx,yy,xx,zeros(size(xx)));

