function [ x ] = newton(f,fprime,xstart,epsilon)
%NEWTON Finds the roots of f using Newton's method for root finding
%   fprime is the first derivative of f, xstart is the starting guess,
%   and epsilon is the desired accuracy
  maxiters = 50;
  x = zeros(maxiters,1);
  
  x(1) = xstart;
  k = 1;
  while abs(f(x(k))) > epsilon && k < maxiters
      x(k+1) =  x(k) - f(x(k))/fprime(x(k));
      k = k+1;
  end
  
  %Get rid of extra entries
  x = x(1:k);
end

