Arithmetic-geometric mean: Difference between revisions
Content added Content deleted
(→{{header|Raku}}: another solution) |
|||
Line 2,853: | Line 2,853: | ||
say agm 1, 1/sqrt 2;</syntaxhighlight> |
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}}== |
=={{header|Raven}}== |