# Harmonic mean not defined in CVX

(Liang Liu) #1

Harmonic mean g(x)=(\sum\limits_{i=1}^K\frac{1}{x_i})^{-1} is concave over x. Now my function is h(g(x)) where h(x) is concave and non-decreasing over x, According to composition rule, h(g(x)) is a concave function. But I do not know how to let CVX accept this function, since it seems that Harmonic mean is not defined in CVX. Is there any way that I can maximize h(g(x)) in CVX? Thanks.

(Mark L. Stone) #2

Note that the harmonic mean is concave when all x_i are positive, but may be convex or indefinite if one or more x_i’s are negative.

In any event, see Harmonic mean in cvx . I don’t think the situation has changed subsequent to the answer provided there. Of course, use of inv_pos in effects forces the arguments to be positive, thereby achieving 1/“harmoinc mean” to be convex. I will defer to others on any further elaboration.

(Mark L. Stone) #3

@eceopt See the solution with harm_mean defined by @wmkoolen in Harmonic mean in cvx .

I tried and successfully used log(harm_mean(x)) and sqrt(harm_mean(x)) .

(Liang Liu) #4