calculate the gradient descent