Algosim documentation: HarmonicMean

HarmonicMean

Computes the harmonic mean of all elements in a container or in a sequence. The elements must be numbers.

Syntax

Description

Computing the mean of a container

If X is a non-empty container of numbers, then HarmonicMean(X) is the harmonic mean of all elements in X.

The following container types are supported:

Typewise, the elements may be either real or complex, and the result is complex iff at least one of the elements is complex.

Computing the mean of a sequence

HarmonicMean(expr, var, a, b) computes the harmonic mean of the expression expr in one variable var as var takes all integer values from a to b (inclusively).

expr must return a number.

Examples

Computing the mean of a container

HarmonicMean(❨5, 1, 2, 6, 3, 8, 4, 10, 2, 3❩)
2.85035629454	(=1200/421)

Computing the mean of a sequence

HarmonicMean(n^2 + 3⋅n + 1, n, 1, 100)
186.411917683

See also