Sunday, June 7, 2009
Ex-2.12
(define (make-center-percent c p)
(let ((width (/ (* c p) 100)))
(make-center-width c width)))
(define (percent i)
(let ((w (width i))
(c (center i)))
(/ (* w 100) c)))
Ex-2.10
(define (div-interval x y)
(if (or (= (lower-bound y) 0)
(= (upper-bound y) 0))
(error ("division by zero"))
(mul-interval
x
(make-interval
(/ 1.0 (upper-bound y))
(/ 1.0 (lower-bound y))))))
Ex-2.9
Using the add-interval definition, for add-interval:
Using the sub-interval definition, for sub-interval
width(x+y) = (upper-bound(x) + upper-bound(y))
- (lower-bound(x) + lower-bound(y))
= width(x) + width(y)
Using the sub-interval definition, for sub-interval
width(x-y) = (upper-bound(x) - lower-bound(y))
-(lower-bound(x) - upper-bound(y))
= width(x) + width(y)
Ex-2.8
(define (sub-interval x y)
(make-interval
(- (lower-bound x) (upper-bound y))
(- (upper-bound x) (lower-bound y))))
Ex-2.7
(define (make-interval a b)
(cons (min a b) (max a b)))
(define (lower-bound interval)
(car interval))
(define (upper-bound interval)
(cdr interval))
Subscribe to:
Posts (Atom)
