Skip to content

Instantly share code, notes, and snippets.

@timo
Forked from grondilu/agm.p6
Created January 18, 2014 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timo/8489532 to your computer and use it in GitHub Desktop.
Save timo/8489532 to your computer and use it in GitHub Desktop.
sub agm( $a is copy, $g is copy ) {
($a, $g) = ($a + $g)/2, sqrt $a * $g
until abs($a - $g) < 0.000001;
return $a;
}
say agm 1, 1/sqrt 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment