Following the terminology of SageMath, let the principal arithmetic-geometric mean, $\operatorname{AGP}$, of $(a,b)\in\mathbb{C}^2$ for $a\ne 0$, $b\ne 0$, $a\ne\pm b$ be defined as follows: $$a_0=a,\, b_0=b,\\ a_{n+1}=\frac{a_n+b_n}{2},\,b_{n+1}=\sqrt{a_n b_n},\\ \operatorname{AGP}(a,b)=\lim_{n\to\infty}a_n=\lim_{n\to\infty} b_n,$$ where at each $b$-iteration, $\sqrt{}$ is chosen such that $\operatorname{Re}b_n\ge 0$ for $n\gt 0$. This corresponds to always taking the so-called "principal square root" (which is usually denoted just by $\sqrt{}$).

Similarly, define the optimal arithmetic-geometric mean, $\operatorname{AGO}$, of $(a,b)\in\mathbb{C}^2$ for $a\ne 0$, $b\ne 0$, $a\ne\pm b$ as follows: $$a_0=a,\, b_0=b,\\ a_{n+1}=\frac{a_n+b_n}{2},\,b_{n+1}=\pm\sqrt{a_n b_n},\\ \operatorname{AGO}(a,b)=\lim_{n\to\infty}a_n=\lim_{n\to\infty} b_n,$$ where at each $b$-iteration, a $+$ or a $-$ sign is chosen such that $|a_n-b_n|\le |a_n+b_n|$ for $n\gt 0$. If $|a_n-b_n|=|a_n+b_n|$, there is an ambiguity, so in case that happens, it is also required that $\operatorname{Im}(b_n/a_n)\gt 0$. Note that the condition which solves the ambiguity if $|a_n-b_n|=|a_n+b_n|$ is either not implemented in the algorithm used in SageMath, or it is implemented but not documented on their official website.

Following the terminology of Cox, a pair of sequences $\{a_n\}_{n=0}^\infty$ and $\{b_n\}_{n=0}^\infty$ is good if $b_{n+1}$ is the right choice for $\pm \sqrt{a_n b_n}$ for all but finitely many $n\ge 0$. The right choice is exactly what $\operatorname{AGO}$ chooses at each $b$-iteration.

Now define the multivalued arithmetic-geometric mean as $$\operatorname{AGM}(a,b)=\lim_{n\to\infty}a_n=\lim_{n\to\infty}b_n$$ whenever $\{a_n\}_{n=0}^\infty$ and $\{b_n\}_{n=0}^\infty$ are good sequences. It is a complex multi-function of two variables which has a countable number of values.

Let $\mathbb{H}=\{\tau\in\mathbb{C}:\,\operatorname{Im}\tau\gt 0\}$ and $$\theta_3 (\tau ,0)=1+2\sum_{n=1}^\infty \mathrm{q}^{n^2}=p (\tau),$$ $$\theta_4 (\tau ,0)=1+2\sum_{n=1}^\infty (-1)^n\mathrm{q}^{n^2}=q (\tau)$$ where $\mathrm{q}=e^{\pi i\tau}$ is the elliptic nome.

An interesting theorem

Cox uses modular functions to prove the following theorem:

Let $|a|\ge |b|$. Then all possible values of $\operatorname{AGM}(a,b)$ are given by $$\frac{1}{\operatorname{AGM}(a,b)}=\frac{d}{\operatorname{AGO}(a,b)}+i\frac{c}{\operatorname{AGO}(a-b,a+b)}$$ where $d$ and $c$ are any relatively prime integers such that $d\equiv 1\pmod 4$ and $c\equiv 0\pmod 4$.

To see the connection between modular functions and $\operatorname{AGM}$, one can observe that $p^2(2\tau)$ is the arithmetic mean of $p^2(\tau)$ and $q^2(\tau)$, and that $q(2\tau)$ is the geometric mean of $p(\tau)$ and $q(\tau)$. Cox's paper explores the connection in greater detail.


There is a non-empty set in $\mathbb{C}^2$ where $\operatorname{AGP}(a,b)=\operatorname{AGO}(a,b)$. What is it exactly?

Some examples: $$\color{green}{\operatorname{AGP}(2+3i,1+i)\approx 1.466+1.871i,}\,\color{green}{\operatorname{AGO}(2+3i,1+i)\approx 1.466+1.871i}$$ $$\color{red}{\operatorname{AGP}(-0.95-0.65i,0.683+0.747i)\approx 0.338-0.0135i,}\,\color{red}{\operatorname{AGO}(-0.95-0.65i,0.683+0.747i)\approx -0.371+0.319i}$$ An example with a $1$ is the following: $\operatorname{AGP}(1,-2-i)\ne\operatorname{AGO}(1,-2-i)$.


$\operatorname{AGO}$ has the nice relation to the values of $\operatorname{AGM}$ in the complex plane, which the $\operatorname{AGP}$ seems to be lacking. The "interesting theorem" produces a multitude of values and it seems pretty hard to distill $\operatorname{AGP}$ from them.

Note also that the homogenity relation $\lambda f(a,b)=f(\lambda a,\lambda b)$ holds for the real arithmetic-geometric mean, but not necessarily for complex $\operatorname{AGP}$. For example, let $a=-0.95-0.65i$ and $b=0.683+0.747i$. Then, curiously, $$a\operatorname{AGP}\left(1,\frac{b}{a}\right)=\operatorname{AGO}(a,b)\ne\operatorname{AGP}(a,b).$$ This is caused by the fact that $w\sqrt{z}=\sqrt{w^2z}$ does not hold for some $w,z\in\mathbb{C}$.

There is also a remarkable connection between $\operatorname{AGO}$ and the hypergeometric function which is taken from Fungrim: Let $(a,b)\in\mathbb{C}^2$ and $a/b\notin (-\infty ,0]$. Then $$\operatorname{AGO}(a,b)=\frac{a+b}{2\, _2\mathrm{F}_1 \left(\frac{1}{2},\frac{1}{2},1,\left(\frac{a-b}{a+b}\right)^2\right)}.$$

Complex plots

Using the color function Complex AGM 1

I made the following plots: Complex AGM 2 The horizontal axis represents $\operatorname{Re}z$ and the vertical axis represents $\operatorname{Im}z$.

A related question.

This question was also asked on MSE.

  • $\begingroup$ @DanieleTampieri: Did you read the question to the very end? :-) $\endgroup$ Mar 13, 2021 at 13:13
  • $\begingroup$ @MateuszKwaśnicki Yep! It seems that I'm missing something 😁. Apologies to everyone! $\endgroup$ Mar 13, 2021 at 13:23
  • 1
    $\begingroup$ Comment about the ambiguity: when I have implemented the AGO, I have resolved the ambiguity using fungrim.org/entry/a2b0f9. It's an arbitrary choice, but it's at least a documented arbitrary choice. $\endgroup$ Mar 14, 2021 at 8:23
  • 1
    $\begingroup$ @FredrikJohansson Thank you for sharing, I couldn't find that on Sage Reference. By the way, I know this is not the best place to discuss this, but I think you have an error here: fungrim.org/entry/93831d. In the numerator, there should be $2^{n+1}$ instead of $2^n$. $\endgroup$
    – Wane
    Mar 14, 2021 at 11:47
  • 2
    $\begingroup$ @Wane Fixed, thanks! $\endgroup$ Mar 15, 2021 at 19:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.