%SNEWTON Symbolic Newton's method
%
function [n,x]=snewton(dig,a,tol,nmax)
n=0;
digits(dig);
a=vpa(a);
x0=a+1; x=a;
while subs(abs(x-x0))>=tol
    n=n+1;
    if n>nmax
        fprintf('n exceeds nmax')
        return
    end
    x0=x;
    x=x0-f(x0)/fd(x0);
end

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

