The code below shows an implementation of this gradient descent method for the function f (x,y) = (x− 1)2e−y2 + y(y + 2)e−2x2 around x = 0.1 and y = −1. Note that the spacing in the two point formula for the derivative is reduced by a factor of 2 after each iteration, and so is the step size in case of overshooting.