Note: this wiki is now retired and will no longer be updated!

The static final versions of the pages are left as a convenience for readers. Note that meta-pages such as "discussion," "history," etc., will not work.

SICP exercise 2.13

From Drewiki
Jump to: navigation, search

Problem

Show that under the assumption of small percentage tolerances there is a simple formula for the approximate percentage tolerance of the product of two intervals in terms of the tolerances of the factors. You may simplify the problem by assuming that all numbers are positive.

Solution

Let's do some experimentation with the constructors and selectors from exercise 2.12 and the procedure mul-interval exercise 2.10. Here are those procedures:

(define (make-interval a b) (cons a b))
 
(define (lower-bound i) (car i))
 
(define (upper-bound i) (cdr i))
 
(define (mul-interval x y)
  (let ((p1 (* (lower-bound x) (lower-bound y)))
        (p2 (* (lower-bound x) (upper-bound y)))
        (p3 (* (upper-bound x) (lower-bound y)))
        (p4 (* (upper-bound x) (upper-bound y))))
    (make-interval (min p1 p2 p3 p4)
                   (max p1 p2 p3 p4))))
 
(define (interval-width i)
  (/ (- (upper-bound i)
        (lower-bound i))
     2))
 
(define (center i)
  (/ (+ (lower-bound i) (upper-bound i)) 2))
 
(define (make-center-width c w)
  (make-interval (- c w) (+ c w)))
 
(define (make-center-percent center percent)
  (let ((width (* center ( / percent 100.0))))
    (make-center-width center width)))
 
(define (percent i)
  (* (/ (interval-width i) (center i)) 100.0))

Here are a few experiments with small percentage tolerances and positive numbers. We're told that there's some approximate formula relating the percentage tolerance of the product of two intervals and the tolerances of the factors of the product, which means we want to use the constructor make-center-percent, the procedure mul-interval and the selector percent:

(define a (make-center-percent 3 0.01))
 
(define b (make-center-percent 4 0.02))
 
(percent (mul-interval a b))

Output:

0.0299999994000041


That's approximately 0.3, which is the sum of the percentage tolerances (0.01 and 0.02) of the two intervals. Let's try a few more data points:

(define b (make-center-percent 4 0.03))
 
(define a (make-center-percent 3 0.02))
 
(percent (mul-interval a b))

Output:

0.0499999969999947


(define a (make-center-percent 10 0.05))
 
(define b (make-center-percent 7 0.03))
 
(percent (mul-interval a b))

Output:

0.0799999880000184


The approximation to the percentage tolerance of the product of two intervals appears to be the sum of the percentage tolerances of the product's two factors.

Personal tools