I have the following functions in an optimization problem.

$x\times 2^{(y/x)-1}$

$ x \log (a+b\times 2^{(y/cx)-1} )$

Here, x,y>0, and also a,b,c>0, and b>a. For these conditions, I checked that both these functions are convex (their Hessian is positive semidefinite). If I want to solve the optimization problem using CVX, I need to write these functions using a disciplined convex programming rule. Can anyone please help me how to do that? Even the first function has affine divided by affine form, and therefore, I am getting an error when running the code with only the first function. Many thanks for your help.

  • $\begingroup$ This is a mathematics site, not a programming site. $\endgroup$ Jul 10, 2020 at 2:14
  • 1
    $\begingroup$ I have seen similar posts on this site, so posted it. $\endgroup$ Jul 10, 2020 at 2:15
  • $\begingroup$ A simple search finds no CVX.... $\endgroup$ Jul 10, 2020 at 7:47
  • 1
    $\begingroup$ @DavidG.Stork: In my opinion, this question is ok. It is about "how can I explain to CVX that this function is convex" and this is rather a question of mathematics (and not of programming). $\endgroup$
    – gerw
    Jul 10, 2020 at 12:29
  • $\begingroup$ @David G. Stork wrote "A simple search finds no CVX.." I entered CVX in the search box on the top of this page, and many pertinent "how to reformulate optimization problems to comply with CVX's Disciplined Convex Programming rules" questions were displayed. In this context, "Disciplined Convex Programming " does not refer to computer programming. it means "optimization", for instance as in "Linear Programming", or "Nonlinear Programming",, or in this case, "Convex Programming". I request you remove your downvote of the question, if you cast one. $\endgroup$ Jul 11, 2020 at 12:00

2 Answers 2


$x\times 2^{(y/x)-1}$ can be reformulated as $\frac{1}{2log(2)}xe^\frac{y}{x}$

If this appears in an objective function, replace $x\times 2^{(y/x)-1}$ with $z$, where $z$ is declared a variable in CVX; and add the constraint, {y,x,2*log(2)*z} == exponential(1) to specify an exponential cone constraint, x*exp(y/x) <= 2*log(2)*z)

If it appears in a constraint: $x\times 2^{(y/x)-1} \le z$, handle it in a similar manner to what I showed for appearance in the objective function, except z need not be declared a variable, unless it already is a variable.

I leave $ x \log (a+b\times 2^{(y/cx)-1} )$ to you as an exercise.

  • $\begingroup$ Thank you so much. I actually read some of the posts yesterday and trying to solve by myself. Can you please check my post in CVXR. ask.cvxr.com/t/… $\endgroup$ Jul 13, 2020 at 2:03

If $f$ is convex, then the perspective $$g(x,t) = t \, f(x / t)$$ is convex.

Your first function is the perspective of $$f(y) = 2^{y - 1}$$ which is convex. The second function is the perspective of $$ f(y) = \log( a + b \, 2^{y/c -1})$$ which is also convex.

Maybe you can invoke the perspective function in CVX.

  • $\begingroup$ Unfortunately, CVX has no perspective function to invoke. $\endgroup$ Jul 10, 2020 at 16:11
  • 1
    $\begingroup$ There is also a more specific statement that if $f$ is expressible using a certain family of cones, then so is its perspective function. That helps here(see the answer by @MarkL.Stone). $\endgroup$ Jul 11, 2020 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .