# 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.

# 999 Megabytes

…though I would have laughed harder if the band was called 1023 Megabytes.

# 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.

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).

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.

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!

After 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:

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.

What 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.