Mathematics 210 - Spring term 2003 - Fourth assignment

This assignment requires you to submit several spreadsheets concerned with (a) the machine representation of real numbers; (b) probability distributions. It is due next Monday, February 10. I repeat the instructions from the first lab:
  • Go to the MathSheet home page and then to the 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. You should save your work frequently. The graph signature mechanism should now be working - please use this feature.
  • Question 1. I have said in class that 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. 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. 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 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

  • Question 2. Clear your spreadsheet. In this question you are to build a spreadsheet with the following property: when you enter a 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 shoows the bits in column c.

    Check your spreadsheet by looking at 1/3 and the largest integer the machine can store exactly, which is 2^53-1. When the grader looks at this, he will try other numbers at random.

    Save this sheet as

  • Question 3. Clear. Build a spreadsheet with this property: In cells a10 down through a60 are the numbers 0 through 50. Suppose that in cells b10 through b20 are arbitrary probabilities pi of getting i on some experiment. Their sum should always be 1. Then in cells c10 down through c30 will be the probabilities of getting i if we choose pairs randomly from this set of values and add them together. In cells d10 down through d40 will be the probabilities of getting a sum of i if we choose triples randomly from this set of values, and in columns e and f the same for quadruples and quintuples. Graph these by bar graphs, starting with one item, then two on top of that, and so on. For dice the graphs look like something like this (only the quintuples have been left out; the colours are your choice):

    For submission, set pi = 1/11. Scale the graph so it looks good. Save this sheet as

That's it!

If you find these questions confusing, please write me.