# Arithmetic-geometric mean

## Definitions

Symbol: AGM $\operatorname{agm}\!\left(a, b\right)$ Arithmetic-geometric mean
Symbol: AGMSequence $\operatorname{agm}_{n}\!\left(a, b\right)$ Convergents in AGM iteration

## Illustrations

Image: Plot of $\operatorname{agm}\!\left(1, x\right)$ on $x \in \left[-2, 2\right]$
Image: X-ray of $\operatorname{agm}\!\left(1, z\right)$ on $z \in \left[-4, 4\right] + \left[-4, 4\right] i$

## Single parameter

$\operatorname{agm}(z) = \operatorname{agm}\!\left(1, z\right) = \operatorname{agm}\!\left(z, 1\right)$

## Domain

$\left(a \in \mathbb{C} \;\mathbin{\operatorname{and}}\; b \in \mathbb{C}\right) \;\implies\; \operatorname{agm}\!\left(a, b\right) \in \mathbb{C}$
$\left(a \in \left[0, \infty\right) \;\mathbin{\operatorname{and}}\; b \in \left[0, \infty\right)\right) \;\implies\; \operatorname{agm}\!\left(a, b\right) \in \left[0, \infty\right)$
$x \in \mathbb{C} \;\implies\; \operatorname{agm}(x) \in \mathbb{C}$
$x \in \left[0, \infty\right) \;\implies\; \operatorname{agm}(x) \in \left[0, \infty\right)$

## Specific values

$\operatorname{agm}\!\left(0, b\right) = 0$
$\operatorname{agm}\!\left(a, 0\right) = 0$
$\operatorname{agm}\!\left(a, -a\right) = 0$
$\operatorname{agm}\!\left(a, a\right) = a$
$\operatorname{agm}\!\left(1, \sqrt{2}\right) = \frac{2 \sqrt{2} {\pi}^{3 / 2}}{{\left(\Gamma\!\left(\frac{1}{4}\right)\right)}^{2}}$
$\operatorname{agm}\!\left(1, \frac{\sqrt{2}}{2}\right) = \frac{2 {\pi}^{3 / 2}}{{\left(\Gamma\!\left(\frac{1}{4}\right)\right)}^{2}}$
$\operatorname{agm}\!\left(1, 3 + 2 \sqrt{2}\right) = \frac{2 \left(2 + \sqrt{2}\right) {\pi}^{3 / 2}}{{\left(\Gamma\!\left(\frac{1}{4}\right)\right)}^{2}}$
$\operatorname{agm}\!\left(1, 3 - 2 \sqrt{2}\right) = \frac{2 \left(2 - \sqrt{2}\right) {\pi}^{3 / 2}}{{\left(\Gamma\!\left(\frac{1}{4}\right)\right)}^{2}}$
$\operatorname{agm}\!\left(1, i\right) = \frac{\sqrt{2} \left(1 + i\right) {\pi}^{3 / 2}}{{\left(\Gamma\!\left(\frac{1}{4}\right)\right)}^{2}}$
$\operatorname{agm}\!\left(1, -i\right) = \frac{\sqrt{2} \left(1 - i\right) {\pi}^{3 / 2}}{{\left(\Gamma\!\left(\frac{1}{4}\right)\right)}^{2}}$
$\operatorname{agm}\!\left(1, \sqrt{2}\right) = \frac{1}{\theta_{4}^{2}\!\left(0, i\right)}$
$\operatorname{agm}\!\left(1, 1\right) = 1$
$\left[ \frac{d}{d x}\, \operatorname{agm}\!\left(1, x\right) \right]_{x = 1} = \frac{1}{2}$
$\left[ \frac{d^{2}}{{d x}^{2}} \operatorname{agm}\!\left(1, x\right) \right]_{x = 1} = -\frac{1}{8}$
$\left[ \frac{d^{n}}{{d x}^{n}} \operatorname{agm}\!\left(1, x\right) \right]_{x = 1} = \frac{{\left(-1\right)}^{n} n !}{{8}^{n}} \text{A060691}\!\left(n\right)$

