function [ x ] = newton( f, x, tolerance )
%NEWTON Finds a root of f near x, with relative absolute error tolerance
%   Uses a straightforward version of Newton's algorithm to find the root.

fPrime = derivative( f );

relativeDelta = tolerance * 2;

while relativeDelta > tolerance
    deltaX = f(x) / fPrime(x);
    relativeDelta = abs( deltaX / x );
    x = x - deltaX;
end

end
