Geometric mean (source code)

= Geometric mean
{title2=$G=(x_1\cdots x_n)^{1/n}$}
{wiki}

The geometric mean replaces a list of nonnegative <real numbers> by one repeated value that preserves their <product of numbers>. For $n\geq1$ inputs,
$$
G=(x_1\cdots x_n)^{1/n},\qquad G^n=x_1\cdots x_n.
$$
For two positive inputs, $G=\sqrt{x_1x_2}$ is their positive <square root>. The <geometric mean> of $1$ and $9$ is three: replacing $1\cdot9$ by $3\cdot3$ retains the same product. In contrast, their <arithmetic mean> five retains the <sum> $1+9=5+5$. The geometric mean is zero if any input is zero; the <logarithm> formula below requires every input to be positive. https://dlmf.nist.gov/1.2.iv[NIST Digital Library of Mathematical Functions, §1.2(iv), equation 1.2.18: geometric mean]{ref}.

Its usefulness becomes immediate for successive <growth factors>. Suppose a hypothetical positive quantity starts at $Q_0=1000$, is multiplied by $3/2$, then by $2/3$. It goes $1000\to1500\to1000$, so the <geometric mean> factor is $\sqrt{(3/2)(2/3)}=1$: a constant factor of one for both steps gives the same endpoint. The <arithmetic mean> factor is $13/12$; repeating it would give $1000(13/12)^2\approx1173.61$, a different endpoint. A mean of factors summarizes multiplicative change; subtracting one afterwards gives the equivalent change per step. Equal-duration steps are necessary to interpret this as change per common time interval.

For positive inputs, <logarithms> turn <multiplication> into <addition>, so
$$
\log G=\frac1n\sum_i\log x_i,\qquad G=\exp\left(\frac1n\sum_i\log x_i\right).
$$
Thus the <geometric mean> is an <arithmetic mean> in logarithmic coordinates, followed by the <exponential function>. For positive measurements with a common unit, one can use dimensionless ratios to a fixed reference $x_0$: $G=x_0\exp(n^{-1}\sum_i\log(x_i/x_0))$. Changing the common unit rescales $G$ by the same factor as the inputs. As a check, doubling one input and halving another retains $G$ while usually changing the <arithmetic mean>.

\Image[/geometric-mean-products-and-log-balance.png]
{title=The <geometric mean> preserves multiplicative endpoints and sits between the <harmonic mean> and <arithmetic mean>}
{description=Left: the original toy factors $3/2$ and $2/3$ return a quantity to its starting value; repeating their <arithmetic mean> would produce a larger endpoint. Right: the dimensionless inputs $e^{-t}$ and $e^t$ keep product one while $H=1/\cosh t$, $G=1$, and $A=\cosh t$ separate as the inputs become less equal. Lines joining time steps are guides, not a continuous growth model.}

The <arithmetic-geometric mean inequality> gives $G\leq A$. Apply that same <inequality> to the <multiplicative inverses> $1/x_i$ to obtain $H\leq G$, where $H$ is the <harmonic mean>. Consequently
$$
\boxed{H\leq G\leq A}
$$
for positive inputs, with equality throughout exactly when all inputs agree. For $30$ and $60$, the three values are $H=40$, $G=30\sqrt2\approx42.4264$, and $A=45$. They preserve, respectively, the sum of inverses, the product, and the sum. No one of these summaries preserves all three for unequal inputs.