# 练习1.40-练习1.46

16 篇文章 0 订阅
15 篇文章 0 订阅

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))

• 0
点赞
• 0
收藏
觉得还不错? 一键收藏
• 打赏
• 0
评论
07-01
01-08 656
01-06 625
02-07 609
01-20 602
01-07 585
01-20 578
01-22 576
01-20 564
01-17 558
01-23 556
01-15 549
01-10 523
01-14 486

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

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

_海阔天空

¥1 ¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。