Wrking gradient descent algorithm