how can we calculate the hessian matrix in general ?

12 vues (au cours des 30 derniers jours)
Hassan
Hassan le 6 Sep 2015
Commenté : Matt J le 8 Nov 2019
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

Réponse acceptée

Matt J
Matt J le 6 Sep 2015
Modifié(e) : Matt J le 6 Sep 2015
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 commentaires
Hassan
Hassan le 6 Sep 2015
matt thank you ... your answer is very complete and in detail ... i got it now what you do in my previous question ... :-)
sonu Lamba
sonu Lamba le 9 Août 2017
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

Connectez-vous pour commenter.

Plus de réponses (1)

Dauren
Dauren le 17 Juin 2019
Modifié(e) : Dauren le 7 Nov 2019
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 commentaire
Matt J
Matt J le 8 Nov 2019
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Quadratic Programming and Cone Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by