how can we calculate the hessian matrix in general ?
15 次查看(过去 30 天)
显示 更早的评论
is there any clear way for calculating the hessian matrix of a complex equation? for example in QP problems we have to change the form of our equation to form of quadprog() function. how can we calculate the matrix H and f in quadprog in general. i asked similar question before in this link: http://www.mathworks.com/matlabcentral/answers/234018-please-solving-this-qp-equation but i cant understand the answers ... please answer my question in detail
0 个评论
采纳的回答
Matt J
2015-9-6
编辑:Matt J
2015-9-6
Well, the Hessian of a function g(x) is by definition the matrix of second partial derivatives
H(i,j) = d^2/(dxi dxj) g(x)
so it can always be calculated that way. As for f, when the objective g(x) is quadratic, f is the gradient of g at x=0 and can likewise be calculated by directly taking partial derivatives.
However, often you don't have to resort to these basic definitions to compute the Hessian. You can put the terms of your function in familiar forms whose Hessian is very easy to inspect. If you haven't done so, for example, you should convince yourself that the Hessian of the general quadratic form
g(x) = (x.' * Q * x)/2
is H=Q. You would never go through the labor of taking partial derivatives for something so basic.
Accordingly, your main problem in your previous thread is that you didn't put your function in matrix-vector form. You have all the terms in your function expanded into sums like,
sum_i sum_j alpha_i*alpha_j*(x_i.' * x_j)
As I explained to you then, the expression above can be written in matrix-vector form as
alpha.'*(X.'*X)*alpha
from which it is easy to see that the Hessian of this term is H=2*(X.'*X). The other terms become similarly easy to manage when put in matrix-vector form.
2 个评论
sonu Lamba
2017-8-9
Hello everyone, Can you tell how to calculate hessian matrix for a spatio-temporal video sequence I(x,y,t)?. Here, t corresponds to next frame. I need to calculate hessian matrix in videos for keypoints detection
更多回答(1 个)
Dauren
2019-6-17
编辑:Dauren
2019-11-7
I think answer to you question is hessian function.
If you have function y=x1^2+2*x1*x2+x2^2
and you want to represent y in form of y=x*H*x',
where x=[x1 x2],
then apply:
syms x1 x2
y=x1^2+2*x1*x2+x2^2
H=1/2.*hessian(y)
1 个评论
Matt J
2019-11-8
Note that this won't be practical with a large number (e.g., 100, 1000) of unknown x(i). The Symbolic Math Toolbox unfortunately does not support symbolic manipulation of vector variables.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!