% Newton's method looks for a zero of function f using an
% inerative method, with first guess x=a.  It stops when |f(x_n)| < tol. 
%
% function root = newton(a,tol)

function [root,x] = newton(a,tol)

test = abs(f(a));
i = 0;
x(i+1) = a;
%while test > tol
for i=1:30
  a = a - f(a)/fp(a); 
  test = abs(f(a));
  i = i+1;
  x(i+2) = a;	
end
i

root = a;

