Lets say, I have a function z = x^2 + y^2
. Now, I want to implement hessian of this function z
in python. Till now, I have calculated the derivative using finite-difference method as given below -
def derivative(x, y, f, h):
return [(f(x + h, y) - f(x - h, y )) / (2*h), (f(x , y + h) - f(x , y - h)) / (2*h)]
I'm not sure how to reuse this to calculate the Hessian.