Hi all, I am writing to inquire about the Hessian matrix and the gradient vector of some functions, this because I have left several exercises functions of two variables and three variables, to find the Hessian matrix and the gradient vector, there is some way to make these calculations in Mathematica?
http://reference.wolfram.com/mathematica/ref/Grad.html
(search for Hessian on the following page)
http://reference.wolfram.com/mathematica/tutorial/Differentiation.html
Thanks for helping David, I consulted the links that you have shown me and I found everything I needed. They are very useful for the job I’m doing,. Thanks again
You can do this using D[]. Given a function with (say) arguments x and y you can write:
D[f[x,y], {{x,y},2}]
You can use Grad[] twice, of course, but D[] will get you there directly.
Some background info here:
On that page, they present an implementation of a Hessian operator:
HessianH[f_, x_] := D[f, {x,2}]
You’d call it like this:
HessianH[f[x,y], {x,y}]
If you don’t want to have to repeat the argument list, you could do something like:
H[f_, x_]:= HessianH[Apply[f, x], x]
So now you can say:
H[f, {x,y}]
As of v12, you can access a pre-defined version of this function as follows:
ResourceFunction["HessianMatrix"][f[x,y], {x,y}]
which emits a matrix in the normal way. More info here:
https://resources.wolframcloud.com/FunctionRepository/resources/HessianMatrix