September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,25 +0,0 @@
(defn van-der-corput
"Get the nth element of the van der Corput sequence."
([n]
;; Default base = 2
(van-der-corput n 2))
([n base]
(let [s (/ 1 base)] ;; A multiplicand to shift to the right of the decimal.
;; We essentially want to reverse the digits of n and put them after the
;; decimal point. So, we repeatedly pull off the lowest digit of n, scale
;; it to the right of the decimal point, and accumulate that.
(loop [sum 0
n n
scale s]
(if (zero? n)
sum ;; Base case: no digits left, so we're done.
(recur (+ sum (* (rem n base) scale)) ;; Accumulate the least digit
(quot n base) ;; Drop a digit of n
(* scale s))))))) ;; Move farther past the decimal
(clojure.pprint/print-table
(cons :base (range 10)) ;; column headings
(for [base (range 2 6)] ;; rows
(into {:base base}
(for [n (range 10)] ;; table entries
[n (van-der-corput n base)]))))

View file

@ -1,6 +0,0 @@
| :base | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|-------+---+-----+-----+-----+------+------+------+-------+-------+-------|
| 2 | 0 | 1/2 | 1/4 | 3/4 | 1/8 | 5/8 | 3/8 | 7/8 | 1/16 | 9/16 |
| 3 | 0 | 1/3 | 2/3 | 1/9 | 4/9 | 7/9 | 2/9 | 5/9 | 8/9 | 1/27 |
| 4 | 0 | 1/4 | 1/2 | 3/4 | 1/16 | 5/16 | 9/16 | 13/16 | 1/8 | 3/8 |
| 5 | 0 | 1/5 | 2/5 | 3/5 | 4/5 | 1/25 | 6/25 | 11/25 | 16/25 | 21/25 |