# How to write perspective function of log-sum-exp in cvx?

Hi! Does anyone know how to write the following constraint in cvx?

y * log(sum_i e^(x_i/y)) \leq y*a

where y and x are variables and a is a scalar. It is obviously convex since it is the perspective function of the convex log-sum-exp. I know you can write the log-sum-exp as an exponential cone, but I cannot seem to figure out how to write it for this form. I would really appreciate the help!

<Comment withdrawn due to misreading * as ^ in RHS>

ay is right? where a is a real number. So I consider the constraint

y * (log(sum_i e^(x_i/y)) - a) \leq 0

<Comment withdrawn due to misreading * as ^ in RHS>

So I consider the constraint

y * (log(sum_i e^(x_i/y)) - a) \leq 0

It is the sum of two convex functions which is convex. So y*log(sum_i e^(x_i/y)) is the perspective function of log(sum_i e^(x_i)).

<Comment withdrawn due to misreading * as ^ in RHS>

<Comment withdrawn due to misreading * as ^ in RHS>

So you say that the following constraint is not convex:

y * log(sum_i e^(x_i/y)) - 2y \leq 0 ?

I withdraw all my comments. I misread the RHS as y^a, not as y*a.

No problem! I already thought there was a misunderstanding. Do you have any idea how to do it for y*a?

Here is an idea:

y * log(sum_i e^(x_i/y)) - ay \leq 0

is equivalent to

b - ay <= 0
b >= y*log(sum_i e^(x_i/y))

which is equivalent to

b - ay <= 0
y >= sum_i z_i
(z_i, y, (x_i -b)) \in exponential cone for i = 1,…,n

Is this correct?

Incorrect comment withdrawn>

If you can model a function then you can model its perspective using the same cone types. This is in https://docs.mosek.com/modeling-cookbook/practical.html#perspective-functions where there is also an example with log-sum-exp.

Thank you very much! It looks like my idea is correct since it gives the right answers after implementation.