Track Meets and Floating Point Numbers

Here is one school’s results from a (relatively) recent track and field meet. Never mind the name of the school or the names of the athletes representing the school; this is a math blog and not a sports blog, even though I’m an avid sports fan. Furthermore, I have nothing but respect for young people who are both serious students and serious athletes. While I have no illusions about the global popularity of this blog, and while the information from the meet are in the public domain, I also have no desire to inadvertently subject these student-athletes to online abuse.

With that preamble, here are the school’s results:

The unusual score for jumps caught my attention. Clearly a score of 16\frac{1}{3} was intended, but this isn’t displayed. (This is also a lesson about using unnecessary precision… unlike the total points field showing 152.33.) Before this unusual decimal expansion, however, I should generally describe how teams are scored at a track and field meet… or at least the high school and college meets that I’ve attended in the United States.

Each meet has multiple events, often categorized as sprints, hurdles, distance races, throwing events, jumping events, relay races, and multi-sport events (like the decathlon). At each event, first place gets 10 points, second place gets 8 points, third place gets 6 points, fourth place gets 5 points, fifth place gets 4 points, sixth place gets 3 points, seventh place gets 2 points, and eighth place gets 1 point.

Let’s explain the last two lines first. At this meet, athletes from this team finished second, sixth, and seventh in the one multi-sport event, earning 8+3+2=13 points for the school. A relay team finished third in the 4×100 meter relay, earning another 6 points for the school.

The third-to-last line — jumps — requires some explanation. No athlete from the school finished in top eight in the long jump or the triple jump (0 points). One athlete won the high jump (10 points). And one athletic finished in a three-way tie for second place in the pole vault. In the case of such a tie, the points for second, third, and fourth place are averaged and given to all three competitors, for (8+6+5)/3 = 6\frac{1}{3} points. In total, the school earned 16\frac{1}{3} points from the jumping events.

In jumping events, it is possible (but rare) for athletes to tie. The table above shows the results of the competition for the top eight finishers. The lingo: P means the competitor passed at that height (to save time and energy), O means a successful attempt, and X means a failed attempt. So, the winner passed at all heights up to and including 2.70 meters, succeeded on the first attempt at 2.85, 3.00, and 3.15 meters. This athlete was the only one who cleared 3.15 meters and thus won the competition. This athlete then failed three times at 3.30 meters: each athlete has three attempts at each height; three failures at one height means elimination from the competition.

The athletes in the next three lines had the exact same performance: success at 2.70 and 2.85 meters on the first attempt, and then three straight failed attempts at 3.00 meters. Because there is nothing to distinguish the three performances, the athletes are deemed to be tied.

The athletes in fifth and sixth place also cleared 2.85 meters, but on their second attempts. Therefore, they are behind the athletes who cleared 2.85 meters on the first attempt. Furthermore, the athlete in fifth place cleared 2.70 meters on the first attempt, while the athlete in sixth place needed two attempts. Similarly, the athletes in seventh and eighth place both cleared 2.70 meters; the tiebreaker is the number of attempts needed at 2.40 meters.

Ties can also happen in elite competition as well. This dramatically happened in the men’s high jump at the 2021 Summer Olympics and the women’s pole vault at the 2023 World Championships, where the top two competitors tied and decided to share the gold medal.

By contrast, at the 2024 Olympics, the top two competitors in the men’s high jump tied but decided to continue the competition with a jumpoff until there was one winner.

My apologies to any track and field experts if my description of the scoring wasn’t quite perfect.

Back to mathematics… and back to the scores. Why did the computer think that the number of points from jumps was 16.333333492279053 and not 16\frac{1}{3} = 16.3333\dots?

There are two parts to the answer: (1) Computers store numbers in binary, and (2) they only store a finite number of binary digits.

Converting 16 into binary is easy: since 16=2^4, its representation in binary is 10000.

Converting \displaystyle \frac{1}{3} into binary is more challenging, and perhaps I’ll write a separate post on this topic. This particular fraction can be found by using the formula for an infinite geometric series:

a + ar + ar^2 + ar^3 + \dots = \displaystyle \frac{a}{1-r}

If we let a = r = \displaystyle \frac{1}{4}, then we find

\displaystyle \frac{1}{4} + \frac{1}{16} + \frac{1}{64} + \dots = \displaystyle \frac{ \frac{1}{4} } { 1 - \frac{1}{4} } = \frac{ 1/4}{3/4} = \frac{1}{3}.

