%SFALSEPOS Symbolic method of false position
% 
function [n,x] =  sfalsepos(dig,a,b,tol,nmax)
n=0;
gigits(dig);
a=vpa(a);b=vpa(b);
while subs(b-a)>=tol
    n=n+1;
    if n>nmax
        fprintf('n exceeds nmax')
        return
    end
    x=a-(a-b)*fa/(fa-fb);
    fx=f(x);
    if abs(subs(fx))<tol, return; end
    if subs(fx*fa) >0
        a=x; fa=fx;
    else
        b=x; fb=fx;
    end
end