a = 1;
b = 2;
N =  1000;
tol = 0.005;


% for i = 1 : N
%     if (a+b)^2/4 - 2 > 0
%         b = (a+b)/2;
%     else
%         a = (a+b)/2;
%     end
% end

%a

while (b-a > tol)
    if (a+b)^2/4 - 2 > 0
        b = (a+b)/2;
    else
        a = (a+b)/2;
    end
end

a
