We will be using a rational number simulator throughout this tutorial. You can start it by clicking on the following button.
As discussed in Chapter 2, a rational number system is characterized by
The rational number simulator allows you to design your own rational number systems. When the simulator first appears, it will be simulating a system with a minimum integer of -2 and a maximum integer of 2. You can verify this by looking at the two controls at the top of the simulator window.
The simulator also displays a list and a graph of the numbers in the rational number system. Finally, the simulator allows you to calculate the values of arithmetic expressions in the rational number system. (Initially, it displays the result of adding 1 and 1.)
Locate all of these pieces of information in the simulator window before going on.
-2 -1 0 1 2because these are the integers between -2 and 2, and the fractions
-2/-2 -2/-1 -2/1 -2/2 -1/-2 -1/-1 -1/1 -1/2 0/-2 0/-1 0/1 0/2 1/-2 1/-1 1/1 1/2 2/-2 2/-1 2/1 2/2because these are all valid ratios of the five integers.
Of course, the five integers and the twenty fractions listed above contain many duplicates, which is why there are only seven numbers listed and graphed in the simulator window.
Let's modify the rational number system being simulated and see how that changes the collection of available numbers. Use the controls at the top of the window to change the minimum integer to -3 and the maximum integer to 3.
Increasing the range of the allowable integers adds eight new numbers to the rational number system.
Now let's turn our attention to what happens when we do arithmetic calculations with rational numbers. Let's return to a simple system with a minimum integer of -2 and a maximum integer of 2. Either do it yourself, or click below.
We will now begin using the expression input region, which should be displaying the result of calculating "1+1". Delete the contents of the input region and enter the product "1*1" instead. When you hit the return key, the product of the two numbers in the current rational number system will be displayed.
Now enter the expression "2+2". This time when you hit the return key, the message
Computation error - 4 out of boundswill be displayed. This error is called an overflow error, and it occurred because the value of the expression was too large to represent in the current system: 4 is not a valid rational number when the minimum integer is -2 and the maximum integer is 2. You can verify this by looking at the list of rational numbers that the simulator displays.
Now use the controls to increase the maximum integer to 4. Because 4 is a member of this system, the value "2+2" will be displayed.
Rational number systems on computers have the following property: When you ask for an arithmetic expression to be evaluated, you will either get an exact answer or an overflow error. An overflow error occurs when either the numerator or the denominator of the result would be either smaller than the minimum integer or larger than the maximum integer.
Note that overflow can occur in the middle of a complicated expression, even though the answer can be represented in a rational number system. To see this, try evaluating the expression "4+4-4" in the current system. The simulator will report the overflow that occurs when it tries to add 4 and 4. If you enter the algebraically identical "4+(4-4)" instead, you will not get an overflow. Be sure that you understand the difference.
Below are several arithmetic calculations. What is the simplest rational number system in which the calculations can be performed without an overflow error occurring? Use the simulator to verify your answers.
Last modified 24Feb97.