# 练习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))

09-06 216
09-18 5551                                                                  08-04 184
11-05 402
08-12 1797
05-28 69
03-13 98
07-03 27
11-13 423
07-09 415
05-28 56
05-28 43
09-02 205
11-12 3597
08-12 61
10-20 37
06-04 1109
08-01 3793
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客