developing gradient descent algorithm