# 练习1.40-练习1.46

1.练习1.40

(define (cubic a b c)
(define (cube x)
(* x x x))
(lambda (x)
(+ (cube x)
(* a (square x))
(* b x)
c)))


(define (newtons-method g guess)
(fixed-point (newton-transform g) guess))

(newtons-method (cubic 1 0 0) 1)

2.练习1.41

(define (double f)
(lambda (x) (f (f x))))

(((double (double double)) (lambda (x) (+ x 1))) 5)

(double double)展开是(f (f  (f (f x))))

(double (double double))展开是(f’ (f‘ (f’ (f‘ x)))))))，每个f‘为(f (f  (f (f x))))，一共是16个f，所以结果是5+16=21

3.练习1.42

(define (compose f g)
(lambda (x) (f (g x))))
4.练习1.43

(define (repeated f n)
(if (= n 1)
(lambda (x) (f x))
(lambda (x) (f ((repeated f (- n 1)) x)))))
5.练习1.44

(define (smooth f)
(let ((dx 0.0000001))
(lambda (x) (/
(+
(f (- x dx))
(f x)
(f (+ x dx)))
3))))

(((repeated smooth 6) square) 2)
6.练习1.45

(define (average-dump-time n)
(floor (/ (log n) (log 2))))

(define (cifanggen x n)
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
(define (cifang x n)
(product (lambda (i) x)
1
(lambda (i) (+ i 1))
n))
(fixed-point ((repeated average-dump (average-dump-time n)) (lambda (i) (/ x (cifang i (- n 1)))))
n))
7.练习1.46
(define (iterative-improve good-enough? improve)
(lambda (a) (if (good-enough? a (improve a))
(improve a)
((iterative-improve good-enough? improve) (improve a)))))

(define (fixed-point f guess)
(define (good-enough1? a b)
(let ((tolerance 0.000001))
(< (abs (- a b)) tolerance)))
((iterative-improve good-enough1? f) guess))

(define (sqrt n)
(fixed-point (lambda (y) (/ (+ y (/ n y)) 2))
1.0))

04-08
09-06 263
08-04 318
09-18 9832
09-02 973
11-05 544
05-07 351
05-26 229
05-28 93
05-28 104
05-28 73
01-27 3169

### “相关推荐”对你有帮助么？

•  非常没帮助
•  没帮助
•  一般
•  有帮助
•  非常有帮助 被折叠的  条评论 为什么被折叠? 到【灌水乐园】发言 _海阔天空

¥2 ¥4 ¥6 ¥10 ¥20  余额支付 (余额：-- )  扫码支付 获取中  扫码支付 点击重新获取   扫码支付 1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。 余额充值