22 hours ago

my attempt to do the exercises in sicp.

## Saturday, July 12, 2008

### sicp exercise 2.9

; Exercise 2.9. The width of an interval is half of the difference between its upper and lower bounds. The width is a measure of the uncertainty of the number specified by the interval. For some arithmetic operations the width of the result of combining two intervals is a function only of the widths of the argument intervals, whereas for others the width of the combination is not a function of the widths of the argument intervals. Show that the width of the sum (or difference) of two intervals is a function only of the widths of the intervals being added (or subtracted). Give examples to show that this is not true for multiplication or division.

(define (make-interval a b) (cons a b))

(define (upper-bound interval) (car interval))

(define (lower-bound interval) (cdr interval))

(define (width interval)

(/ (- (upper-bound interval) (lower-bound interval)) 2))

#!

(width (sum a b))

(width ((+ ua ub) , (+ la lb)))

(/ (- (+ ua ub) (+ la lb)) 2)

(+ (/ (- ub lb) 2) (/ (- ua la) 2))

!#

Subscribe to:
Post Comments (Atom)

## No comments:

Post a Comment