# Convex constraints

I am running into problem when I am trying to implement a constraint as below:

y >= x.^2/z

where x,y,z are the variables which are strictly positive. Therefore, the RHS is a quadratic divided by a affine function and the variables are all positive and non-zero. Then, the right hand side is convex. I have tried various ways to implement this, but I haven’t been successful. Please help!!!

1 Like

Not sure what exactly you mean dimension-wise, since the RHS looks like it could be a vector, but checking the function quad_over_lin should be a good starting point.

Thank you for responding, x,y,z are vectors and my optimization variables. The RHS is a quadratic divided by a linear function. Since the variables are positive the RHS is convex.
The question is how to define this in CVX??

1 Like

And the answer, as provided by @Michal_Adamaszek, is to use `quad_over_lin`.

quad_over_lin Sum of squares over linear.
Z=quad_over_lin(X,Y), where X is a vector and Y is a scalar, is equal to
SUM(ABS(X).^2)./Y if Y is positive, and +Inf otherwise. Y must be real.

``````If X is a matrix, quad_over_lin(X,Y) is a row vector containing the values
of quad_over_lin applied to each column. If X is an N-D array, the operation
is applied to the first non-singleton dimension of X.

quad_over_lin(X,Y,DIM) takes the sum along the dimension DIM of X.
A special value of DIM == 0 is accepted here, which is automatically
replaced with DIM == NDIMS(X) + 1. This has the effect of eliminating
the sum; thus quad_over_lin( X, Y, NDIMS(X) + 1 ) = ABS( X ).^2 ./ Y.

In all cases, Y must be compatible in the same sense as ./ with the squared
sum; that is, Y must be a scalar or the same size as SUM(ABS(X).^2,DIM).

Disciplined convex programming information:
quad_over_lin is convex, nonmontonic in X, and nonincreasing in Y.
Thus when used with CVX expressions, X must be convex (or affine)
and Y must be concave (or affine).``````
2 Likes