% SBISEC Symbolic bisection method
%
function [ntol,x] = sbisec(dig,a,b,tol)
ntol = ceil(log((b-a)/tol)/log(2));
digits(dig);
a=vpa(a); b=vpa(a);
for n=1:ntol
    x=vpa((a+b)/2);
    fx=subs(f(x));
    if fx<0
        a=x;
    else
        b=x;
    end
end

% function y = f(x)
% y=0.5*x - sin(x);

function y = f(x)
y = -x^2/(1+x) + log(x)/(1+x) -log(x);
