Arithmetic-Geometric Mean Calculator
Compute the AGM of two numbers by iteration, with the step count and limits.
What it does
The arithmetic-geometric mean is the shared limit of two sequences built from a pair of numbers. At each step you take their arithmetic mean and their geometric mean, then repeat with the new pair. The two values close in surprisingly fast.
This tool runs the iteration until the numbers agree to high precision and reports both the limit and the step count. The count is useful because the AGM converges far more quickly than a simple repeated average.
The construction is associated with Gauss and with earlier work on elliptic integrals. It later became the basis of efficient methods for computing pi and related constants, and it gives a clean way to compare two averages that start apart.
Either input may be zero, in which case the AGM is zero. Negative inputs are rejected here because the geometric mean of a negative pair would not be a real number.
How to use
- Enter the first non-negative number.
- Enter the second non-negative number.
- Read the common limit in the main result.
- Check how many iterations were needed to get there.
- Try a wide gap to see how few steps are required.
- Set the inputs equal to confirm the limit is that same number.
Formula
- a(n), b(n)
- The arithmetic and geometric sequences at step n.
- sqrt
- The positive square root.
- AGM(a,b)
- The limit both sequences approach.
The arithmetic sequence decreases and the geometric sequence increases, so the limit stays trapped between them. The gap shrinks by more than half at every step, and in practice the number of agreeing digits roughly doubles. The tool stops when the pair differs by less than 1e-13 or after 200 steps, whichever comes first. Scaling both inputs by the same factor scales the AGM by that factor.
Worked example
Example: AGM of 24 and 6
Inputs a = 24 and b = 6.
- Step 0: the pair is 24 and 6.
- Step 1: arithmetic 15, geometric sqrt(144) = 12.
- Step 2: arithmetic 13.5, geometric sqrt(180) = 13.416408.
- Step 3: arithmetic 13.458204, geometric 13.458139.
- Step 4: both values round to 13.458171.
- Tool reports 13.458171 after 5 iterations.
Reference table
| a | b | AGM(a,b) |
|---|---|---|
| 24 | 6 | 13.458171 |
| 1 | 2 | 1.456791 |
| 1 | 1 | 1 |
| 0 | 5 | 0 |
| 10 | 90 | 39.362355 |
Limits
- Negative inputs are not supported because the geometric mean would be complex.
- Very large numbers are capped to keep the iteration stable.
- The result is limited by double precision, roughly fifteen digits.
- Zero is a valid input but collapses every step to zero.
Common mistakes
- Averaging the starting numbers once and calling that the AGM.
- Expecting linear convergence instead of rapid convergence.
- Using negative inputs and trusting a meaningless result.
- Confusing the AGM with the ordinary arithmetic mean.
- Stopping the loop as soon as the first decimal matches.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is the first step for 24 and 6?
Arithmetic 15 and geometric 12.
What is the AGM of a number with itself?
That number, since both sequences are already equal.
Why does the AGM converge quickly?
The gap shrinks by at least half each step, so matching digits roughly double.
Questions
What is the arithmetic-geometric mean?
The common limit of iterated arithmetic and geometric means.
Who introduced it?
It is associated with Gauss and with work on elliptic integrals.
What is it used for?
Fast computation of pi, elliptic functions, and related constants.
Does it work with zero?
Yes. If either input is zero the AGM is zero.
Can it handle negative numbers?
Not with real square roots, so this tool rejects them.
How many steps are typical?
Often fewer than ten to reach high precision.
Sources
- Encyclopedia of Mathematics: Arithmetic-geometric mean process
- SciPy documentation: scipy.special.agm