 # How to write x*sqrt(x/y) in cvx?

Hi! Does anyone know how to write x*sqrt(x/y) in cvx? For x >=0, y >0, this should be convex in x and y since it is the perspective function of the convex function sqrt(1/y). Thank you!

My back on the envelope computations shows that

x*sqrt(x/y)<= t

is equivalent to

|x| <= (t^2y)^(1/3)=t^(2/3)*y^(1/3)
t,y>0.0

which is a power cone.

Thank you very much @Erling . This really helps.

@Erling, I am sorry I am very new to programming in cvx. When I write this constraint in CVX, i get the following error: cannot perform the operation (concave).*(concave). Any idea how to solve this?

I do not think cvx has the power cone, but if you take geometric mean of (t,t,y) you got what you need since

t^1/3 * t^1/3 * y^1/3 >=|x|

Note the LHS is the geometric mean.

So you can use geometric mean cone mentioned at

http://web.cvxr.com/cvx/doc/funcref.html#nonlinear

Most likely you find in the documentation how to use geo_mean_cone.

1 Like

help geo_mean

geo_mean Geometric mean.
Y=geo_mean(X), where X is a vector, computes the geometrix mean of X. If any
of the elements of X are negative, then Y=-Inf. Otherwise, it is equivalent
to Y=PROD(X).^(1/LENGTH(X)). All elements must be real.

For matrices, geo_mean(X) is a row vector containing the geometric means of
the columns. For N-D arrays, geo_mean(X) is an array of the geometric means
taken along the first non-singleton dimension of X.

geo_mean(X,DIM) takes the geometric mean along the dimension DIM of X.

geo_mean(X,DIM,W), where W is a vector of nonnegative integers, computes a
weighted geometric mean Y = PROD(X.^W)^(1/SUM(W)). This is more efficient
than replicating the values of X W times. Note that W must be a vector,
even if X is a matrix, and its length must be the same as SIZE(X,DIM).

Disciplined convex programming information:
geo_mean is concave  and nondecreasing; therefore, when used in CVX
specifications, its argument must be concave.
1 Like

@Erling, @Mark_L_Stone. Thank you very much for your replies. I have now written the following code, where I used geo_mean.

cvx_begin
variable x;
variable w(3,1);

minimize(w(1))
subject to
w(1)==w(2);
abs(x) <= geo_mean(w);
x >= 1;
w(3) - 2*x + 1 >= 0;
cvx_end

However, it returns the status: Inaccurate/solved, with optimal value +0.000419713. It is obvious that the optimal value should go to zero in this case. Is something wrong with my code?

I don’t see how you got your formulation. Are you incorporating other constraints?

Nevertheless, by including the following in your CVX program

variables x y t;
abs(x) <= geo_mean([t,t,y]);
x >= 0
y>=0


you can use t in place of x*sqrt(x/y).

The program

cvx_begin
variables x y t;
minimize(t)
subject to
abs(x) <= geo_mean([t,t,y]);
x >= 0
y>=0
cvx_end


results, within solver tolerance, in optimal value of x and t both equal to zero, and y being any positive number.

Adding the constraint x >= 1 makes the problem ill-posed, because the infimum of 0 is achieved (actually, not achieved) in the limit as y \rightarrow \infty. Solvers don’t like that.