# SICP - Solution: Exercise 2.9

##### January 11, 2019

**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.

**Solution**

We will use two interval $x$ and $y$. Per definition:

$$2\cdot x_{width}=x_{upper}-x_{lower}$$

$$2\cdot y_{width}=y_{upper}-y_{lower}$$

### Addition #

Let’s compute the bound for the sum of interval $x$ and $y$

$$z = x + y$$

$$z_{lower}=x_{lower}+y_{lower}$$ $$z_{upper}=x_{upper}+y_{upper}$$

Based on that, we can compute and simplify the width:

$$2\cdot z_{width}=y_{upper}-y_{lower}=(x_{upper}+y_{upper})-(x_{lower}+y_{lower})$$ $$2\cdot z_{width}=x_{upper}-x_{lower}+y_{upper}-y_{lower}$$ $$2\cdot z_{width}=2\cdot x_{width}+2\cdot y_{width}$$ $$z_{width}=x_{width}+y_{width}$$

### Subtraction #

Let’s compute the bound for the subtraction of interval $x$ and $y$

$$z = x - y$$

$$z_{lower}=x_{lower}-y_{upper}$$ $$z_{upper}=x_{upper}-y_{lower}$$

Based on that, we can compute and simplify the width:

$$2\cdot z_{width}=y_{upper}-y_{lower}=(x_{upper}-y_{lower})-(x_{lower}-y_{upper})$$ $$2\cdot z_{width}=x_{upper}-y_{lower}-x_{lower}+y_{upper}$$ $$2\cdot z_{width}=x_{upper}-x_{lower}+y_{upper}-y_{lower}$$ $$z_{width}=x_{width}+y_{width}$$

### Multiplication #

One possible case, if all number are > 1

$$z_{lower}=x_{lower}*y_{lower}$$ $$z_{upper}=x_{upper}*y_{upper}$$

$$2\cdot z_{width}=y_{upper}-y_{lower}=(x_{upper}*y_{upper})-(x_{lower}*y_{lower})$$

Example:

```
(newline)
(define r3 (make-interval 100.0 101.0))
(define r4 (make-interval 22.0 23.0))
(display "r3= ") (display (width-interval r3)) (newline)
(display "r3= ") (display (width-interval r4)) (newline)
(display "mul= ") (display (width-interval (mul-interval r3 r4))) (newline)
(display "div= ") (display (width-interval (div-interval r3 r4))) (newline)
```

```
r3=0.5
r4=0.5
mul=61.5
div=0.12154150197628466
```