implementation of newton-gmres for solution of nonlinear equations