2.13
练习 2.13 请证明,在误差为很小的百分数的条件下,存在着一个简单公式,利用它可以从两个被乘区间的误差算出乘积的百分数误差值。你可以假定所有的数为正,以简化这一问题。
在前面的练习2.11 中,已经讨论了区间相乘的 9 种情况。在所有的数都为正的情况下,有:
一个区间的百分数误差值和宽度以及中心点的关系是:
(define (make-interval a b) (cons a b))
(define upper-bound cdr)
(define lower-bound car)
(define (add-interval x y)
(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)
看起来是 (1/2) * (1/4) = (1/3) = (1+1) / (2+4)
不过,这个直观的规律和并不能和以上的定义产生什么联系。还是老老实实地计算吧。
证明
令 以及
int3 的百分数误差值是
又
引入中心点的关系,
即:
代入上面的公式,得到
由于 都很小,所以相乘后的结果几乎为0,从而以上公式可以得到