CVX help!How to avoid situations like {convex} .^ {2}


m and n are greater than 0,this has a convex function.The goal is to make it less than a number. How do you program it in cvx?
How to avoid situations like {convex} .^ {2}

square_pos(inv_pos(m)+inv_pos(n)) <= number

But it’s probably better to use
inv_pos(m)+inv_pos(n) <= sqrt(number)

Thank you for your generous answer! The code seems to be correct, and the constraints of the square_pos() are satisfied, but there seems to be something wrong with the output of the function.


variables m n t x positive
 subject to      
 square_pos(inv_pos(m)+inv_pos(n)) <= 50;


Status: Solved
Optimal value (cvx_optval): +0.141421

ans =


ans =


Squared with^2 is correct ,Is this normal?

I don’t know why your square_pos(inv_pos(m)+inv_pos(n)) comes out to 1. Mine comes out to 49.999987213706319, which is within solver tolerance of 50.

Note that the solve will set the optimal value of n to a very large number, so that 1/n is very small. Also note that variables m n t x positive did not declare m ,n, and t as positive, but actually declared positive as a variable. However, use of inv_pos has the effect of constraining m and n to be positive. If you want to declare a variable as positive, you can only declare a single variable as such per statement, using variable, not variables. That is so that the attribute, such as positive will not be confused as being a variable name in a variables statement.

There are actually 2 different square_pos functions. One of them is used on CVX expressikons, and is what is used during the optimization. The other is what is applied to double precision arguments, and is what is called after cvx_end, when m and n are double precision values which CVX set to their optimal values. So perhaps something is corrupted with or another version of square_pos was called in your case. Do you have another square_pos from something? I am not aware of any square_pos, other than from CVX, being in any publicly available MATLAB toolbox or add-on, or base MATLAB.