## AGM iteration

### Recurrence and limit

$\operatorname{agm}\!\left(a, b\right) = \lim_{n \to \infty} a_{n} = \lim_{n \to \infty} b_{n}\; \text{ where } \left(a_{n}, b_{n}\right) = \operatorname{agm}_{n}\!\left(a, b\right)$
$\operatorname{agm}_{0}\!\left(a, b\right) = \left(a, b\right)$
$\left(a_{n + 1}, b_{n + 1}\right) = \left(\frac{a_{n} + b_{n}}{2}, \sqrt{a_{n} b_{n}}\right)\; \text{ where } \left(a_{k}, b_{k}\right) = \operatorname{agm}_{k}\!\left(a, b\right)$
$2 a_{n + 1} = a_{n} + b_{n} \;\mathbin{\operatorname{and}}\; b_{n + 1}^{2} = a_{n} b_{n}\; \text{ where } \left(a_{k}, b_{k}\right) = \operatorname{agm}_{k}\!\left(a, b\right)$

### Correct square root for complex variables

$\left(a_{n + 1}, b_{n + 1}\right) = \left(x, s y\right)\; \text{ where } x = \frac{a_{n} + b_{n}}{2},\;y = \sqrt{a_{n} b_{n}},\;s = \begin{cases} +1, & y = 0 \;\mathbin{\operatorname{or}}\; \operatorname{Re}\!\left(\frac{x}{y}\right) \ge 0\\-1, & \text{otherwise}\\ \end{cases}\; \text{ where } \left(a_{k}, b_{k}\right) = \operatorname{agm}_{k}\!\left(a, b\right)$

## Brent-Salamin algorithm for pi

$\pi = \frac{4 {\left(\operatorname{agm}\!\left(1, \frac{1}{\sqrt{2}}\right)\right)}^{2}}{1 - \sum_{j=0}^{\infty} {2}^{j} c_{j}^{2}} = \lim_{n \to \infty} \frac{{\left(a_{n} + b_{n}\right)}^{2}}{1 - \sum_{j=0}^{n} {2}^{j} c_{j}^{2}}\; \text{ where } \left(a_{n}, b_{n}\right) = \operatorname{agm}_{n}\!\left(1, \frac{1}{\sqrt{2}}\right),\;c_{n} = a_{n} - b_{n}$
$\left|\pi - \frac{{\left(a_{n} + b_{n}\right)}^{2}}{1 - \sum_{j=0}^{n} {2}^{j} c_{j}^{2}}\right| \le {2}^{n + 8} {e}^{-\pi {2}^{n + 1}}\; \text{ where } \left(a_{n}, b_{n}\right) = \operatorname{agm}_{n}\!\left(1, \frac{1}{\sqrt{2}}\right),\;c_{n} = a_{n} - b_{n}$
${e}^{\pi} = 32 \prod_{n=0}^{\infty} {\left(\frac{a_{n + 1}}{a_{n}}\right)}^{{2}^{1 - n}}\; \text{ where } \left(a_{n}, b_{n}\right) = \operatorname{agm}_{n}\!\left(1, \frac{1}{\sqrt{2}}\right)$

## Functional equations

