Chat (Lingr.com)
Informaiton
Daily
Column
- MySQL日本語の旅(5/1)
- アクセス向上秘伝(5/9)
- 一風変ったHaskellλ門(6/13)
- SICP Answer Book (5/31) 問題3.26追加
Zope Solution
Extra
アーカイブ
OSS案内所
Site Info
関連リンク
##(link2sicp "book-Z-H-12.html#%_thm_1.35" "Exercise 1.35")
解答例
x |-> 1 + 1/x の不動点は x = 1 + 1/x すなわち x^2 =- x + 1 の解、すなわち、黄金比である。
(define tolerance 0.00001)
(define (fixed-point f first-guess)
(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))
実行結果
gosh> (fixed-point (lambda (x) (+ 1 (/ 1 x))) 1.0) 1.6180327868852458
コード
##(sicp-answer-code "ex-1.35.scm")