# How to express this convex function in CVX： **y·ln( 1-exp(-x/y) )**?

I want to express this convex function: y·ln( 1-exp(-x/y) ) in CVX. However, directly writing it is not working, since x/y is {real affine}/{real affine}.

That is neither convex nor concave. For instance, at x = y = 1, its Hessian has one positive and one negative eigenvalue. (And there is nothing special about that point from a Hessian indefiniteness standpoint.)

Edit: ignore the above. I misread * as -

But, it should be the perspective function of log(1 - exp(-x)), right? When x>0, I checked the plot of log(1 - exp(-x)), and it is concave. If so, the function y·ln( 1-exp(-x/y) ) should also be concave. I’m not sure if that make sense.

Sorry. I misread the * as -

Do you know how to express this perspective function in CVX?

Actually, y*log(1-exp(-x/y)) is concave. it is the negative of the perspective of the convex function -log(1-exp(-x)).

-log(1-exp(-x)) is directly accepted by CVX (because it is log of concave argument). So follow the directions for formulating its perspective at “7.1.1 Perspective functions” of https://docs.mosek.com/modeling-cookbook/practical.html#conic-reformulations#Perspective_functions

Thank you very much, Mark. I found another way to represent the function, so I don’t have to tackle the perspective function anymore

Perhaps you’d like to tell us what that other way is?

actually it is not related to the perspective function, but I can also provide it in case someone else has similar problem.
Primal function: \prod_i s_{i}\cdot \left(1-e^{-d_i}\right) \leq \text{constant}, where s is a binary variable.
I’ve done the problem transformation: \ln\prod_i s_{i}\cdot \left(1-e^{-d_i}\right) \leq \ln\text{constant}, turns to: \sum_i \ln s_{i}\cdot \left(1-e^{-d_i}\right)\leq \ln\text{constant}, in order to turn \ln s_{i}\cdot \left(1-e^{-d_i}\right) into concave, I changed the optimization variable d_i into \tilde{d}_i=d_i\cdot s_i. Then, we get \sum_i \ln s_{i}\cdot \left(1-e^{-\frac{\tilde{d}_i}{s_i}}\right)\leq\ln\text{constant}.
Although it turns to be concave, it is hard to be expressed in CVX.
There is a much easier to transform this problem. After taking logarithm of both side of primal function, we can also get: \sum_i \ln s_i + \sum_i \ln(1-e^{-d_i}) \leq \ln \text{constant}. The LHS of this equation is concave, and it can be directly accepted by CVX.
However, there is another question: can \text{concave function} \leq \text{constant} be accepted by CVX?

Question: Can concave function≤constant be accepted by CVX?
Answer: No. That is a non-convex constraint.

Will CVX accept none of the concave functions? even if log(x) <= C?

That is a non-convex constraint. Maybe you need to study https://web.stanford.edu/~boyd/cvxbook/

However, in that particular case, it is geometrically convex, and you could use x <= exp(C) instead, presuming C is s constant. But CVX will not do that for you automatically.

If so, does it mean that convex_function >= C is also nonconvex?

Yes, it does. …