DCP error: product is complex


I received a disciplined convex programming error: invalid quadratic form, product is complex.

Below is generally how I’m using CVX:

variable w(N,1)
variable x

subject to

w'*H*w - w2'*H*(w-w2) <= constant;

w'*w <= x;


h is a know column vector, and w2 is known as well. H is Hermitian for sure, as it’s the product of a vector and its transpose. Is it the way of constructing H that makes it an error?

Actually there’s a loop inside CVX, and I need to construct matrix H each time from vector h, so I can’t write it before CVX. Is there any way to get rid of this error? Thanks for your response ahead!

Can you explain why
w'*H*w - w2'*H'*(w-w2) <= constant;
is a valid constraint, in compliance with CVX"s rules? I don’t believe it is.

Thank you for your reply!

H is positive definite here, making




is linear with respect to w.
So the left hand side is convex, and the right hand side is concave (just a constant). Did I miss anything? Thank you!

Let H = [1 i;-i 1], which is Hermitian semidefinite.
Let w2 be the real vector [1;1].
Then w2'*H = [1-i 1+i]
Therefore,w2'*H*w is a linear function of w, but is complex, not real. As mentioned in response to one of your previous questions DCP error: {complex affine} >= {constant} , you can not have complex expressions in an inequality in CVX.

thank you Mark! I see what you mean, and that reminds me of the issue here.

CVX recognises


as quadratic, but seems not able to find H Hermitian. So although I tried real( ), it didn’t help.

Simply halt before this line, input


and I still get the error “invalid quadratic form: product is complex”. In the previous question, real( ) did work.

Any idea why this happened? Thank you again Mark.

Please see Invalid quadratic form: product is complex,
real( ) was claimed not helpful as well in the last post…

O.k., I don’t know what’s going on with that. You’ll have to wait for someone more knowledgeable than me in that area to assess that.

However, if H is not being recognized as Hermitiam, perhaps you could try “Hermitianizing” it.
H = 0.5*(H+H');
However, if H was formed as a result of H = h*h'; that looks fairly “innocent” to me. But then again, i am not an expert in thee matters.

Thank you Mark, I just tried introducing an intermediate variable, say, u,




is convex (scalar). So if we have to use the vector h in this expression, this is a way.

Also your method works. :slight_smile: If we can use the matrix, just write it like that.

Thank you so much for these discussions!

If that works, then perhaps
(w'*h)*(w'*h)' will work.
The MATLAB editor provides hints to use parentheses in order to make matrix expressions which would be symmetric in exact arithmetic come out symmetric in MATLAB double precision.

yes, you are right.

When I wrote this line, the hint was to parenthesize the multiplication of vector h and its transpose. Parenthesizing w and h is the actually correct one. Thank you!