(def e (map (fn [i] (apply + (map (comp / factorial) (range i)))) (range)))
You can evaluate this sequence into:
(0 1 2 5/2 8/3 65/24 163/60 1957/720 ...)
In this way we will provide us with an approximation for e. Here are some additional sequences:
(def pi (infinite-series (fn [n] (/ (* 4 (Math/pow -1 n)) (+ (* 2 n) 1))))) (def golden-ratio (map (fn [i] (/ (nth fib (inc i)) (nth fib i))) (rest (range))))
These should make for relatively good approximations of these irrational numbers.
No comments:
Post a Comment