function [x, k, vec] = mynewton(f, fprime, x)
    %MYNEWTON mynewton(f, fprime, b) find approximation for
    % the root of the equation f(x) = 0.
    % Returns the approximation for a root, the number
    % of function evaluations, and the vector of approximations

    vec = [];  
    k = 0;
    xprev = x;
    while abs(x - xprev) > eps*abs(x) || k < 1
        xprev = x;
        x = x - f(x)/fprime(x);
        k = k + 1;
        vec = [vec x];
    end
end

