Exercise 2.13
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 assumingthat all numbers are positive.
After considerable work, Alyssa P. Hacker delivers her finished system. Several years later, after she has forgotten all about it, she gets a frenzied call from an irate user, Lem E. Tweakit. It seems that Lem has noticed that the formula for parallel resistors can be written in two algebraically equivalent ways:
He has written the following two programs, each of which computes the parallel-resistors formula differently:
(define (par1 r1 r2)
(div-interval (mul-interval r1 r2)
(add-interval r1 r2)))
(define (par2 r1 r2)
(let ((one (make-interval 1 1)))
(div-interval
one (add-interval (div-interval one r1)
(div-interval one r2)))))
Lem complains that Alyssa's program gives different answers for the two ways of computing. This is a serious complaint.
This question is to modify the multiplication function and to demonstrate that the two methods of calculating parallel resistance calculate inconsistent results.
(define (mul-interval x y)
(let ((cx (center x))
(cy (center y))
(px (/ (percent x) 100)))
(py (/ (percent y) 100)))))
(make-interval (* (- cx (* cx px)) (- cy (* cy py))))
(* (+ cx (* cx px)) (+ cy (* cy py))))))
(define r1 (make-interval 6.12 7.48))
(define r2 (make-interval 4.465 4.935))
(display-interval-tolerance (par1 r1 r2))
(display-interval-tolerance (par2 r1 r2))
Result
2.844199964577264 ± 22.613352145193332 percent
2.777440701636504 ± 7.05260392723452%
Exercise 2.14
Demonstrate that Lem is right. Investigate the behavior of the system on a variety of arithmetic expressions. Make some intervals A and B, and use them in computing the expressions A/A and A/B. You will get the most insight by using intervals whose width is a small percentage of the center value. Examine the results of the computation in center-percent form (see Exercise 2.12).
(define r1 (make-interval 6.12 7.48))
(define r2 (make-interval 4.465 4.935))
(display-interval (div-interval r1 r1))
(display-interval (div-interval r1 r2))
(newline)
(display-interval-tolerance (div-interval r1 r1))
(display-interval-tolerance (div-interval r1 r2))
The result of the execution is
[0.818181818181818182, 1.2222222222222222222]
[1.2401215805471126, 1.6752519596864504]
1.02020202020202 ± 19.801980198019795
1.4576867701167815 ± 14.925373134328357%
According to the result, Lem is obviously right, and for A/A, the answer should be 1. However, the program calculates a relatively large range, because when calculating interval division, we don't define the concept of "equality", so when calculating A/A, it also follows the general method to calculate This is because we didn't define the concept of "equal" when calculating interval division, so when calculating A/A, it follows the general method.
Exercise 2.15
Eva Lu Ator, another user, has also noticed the different intervals computed by different but algebraically equivalent expressions. She says that a formula to compute with intervals using Alyssa's system will produce tighter error bounds if it can be written in such a form that no variable that represents an uncertain number is repeated. Thus, she says, par2 is a "better" program for parallel resistances than par1. Is she right? Why?
Eva is right, for the two answers calculated in Exercise 2.13, par2 is more accurate and consistent with the answer given in the book. As for the reason, I think it should be that operations between intervals increase the uncertainty every time. par2 actually only has the step of adding two intervals to perform the operation, and the rest can be regarded as operations of determining a number with an interval, without adding extra uncertainty; while par1 performs 3 operations between intervals ---- multiplication, addition, and division, and both multiplication and division make the result uncertain.
Exercise 2.16
Explain, in general, why equivalent algebraic expressions may lead to different answers. Can you devise an interval-arithmetic package that does not have this shortcoming, or is this task impossible? (Warning: This problem is very difficult.)
(define a (make-interval 2 4))
(define b (make-interval -2 0))
(define c (make-interval 3 8))
(define x (mul-interval a (add-interval b c)))
(define y (add-interval (mul-interval a b))))
(mul-interval a c))))
(display-interval x)
(display-interval y)
The result of the execution
[-2, 32]
[-2, 32]
As you can see from the results above, interval arithmetic is not even guaranteed by the multiplicative distributive law. As for whether there are any flawless rules for interval arithmetic, I probably thought about it for a while and didn't have a clue, so I didn't continue to think about it.