# Quadratic programming: product is complex!

Hi everyone,

I’ve encountered an issue while running the following program:

``````h_sr = sqrt(1/2) * (randn(4, 1) + 1i*(randn(4, 1)));
h_tr = sqrt(1/2) * (randn(4, 1) + 1i*(randn(4, 1)));
h_st = sqrt(1/2) * (randn(1, 1) + 1i*(randn(1, 1)));

alpha_int = 0.5;
channel = h_sr + alpha_int .* h_st .* h_tr;
MF_g = channel/norm(channel);

cvx_begin
variable alphaa(2,1) complex

R = [MF_g'*h_st*(h_tr*h_tr')*h_st'*MF_g, MF_g'*h_st*h_tr*h_sr'*MF_g ; MF_g'*h_sr*h_tr'*h_st'*MF_g, 0];

obj = alphaa'*R*alphaa;

maximize real(obj)
subject to

(1-square_abs(alphaa))* Power * abs(MF_g'*h_sr)^2 >= P_th;
square_abs(alphaa) <= 1;

cvx_end
``````

Unfortunately, while executing the above code, I encountered an error related to the DCP rules. Notably, the matrix R in the program is Hermitian. Here is the exact error message:

Error using * (line 258)
Disciplined convex programming error:
Invalid quadratic form: product is complex.

Error in main (line 43)
obj = alphaa’Ralphaa;

I would appreciate any assistance or guidance on how to resolve this issue. Thank you.

R has one positive eigenvalue and one negative eigenvalue. Therefore, it is not hermitian negative semidefinite, as is required for `obj` to be (real) concave.

I.e., your problem is not convex. I have no idea whether you made a mistake in implementing your intended (convex) optimization problem; or your CVX formulation is the problem you really want to solve, in which case it is non-convex, and you need to use a different tool, such as YALMIP.

Dear Mark, thank you for your prompt response. You’re absolutely correct, and I have since revised my approach accordingly. However, I’ve encountered a new error. The objective function is indeed a quadratic convex expression, and maximizing it doesn’t logically hold. The model I’m simulating, according to my references, maximizes a quadratic function subject to modulus constraints. Could you possibly provide any further guidance or recommendations on how to tackle this?

If `R` is hermitian with both eigenvalues being non-positive, the objective of maximizing `alphaa'*R*alphaa` will be convex. I have no ideas what your revision was.