Integrate a function f from a to b
Examples:
(defn f1 [x] 1)
(defn f2 [x] (Math/pow x 2))
(defn f3 [x] (* x (Math/exp (Math/pow x 2))))
(integrate f1 0 5)
(integrate f2 0 1)
(integrate f3 0 1)
;; normal distribution
(def std 1)
(def mu 0)
(defn normal [x]
(/ 1
(* (* std (Math/sqrt (* 2 Math/PI)))
(Math/exp (/ (Math/pow (- (- x mu)) 2)
(* 2 (Math/pow std 2)))))))
(integrate normal 1.96 10)
Reference:
http://jng.imagine27.com/articles/2009-04-09-161839_integral_calculus_in_lambda_calculus_lisp.html
http://iam.elbenshira.com/archives/151_integral-calculus-in-haskell/
Comments top
No comments for integrate. Log in to add a comment.