Said another way,

\displaystyle \frac{1}{3} = \frac{0}{2^1} + \frac{1}{2^2} + \frac{0}{2^3} + \frac{1}{2^4} + \frac{0}{2^5} + \frac{1}{2^6} + \dots = 0.01010101\dots

Combining the two results,

\displaystyle 16\frac{1}{3} = 10000.010101010101010101010101010101\dots

This is mathematically correct; however, computers use floating-point arithmetic only store a finite number of digits to represent any number. In this case, we can reverse-engineer to figure out how many digits are stored. In this case, after some trial and error, I found that 21 digits were apparently stored after the decimal point:

\displaystyle 16\frac{1}{3} \approx 10000.010101010101010101011

This is equivalent to the sum 2^4 + \displaystyle \frac{1}{2^2} + \frac{1}{2^4} + \frac{1}{2^6} + \dots + \frac{1}{2^{20}} + \frac{1}{2^{21}}; notice that the last fraction is basically rounding up in binary. Mathematica confirms that this sum matches the sum shown in the school’s team score:

So the computer showed far too many decimal places in the “Jumps” field, and it probably should’ve been programmed to show only two decimal places, like in the “Points” field.

I close by linking to this previous post on the 1991 Gulf War, describing why a similarly small error in approximating \displaystyle \frac{1}{10} in binary tragically led to a bigger computational error that caused the death of 28 soldiers.

My Mathematical Magic Show: Index

I’m doing something that I should have done a long time ago: collecting a series of posts into one single post. Here’s my series on the mathematical magic show that I’ll perform from time to time.

Part 1: Introduction.

Part 2a, 2b, and 2c: The 1089 trick.

Part 3a, 3b, and 3c: A geometric magic trick (see also here).

Part 4a, 4b, 4c, and 4d: A trick using binary numbers.

Part 5a, 5b, 5c, 5d: Predicting a digit that’s been erased from a number.

Part 6: Finale.

Part 7: The Fitch-Cheney 5-card trick.

Part 8a, 8b, 8c: A trick using Pascal’s triangle.

 

My Mathematical Magic Show: Part 4d

Last March, on Pi Day (March 14, 2015), I put together a mathematical magic show for the Pi Day festivities at our local library, compiling various tricks that I teach to our future secondary teachers. I was expecting an audience of junior-high and high school students but ended up with an audience of elementary school students (and their parents). Still, I thought that this might be of general interest, and so I’ll present these tricks as well as the explanations for these tricks in this series. From start to finish, this mathematical magic show took me about 50-55 minutes to complete. None of the tricks in this routine are original to me; I learned each of these tricks from somebody else.

green line

