Derivatives on quadratic programming

158 Views Asked by At

I'm trying to minimize a function using quadratic programming. The loss function to minimize is:

$$L=\sum_{i}x_{i}M(a_{i}, a_{i})-\sum_{i,j}x_{i}x{j}M(a_{i},a_{j})$$

where M is a $NxN$ matrix and I have to calculate values of x.

For quadratic programming y need to calculate the $H$ matrix (hessian matrix) and the $c$ coefficients vector.

I get that $H$ matrix is $-2M$ and $c$ is the diagonal of $M$ => $c=diag(M)$ calculating derivatives.

I have seen the solution and $H$ matrix is equal to $2M$ and $c=-diag(M)$.

My question is: why the solution changes the sign of $H$ and $c$? and why it works and my solution doesn't?

Thanks