SICP Exercise 2.9

Question

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.

Answer

Addition and Subtraction

This is easily verified programmatically with an example:

(define (get-width i)
  (/ (- (upper-bound i) (lower-bound i)) 2))

(define i1 (make-interval 3 11))
(define i2 (make-interval 7 2))

(display "sum: ") (get-width (add-interval i1 i2))
(display "diff: ")(get-width (sub-interval i1 i2))
(newline)
(display "widths added: ") (+ (get-width i1) (get-width i2))

Results:

sum: 13/2
diff: 13/2

widths added: 13/2

But of course this could just be a coincidence. So let us also verify it mathematically. I’m using the terms x and y for the two intervals and the term w for width.

wx=xupperxlower

(x+y)lower=xlower+ylower

(x+y)upper=xupper+yupper

From these two definitions follows:

wx+y=(xupper+yupper)(xlower+ylower)2

wx+y=xupper+yupperxlowerylower2

Which is the same as:

wx+wy=xupper+yupper2xlower+ylower2

Therefore, wx+y=wx+wy.

Let us do the same for subtraction as well:

wxy=(xupperylower)(xloweryupper)2

wxy=xupperylowerxlower+yupper2

If you reorder this a little, you receive the same right side as with addition:

wxy=xupper+yupperxlowerylower2

So it is shown that wx+y=wxy=wx+wy.

Multiplication and Division

Just trying this programmatically makes it apparent that there is no such connection for multiplication and division:

(define i1 (make-interval 3 11))
(define i2 (make-interval 7 2))

(display "mul: ") (get-width (mul-interval i1 i2))
(display "div: ") (get-width (div-interval i1 i2))
(newline)
(display "widths added: ") (+ (get-width i1) (get-width i2))

Results:

mul: 71/2
div: 2.5357142857142856

widths added: 13/2

We can also show this mathematically (note that I am assuming some things here, for example that both upper and lower bounds are positive numbers):

xyupper=xupperyupper

xylower=xlowerylower

2wxy=xyupperxylower

2wxy=xupperyupperxlowerylower

At this point, we can’t really simplify any further in terms of wx and wy. So there does not seem to be any obvious connection between wxy and wxwy.