Created
November 25, 2010 07:36
-
-
Save abscondment/715040 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
(use '(incanter core charts io latex)) | |
(defn stirling [#^Integer n] | |
(* (Math/sqrt (* 2 n Math/PI)) | |
(Math/pow n n) | |
(Math/pow Math/E (* -1 n)))) | |
(defn fact [#^Integer n] | |
(reduce * (range 2 (inc n)))) | |
(let [n-vals (range 5 1000)] | |
(view | |
(xy-plot n-vals | |
(map #(- (/ (fact %) (stirling %)) 1.0) n-vals) | |
:x-label "n" | |
:y-label "factorial(n)/stirling(n) - 1"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment