def newton(f, f_derivative, x0, eps, kmax):
    """Newton's method for finding roots.
    
    The Newton's method (Newton–Raphson method) is a root-finding algorithm 
    which produces approximations to the roots (or zeroes) 
    of a real-valued function. [Wiki].

    Args:
        f (function): single-variable function f ,
        f_derivative (function):  the function's derivative f ′,
        x0 (float): initial guess,
        eps (float): precision wanted,
        kmax (int): maximum number of iterations.

    Returns:
        x (float): root of f(x) = 0.

    """
    x = x0
    x_prev = x0 + 2 * eps
    i = 0
	
    while (abs(x - x_prev) >= eps) and (i < kmax):
        #print("Step", i, ":", int(x), int(x_prev), ", x - f(x) = ", int(x - f(x)), ", f_derivative(x) = ", int(f_derivative(x)), "f/f'=",int(f(x)/f_derivative(x)))
        x, x_prev =  x - ( f(x) / f_derivative(x) ), x
        i += 1
        

    return x