1

To compute the gradient of a function, it can be made with matematica using Grad[f[x,y],{x,y}]

Suprisingly, it's not possible to compute the Hessian matrix (something as HessianMatrix[f[x,y],{x,y}], doesn't exist (I check in Wolfram website here, but nothing relevant). Is it possible that mathematica can't compute the Hessian of a function ? And if no (what I guess), how can I do ?

Michael E2
  • 235,386
  • 17
  • 334
  • 747
tiko
  • 11
  • 1
  • Here's a link in here: https://mathematica.stackexchange.com/questions/123403/compute-hessian-of-function-symbolically Also, very convenient now to just google anything you want in mathematica to find it usually here. That's what I did, I just googled: "Hessian matrix in mathematica" to get to that link. – Dominic Feb 19 '21 at 13:10
  • 12
    D[f[x, y], {{x, y}, 2}] – cvgmt Feb 19 '21 at 13:20
  • @Dominic: Thanks a lot for your message. Indeed, I found this link, but trying to apply it, didn't work with me... I'll see if I can apply it properly. – tiko Feb 19 '21 at 13:21
  • @cvgmt: Definitely much better. Thank a lot. – tiko Feb 19 '21 at 13:22
  • 2
    Here's another from Mathworld: HessianH[f_, x_List?VectorQ] := D[f, {x, 2}] – Dominic Feb 19 '21 at 13:23
  • @Dominic: It didn't work when I wrote that as well... – tiko Feb 19 '21 at 13:24
  • Ok sorry. You may wish to click the up arrow on cvgmt's answer. We do that in here if the comment is helpful and if someone actually post code below and it answers your question, consider clicking the up arrow on that post as well as the check signifying the question is answered. – Dominic Feb 19 '21 at 13:47
  • @Dominic: Unfortunately, my score is to low for that (I can't up vote comment). – tiko Feb 19 '21 at 14:11
  • 4
    Presumably, you entered something wrong when testing solution by @Dominic. With HessianH[f_, x_List?VectorQ] := D[f, {x, 2}] then HessianH[f[x, y], {x, y}] == D[f[x, y], {{x, y}, 2}] evaluates to True – Bob Hanlon Feb 19 '21 at 14:11

0 Answers0