max_iter = 1000
x_o=0
y_o=0
alpha = 0.01 ## Step Size
x_k=2 ## Starting position of x coordinate 
y_k=2 ## Starting position of y coordinate 




"""
Explanation: Code for Gradient disent
Code for calculating local minima for $$f(x,y)= x^4 + y^4 - x^2 - y^2$$ with partial derivative wrt x : $$4x^3 - 2x$$ and partial derivative wrt y: $$4y^3 - 2y$$
End of explanation
"""


def devx(x): ## Defining partial derivative wrt x
    return 4*x**3 - 2*x
def devy(y): ## Defining partial derivation wrt y
    return 4*y**3 -2*y
for i in range(max_iter):
    x_o = x_k
    y_o = y_k
    x_k = x_o - alpha * devx(x_o)
    y_k = y_o - alpha * devy(y_o)

print "Local Minimum at",x_k,",",y_k

"""
Explanation: Here we set the Max iterations as 1000 and starting coordinte in ($x_k,y_k$) = (2,2) and Step size as 0.01 donated by alpha
End of explanation
"""


