Talk:Arithmetic-geometric mean

From Rosetta Code
Revision as of 14:15, 7 February 2012 by Nigel Galloway (talk | contribs)

Trivial solution

Asking to compute a single number without specifying the algorithm invites solutions like PRINT .85. Perhaps we want to specify the algorithm, or specify to write some general code that will compute agm for all values of a an b. Is there something special about the function applied to these particular numbers? The C++ example computes many digits of precision. Is this relevant? The Mathworld page is full of interesting stuff about the function. Perhaps we could add a little more interest to the task by taking something from there. —Sonia 19:58, 6 February 2012 (UTC)

It's short but not quite trivial. A trivial solution doesn't work with IEEE doubles as it doesn't manage to get the final ULP to converge (see my notes with the Tcl solution). Still, it's a very rapidly converging function and not difficult to write provided you're not looking for more than about 15 decimal places of precision. I have yet to be convinced that it is worth trying for more accuracy than that (especially as that would require using non-builtin arithmetic). –Donal Fellows 09:54, 7 February 2012 (UTC)
1 / agm(1,sqrt(2)) is Gauss's Constant. Any constant named after someone is important. A constant named after Gauss is the most important constant in the world. If we look at (16) in the reference we can see that it is Pi in disguise. The precision with which you can calculate Pi is then limited by the precision to which you can calculate this, if Pi to 10 decimal places is good enough then okay. It is not necessary to calculate this using the algorithm used in the C++ example. Here Gauss' Constant is calculated to 20,000 places 1 digit at a time http://oeis.org/A014549/b014549.txt.

--Nigel Galloway 14:15, 7 February 2012 (UTC)