updated code to do gradient descent in dual of minmax