# 2.13

## 练习 2.13 请证明，在误差为很小的百分数的条件下，存在着一个简单公式，利用它可以从两个被乘区间的误差算出乘积的百分数误差值。你可以假定所有的数为正，以简化这一问题。

$[x_1, x_2] \cdot [y_1, y_2] = [x_1\cdot y_1, x_2 \cdot y_2]$

$center \cdot percent = width$

(define (make-interval a b) (cons a b))
(define upper-bound cdr)
(define lower-bound car)
(make-interval (+ (lower-bound x) (lower-bound y))
(+ (upper-bound x) (upper-bound y))))
(define (sub-interval x y) (add-interval x (make-interval (- 0 (upper-bound y)) (- 0 (lower-bound y)))))
(define (subtract-interval x y)
(define p1 (- (lower-bound x) (lower-bound y)))
(define p2 (- (lower-bound x) (upper-bound y)))
(define p3 (- (upper-bound x) (lower-bound y)))
(define p4 (- (upper-bound x) (upper-bound y)))

(make-interval (min p1 p2 p3 p4) (max p1 p2 p3 p4)))

(define (mul-interval x y)
(define p1 (* (lower-bound x) (lower-bound y)))
(define p2 (* (lower-bound x) (upper-bound y)))
(define p3 (* (upper-bound x) (lower-bound y)))
(define p4 (* (upper-bound x) (upper-bound y)))

(make-interval (min p1 p2 p3 p4) (max p1 p2 p3 p4))
)

(define int1 (make-interval 2 4))
(define int2 (make-interval 3 6))
(mul-interval int1 int2)

(define (make-center-percent center percent)
(make-interval (- center (* center percent))
(+ center (* center percent))))

(define (center x) (/ (+ (lower-bound x) (upper-bound x)) 2))

(define (percent x)
(/ (width x) (center x)))

(define int (make-center-percent 2 0.5))
int

(center int)

(define (width x) (/ (- (upper-bound x) (lower-bound x)) 2))
(percent int)


(define i1 (make-center-percent 2 0.5))
(define i2 (make-center-percent 2 0.25))

i1

i2

(define i3 (mul-interval i1 i2))
i3

(percent i3)


### 证明

$int1 = [x_1, x2], int2 = [y_1, y_2]$ 以及 $[x_1, x_2] \cdot [y_1, y_2] = [x_1\cdot y_1, x_2 \cdot y_2] = int3$

int3 的百分数误差值是

$p_3 = \frac{\frac{x_2 y_2 - x_1 y_1}{2}}{\frac{x_1 y_1 + x_2 y_2}{2}} = \frac{x_2 y_2 - x_1 y_1}{x_1 y_1 + x_2 y_2}$

$p_1 = \frac{x_2 - x1}{x_1 + x_2} p_2 = \frac{y_2 - y1}{y_1 + y_2}$

$c_1 = \frac{x_1 + x_2}{2}, c_2 = \frac{y_1 + y_2}{2}$

$x_1 = c_1 - c_1 p_1, x_2 = c_1 + c_1 p_1, y_1 = c_2 - c_2 p_2, y_2 = c_2 + c_2 p_2$

$p_3 = \frac{x_2 y_2 - x_1 y_1}{x_1 y_1 + x_2 y_2}$ $= \frac{(c_1 + c_1 p_1) (c_2 + c_2 p_2) - (c_1 - c_1 p_1) (c_2 - c_2 p_2)}{(c_1 - c_1 p_1) (c_2 - c_2 p_2) + (c_1 + c_1 p_1) (c_2 + c_2 p_2)}$ $= \frac{(c_1 c_2 + c_1 c_2 p_2 + c_1 p_1 c_2 + c_1 p_1 c_2 p_2) - (c_1 c_2 - c_1 c_2 p_2 - c_1 p_1 c_2 - c_1 p_1 c_2 p_2)}{(c_1 - c_1 p_1) (c_2 - c_2 p_2) + (c_1 + c_1 p_1) (c_2 + c_2 p_2)}$ $= \frac{p_1+p_2}{1+p_1 p_2}$

$p_3 \approx p_1 + p_2$