## Tuesday, October 4, 2011

### Implementing cauchy sequences

I have decided to work on constructing some of the computable numbers using cauchy sequences. Generally, this is as simple as mapping over the counting numbers. Here is a construction of e:

(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.