SICP

# SICP 2.5.3 (Extended) Exercises

September 15, 2016 11:49

This extended exercise will require changes to several parts of the arithmetic system. The polynomials will see the most extensive change, but the rational numbers will change and other parts (such as the integers) may also require modification. There are several approaches to take, and the necessary alterations may well depend on how the original system was written.

For that reason, it’s a good idea to keep running all the original tests; this makes sure that we haven’t unintentionally broken something that was already working. All the math tests should continue to function after each change to the arithmetic system. It’s sensible to only do the tests once for each section, to save time when reading the output. While this section is structured around a single test case, a few additional polynomial tests are also added at the end. This is mostly to see if polynomials can be built using generic operations as in Exercise 2.93; putting them at the end ensures that the final system still works with them.

These exercises continue to demonstrate how putting a system into practice can help refine it, as some bugs or inefficient portions are revealed in how it is actually used. Even when a system is meant to be generic, it’s often the case that it there are hidden assumptions that amount to an unstated specification, or optimization for a certain common case. This isn’t always a bad thing, since it’s good to be designed for real-world usage. The refinement of a design should be in figuring out whether something is truly helpful for common usage, or if it can be simplified to make the system more robust without sacrificing performance.

The system should be built on your solution for section 2.5.3. I load the entirety of the file at the start of the exercises. You can alternatively copy only the install/definitions of the system, built on the generic arithmetic system. As you work through the exercises, you’ll notice that since internal definitions are not preserved in the table, you have to continue to copy nearly all of the system each time there is a change. It’s a useful exercise to determine just which internal routines are needed for each exercise, so that you understand what they are relying on (this can also point the way to improvements in the system itself).

#### Polynomial Tests

-New arithmetic lines