modified gradient descent for use in testing