# Getting error in this

Error using *
Disciplined convex programming error:
Invalid quadratic form: product is complex.

``````Error in Jan12_SumRate (line 138)
2*real(((v_0*H_hat+H_Direct_WET(i,:))*a_k(:,i)).'*((v0*H_hat+H_Direct_WET(:,i))*ak(:,i))) -abs(((v_0*H_hat+H_Direct_WET(:,i))*a_k(:,i)))^2 >= b_k-(log(z(i)))/q_k;
% v0 and ak optimal, used this for next iterations
``````

I have checked the expression and it is correct as per my understanding. I am running for loop, i=1:K. and defined following variables in cvx

``````cvx_begin
variable t(2) nonnegative;
variable f(K) nonnegative;                  %tau_k=p_k*t1
variable z(K) nonnegative;
variable v_0(1,N1) complex;
variable a_k(M,K) complex;Kindly help.
``````

thank you.

CVX does not allow `abs(...)^2`.

However, you can use `square_abs(...)` instead.of `abs(...)^2`.

Still error persists.

Invalid quadratic form: product is complex.

Where else does your program have a multiplication of variables?

``````cvx_begin
variable t(2) nonnegative;
variable f(K) nonnegative;                  %tau_k=p_k*t1
variable z(K) nonnegative;
variable v_0(1,N1) complex;
variable a_k(M,K) complex;
dual variables y4 y5 y6 y7 y8 y9 y10 y11 y12;
% Objective function
expression R_k(K)
R_k(i)=-rel_entr(t(2,1),t(2,1)+sum(f(i)*Kappa(i)))/log(2);
maximize sum(R_k);
% Constraints
subject to
% SCA based constraints
**2*real(((v_0*H_hat+H_Direct_WET(i,:))*a_k(:,i)).'*((v0*H_hat+H_Direct_WET(:,i))*ak(:,i))) -square_abs(((v_0*H_hat+H_Direct_WET(:,i))*a_k(:,i))) >= b_k-(log(z(i)))/q_k;**
f(i)<=X_k*((t(1,1)/1+z(i))-((t(1,1)/(1+z(i))^2)*(zk(:,i)-z(i)))+(2*sqrt(t(1,1))/(1+z(i)))*(sqrt(t0)-sqrt(t(1,1))))-Y_k*t(1,1);
% Time, Power constraint and positivity constraints
y4 : t(1,1)+t(2,1) <= Tmax;
y5 : t(1,1) >= 0;
y6 : t(2,1)>= 0;
y7 : sum(norm(a_k))<=Pmax;
y8 : abs(v_0(N1))<=1;
f(i)>= 0;
z(i)>= 0;
cvx_end
``````

This is my code, i running it inside a for loop i=1:K
the line which is bold is giving error.

`((v_0*H_hat+H_Direct_WET(i,:))*a_k(:,i))`
has multiplicatio0n of `v_0` and `a_k`, both of which are variables. That should be sufficient to cause the error message. i donâ€™t know how many other errors your program contains.

It would appear that you have not done SCA correctly, given that you have this non-convex item.