$\operatorname{agm}\!\left(a, b\right) = \operatorname{agm}\!\left(b, a\right)$
$\operatorname{agm}\!\left(\overline{a}, \overline{b}\right) = \overline{\operatorname{agm}\!\left(a, b\right)}$
$\operatorname{agm}\!\left(-a, -b\right) = -\operatorname{agm}\!\left(a, b\right)$
$\operatorname{agm}\!\left(a, b\right) = a \operatorname{agm}\!\left(1, \frac{b}{a}\right)$
$\operatorname{agm}\!\left(a, b\right) = b \operatorname{agm}\!\left(1, \frac{a}{b}\right)$
$\operatorname{agm}\!\left(c a, c b\right) = c \operatorname{agm}\!\left(a, b\right)$
$\operatorname{agm}\!\left(a, b\right) = \operatorname{agm}\!\left(\frac{a + b}{2}, \sqrt{a b}\right)$
$\operatorname{agm}\!\left(a, b\right) = \operatorname{agm}\!\left(x, s y\right)\; \text{ where } x = \frac{a + b}{2},\;y = \sqrt{a b},\;s = \begin{cases} +1, & y = 0 \;\mathbin{\operatorname{or}}\; \operatorname{Re}\!\left(\frac{x}{y}\right) \ge 0\\-1, & \text{otherwise}\\ \end{cases}$
$\operatorname{agm}\!\left(1, b\right) = b \operatorname{agm}\!\left(1, \frac{1}{b}\right)$
$\operatorname{agm}\!\left(1, b\right) = \frac{b + 1}{2} \operatorname{agm}\!\left(1, \frac{2 \sqrt{b}}{b + 1}\right)$
$\operatorname{agm}\!\left(1 + b, 1 - b\right) = \operatorname{agm}\!\left(1, \sqrt{1 - {b}^{2}}\right)$

## Representation by other functions

$\operatorname{agm}\!\left(a, b\right) = \frac{a + b}{2 \,{}_2F_1\!\left(\frac{1}{2}, \frac{1}{2}, 1, {\left(\frac{a - b}{a + b}\right)}^{2}\right)}$
$\operatorname{agm}\!\left(a, b\right) = \frac{\pi}{4} \frac{a + b}{K\!\left({\left(\frac{a - b}{a + b}\right)}^{2}\right)}$

## Representation of other functions

$K(m) = \frac{\pi}{2 \operatorname{agm}\!\left(1, \sqrt{1 - m}\right)}$
$\log\!\left(\frac{1}{q}\right) = \frac{\pi}{\operatorname{agm}\!\left(\theta_{2}^{2}\!\left(0, q\right), \theta_{3}^{2}\!\left(0, q\right)\right)}$

## Derivatives and differential equations

$\frac{d}{d a}\, \operatorname{agm}\!\left(a, b\right) = \frac{\operatorname{agm}\!\left(a, b\right)}{\pi a \left(a - b\right)} \left(\pi a - 2 \operatorname{agm}\!\left(a, b\right) E\!\left({\left(\frac{a - b}{a + b}\right)}^{2}\right)\right)$
$2 a \left({b}^{2} - {a}^{2}\right) {\left(f'(a)\right)}^{2} - a {\left(f(a)\right)}^{2} + \left(\left(3 {a}^{2} - {b}^{2}\right) f'(a) + a \left({a}^{2} - {b}^{2}\right) f''(a)\right) f(a) = 0\; \text{ where } f(a) = \operatorname{agm}\!\left(a, b\right)$

## Series expansions

$\operatorname{agm}\!\left(1, 1 + x\right) = \sum_{n=0}^{\infty} \frac{\text{A060691}\!\left(n\right)}{{8}^{n}} {\left(-x\right)}^{n}$

## Integral representations

$\operatorname{agm}\!\left(a, b\right) = \frac{\pi}{2 I}\; \text{ where } I = \int_{0}^{\pi / 2} \frac{1}{\sqrt{{a}^{2} \cos^{2}\!\left(x\right) + {b}^{2} \sin^{2}\!\left(x\right)}} \, dx$

## Bounds and inequalities

$\sqrt{a b} \le \operatorname{agm}\!\left(a, b\right) \le \frac{a + b}{2}$
$\left|\operatorname{agm}\!\left(a, b\right)\right| \le \left|\operatorname{agm}\!\left(\left|a\right|, \left|b\right|\right)\right|$
$\left|\operatorname{agm}\!\left(1, z\right) - a_{n}\right| \le \left|a_{n} - b_{n}\right|\; \text{ where } \left(a_{n}, b_{n}\right) = \operatorname{agm}_{n}\!\left(1, z\right)$

Copyright (C) Fredrik Johansson and contributors. Fungrim is provided under the MIT license. The source code is on GitHub.

2021-03-15 19:12:00.328586 UTC