function xNew = NewtonE(f, df, x0, tol, exact)

fprintf('\n Newton method solver \n\n');
horzLine = '______________________________________________________';
fprintf(' n |        x(n)        |   error   | log(error)|  f(x(n)) \n%s\n', horzLine);
xOld = x0;

for n = 1:100
    xNew = xOld - f(xOld) / df(xOld);

    error(n) = abs(xNew-exact);
    if (error(n) > 0) logError = log(error(n)); 
    else logError = -Inf;
    end;
     
    fprintf('%2d | %18.12g | %9.2e | %9.2e | %9.2e \n', n, xNew, error(n), logError, f(xNew));  
    if  abs(xNew - xOld) < tol
        ConvOrder(error);
        return
    end

    xOld = xNew;
end
fprintf('*** Newton method failed to converge after 100 iterations');