1
$\begingroup$

If f:= x^2y + z^3 + xz; and if {{1,2,9},{2,4,6},{9,5,9},{3,3,1},{6,5,3}} is a list of points. I need to evaluate the hessian at each point and then evaluate the determinant at each hessian at the same time.

I have tried the following code to evaluate hessian at $5$ points

f[x_, y_, z_] :=  f:= x^2y + z^3 + xz;

hessianF[x_,y_,z_] = hessian[x, y, z][f[x, y, z]]//FullSimplify

hessianF @@@ {{1,2,9},{2,4,6},{9,5,9},{3,3,1},{6,5,3}} 

Thanks for any help

$\endgroup$
2
  • 1
    $\begingroup$ D[f[x, y, z], {{x, y, z}, 2}] gives the Hessian. $\endgroup$ Commented Oct 20, 2015 at 9:58
  • $\begingroup$ Did you forget to include the code for hessian? $\endgroup$ Commented Oct 20, 2015 at 14:51

1 Answer 1

2
$\begingroup$
f = x^2 y + z^3 + x z;
hessian[x_, y_, z_] = D[f, {{x, y, z}, 2}]
{{2 y, 2 x, 1}, {2 x, 0, 0}, {1, 0, 6 z}}

m = {{1, 2, 9}, {2, 4, 6}, {9, 5, 9}, {3, 3, 1}, {6, 5, 3}};

h = hessian[##] & @@@ m
{{{4, 2, 1}, {2, 0, 0}, {1, 0, 54}}, {{8, 4, 1}, {4, 0, 0}, {1, 0, 
   36}}, {{10, 18, 1}, {18, 0, 0}, {1, 0, 54}}, {{6, 6, 1}, {6, 0, 
   0}, {1, 0, 6}}, {{10, 12, 1}, {12, 0, 0}, {1, 0, 18}}}

det = Det[##] & /@ h
{-216, -576, -17496, -216, -2592}
$\endgroup$
2
  • $\begingroup$ hessian @@@ m and Det /@ h suffice. $\endgroup$ Commented Oct 20, 2015 at 13:07
  • $\begingroup$ @J.M. Thanks for the hint. $\endgroup$
    – user31001
    Commented Oct 20, 2015 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.