# The Confusion about the “Scalar quadratic forms’ constrains”

Dear all,
I have a simple optimization problem that shows below:

\begin{aligned} \Delta = \{a,b,c_1,c_2:a&=0.45+0.5\times(1-e^{(-8000(\theta_1^2+\theta_2^2)}),\\ b&=1+\theta_2^2,\\ c_1&=0.2+(\theta_2+sin(\theta_2)+0.1)\times sin(2\pi\theta_2),\\ c_2&=0.5+\theta_1^2cos(\theta_2),\\ (\theta_1,\theta_2)&\in[-1/3,1/3]^2\} \end{aligned}
l_{(a,b,c_1,c_2)}(k_1,k_2)=\frac{(c_1+bk_1)^2+(c_2+bk_2)^2+2a(c_1+bk_1)(c_2+bk_2)}{1-a^2}
\begin{aligned} &\underset{k_1,k_2,h}{min}\ \ h\\ &subject\ \ to:\ \ l_{(a,b,c_1,c_2)}(k_1,k_2)\leqslant h,\ i=1,...,5206 \end{aligned}

For any value of a,b,c_1,c_2 with |a|<1 and b\neq0 ,function l_{(a,b,c_1,c_2)}(k_1,k_2) is convex in k_1,k_2 (actually, it is a paraboloid).

clc
clear

% number of variable
d = 3;
% confidence parameter
Beta = 10^(-10);
% violation parameter
Epsilon = 0.1;
N = ceil(2 / Epsilon * (log(1/Beta)+d));
% sampling
Theta1 = rand(1,N) * (2/3)-(1/3);
Theta2 = rand(1,N) * (2/3)-(1/3);

a = 0.45 + 0.5 * (1-exp(-8000*(Theta1.^2 + Theta2.^2)));
b = 1 + Theta2.^2;
c1 = 0.2 + (Theta2 + sin(Theta2) + 0.1) .* sin(2*pi.*Theta2);
c2 = 0.5 + (Theta1.^2) .* cos(Theta2);
%% CVX part
cvx_begin
variables k1 k2 h
minimize(h);
subject to
for i = 1:N
((c1(i)+b(i)*k1)^2 + (c2(i)+b(i)*k2)^2 + 2*a(i)*(c1(i)+b(i)*k1)*(c2(i)+b(i)*k2))/(1-a(i)^2)<=h;
end
cvx_end


As a rookie of CVX, I must make some stupid mistakes.

warning: A non-empty cvx problem already exists in this scope.
It is being overwritten.
misuse  .*  (Line 262 )
Disciplined convex programming error:
Invalid quadratic form(s): not a square.

error  *  (Line 36 )
z = feval( oper, x, y );

error example1 (Line 25 )
((c1(i)+b(i)*k1)^2+(c2(i)+b(i)*k2)^2+2*a(i)*(c1(i)+b(i)*k1)*(c2(i)+b(i)*k2))/(1-a(i)^2)<=h;


I am trying to learn The DCP rulerset. But I still can’t find the problem. I learned that the no-product rule described in Expression rules. But the Scalar quadratic forms confused me. Because my constrains seem the same with Scalar quadratic forms.

( x + y ) ^ 2
( x + y ) * ( x + y )


Put the quadratic in the form: [k1 k2]*Q*[k1;k2], where you should figure out the needed value of Q, which should be symmetric and only be a function of the input data. If the quadratic is convex as you claim, then Q will be positive semidefinite and CVX will accept it as being convex.

Dear Mark, Thank you very very much!

I let A=c_1+bk_1 and B=c_2+bk_2 ,then l_{(a,b,c_1,c_2)}(k_1,k_2)=\frac{(c_1+bk_1)^2+(c_2+bk_2)^2+2a(c_1+bk_1)(c_2+bk_2)}{1-a^2} is transformed into

[A\ \ B]*\begin{bmatrix} \frac{1}{1-a^2} & \frac{a}{1-a^2} \\ \frac{a}{1-a^2} & \frac{1}{1-a^2} \end{bmatrix}*[A;B]

And the CVX works very well.