# Rel_entr and log-sum-exp function question

Does anyone have any idea about writing this line of code in MATLAB?

-(1-\beta)*log_2(\sum^K_{i=k+1}h_i*2^{\frac{z_i}{1-\beta}}+W)>constant

where \beta and z_i are optimization variables. This is a convex constraint which comes from the fact that the log-sum-exp function is convex and (1-\beta)*2^{\frac{z_i}{1-\beta}} is also a convex function with respect to \beta and z_i (by using the perspective function)

Also, I have trouble in writing the following constraint:
(1-\beta)*2^{\frac{z_i}{1-\beta}}<=\text{affine} which its perspective function is the convex function 2^{z_i}.

Thank you so much for your help!

I’m not sure about your “proof”, but I think (but haven’t proven) the 1st constraint is convex, presuming 1 - beta > 0 and h(i) >= 0. But it would appear no one knows how to formulate that for CVX (f someone does, please post).

Again presuming 1 - beta > 0, the 2nd constraint can be handled with exponential cone constraint, after changing from base 2 to base e.

variable z
{log(2)*x(i),1-beta,z} == exponential(1)
z <= affine

Hi @shayan66,

\begin{array}{l} r \log( \sum_i h_i \exp( z_i / r) + W) \leq t\\ \Longleftrightarrow \sum_i h_i \exp( z_i / r) + W \leq \exp( t/r )\\ \Longleftrightarrow \sum_i h_i \exp( \frac{z_i-t}{r}) + W \exp( \frac{-t}{r} ) \leq 1\\ \Longleftrightarrow \sum_i h_i r \exp( \frac{z_i-t}{r}) + W r \exp( \frac{-t}{r} ) \leq r\\ \Longleftrightarrow \sum_i h_i u_i + W v \leq r,\quad r \exp( \frac{z_i-t}{r}) \leq u_i,\quad r \exp(\frac{-t}{r} ) \leq v \end{array}

assuming r \geq 0, h_i \geq 0 and W \geq 0. This works with any logarithmic/exponential pair of functions, e.g., base 2 where \log(\cdot) and \exp(\cdot) are changed to \log_2(\cdot) and 2^{(\cdot)}.

To apply it to your question, just substitute r = 1 - \theta and switch to base 2 (that is, r 2^{\frac{z_i - t}{r}} \leq u_i and r 2^{\frac{- t}{r}} \leq v) which @Mark_L_Stone told you how to formulate.

1 Like