Created
April 5, 2011 03:07
-
-
Save murven/902954 to your computer and use it in GitHub Desktop.
Leibniz formula for PI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let inverse x = 1.0/x | |
let inverseNext x = 1.0/(x+2.0) | |
let substractNextInverse x = inverse x - inverseNext x | |
let skip4List accuracy = [1.0 .. 4.0 .. accuracy] | |
let add a b = a + b | |
let inverses accuracy = (List.map substractNextInverse (skip4List accuracy)) | |
let PI accuracy = (List.reduce add (inverses accuracy)) * 4.0 | |
let pi10000000 = PI 10000000.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment