Finding the gradient and the hessian of the same function

24 次查看(过去 30 天)
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?

采纳的回答

KSSV
KSSV 2022-11-7
Read about gradient, hessian.
  7 个评论
Howie
Howie 2022-11-7
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 2022-11-7
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 = 

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by