Arithmetic-Geometric Mean Calculator
Introduction
The arithmetic-geometric mean, usually shortened to AGM, starts with two positive numbers and repeatedly blends them in two different ways. One update uses the ordinary average, and the other uses the geometric mean. At first that sounds like a small numerical trick, but it turns into a surprisingly powerful process. When you continue the iteration, the two running values rush toward the same limit. That common limit is called the arithmetic-geometric mean of the original pair, and it often appears after only a handful of rounds.
For two positive starting values and , the arithmetic mean is , while the geometric mean is . Gauss discovered that if you repeatedly replace the first value by the arithmetic mean and the second value by the geometric mean, the resulting sequences do not wander around randomly. Instead, they collapse onto the same number with exceptional speed. That fast convergence is why the AGM shows up in serious numerical work, not just classroom exercises.
This calculator is designed to make that idea concrete. Enter any two positive real numbers, and the page will iterate until the arithmetic and geometric tracks become practically indistinguishable within a small tolerance. The result is useful on its own as a special mean, but it also opens the door to deeper mathematics involving elliptic integrals, high-precision algorithms, and elegant identities that connect simple averages to advanced analysis.
How to Use
Using the tool is straightforward. Type a positive starting value into the first field labeled First Value a₀ and another positive starting value into Second Value b₀. Decimal inputs are welcome, so you can test ordinary examples such as 24 and 6, very close pairs such as 1 and 1.01, or dramatically different values such as 1 and 1000. After you press Compute AGM, the calculator performs the iteration and reports the shared limit, the number of iterations needed, and the final gap between the two sequences.
If the result interests you for later comparison, the Copy Result button appears after a successful calculation. That copied summary is handy when you are comparing several starting pairs, building class notes, or keeping a quick record of how the convergence speed changes as the ratio between the initial values changes. In general, pairs that begin close together converge almost immediately, while pairs with a wider starting ratio need more rounds, though still not many.
A good way to explore the behavior is to run the calculator several times with the same scale but different ratios. For example, compare 10 and 9, then 10 and 5, then 10 and 1. You will notice an important pattern: the AGM is not simply halfway between the two values, and it is not identical to the geometric mean either. It lies between them, but the iteration keeps refining that middle ground until both running values settle on one shared number.
- Enter two positive numbers. Zero and negative values are rejected because the geometric mean step must stay in the positive real numbers for this calculator.
- Click Compute AGM to run the iteration until the difference is below the tolerance or the safety cap on iterations is reached.
- Read the final mean, the iteration count, and the final absolute difference to judge how rapidly the pair converged.
Formula
To outline the procedure explicitly, let and denote the initial values. The next arithmetic term is , and the next geometric term is . Iterating these definitions yields and , and both sequences share a common limit called . In the limit, the two tracks meet so that for large .
The calculator implements exactly that loop. After checking that the starting values are valid, it updates the pair until the absolute difference becomes smaller than a tiny tolerance. Here the threshold is , which is much smaller than the scale of typical inputs. Each round needs only a few operations: one arithmetic average and one square root. Even so, the convergence is so strong that the algorithm usually finishes in very few steps.
The limit produced by this process obeys interesting identities. For instance, if you define the complementary modulus , then the complete elliptic integral can be expressed as . This is one reason the AGM matters beyond a single calculator page: the same iteration that feels simple here becomes a practical engine for fast evaluation of important special functions.
| Iteration | an | bn | |an − bn| |
|---|---|---|---|
| 0 | 1.000000 | 0.250000 | 0.750000 |
| 1 | 0.625000 | 0.500000 | 0.125000 |
| 2 | 0.562500 | 0.559017 | 0.003483 |
| 3 | 0.560758 | 0.560756 | 0.000002 |
The shrinking difference column is the important story. After only a few passes, the arithmetic track and the geometric track are nearly identical. In plain language, the iteration keeps pulling the larger value downward and the smaller value upward, but it does so in a balanced way that avoids the instability of many more complicated numerical methods. That blend of simplicity and speed is exactly what makes the AGM memorable.
Properties Worth Noticing
Several compact facts make the AGM easier to reason about. First, the construction is symmetric: swapping the starting values never changes the answer, so . Second, the process respects a common positive scale factor, which means . Third, if the pair is already balanced, the iteration is finished from the start because . These properties explain why test cases behave predictably when you swap or rescale inputs.
It is also useful to know where the limit sits during the computation. At every stage, the shared limit stays trapped between the current terms, so . The updates keep repeating in the same form, namely and . As the loop continues, the difference collapses, so , and the ratio approaches equality, so . In practical terms, that is exactly why the output can stop after only a few iterations without sacrificing meaningful accuracy.
Worked Example
Suppose you start with and . The first arithmetic mean is , while the first geometric mean is . The next iteration uses and to get and about . After only a few more steps, both values settle near . When you enter the same pair into the calculator, you can watch that convergence happen numerically instead of just reading about it.
This example also helps with interpretation. The AGM is smaller than the initial arithmetic mean of 15 because the geometric step pulls the larger value down more aggressively than a simple midpoint would. At the same time, it is larger than the initial geometric mean of 12 because the arithmetic step pulls the smaller value up. The final answer therefore sits between the classical means while reflecting the iterative balance between them.
If you try a much closer pair, such as 8 and 7.9, you will see the same logic compressed into almost no time at all. The arithmetic average and geometric average are already close, so each update makes only a tiny correction before the pair becomes essentially equal. If you try a much wider pair, such as 100 and 1, the early steps are dramatic because the arithmetic update and geometric update begin far apart. Even then, the method remains stable and quickly settles into agreement. This is one of the main reasons the AGM feels so elegant in practice: it behaves gently when inputs are close and efficiently when they are far apart.
Historical Background
Carl Friedrich Gauss studied the AGM in the early nineteenth century during his work on modular functions and elliptic integrals. Although his notes on the subject were not immediately published, later mathematicians recognized that he had uncovered an iteration of unusual elegance. A process that begins with little more than averaging and square roots turns out to compress difficult calculations into a short sequence of rapidly improving estimates.
One striking application is the high-precision calculation of the constant . Through formulas related to elliptic integrals and the geometry of ellipses, mathematicians such as Salamin and Brent developed AGM-based algorithms whose accuracy grows extraordinarily fast. Instead of gaining a small number of digits per step, these methods can roughly double the number of correct digits each round. That is a dramatic advantage over many classical series expansions.
The broader lesson is that numerical mathematics often rewards the right reformulation more than raw computational force. The AGM does not succeed because it performs a huge number of operations. It succeeds because it transforms a difficult question into a short sequence of particularly informative updates. The calculator on this page captures that spirit in a simple form: a basic loop, carefully interpreted, can reveal a powerful mathematical structure.
Limitations and Assumptions
This calculator assumes you are working with positive real numbers. That restriction is not arbitrary. In the real-number setting, the geometric mean step is clean and meaningful only when the product remains nonnegative, and this page is intentionally focused on the standard positive-input version of the AGM. If you need complex-number variants or symbolic transformations, you would need a more specialized mathematical tool.
The output is also numerical rather than exact. Internally, the page uses ordinary floating-point arithmetic and stops when the running difference is smaller than a preset tolerance or when a maximum iteration count is reached for safety. That is exactly what most users want in practice, but it means the result is an approximation, not a formal proof object. For almost all everyday inputs, the approximation is excellent, and the final displayed difference gives you a direct sense of that accuracy.
There is one more interpretive limitation worth remembering: the AGM is not a universal replacement for other means. If you need the plain average of measurements, the arithmetic mean is still the correct statistic. If you are combining growth factors or ratios, the geometric mean often remains the more natural tool. The AGM is special because it emerges from an iteration between those two ideas. It is especially valuable when that iteration itself matters, or when you are studying the analytic structures connected to it.
Broader Mathematical Connections
The AGM is part of a larger family of mean iterations. Mathematicians often ask what happens when two or more averaging rules are repeatedly composed. Some pairs behave badly, some converge slowly, and some approach different limits depending on the setup. The arithmetic and geometric means, however, form a particularly elegant partnership. Their iteration is stable, symmetric, and astonishingly fast. That combination helps explain why the AGM appears so often in advanced computation.
Beyond numerical algorithms, the AGM touches modular forms, complex analysis, and the geometry of tori. Those topics go well beyond the scope of this page, yet they point to a recurring mathematical lesson: a simple-looking computational rule can encode unexpectedly deep structure. The AGM is a beautiful example of that lesson because you can appreciate it at two levels at once. At a practical level, it is a fast calculator routine. At a theoretical level, it is a gateway into rich parts of analysis and number theory.
Another practical connection is software design. The AGM is a good example of an algorithm whose stopping rule matters almost as much as its update rule. You need a clear tolerance, a clear interpretation of the final gap, and a safety limit in case something unusual happens numerically. Those are the same ideas that appear in many calculators, scientific programs, and engineering workflows: define a stable iteration, measure the residual, and stop when the result is good enough for the task at hand.
Documenting Convergence
When you run several examples, the Copy Result button makes it easy to keep a small convergence log. Recording the final mean, the iteration count, and the starting ratio helps you see patterns more clearly. You can compare close pairs with widely separated pairs, test scale changes, and build intuition for how little time the AGM usually needs to settle.
A simple notebook exercise can make the page even more useful. Try choosing one fixed first input, such as 10, and pair it with 9, 7, 5, 2, and 1. Write down the AGM result and the number of iterations reported each time. You will see that the absolute scale of the numbers matters less than their relationship. In many cases, the ratio between the starting values tells you more about the convergence pattern than the raw magnitudes alone. That observation is not merely anecdotal; it reflects the way the arithmetic and geometric updates respond to imbalance.
Continue exploring related topics with the Harmonic Mean Calculator, the Arithmetic Series Calculator, and the Geometric Series Calculator.
AGM Convergence Mini-Game
This optional mini-game turns the same iteration into a fast reflex and judgment challenge. Each lane contains a pair of values represented by two glowing nodes. Click or tap a lane to send one AGM pulse through the front pair in that lane. The pulse replaces the pair with its arithmetic and geometric means, which moves the nodes closer together. Your goal is to make each pair converge before it reaches the bottom convergence line. Wide ratios need more pulses, tight ratios need fewer, and later waves spawn faster pairs to keep the run lively.
Educational idea behind the game: the farther apart two positive starting values begin, the more AGM iterations they usually need before the arithmetic and geometric tracks are nearly the same.
