Arithmetic-geometric mean: Difference between revisions
Content added Content deleted
m (elided a doubly linked to URL.) |
m (→{{header|REXX}}: added/changed whitespace and comments.) |
||
Line 2,393: | Line 2,393: | ||
say '2nd # =' b /* " " B " */ |
say '2nd # =' b /* " " B " */ |
||
say ' AGM =' agm(a, b) /* " " AGM " */ |
say ' AGM =' agm(a, b) /* " " AGM " */ |
||
exit |
exit 0 /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
agm: procedure: parse arg x,y; if x=y then return x /*is this an equality case?*/ |
agm: procedure: parse arg x,y; if x=y then return x /*is this an equality case?*/ |
||
Line 2,403: | Line 2,403: | ||
ox= x + 1 /*ensure that the old X ¬= new X. */ |
ox= x + 1 /*ensure that the old X ¬= new X. */ |
||
do while ox\=x & abs(ox)>tiny /*compute until the old X ≡ new X. */ |
do while ox\=x & abs(ox)>tiny /*compute until the old X ≡ new X. */ |
||
ox= x |
ox= x; oy= y /*save the old value of X and Y. */ |
||
oy= y /* " " " " " Y. */ |
|||
x= (ox + oy) * .5 /*compute " new " " X. */ |
x= (ox + oy) * .5 /*compute " new " " X. */ |
||
y= sqrt(ox * oy) /* " " " " " Y. */ |
y= sqrt(ox * oy) /* " " " " " Y. */ |