SICP Exercise 2.15
Question
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?
Answer
This question touches on the subject of identity. The reason that the two procedures return different results is because of the way interval division works. This is a somewhat hard problem in mathematics.
Of course, if you divide any regular number by itself, the result is always \(1\). So if we have an interval \(A\), we would expect \(\frac{A}{A}\) to also be \(1\).
The reason why this does not happen is because \(\frac{A}{A}\) is a stateless function, that is, we do not have the information that the \(A\) in the denominator and the \(A\) in the numerator are in fact the same value. Because \(A\) is an interval, for all we know, those two $A$s could refer to different values within the same range. In other words, while \(A\) could refer to any given value within an interval, every instance of \(A\) within the same function always refers to the same value. But there is no way to tell the function that, so it produces overly wide error margins.
This uncertainty increases proportionally to the number of instances of an
uncertain interval like \(A\) being divided by itself. Because par2
does
not contain a division of an interval by itself, this is not an issue, and
Eva is correct in saying that par2
will yield a more accurate result.
Although this may or may not be a good thing, since it may be useful to
reflect uncertainty in the result if it exists. So whether par2
is
actually the better function depends entirely on the use case.