标签:style os ar sp line on new size ef
解:1.37
(define tolerance 0.00001) (define (average x y) (/ (+ x y) 2.0)) (define (fixed-point f first-guess) (define (close-enought? v1 v2) (< (abs (- v1 v2)) tolerance)) (define (try guess) (display guess) (newline) (let ((next (f guess))) (if (close-enought? guess next) next (try next)))) (try first-guess)) (define (cont-frac n d k) (define (calc i) (if (> i k) 0 (/ (n i) (+ (d i) (calc (+ i 1)))))) (calc 1)) (define (cont-frac-iter n d k) (define (calc i result) (if (= i 0) result (calc (- i 1) (/ (n i) (+ (d i) result))))) (calc k 0))
1.38
(define (calc-e k) (define (d i) (let ((r (remainder i 3))) (if (or (= r 0) (= r 1)) 1 (+ 2 (* (floor (/ i 3)) 2))))) (+ 2 (cont-frac-iter (lambda (x) 1.0) d k)))
1.39
N函数要注意另上负号
(define (tan-cf x k) (define (n i) (if (= i 1) x (- (* x x)))) (define (d i) (- (* 2 i) 1)) (cont-frac-iter n d k))
标签:style os ar sp line on new size ef
原文地址:http://my.oschina.net/u/1445655/blog/307427