Arithmetic-geometric mean: Difference between revisions

→‎{{header|Raku}}: another solution
(→‎{{header|Raku}}: another solution)
Line 2,853:
 
say agm 1, 1/sqrt 2;</syntaxhighlight>
 
We can also get a bit fancy and use a converging sequence of complex numbers:
 
<syntaxhighlight lang=raku>sub agm {
($^z, {(.re+.im)/2 + (.re*.im).sqrt*1i} ... * ≅ *)
.tail.re
}
say agm 1 + 1i/2.sqrt</syntaxhighlight>
 
=={{header|Raven}}==
1,934

edits