Mathematics 210 - Spring term 2005 - First assignment

This assignment requires you to submit several spreadsheets concerned with the machine representation of real numbers and decimal expansions of fractions. It is due before class time Monday, January 17.
  • Go to the MathSheet home page and then to the new applet page. Open a running copy of the spreadsheet and return to this page.
  • Log in immediately: File/Log in. Your login id is your Mathematics Department login name, and your password is your student number. This allows you to save and load spreadsheet files. Save your work frequently. To put it in simpler terms, save your work frequently.
  • Question 1. A positive real number y in the computer is stored in the form y = 2e x where 1 ≤ x < 2 and takes up 53 bits in its base 2 expression. Thsi is explained in more detail in the notes How a computer stores numbers. In the next few questions you are going to use the spreadsheet to explore this.

    The base 2 expression for 1 is 1, that for 3 is 11 = 2 + 1, that for 7 is 111 = 4 + 2 + 1, with 0 and 1 replacing the usual digits. These are called bits. Work out by hand or using the spreadsheet for scratch work the base 2 expressions for 15, 31, 63, 26, 121, 1023. Put these expressions as strings in the spreadsheet like "11 in cells b0 down the second column with the corresponding number itself in the first column. Keep in mind that it should be easier to check your answer than to find it.

    If y is an arbitrary positive number, here is how to find its base 2 expression: (1) find e such that 2e ≤ y < 2e+1. (2) If x = y/2e, then 1 ≤ x < 2. You now want to express x as a possibly infinite sequence of bits bi equal to 0 or 1:

    x = b0.b1b2 ...

    If x has an expression like this with b0 equal to 0 or 1, then either 0 ≤ x < 1 or 1 ≤ x < 2. In the first case b0 = 0 and in the second b0 = 1. In either case, the first bit b0 is the integer just below x, which is calculated as the floor of x in the spreadsheet. Thus floor(1 + 1/4 + 1/8) = 1 and the bit expression for it is 1.011. Then

    x - b0 = .b1b2 ...
    2(x - b0) = b1.b2 ...

    and we can now calculate b1 as the floor of this new number. Etc. Calculate e and the first 10 bits of the base 2 expression for the fraction 1/3 (by hand, or using the spreadsheet for scratch work). Put the string for this in c0 in the form "1/3 = ... . Then do the same for 1/5, in cell c1, and 5/7, in cell c2.

    Save this sheet as m210.1.1.ms.

  • Question 2. Clear your spreadsheet. In this question you are to build a spreadsheet with the following property: when you enter a real number y in cell b0, it displays in cell b1 the exponent e, in cell b2 the number x, and in cells c3 down the next 60 bits in the base 2 expression for x. The cells b3 down should be used to derive these, and in the cells a3 down are the integers 0, 1 etc. indexing the bits in column c. Format columns a and c for 0 digits to make them easier to read. Make a bar graph that shows the bits in column c.

    Check your spreadsheet by looking at 1/3 and the largest integer the machine can store exactly, which is 253-1.

    When the grader looks at this, he will try other numbers at random.

    Save this sheet as m210.1.2.ms.

  • Question 3. Clear your spreadsheet. In this question you are to build a spreadsheet with the following property: you put two integers p and q in cells a0 and a1 with 0 < p < q. The machine displays in cells b0 through b63 the first 64 digits in the decimal expansion of the fraction p/q. Exhibit the example 1/17.

    When the grader looks at this, he will try other numbers at random.

    Save this sheet as m210.1.3.ms.

That's it!

If you find these questions confusing, please write me.