function [x,k] = newton(f,df,x0)
% Computes iterates of Newton's method for solving f(x) = 0
% returns iterate where |f(x_k)| < 1e-10 or k=100

% Initialize values
maxsteps = 100;
k = 0;
x = x0;

while ((k < maxsteps) && abs(f(x)) > 1e-10)
    % Compute next iterate
    x = x - f(x)/df(x);
    k = k+1;
end

end