How can I express 1/x^2 as a convex function using DCP rules?

(Let’s say I want to solve the following problem:

cvx_begin

variables x

minimize 1/x

subject to

1<=x<=2

cvx_end)

How can I express 1/x^2 as a convex function using DCP rules?

(Let’s say I want to solve the following problem:

cvx_begin

variables x

minimize 1/x

subject to

1<=x<=2

cvx_end)

You can use `inv_pos(x)`

or `pow_p(x,-1)`

for 1/x,

or use `pow_p(x,-2)`

or `square(inv_pos(x))`

for 1/x^2.

This is addressed in the CVX Users Guide http://cvxr.com/cvx/doc/funcref.html#new-functions .

Edit: As discussed below, `square(inv_pos(x))`

is valid under CVX 3.0beta, but not under CVX 2.1.

Thanks a lot.

pow_p(x,-2) works fine!

(However square(inv_pos(x)) produces the error Illegal operation: square( {convex} )).

Sorry about that. `square(inv_pos(x))`

works under CVX 3.0beta which is more “lenient” (sophisticated) on sign-dependent matters, but not under CVX 2.1. `square_pos(inv_pos(x)`

) should work under both CVX 2.1 and 3.0 beta. As well, of course, as `pow_p(x,-2)`

.

I have another question and I would be grateful if you could help:

Even though x/(x+1)^2 is not convex on the whole real line, it can be shown that it is convex for x>=2.

How can i formulate let’s say the following problem in CVX?

‘minimize x/(x+1)^2

subject to 2<=x<=3’

I don;t see how to do it. Convexity (or concavity) only over a restricted range is often not possible to deal with in CVX. But I’m not saying it definitely can’t be done. So I’ll leave your question at X/(x+1)^2 convex for x>=2 open, so that someone can weigh in more definitively.

Edit: My suspicion is confirmed by mcg’s answer at the linked question.