Finding the gradient and the hessian of the same function

29 views (last 30 days)
If I have the function
fv = @(x) x(1)^2 + x(1)*x(2) + (3/2)*x(2)^2 - 2*log(x(1)) - log(x(2));
What would be the best way to find the hessian of said function?

Accepted Answer

KSSV
KSSV on 7 Nov 2022
Read about gradient, hessian.
  7 Comments
Howie
Howie on 7 Nov 2022
syms x [1 2]
fv = x(1)^2 + x(1)*x(2) + (3/2)*x(2)^2 - 2*log(x(1)) - log(x(2));
%hessian(fv,x)
[x(1),x(2)] = gradient(fv)
Error using sym/gradient
Too many output arguments.
I get an error when trying to use gradient function
Torsten
Torsten on 7 Nov 2022
Same way means:
syms x [1 2]
fv = x(1)^2 + x(1)*x(2) + (3/2)*x(2)^2 - 2*log(x(1)) - log(x(2));
g = gradient(fv,x)
g = 

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!