Project: How often must fractions be reduced?

As we saw when we studied Chez Scheme's treatment of numerals, when Chez Scheme constructs an exact rational number, it always reduces the fraction to lowest terms immediately. (For instance, if you type in 100/75, Chez Scheme will immediately reduce the fraction to 4/3 and store the value in that form.)

In many cases, of course, the fraction will already be so reduced; if you type in 5/7, the number is stored as 5/7, and that's that. This suggests a question: How often -- in what proportion of the cases -- will a reduction be necessary?

  1. A Scheme program that makes this question precise and can be used to obtain an answer to it can be found at random-project.ss, in partially complete form. Copy this program into an appropriately named file in your account, load it into XEmacs, and study it. Load it into Chez Scheme and experiment with the early procedures to see how they work.

  2. A few lines are missing from the choose-random-denominator, test-random-fraction, multiple-test, and inaccuracy procedures; supply them and test the effects.

  3. Run the inaccuracy procedure a few times, with various arguments. Does the value returned depend on the magnitude of the argument? If so, how?

  4. Revise or add to the program so that it can be used to determine the number of cases in which the common factor by which the numerator and the denominator of a fraction must be reduced is even. What is the expected value this time?

  5. Revise or add to the program so that it can be used to determine the average value of the common factor by which the numerator and the denominator are reduced.


This document is available on the World Wide Web as

http://www.math.grin.edu/courses/Scheme/spring-1997/random-project.html

created February 9, 1997
last revised May 28, 1997
John David Stone (stone@math.grin.edu)