Posts

Showing posts from December, 2017

SICP Exercise 2.13 percent tolerance for product

Image
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 assuming that all numbers are positive. SOLUTION

SICP Exercise 2.12 width-of-interval - make-center-percent

Exercise 2.12.   Define a constructor   make-center-percent   that takes a center and a percentage tolerance and produces the desired interval. You must also define a selector   percent   that produces the percentage tolerance for a given interval. The   center   selector is the same as the one shown above. SOLUTION The code and tests are here .

SICP Exercise 2.11 width-of-interval - mul rewritten

Exercise 2.11.    In passing, Ben also cryptically comments: ``By testing the signs of the endpoints of the intervals, it is possible to break  mul-interval  into nine cases, only one of which requires more than two multiplications.'' Rewrite this procedure using Ben's suggestion. SOLUTION The code and tests are here .

SICP Exercise 2.10 width-of-interval - zero check

Exercise 2.10.    Ben Bitdiddle, an expert systems programmer, looks over Alyssa's shoulder and comments that it is not clear what it means to divide by an interval that spans zero. Modify Alyssa's code to check for this condition and to signal an error if it occurs. SOLUTION The code and tests are here .