Newton-Raphson method of solving equations