# Sqrt of (x^2-a^2) in cvx

(ya) #1

Hi,

Sir, I want to write D-sqrt(x^2-A^2) in cvx. Could you please help me writing it in cvx.

Thanks

How to express sqrt(1/x+1) by CVX?
(Erling D.Andersen) #2

How does that appear in the model? In the objective? In a constraint? And what is constants and what is variables?

(ya) #3

Thanks for reply.
It appears in objective function x is optimization variable. In the domain of my interest its 2nd derivative is positive. My problem is just to make it compatible with cvx and ‘a’ is constant.

(Erling D.Andersen) #4

Something like:

\begin{array}[lc] \mbox{min} & D -t \\ st. &(x+a)(x-a) \geq t^2 \\ & x-a \geq 0 \\ \end{array}

should do it.
The two constraints can expressed using a rotated quadratic cone.

Note we are actually saying

|t| \leq (x+a)^{0.5} (x-a)^{0.5}

so t has to be less than the geometric average of (x+a) and (x-a).

1 Like
(ya) #5

Thanks for your prompt reply. I am just curious if this function appear in constraint then how would we right it.

(Erling D.Andersen) #6

Look at the rotated_lorentz entry at http://cvxr.com/cvx/doc/funcref.html#sets .