nD gradient descent