# 如何编写xlog（1+y/x）

This is an English language forum. Please use an online translator (for instance, Google Translate ](https://translate.google.com/) is necessary.

In any event,
`-rel_entr(x,x+y)'` can be used in CVX, and equals s*log(1+y/x).

One or both of `x` an d `y` can be vectors of the same dimension, in which case `sum(-rel_entr(x,x+y)`’ can be used in CVX to sum `x(i)*log(1+y(i)/x(i))`

As per the help below, `x` must be affine. `y` must be concave (`y` being affine is o.k., because affine is a special case of concave).

`help rel_entr

rel_entr Scalar relative entropy.
rel_entr(X,Y) returns an array of the same size as X+Y with the
relative entropy function applied to each element:
{ X.*LOG(X./Y) if X > 0 & Y > 0,
rel_entr(X,Y) = { 0 if X == 0 & Y >= 0,
{ +Inf otherwise.
X and Y must either be the same size, or one must be a scalar. If X and
Y are vectors, then SUM(rel_entr(X,Y)) returns their relative entropy.
If they are PDFs (that is, if X>=0, Y>=0, SUM(X)==1, SUM(Y)==1) then
this is equal to their Kullback-Liebler divergence SUM(KL_DIV(X,Y)).
-SUM(rel_entr(X,1)) returns the entropy of X.

``````Disciplined convex programming information:
rel_entr(X,Y) is convex in both X and Y, nonmonotonic in X, and
nonincreasing in Y. Thus when used in CVX expressions, X must be
real and affine and Y must be concave. The use of rel_entr(X,Y) in
an objective or constraint will effectively constrain both X and Y