SICP 全笔记

Exercise 1.35. Show that the golden ratio (section 1.2.2) is a fixed point of the transformation x 1 + 1/x, and use this fact to compute by means of the fixed-point procedure.

要证明黄金比率 $\phi$$x \mapsto 1+\frac{1}{x}$ 的不动点,就只需要证明这个点的值代入 $1+\frac{1}{x}$ 之后的结果依然是 $\phi$

我们已经知道了

$$\phi = \frac{1+\sqrt{5}}{2} $$ 代入之后:

$$x = 1 + \frac{1}{x} = 1 + \frac{1}{\frac{1+\sqrt{5}}{2}} = \frac{1+\sqrt{5}}{2} $$ 所以 $\phi$ 是上面公式的不动点。

使用过程 fixed-point 来求这个不动点的值:

(define (fixed-point f first-guess)
  (define tolerance 0.00001)
  (define (close-enough? v1 v2)
    (< (abs (- v1 v2)) tolerance))
  (define (try guess)
    (let ((next (f guess)))
      (if (close-enough? guess next)
          next
          (try next))))
  (try first-guess))

(fixed-point (lambda (x) (+ 1 (/ 1 x))) 1.0)
;Value: 1.6180327868852458