R/exports.R
harmonic_mean.Rd
The harmonic mean, \(\left(\frac{1}{n} \sum_{i=1}^n x_i^{-1}\right)^{-1}\). For a matrix, the function is applied over all entries.
harmonic_mean(x)
An Expression, vector, or matrix.
An Expression representing the harmonic mean of the input.
x <- Variable() prob <- Problem(Maximize(harmonic_mean(x)), list(x >= 0, x <= 5)) result <- solve(prob) result$value #> [1] 5 result$getValue(x) #> [1] 5