Script checking convergence of nonlinear newtons method