1

I have the pseudocode function f(x,y)=x+y, and I want to find the symbolic Hessian matrix (2x2 second order partial derivative matrix) using Matlab. How do I do this?

Here is my first attempt, which is very far from the correct syntax:

syms x y
f=x+y
f_jacobian = jacobian(f, [x, y])
f_hessian = jacobian(f_jacobian,[x,y])
Amir
  • 10,600
  • 9
  • 48
  • 75
Andrew Hundt
  • 2,551
  • 2
  • 32
  • 64

1 Answers1

3

You can use hessian. From the example:

syms x y z 
f = x*y + 2*z*x;
hessian(f,[x,y,z])


ans =
[ 0, 1, 2]
[ 1, 0, 0]
[ 2, 0, 0]
yhenon
  • 4,111
  • 1
  • 18
  • 34