1 (require
"sicp_2.7-2.11.rkt")
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2.12
3 (define (make-center-
width c w)
4 (make-interval (- c w) (+
c w)))
5
6 (define (make-center-
percent c p)
7 (let ((width (* c (/ p
100))))
8 (make-interval (- c width) (+
c width))))
9
10 (define (center i)
11 (/ (+ (lower-bound i) (upper-bound i))
2))
12
13 (define (percent i)
14 (*
100 (abs (/ (width-
interval i) (center i)))))
15
16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2.14
17 (define (par1 r1 r2)
18 (div-interval (mul-
interval r1 r2)
19 (add-
interval r1 r2)))
20
21 (define (par2 r1 r2)
22 (let ((one (make-interval
1 1)))
23 (div-
interval one
24 (add-interval (div-
interval one r1)
25 (div-
interval one r2)))))
26
27 (define inter1 (make-center-percent
2 50))
28 (define inter2 (make-center-percent
4 50))
29 (define A (make-center-percent
2 0.0004))
30 (define B (make-center-percent
4 0.0004))
31
32 (par1 inter1 inter2)
33 (par2 inter1 inter2)
34
35 (div-
interval A B)
36 (div-interval A A)
转载于:https://www.cnblogs.com/tclan126/p/6385714.html