For my third trick, I’ll present something that I first saw when pulling Christmas crackers with my family. I’ll give everyone a piece of paper with six cards printed. I’ll also have a large version of this paper shown at the front of the room (taken from http://diaryofagrumpyteacher.blogspot.com/2014/04/freebie-friday-magic-number-cards.html; see also this Google search if this link somehow goes down):

Here’s the patter:

Think of a number from 0 to 63. Then, on your piece of paper, circle the cards that contain your number. For example, if your number is 15, you’ll need to circle the card in the upper-left because 15 is on that card. You’d have to circle all the cards that contain 15.

(pause)

Is everyone done? (Points to someone) Which cards did you circle?

At this point, the audience member will say something like “Top left, top middle, and bottom right.” Then I will add the smallest numbers on each card (in this case, 1, 2, and 32) and answer in five seconds or less, “Your number was 35 (or whatever the sum is).” It turns out that the number is always the sum of the smallest numbers on the selected cards.As shown in yesterday’s post, this is a consequence of the binary representation of whole numbers (as opposed to the ordinary decimal representation).

green line

Though I don’t do this in my magic routine for the sake of time, I have challenged my future high school math teachers to develop a similar magic trick for some other base, like base 3, just to make sure that they really understand the concept behind the above magic trick. Here are the cards that work for base 3 (taken from http://www.mathman.biz/html/sherimagic.html).

I encourage the reader to develop another set of cards for base 5. It will require 10 cards for numbers from 1 to 24.

With tomorrow’s post, I’ll continue my description of my magic routine.

My Mathematical Magic Show: Part 4c

Last March, on Pi Day (March 14, 2015), I put together a mathematical magic show for the Pi Day festivities at our local library, compiling various tricks that I teach to our future secondary teachers. I was expecting an audience of junior-high and high school students but ended up with an audience of elementary school students (and their parents). Still, I thought that this might be of general interest, and so I’ll present these tricks as well as the explanations for these tricks in this series. From start to finish, this mathematical magic show took me about 50-55 minutes to complete. None of the tricks in this routine are original to me; I learned each of these tricks from somebody else.

green line

For my third trick, I’ll present something that I first saw when pulling Christmas crackers with my family. I’ll give everyone a piece of paper with six cards printed. I’ll also have a large version of this paper shown at the front of the room (taken from http://diaryofagrumpyteacher.blogspot.com/2014/04/freebie-friday-magic-number-cards.html; see also this Google search if this link somehow goes down):

Here’s the patter:

Think of a number from 0 to 63. Then, on your piece of paper, circle the cards that contain your number. For example, if your number is 15, you’ll need to circle the card in the upper-left because 15 is on that card. You’d have to circle all the cards that contain 15.

(pause)

Is everyone done? (Points to someone) Which cards did you circle?

At this point, the audience member will say something like “Top left, top middle, and bottom right.” Then I will add the smallest numbers on each card (in this case, 1, 2, and 32) and answer in five seconds or less, “Your number was 35 (or whatever the sum is).” It turns out that the number is always the sum of the smallest numbers on the selected cards.

In yesterday’s post, I gave a similar but utterly unimpressive trick; the trick was unimpressive because it was obvious that the trick used our ordinary base-10 representation of whole numbers. The trick above is much more impressive because it uses binary (base-2) instead of base-10.

The cards above are carefully rigged using binary arithmetic, so that all numbers are written as sums of powers of 2. For example, on the card in the upper left, the first few numbers are

1 = 1

3 = 2 + 1

5 = 4 + 1

7 = 4 + 2 + 1

9 = 8 + 1

11 = 8 + 2 + 1,

and so on. On the right-hand side, I’ve written each number as the sum of powers of 2 (for the numbers at hand, that means 1, 2, 4, 8, 16, and 32). Notice that each expansion on the right hand side contains a 1. So, if the audience member tells me that her number is on the upper-left card, that tells me that there’s a 1 in the binary representation of her number.

Let’s now take a look at the first few number in the upper-middle card:

2 = 2

3 = 2+1

6 = 4+2

7 = 4+2+1

10 = 8+2

11 = 8+2+1,

and so on. Notice that each expansion on the right hand side contains a 2. So, if the audience member tells me that her number is on the upper-middle card, that tells me that there’s a 2 in the binary representation of her number.

Similarly, the upper-right card has numbers which contain 4 in its binary representation. The lower-left card has numbers containing 8. The lower-middle card has numbers containing 16. And the lower-right card has numbers containing 32. Happily for the magician, each of these numbers is also the smallest number on the card.

So, if the audience member will says “Top left, top middle, and bottom right,” then I know that the binary representation of her number contains 1, 2, and 32. Adding up those numbers, therefore, gives me the original number!

green lineAfter explaining how the trick works, I’ll call up an audience member to play the magician and repeat the trick that I just performed. Then I’ll move on to the next magic trick in the routine.

 

Lychrel Numbers

A friend of mine posted the following on Facebook (with names redacted):

So [my daughter] comes home with this assignment:

For each number from 10 – 99, carry out the following process.

  1.  If the number is a palindrome (e.g., 77), stop.
  2.  Else reverse the number and add that to the original. E.g.: 45+54 = 99.
  3.  If the result is not a palindrome, repeat step (2) with the result.
  4.  Record the final palindromic result and the number of steps taken.

Most are simple.

  • 56 + 65 = 110
  • 110 + 011 = 121
  • Stop. 2 steps taken.

The numbers 89 and 98 were given for extra credit, and they mysteriously explode, taking 24 steps. It made [my daughter] cry.

She wanted me to check her work, so I decided it was a good time to teach the wonders of Python, and we very quickly had a couple of simple functions to do the trick.

Well, you saw where this was going. How many steps does 887 take?

We’re up to 104000 steps so far, and Python is crying.

True or false: For a given n, the above algorithm completes in finite time?

I guess I’ve been living under a rock for the past 20 years, because I had never heard of this problem before. It turns out that numbers not known to lead to a palindrome are called Lychrel numbers. However, no number in base-10 has been proven to be a Lychrel number. The first few candidate Lychrel numbers (i.e., numbers that have not been proven to not be Lychrel numbers) are 196, 295, 394, 493, 592, 689, 691, 788, 790, 879, 887, 978, 986, 1495, 1497, 1585, 1587, 1675, 1677, 1765, 1767, 1855, 1857, 1945, 1947, 1997, 2494, 2496, 2584, 2586, 2674, 2676, 2764, 2766, 2854, 2856, 2944, 2946, 2996, 3493, 3495, 3583, 3585, 3673, 3675…

The above algorithm is called the 196-algorithm, after the smallest suspected Lychrel number.

For further reading, I suggest the following links and the references therein:

http://mathworld.wolfram.com/196-Algorithm.html

http://mathworld.wolfram.com/LychrelNumber.html

http://www.p196.org/

http://www.mathpages.com/home/kmath004/kmath004.htm (which contains a proof that 10110 is a Lychrel number in binary and that Lychrel numbers always exist in base 2^k)

http://en.wikipedia.org/wiki/Lychrel_number

Lessons from teaching gifted elementary school students (Part 3b)

Every so often, I’ll informally teach a class of gifted elementary-school students. I greatly enjoy interacting with them, and I especially enjoy the questions they pose. Often these children pose questions that no one else will think about, and answering these questions requires a surprisingly depth of mathematical knowledge.

Here’s a question I once received:

Suppose

A \times A = B

B \times B \times B = C

C \times C \times C \times C= D

If the pattern goes on, and if A = 2, what is Z?

In yesterday’s post, we found that the answer was

Z =2^{26!} =  10^{26! \log_{10} 2} \approx 10^{1.214 \times 10^{26}},

a number with approximately 1.214 \times 10^{26} digits.

How can we express this number in scientific notation? We need to actually compute the integer and decimal parts of 26! \log_{10} 2, and most calculators are not capable of making this computation.

Fortunately, Mathematica is able to do this. We find that

Z \approx 10^{121,402,826,794,262,735,225,162,069.4418253767}

\approx 10^{0.4418253767} \times 10^{121,402,826,794,262,735,225,162,069}

\approx 2.765829324 \times 10^{121,402,826,794,262,735,225,162,069}

Here’s the Mathematica syntax to justify this calculation. In Mathematica, \hbox{Log} means natural logarithm:

bigexponent

Again, just how big is this number? As discussed yesterday, it would take about 12.14 quadrillion sheets of paper to print out all of the digits of this number, assuming that Z was printed in a microscopic font that uses 100,000 characters per line and 100,000 lines per page. Since 250 sheets of paper is about an inch thick, the volume of the 12.14 quadrillion sheets of paper would be

1.214 \times 10^{16} \times 8.5 \times 11 \times \displaystyle \frac{1}{250} \hbox{in}^3 \approx 1.129 \times 10^{17} \hbox{in}^3

By comparison, assuming that the Earth is a sphere with radius 4000 miles, the surface area of the world is

4 \pi (4000 \times 5280 \times 12) \hbox{in}^2 \approx 8.072 \times 10^{17} \hbox{in}^2.

Dividing, all of this paper would cover the entire world with a layer of paper about 0.14 inches thick, or about 35 sheets deep. In other words, the whole planet would look something like the top of my desk.

green lineWhat if we didn’t want to print out the answer but just store the answer in a computer’s memory? When written in binary, the number 2^{26!} requires…

26! bits of memory, or…

about 4.03 \times 10^{26} bits of memory, or…

about $latex 5.04 \times 10^{25} bytes of memory, or …

about 5.04 \times 10^{13} terabytes of memory, or…

about 50.4 trillion terabytes of memory.

Suppose that this information is stored on 3-terabyte external hard drives, so that about 50.4/3 = 16.8 trillion of them are required. The factory specs say that each hard drive measures 129 \hbox{mm} \times 42 \hbox{mm} \times 167 \hbox{mm}. So the total volume of the hard drives would be 1.52 \times 10^{19} \hbox{mm}^3, or 15.2 \hbox{km}^3.

By way of comparison, the most voluminous building in the world, the Boeing Everett Factory (used for making airplanes), has a volume of only 0.0133 \hbox{km}^3. So it would take about 1136 of these buildings to hold all of the necessary hard drives.

The cost of all of these hard drives, at $100 each, would be about $1.680 quadrillion. So it’d be considerably cheaper to print this out on paper, which would be about one-seventh the price at $242 trillion.

Of course, a lot of this storage space would be quite repetitive since 2^{26!}, in binary, would be a one followed by 26! zeroes.

How high can you count on two hands?

How high can you count on two hands? The answer is 1023, if you use binary. I made the following video to demonstrate this to my students.

True story: This is a trick that I came up with when I was 10 years old. As is common in classrooms, my teacher had had enough disruptions in class, and told us students to put our heads on our desks in silence for 15 or 20 minutes as punishment. Naturally, I was trying to think of something to do to pass the time, and I somehow came up with the idea that I could keep myself entertained by counting in binary using my fingers.

When I was a kid, I could count to 1023 in about 5 minutes. But I was a lot more dextrous then, and so it takes me about 6 or 7 minutes today.

Thoughts on 1/7 and other rational numbers (Part 7)

In a previous post concerning roundoff error, I mentioned that the number 1/10 equals

\displaystyle \frac{1}{2^4} + \frac{1}{2^5} +\frac{1}{2^8} + \frac{1}{2^9} + \frac{1}{2^{12}} + \frac{1}{2^{13}} + \dots

In other words, the binary expansion of 1/10 is

0.0001100110011001100110011001100....

That’s the expansion of the fraction in base 2, as opposed to base 10.

In the previous post, I verified that the above infinite series actually converges to 1/10:

S = \displaystyle \left(\frac{1}{2^4} + \frac{1}{2^5}\right) +\left(\frac{1}{2^8} + \frac{1}{2^9}\right) + \left(\frac{1}{2^{12}} + \frac{1}{2^{13}}\right) + \dots

S = \displaystyle \frac{3}{2^5} + \frac{3}{2^9} + \frac{3}{2^{13}} + \dots

S = \displaystyle \frac{\displaystyle \frac{3}{2^5}}{\quad \displaystyle 1 - \frac{1}{2^4} \quad}

S = \displaystyle \frac{\displaystyle \frac{3}{32}}{\quad \displaystyle \frac{15}{16} \quad}

S = \displaystyle \frac{3}{32} \times \frac{16}{15}

S = \displaystyle \frac{1}{10}

Still, a curious student may wonder how one earth one could directly convert 1/10 into binary without knowing the above series ahead of time.

This can be addressed by using the principles that we’ve gleaned in this study of decimal representations, except translating this work into the language of base 2. In the following, I will use the subscripts \hbox{ten} and \hbox{two} so that I’m clear about when I’m using decimal and binary, respectively.

To begin, we note that 10_{\hbox{\scriptsize ten}} = 1010_{\hbox{\scriptsize two}} = 10_{\hbox{\scriptsize two}} \times 101_{\hbox{\scriptsize two}}. (In other words, ten is equal to two times five.) So, following Case 3 of the previous post, we will attempt to write the denominator in the form

10_{\hbox{\scriptsize two}}^d \left(10_{\hbox{\scriptsize two}}^k - 1 \right), or 2_{\hbox{\scriptsize ten}}^d \left(2_{\hbox{\scriptsize ten}}^k - 1 \right)

  • If k = 1_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^1 - 1 = 1_{\hbox{\scriptsize ten}}, but 1_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}}  is not an integer.
  • If k = 2_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^2 - 1 = 3_{\hbox{\scriptsize ten}}, but 3_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}}  is not an integer.
  • If k = 3_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^3 - 1 = 7_{\hbox{\scriptsize ten}}, but 7_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}}  is not an integer.
  • If k = 4_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^4 - 1 = 15_{\hbox{\scriptsize ten}}. This time, 15_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}} = 3_{\hbox{\scriptsize ten}}. Written in binary,

101_{\hbox{\scriptsize two}} \times 11_{\hbox{\scriptsize two}} = 1111_{\hbox{\scriptsize two}}

We now return to the binary representation of 1/10_{\hbox{\scriptsize ten}} = 1/1010_{\hbox{\scriptsize two}}.

\displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} = \displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} \times \frac{11_{\hbox{\scriptsize two}}}{11_{\hbox{\scriptsize two}}}

\displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} = \frac{11_{\hbox{\scriptsize two}}}{11110_{\hbox{\scriptsize two}}}

Therefore, the binary representation has a delay of one digit and a repeating block of four digits:

\displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} = 0.0\overline{0011}

Naturally, this matches the binary representation given earlier.