Arithmetic-geometric mean: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed comments and whitespace, used a template for the OUTPUTs..) |
No edit summary |
||
Line 117: | Line 117: | ||
</pre> |
</pre> |
||
=={{header|8th}}== |
|||
<lang 8th>: epsilon 1.0e-12 ; |
|||
with: n |
|||
: iter \ n1 n2 -- n1 n2 |
|||
2dup * sqrt >r + 2 / r> ; |
|||
: agn \ n1 n2 -- n |
|||
repeat iter 2dup epsilon ~= not while! drop ; |
|||
"agn(1, 1/sqrt(2)) = " . 1 1 2 sqrt / agn "%.10f" s:strfmt . cr |
|||
;with |
|||
bye |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
agn(1, 1/sqrt(2)) = 0.8472130848 |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
<lang Ada>with Ada.Text_IO, Ada.Numerics.Generic_Elementary_Functions; |
<lang Ada>with Ada.Text_IO, Ada.Numerics.Generic_Elementary_Functions; |