Chapter 2, Building Abstractions with Data
Section  2.1  Introduction to Data Abstraction
Exercise 2.16
We know from previous exercise that this problem arises because we expect that an intervalvariable should take same value in all the occurrences in an expression. Thus to fix this we have to make sure that an an intervalvariable should takes same value in all the occurrences in an expression while doing the interval arithmetic.
This problem can be approached in two ways:

Convert the expression so that each interval variable occurs only once. This is however not possible. For eg: can not be converted to an expression containing only once.

To do intervalarithmetic in such a way that when a variable is repeated then all occurrences of an interval variable takes same value.
Thus we have only second approach as first approach will not work. I will try to outline my approach how we may do it:
Note: I think there are high chances that it is an incorrect approach. I wrote it to remember so that if I ever visit again I may get some direction from this approach.
We will do lazyevaluation i.e. we will not perform computation till we get the whole expression and after analyzing the whole expression we will be able to come up with a formulae for lowerbound and upperbound.
Instead of computing lowerbound and upperbound while doing interval arithmetic we will remember the intervalvariables used for computing the lowerbounds and upperbounds and the corresponding operation. For eg:
In case of addition of , remember that . Note that we are not computing the sum, but we rememeber that the lowerbound of is sum of lowerbounds of and . Similarly we store for upperbounds.
Same process can be repeated for multiplication: , we will follow the same process to remember which values are used of the intervals to compute lower or upper bounds.
Thus we can extend the same process of remembering for finding upperbound of or .
Extending further we recursively keep remembering the overall formula for computing without actually computing the lowerbound and upperbound till we are done reading the complete expression.
For eg: , may be we have lowerbound = where lowerbound and upperbound.
Once we are done, we have the formulas for computing lowerbound and upperbound(one for each). Now we can compute the final value of lowerbound and upperbound using these formulas as follows:
If a variable is repeated multiple times in the formula then we only need to worry when some repetitions are using lowerbound of the repeated variable and other using upperbound. Otherwise if all repetitions uses same bound then we can use that value while computing the overall value of the bound(lower or upper).
For the case, we compute the bound(lower or uppert) two times, one by using lowerbound and other by using upperbound. And depending on which bound, lower or upper, we are computing, we will pick the boundvalue(lower or upper) of the repetitive variable which results in smallest or largest value accordingly. We can use arbitrary values for other variables(obviously from the corresponding interval range only)