# How to write the following objective function about Exponential function in CVX?

We know g（x,t）=tf(x/t) is perspective function,if f is a convex function,g is also a convex function,or if f is a convex function,g is also a convex function.
Assume f(x)=exp(x),then g(x,t)=t
exp(x/t) ,g(x,t) is a f is a convex function. So how to express this objective function ?
if we write the
cvx_begin
variable x
variable y
minimize x*exp(y/x);
subject to
x>0;
y>0;
y<1
cvx_end
then there is error"Disciplined convex programming error:
Invalid operation: {real affine} / {real affine}",

so how to write it?

Use the exp_cone set documented at http://cvxr.com/cvx/doc/funcref.html#sets . That documentation does not tell you that you need to implement
`y > 0 , y*exp(x/y) <= z`
as
`{x,y,z} == exponential(1)`

In your case, the roles of `x` and `y` are reversed from the above. So you could do

``````cvx_begin
variables x y z
minimize(z)
subject to
{y,x,z} == exponential(1)
0 <= y <= 1
cvx_end
``````

I recommend you read CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions . The code I provided above will invoke CVXQUAD’s Pade Approximation, presuming that CXVQUAD and its `exponential.m` replacement are installed per the instructions.

That said, this is a rather boring problem, exactly as stated, because the optimal solution has x = y = z = 0. So presumably, you ultimately want to solve a more interesting problem building on this construct.

Thank you！However,if “<=” is reversed “>=”,what should I do?

You need to make clearrer what your new problem would be. Which `<=` would be reversed to `>=` ?

for the program
“cvx_begin
variables x y z
minimize(z)
subject to {y,x,z} == exponential(1)
0<=y<=1
cvx_end”,

if “minimize(z)” is reversed “maximize(z)”, " `y > 0 , y*exp(x/y) <= z`"is reversed “y > 0 , y*exp(x/y) >= z”, what should I do,how to use the structure of “{y,x,z} == exponential(1)” ?

So do you want to
maximize `x*exp(y/x)`
minimize `x*exp(y/x)` ?

If so, that would be non-convex and cannot be handled with CVX.

Thanks to reply my questions! I understand.

In any event, if the problem you want to solve is maximize `x*exp(y/x)` subject to `0 <= y <= 1, x >= 0`, it is unbounded with the objective function going to infinity as x goes to infinity (with “optimal” y = 1 (or really, any positive value of y)). This must be so because limit as x goes to infinity of `x*exp(1/x)` equals infinity.

I have read the topic you recommend. And I have got how to model the exponential cone constraint.

By the way, in the yalmip, I have used the function “expcone” which is used to model a low-level exponential cone.
And the “exp_cone” herein can be used like the “expcone” ?

Use the syntax in my first post of this thread to specify exponential cone constraint.

The CVX Users’ Guide is somewhat misleading - you can’t directly use `exp_cone` as such . it is handled per my first post.

Yalmip’s syntax for exponential cone constraint is different than CVX’s.