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

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

x(1)=init;

for k=1:100
    x(k+1)=x(k) - f(x(k))/fprime(x(k)) ;
    if abs( f(x(k+1)) ) <= tol
        break
    end
end

seq=x.';
end
