若 φ=0 , 则 φ^2=φ+1 不成立 , 故 φ≠0
φ^2 = φ+1 ==>
φ = (φ+1)/φ = 1 + (1/φ)
(fixed-point (lambda(x) (+ 1 (/ 1 x))) 1.0)
1.36
(define tolerance 0.00001)
(define (fixed-point f first-guess)
(define (close-enough? x y)
(< (abs (- x y)) tolerance))
(define (try guess)
(let ((next (f guess)))
(display next)
(newline)
(if (close-enough? guess next)
next
(try next))))
(try first-guess))
平均阻尼法和不用平均阻尼分别如下,它们步数分别为 9 和 34 。
(fixed-point (lambda(x) (/ (+ x (/ (log 1000) (log x))) 2)) 2.0)
(fixed-point (lambda(x) (/ (log 1000) (log x))) 2.0)
1.37
(define (cont-frac-r n d k)
(define (redu i)
(if (= i k)
(/ (n i) (d i))
(/ (n i) (+ (d i) (redu n d (+ i 1))))))
(redu 1))
(define (cont-frac n d k)
(define (iter i result)
(if (= i 0)
result
(iter (- i 1) (/ (n i) (+ (d i) result)))))
(iter k 0))
(define (get-phai k)
(/ 1 (cont-frac (lambda(i) 1.0) (lambda(i) 1.0) k)))
(define (get-k)
(define (iter i)
(if (< (abs (- (get-phai i) 1.6180)) 0.00005)
i
(iter (+ i 1))))
(iter 1))
k = 11 时,精度满足 4 位 十进制数。
1.38
(define (euler-d i)
(cond ((= i 2) 2.0)
((and (> i 2) (= 0 (remainder (- i 2) 3)))
(* (/ (+ i 1) 3.0) 2.0))
(else 1.0)))
(define (get-e k)
(+ 2 (cont-frac (lambda(i) 1.0) euler-d k)))
1.39
(define (tan-cf x k)
(define (tan-n i)
(if (= 1 i)
x
(- (* x x))))
(cont-frac tan-n (lambda(i) (- (* i 2.0) 1.0)) k))