Hello,
experimenting with streams I found, by chance, a very simple way to compute the golden ratio. I don't know if it's well known:
(define (improve n) (/ (+ n 1) n))
(define golden-ratio (stream-cons 1 (stream-map improve golden-ratio)))
(displayln (stream->list (stream-take golden-ratio 7)))
; => (1 2 3/2 5/3 8/5 13/8 21/13) here you can see the ratios
; of fibonacci numbers
(displayln (exact->inexact (stream-ref golden-ratio 40)))
; => 1.618033988749895 in less than 40 iterations it's done
; maximum precision reached
The improve
procedure can seem intuitive, but it's interesting to see how it works:
It starts with 3/2 and ends with 5/3.
Matteo