Last active
January 3, 2016 20:29
-
-
Save cohalz/8515021 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 integral f a b = | |
let n = 10000.0 in | |
let delta = (b -. a) /. n in | |
let rec approx f a b i sum = | |
if i > n then sum else (approx f) a b (i +. 1.0) (sum +. (((f(a +. (i -. 1.0) *. delta) +. f(a +. i *. delta)) *. delta) /. 2.0)) in | |
(approx f) a b 1.0 0.0 | |
integral sin 0.0 3.14159265359 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment