My Mathematical Magic Show: Part 5e

As discussed earlier in this blog, here’s one of my favorite mathematical magic tricks. The trick works best when my audience has access to a calculator (including the calculator on a phone). The patter:

Write down any five-digit number you want. Just make sure that the same digit repeated (not something like 88,888).

(pause)

Now scramble the digits of your number, and write down the new number. Just be sure that any repeated digits appear the same number of times. (For example, if your first number was 14,232, your second number could be 24,231 or 13,422.)

(pause)

Is everyone done? Now subtract the smaller of the two numbers from the bigger, and write down the difference. Use a calculator if you wish.

(pause)

Has everyone written down the difference. Good. Now, pick any nonzero digit in the difference, and scratch it out.

(pause)

(I point to someone.) Which numbers did you not scratch out?

The audience member will say something like, “8, 2, 9, and 6.” To which I’ll reply in three seconds or less, “The number you scratched out was a 2.”

Then I’ll turn to someone else and ask which numbers were not scratched out. She’ll say something like, “3, 2, 0, and 7.” I’ll answer, “You scratched out a 6.”

green line

As discussed in a previous post, the difference found by the audience member must be a multiple of 9. Since the sum of the digits of a multiple of 9 must also be a multiple of 9, the magician can quickly figure out the missing digit. In the previous example, 3+2+0+7=12. Since the next multiple of 9 after 12 is 18, the magician knows that the missing digit is 18-12 = 6.

To speed things up (and to reduce the possibility of a mental arithmetic mistake), the magician doesn’t actually have to add up all of the digits. If the audience member gives a digit of either 0 or 9, then the magician can ignore that digit for purposes of the trick. Likewise, if the magician notices that some subset of the given digits add up to 9, then those digits can be effectively ignored. In the current example, the magician could ignore the 0 and also the 2 and 7 (since 2+7=9). That leaves only the 3, and clearly one needs to add 6 to 3 to get the next multiple of 9.

I was a little curious about how often this happens — how often the magician can get away with these shortcuts to find the missing digits. So I did some programming in Mathematica. Here’s what I found. If the audience starts with a 5-digit number, so that the difference must be some multiple of 9 between 9 and 99,999:

  • There are 690 multiples (out of 11,111, or about 6%) that do not reduce at all (for example, 57,888). So the magician can expect to do the full addition about one-sixth of the time.
  • There are 5535 multiples (about 50%) whose digits can be divided into subsets that sum to 9. So, about half the time, the magician can expect to quickly find the missing digit without having to add past 9.

I’ve put on my mathematical wish-list some kind of theorem about this splitting of digits of multiples of 9s.

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. The links below show the mathematical magic show that I’ll perform from time to time.

Part 1: Introduction.

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

Part 3a, Part 3b, and Part 3c: A geometric magic trick.

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

Part 5a, Part 5b, Part 5c, and Part 5d: A trick using the rule for checking if a number is a multiple of 9.

Part 7: The Fitch-Cheney card trick, which is perhaps the slickest mathematical card trick ever devised.

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

Part 9: Mentally computing n given n^5 if 10 \le n \le 99.

Part 10: A mathematical optical illusion.

Part 11: The 27-card trick, which requires representing numbers in base 3.

Part 6: The Grand Finale.

And, for the sake of completeness, here’s a picture of me just before I performed an abbreviated version of this show for UNT’s Preview Day for high school students thinking about enrolling at my university.

magician

My Mathematical Magic Show: Part 11

A couple years ago, I learned the 27-card trick, which is probably the most popular trick in my current repertoire. In this first video, Matt Parker performs this trick as well as the 49-card trick.

Here’s a quick explanation from the American Mathematical Society for how the magician performs this trick. In short, the magician needs to do some mental arithmetic quickly.

The 27 card trick is based on the ternary number system, sometimes called the base 3 system.

Suppose the volunteer chooses a card and also chooses the number 18. You want to make her chosen card move to the 18th position in the deck, which means you need 17 cards above it. You first need to express 17 in base 3, writing it as a three digit number. For the procedure used in this trick, it’s also handy to write the digits in backward order: 1s digit first, 3s digit second, and 9s digit last. In this backward base 3 notation 17 becomes 221, since 17 = 2×30 + 2×31 + 1×32.

With the understanding that 2 = bottom, 1 = middle, and 0 = top, the number 17 becomes “bottom-bottom-middle.”

Now deal the cards into three piles. The subject identifies the pile containing her card. That pile should be placed at the position indicated by the 1s digit, which is 2, or bottom. After picking up the three piles with the pile containing the chosen card on the bottom, deal the cards a second time into three piles. This time place the pile containing the chosen card in the position indicated by the 3s digit, which is also 2, or bottom. Finally, after placing the pile containing the subject’s card on the bottom, deal the cards into three piles for a third time. When picking up the piles, this time place the pile containing her card in the position indicated by the 9s digit, which is 1, or middle. Deal out 17 cards. The 18th will be her card.

Making a schematic picture of the deck, like Matt does in his second video [below], should convince you that this procedure does precisely what is claimed. But there is no substitute for actually doing it—take 27 cards and try it!

Of course this procedure will work regardless of which position the subject chooses, for her choice is always a number between 1 and 27. This means you need between 0 and 26 cards on top of it, and in base 3 we have 0 = 000 (top-top-top) and 26 = 222 (bottom-bottom-bottom). Every possible position that the subject can choose corresponds to a unique base 3 representation.

In general, if you deal a pack of nk cards into n piles, have the subject identify the pile that contains her card, and repeat this procedure k times, you can place her card at any desired position in the deck. The idea is the same: Subtract one from the desired position number, and convert the result to base n as a k digit number. The ones digit of this number tells you where to place the packet containing her card after the first deal (n – 1 = bottom, 0 = top), and the procedure continues for the remaining deals.

In Mathematics, Magic and Mystery (Dover, 1956), Martin Gardner discusses the long history and many variations of this effect. See Chapter 3, “From Gergonne to Gargantua.”

In this Numberphile video, Matt Parker explains why the trick works.

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. The links below show the mathematical magic show that I’ll perform from time to time.

Part 1: Introduction.

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

Part 3a, Part 3b, and Part 3c: A geometric magic trick.

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

Part 5a, Part 5b, Part 5c, and Part 5d: A trick using the rule for checking if a number is a multiple of 9.

Part 7: The Fitch-Cheney card trick, which is perhaps the slickest mathematical card trick ever devised.

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

Part 9: Mentally computing n given n^5 if 10 \le n \le 99.

Part 6: The Grand Finale.

And, for the sake of completeness, here’s a recent picture of me just before I performed an abbreviated version of this show for UNT’s Preview Day for high school students thinking about enrolling at my university.

magician

 

English words in hexadecimal

Here’s a standard joke involving representing numbers in different bases.

Q: If only DEAD people understand hexadecimal, then how many people understand hexadecimal?

A: 57,005.

The joke, of course, is that DEAD can be considered a number written in base 16, using the usual convention A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15. In other words, DEAD can be converted to decimal as follows:

DEAD_{\small sixteen} = 13 \times 16^3 + 14 \times 16^2 + 10 \times 16 + 13 = 57,005.

After I heard this joke, I wondered just how many English words can be formed using only the letters A, B, C, D, E, and F so that I could make a subtle joke on a test. To increase the length of my list, I also allowed words that included the letters O (close enough to a 0), I (close enough to 1), and/or S (close enough to 5). However, I eliminated words that start with O (since a numeral normally doesn’t start with 0) and/or end in S (the plural version of these words are easily formed).

So I wrote a small program to search the dictionary that I have on my computer. The unabridged list follows, with words beginning with a capital letter (such as names or places) listed at the bottom. I emphasize that this list is unabridged, as there are several words on this list that I wouldn’t place on a test for obvious reasons: I would never ask my class to convert the base-10 numeral 721,077 into hexadecimal just so they can obtain the answer of B00B5.

a

abaci

abase

abased

abbé

abed

abide

abided

abode

aboded

abscessed

abscissa

abscissae

acacia

accede

acceded

accessed

ace

aced

acid

acidic

acidified

ad

add

added

ado

adobe

aid

aide

aided

aside

assessed

b

baa

baaed

babe

babied

bad

bade

baobab

base

based

basic

bassi

basso

be

bead

beaded

bed

bedded

bedside

bee

beef

beefed

beside

biased

biassed

bib

bid

bide

bided

boa

bob

bobbed

bode

boded

bodice

boo

boob

boobed

booed

bossed

c

cab

cabbed

cabbie

caboose

cacao

cad

caddied

café

cascade

cascaded

case

cased

cassia

cease

ceased

cede

ceded

cicada

cicadae

cob

cobbed

cocci

cocoa

cod

coda

codded

code

coded

codified

coed

coffee

coif

coifed

coiffed

coo

cooed

d

dB

dab

dabbed

dad

dado

dead

deaf

deb

debase

debased

decade

decaf

decease

deceased

decide

decided

decode

decoded

deed

deeded

deface

defaced

defied

deice

deiced

deified

dice

diced

did

die

died

diocese

diode

disc

disco

discoed

disease

diseased

dissed

do

doc

dodo

doe

doff

doffed

doodad

dose

dosed

e

ease

eased

ebb

ebbed

eddied

edifice

edified

efface

effaced

f

fa

facade

face

faced

fad

fade

faded

fed

fee

feed

fiasco

fib

fibbed

fie

fief

fife

fob

fobbed

foci

foe

food

i

ice

iced

id

idea

if

sac

sad

safe

said

sassed

scab

scabbed

scad

scoff

scoffed

sea

seabed

seafood

seaside

secede

seceded

see

seed

seeded

sic

side

sided

so

sob

sobbed

sod

soda

sodded

sofa

A

Abbasid

Abe

Ac

Acadia

Ada

Addie

Aida

Asia

Assad

Assisi

B

Ba

Basie

Be

Bede

Beebe

Bessie

Bi

Bib

Bic

Bob

Bobbi

Bobbie

Boccaccio

Boise

Bose

C

Ca

Case

Casio

Cassie

Cd

Cf

Ci

Cid

Co

Cobb

D

Dacca

Dada

Debbie

Dec

Decca

Dee

Defoe

Di

Dido

Doe

E

Eco

Ed

Edda

Eddie

Effie

Essie

F

Fe

Feb

Fed

Fido

I

Iaccoca

Ibo

Ida

Io

Isaac

Issac

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.