/* NetRexx */ options replace format comments java crossref symbols nobinary numeric digits 18 parse arg a_ g_ . if a_ = '' | a_ = '.' then a0 = 1 else a0 = a_ if g_ = '' | g_ = '.' then g0 = 1 / Math.sqrt(2) else g0 = g_ say agm(a0, g0) return -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method agm(a0, g0) public static returns Rexx a1 = a0 g1 = g0 loop while (a1 - g1).abs() >= Math.pow(10, -14) temp = (a1 + g1) / 2 g1 = Math.sqrt(a1 * g1) a1 = temp end return a1 + 0