Talk:Arithmetic-geometric mean

From Rosetta Code
Revision as of 20:48, 9 February 2012 by Sonia (talk | contribs) (''ubiquitous'' constant)

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)
That was one of the most amazing paragraph to have ever graced RC, where except the first and the last, every sentence is wrong to some extent, and it was written sincerely (as far as I can tell). For one thing, who's to rate which constant is more important than others? π is named after Archimedes, e is named after Euler, not to mention stuff like 0 an 1 are so fundamental that they didn't even get the chance to be named after anybody. And how is Gauss's Constant "π in disguise"? Since we don't know if π and e are independent, your (16) in the reference isn't really all that helpful in establishing a crucial connection between π and Gauss's Constant, so it's not sensical to say "precision with which you can calculate Pi is then limited by ... this". It's fine to have a task to calculate the constant, but you don't need to hype it up all over the place. --Ledrug 17:59, 7 February 2012 (UTC)
Thank you for your interest, but why so angry? I was asked why 1 and 1/sqrt(2) and why so many digits? The answer is my sincere reason for choosing those numbers and so many digits. Surely π and e are related by Eulers formula (see:http://mathworld.wolfram.com/EulerFormula.html) which he did discover, unlike the constant named in his honour but discoverd by the 8th Laird of Merchistoun, John Napier. I have added http://rosettacode.org/wiki/Pi#C.2B.2B which I hope will help you to understand the raltionship between agm(1,1/sqrt(2)) and Pi, and hence why the accuracy with which this task can be computed limits the accuracy with which Pi can be computed using this method. Incidently it is debatable whether 0 is even a number let alone an important constant, more of a nuiscence really.--Nigel Galloway 12:44, 9 February 2012 (UTC)
The main problem I have with the description as it is is that it is too vague for the goal of finding the value of a constant. If the task goal is to give that value then it's pretty trivial to just calculate it offline (or look it up) and print it as text straight up. If the task goal is to calculate a general arithmetic-geometric mean then it needs a rename and I would suggest using different numbers. It would be nice to have smaller-precision values so that languages with no arbitrary precision libraries can participate. --Mwn3d 18:17, 7 February 2012 (UTC)
I've rewritten the task description to make the focus be on the agm function, with the application to computing agm(1,2**-0.5) being just an application of it. I've also linked things into Wikipedia, as that's a little more accessible than Mathworld. (I'll rename the task in a moment or two.) I'll not tackle whether that is the right value to calculate; for me, the interesting thing is computing a value using a (pair of) converging sequence(s). –Donal Fellows 10:14, 8 February 2012 (UTC)

Are people missing that the number specified is not Gauss's? agm(1, 1/sqrt(2)) is about .85 and Gauss's, 1/agm(1, sqrt(2)) is about .83. Either way, I'll clarify that I think a task to compute a constant should a) specify an algorithm to be used, and b) specify the precision to be obtained. —Sonia 19:07, 7 February 2012 (UTC)

+1 on a and b. --Mwn3d 19:11, 7 February 2012 (UTC)

Of possible interest: [1]Sonia 20:48, 9 February 2012 (UTC)