[CS Dept., U Chicago] Courses


CMSC 16100: Honors Introduction to Computer Programming I (Autumn 2003)

Class Project

Step 2: Exact reals as functions



Project step 2 is due at 11:59 PM on Monday, 17 November, 2003.

Port all of my 2002 work on the precfunc implementation of xreal. In this implementation, an exact real number is represented by a function from rationals to rational intervals. I have useful definitions in xreal-2_precfunc-1,mod4.scm, xreal-2_precfunc-1-exp-1,mod4.scm, and xreal-1_precfunc-1-ratpowers-2.scm. If you find any other useful sources of definitions, please post. I think that I added the ratpowers definitions mainly so we could generate nontrivial examples of exact reals by taking roots.

Define the following functions from the xreal abstraction that I left out:

  1. All of the predicates, except xreal?: member_xreal_ratintvl?, ..., gt_xrealcomp? (all but member_xreal_ratintvl? are trivial)
  2. div_xreal (tricky)
  3. ln_xreal
  4. expt_xreal (just try the simple implementation using exp_xreal, ln_xreal, and mult_xreal)

I left a note last year that "my definition of negative powers depends on division, so that won't work." I think this refers to rational_power->xreal. Check it out, and make sure that anything depending on div_xreal has been fixed.

precfunc implementations of xreal functions require a very different sort of thinking from conventional numerical operations. Simple ideas, such as performing multiplication by iterated addition and exponentiation by iterated multiplication, may not work. Make sure you discuss the basic approach to each function early in the week, and design a solution carefully before writing definitions.

Functions involving rationals as well as xreals (e.g., rational_power->xreal takes two rational arguments and returns an xreal) may call for very different definitions than similar looking functions on xreals alone. I didn't understand this point thoroughly when I started defining the project. If you notice places where we should have more special case definitions for rationals, or even better if you notice ways to reunify the rational and xreal cases (other than just (cond ((rational? x) ...))), please post.

What to hand in

Hand in your work with the handin command in the form

handin P2 <files>

We are looking at the file naming standards, and may polish them slightly. [MOD, 9 Nov]


Valid HTML 4.0!


Last modified: Tue Nov 11 12:12:07 CST 2003