Hello,
My objective function is y’Ky + y’*L, which is quadratic. I know that in order this to be convex, K must be positive semidefinite.

In my case K is a sparse 25x25 matrix and its eigen values are roughly:
1st eigen value: 1000
2nd eigen value: 1
3rd eigen value: 0.5
4th eigen value: 0.2
and the rest is all zero.

I get an an error from function quad_form(), when i run cvx:
“The second argument must be positive or negative semidefinite”.

Even though all eigen values are non negative, how do i not have semidefinite matrix of K.

My code is
cvx begin
variable y(25,1)
minimize y’Ky + y’*L
cvx end

Ps: There are some constraint equalities as well, but they dont affect whether I get this error or not.

It’s possible that one or more eigenvalues evaluate to be very slightly negative (I don’t know exactly how CVX is evaluating definiteness), thereby triggering the error. What does min(eig(K)) evaluate to? From a practical perseptive, you may be in precarious territory if chol(K) fails.

Perhaps you can add a very small positive number to the diagonal to make it numerically psd.