function [seq]=newton(func,fderiv,init,tol)
% implements Newton's method using a WHILE loop
% outputs the sequence of iterates as a column vector

f=inline(func,'x');
fprime=inline(fderiv,'x');

x(1)=init;
k=1;
while abs( f(x(k)) ) > tol
    k=k+1;
    if k>100
        break
    end
    x(k)=x(k-1) - f(x(k-1))/fprime(x(k-1)) ;
end

seq=x.';
end
