# Mathematical Magic

The universe is full of magical things, patiently
waiting for our wits to grow sharper
.
Eden Phillpotts   (1862-1960)

That must be wonderful !
I don't understand it at all
.
(Anonymous)

Any sufficiently advanced technology is indistinguishable from magic.
Third Law  of   Arthur C. Clarke  (1917-)

### Related Links (Outside this Site)

Beginner's Easy Magic Tricks   |   Math Magic by Larry Moss.
1089 and all that, by David Acheson   (Plus magazine, Sept. 2004)
Magic Tricks with NumbersMartin Gardner  (Games Magazine, May 1999).
grand-illusions.com:  Illusions for sale... and great giveaways!
Learn Free Magic Tricks.
Math Tricks at  John Handley High School.

Video  (courtesy of  Encyclopedia Britannica)   mp4 (116 MB)  |  wmv (113 MB)
Mystery and Magic of Mathematics:  Martin Gardner and Friends

## Mathematical "Magic" Tricks

(2004-12-02)   1089
Pick a 3-digit number where the first and last digits differ by 2 or more...
• Consider the "reverse" number, obtained by reading it backwards.
• Subtract the smaller of these two numbers from the larger one.
• Add the result to its own reverse.
Why is this always equal to 1089?

This is one of the better tricks of its kind, because the effect of reversing the digits is not obvious to most people at first...  If the 3-digit number reads abc, it's equal to 100a+10b+c, and we have the following result after the second step:

| (100a+10b+c) - (100c+10b+a) |     =     99 | a-c |

The quantity  | a-c |  is between 2 and 9, so the above is a 3-digit multiple of 99, namely: 198, 297, 396, 495, 594, 693, 792 or 891.  The middle digit is always 9, while the first and last digits of any such multiple add up to 9.  Thus, adding the thing and its reverse gives 909 plus twice 90, which is 1089, as advertised.

(2009-03-31)   Mass Media Mentalism
The magic of David Copperfield (1992)

In a 1992 TV show,  David Copperfield  turned simple-minded mathematical properties into something wonderful, for an audience who was (skillfully) led to expect magical things to happen.

Copperfield first asks you to take  N  steps forward and  N  steps back.  It doesn't matter what  N  is, does it?  Later he asks you to go  halfway  around a circle in whichever direction you choose  (another type of irrelevant choice).

Regardless of the details of that particular show, it should be clear that a magician can only make predictions about outcomes which do not depend on the choices of his many spectators.  However, surprisingly many people want to believe in some irrational explanation.  This is what really scares  me.

Besides the visual effects and the dramatic setup, the challenge in designing such a collective effect is also to devise instructions that  everyone  can follow...

(2004-04-03)   Grey Elephants in Denmark
Mental magic  for classroom use...   [Single-use collective mentalism]

The teacher tells the class that a crowd can be driven to think about the same thing; very few people will escape the mental picture shared by all others...

Each student in the class is asked to think about a small number and is then instructed to perform the following operations silently.

• Double the number.
• Add 8 to the result.
• Divide the result by 2.
• Subtract the original number...
• Convert this into a letter of the alphabet. (1=A, 2=B, 3=C, 4=D, etc.)
• Think of the name of a country which starts with this letter.
• Think of an animal whose name starts with the country's second letter.
• Think of the color of that animal...

The teacher then announces to a puzzled classroom that their collective thinking must have gone wrong, since "there are no grey elephants in Denmark"...

Well, there  are  elephants in Denmark:  At this writing, the home of Kungrao (M), Surin (F) and Tonsak (F) is the Copenhagen Zoo...

The trick works in most parts of the World, but I wonder how many students from the Caribbeans would think of an "ostrich in Dominica" instead.

Michael Jørgensen (2004-03-24)   The 5-Card Trick of Fitch Cheney
How to reveal one of 5 random cards by showing the other 4 in order.

The 4! = 24 ways of showing 4 given cards in order would not be enough to differentiate among the remaining 48 cards of the pack.  However, since we may choose what card is offered for guessing, we have an additional choice among 5.  This translates into 120 possible courses of action, which is more than enough to convey the relevant information.  Here's one practical way to do so:

Consider two cards of the same suit  (among 5 cards we always have  at least  one such pair available).  Let's call them the   base card  and the  hidden card, in whichever way makes it possible to go from the base card to the hidden card card by counting at most 6 steps clockwise on a circle of the 13 possible values.  (King is followed by Ace, Ace is followed by 2, 3, 4, etc.)

We offer the hidden card up for "guessing".  By revealing the base card first, we reveal immediately the suit of the hidden card and we also set the point where a count of up to 6 "clockwise" steps is to begin to determine the hidden card.

The order in which the remaining 3 cards are presented can be used to reveal this count, as there are 6 possible permutations of 3 given cards.  Using some agreed-upon ordering of the cards in a deck, we have a high card (H), a medium card (M) and a low card (L) in hand.  Some arbitrary code may be used, like:

LMH = 1 ;   LHM = 2 ;   MLH = 3 ;   MHL = 4 ;   HLM = 5 ;   HML = 6

This trick is credited to Dr. William Fitch Cheney, Jr. (Fitch the Magician, 1894-1974)  who earned the first math Ph.D. ever awarded by MIT (1927).

The puzzle is presented in the 1960 book of Wallace Lee  entitled  Math Miracles  (chapter 14, as quoted by Martin Gardner)  and was popularized by the magician Art Benjamin in 1986.  It was used in a 1994 job interview and subsequently appeared on the rec.puzzles newsgroup, where Bob Vesterman posted the particular solution presented above  (1994-04-25).

In 1995, Robert Orenstein implemented Vesterman's encoding for online play at  http://www.anamorph.com/docs/ct/cards.html, but the interactive part has "temporarily" been shut down, since 2002-08-15.

The Best Card Trick  (PDF)  by Michael Kleber.  Mathematical Intelligencer 24 #1 (Winter 2002).
Fitch Cheney's Five-Card Trick  by Colm Mulcahy  (MAA Horizons, Feb. 2003).

Eric Farmer (2004-03-25)   [Generalization of the above]
Reveal n random cards (from a deck of d) by showing only k of them...

The previous article deals with k=4, n=5, d=52.  The case k=3, n=8, d=13 has been dubbed  Devil's Poker :  The Devil chooses 5 cards of a single suit and you present 3 of the remaining 8 cards one by one to an Angel who must guess the Devil's hand, using a  prior  convention between you and the Angel.

We have   k! C(n,k) = n!/(n-k)!   possible actions to reveal one of  C(d-k,n-k) compatible possibilities.  This task is only possible if the former number exceeds the latter, which means that  n!(d-n)!  must be greater than or equal to  (d-k)! .

In the case considered by Michael Kleber in the Mathematical Intelligencer article (PDF) mentioned at the end of the previous article, we have  k = n-1, so the above inequality boils down to  d < n!+n, as stated by Kleber who goes on to prove that this necessary condition is sufficient to establish a working strategy...

(2006-05-01)   The Kruskal Count
Kruskal's card trick.

This trick is attributed to the physicist Martin David Kruskal  (1925-2006).  It illustrates a statistical feature which is amazing enough when one first encounters it.  Here's one way to present the effect:

If we use a regular deck of cards, we either remove the face cards or attribute to them the same value (1) as aces.  Beforehand, a player choses  secretly  a special number N from 1 to 10.  As the cards from the deck are revealed one by one, the player counts cards and considers the N-th card revealed to be his  new  special number and keeps counting N cards from that one, and so forth...  All told, only a few cards are thus singled out as special.  The majority are not...

Yet, toward the end of the deck the dealer  (the magician)  can confidently point out that one particular card is "special"...

The same trick can be demonstrated by a clever dealer which just looks at the cards before dealing them and announce that a specific card (which may be flipped in the deck)  will  turn out to be special.  You may play this version online with a computer which (honestly) shuffles the deck.  Allow yourself to be baffled a few times before reading on...

Well, the explanation is simply statistical.  Consider, for simplicity, the related case of

Two subsequences extracted with the above rules from an infinite sequence of digits (0 to 9) will enventually coincide, because if they coincide once they coincide forever  (think about it).

(2008-01-25)   Kruskal Paths to  God.   (Martin Gardner, 1999)
In the  U.S. Declaration of Independence,  all paths lead to  God.

In the  May 1999 issue of  Games MagazineMartin Gardner published the following puzzle, among a small collection of  some magic tricks with numbers.  It involves the first sentences of the  US Declaration of Independence :

 When in the Course of human Events, it becomes necessary for one People to dissolve the Political Bands which have connected them with another, and to assume, among the Powers of the Earth, the separate and equal Station to which the Laws of Nature and of Nature's God entitle them, a descent Respect to the Opinions of Mankind requires that they should declare the causes which impel them to the Separation.

You are instructed to pick any word in the first (red) section of the text.  Then, skip as many words as there are letters in your chosen word.  For example, if you picked the fourth word ("Course") you have to skip 6 words ("of human Events, it becomes necessary") to end up on the word "for"...  Iterate the same process, by skipping as many words as there are letters in the successive words you land on.

What's the first word you encounter in the last (green) section?  Answer:  God.  Always.  (The sequence would continue with the words: descent, that, causes.)

The "magic" is based on the Kruskal principle discussed above...  You will ultimately land on  God  by starting with most words in the middlle (yellow) section.  The words that do work have been underlined for you.  You may check that this underlining is correct by working it out (backwards) for yourself, starting with the last yellow words  ("and", "of") which do land on  God  in one step.  As any word which leads to an underlined word gets underlined itself, almost all words in the yellow section end up being underlined.  This includes the first 17 words of that yellow section.  Since all words of the red section have less than 17 letters, that solid chunck of underlined words can't be jumped over and, therefore, all paths starting in the red section will ultimately lead to the word "God" in the green section.  (Actually, any word up to the word "Station" is a valid beginning of a sequence which ends up on the word "God".)

Kruskal Count  by  Doctor Douglas  (2007-04-01)

CHaSeD
C
§
H
S
ª
D
¨
A 4 7 10
K 3 6 9
Q 2 5 8
J A 4 7
10 K 3 6
9 Q 2 5
8 J A 4
7 10 K 3
6 9 Q 2
5 8 J A
4 7 10 K
3 6 9 Q
2 5 8 J
§
1
2
ª
3
¨
0

(2009-01-08)   Stacked Deck
A predictable deck of cards that  looks  disordered.

The ordering illustrated above and presented at right is also  revealed  at the end of a video posted by  Furrukh Jamal  presenting two related magic tricks.

You may  cut  such a deck many times, but don't shuffle it  (seasoned illusionists may use  false shuffling  techniques).

The value of the  Nth  card from the top  (face down)  is:

x   =   B  +  3 N   (mod 13)

Here,  B  is the value of the  bottom card,  using the following numerical convention  (discarding multiples of 13).

 A J Q K 1 2 3 4 5 6 7 8 9 10 11 12 0 2 3 4 5 6 7 8 9 10

With the numerical code for suits given at the bottom of our main table, if  S  is the suit of the bottom card, then the suit of the  Nth  card is simply:

y   =   S + N   (mod 4)

For example, if the bottom card is the jack of diamonds  (B=11, S=0)  then the tenth card  (N=10)  is a  deuce  (since 11+3.10 is 41, which is equal to 2 modulo 13).  It's the deuce of  hearts  because  0+10  is equal to 2 modulo 4.

One trick is to have a spectator cut the deck.  You secretly look at the bottom card and call the card  3  units higher in the next suit  (from the  "CHaSeD"  sequence  Clubs, Hearts, Spades, Diamonds)  before revealing the  top  card.

### Find a Specific Card by Counting :

Conversely, the position  N  of the card  x  of suit  y  can be obtained from the Chinese Remainder Theorem  (a result N=0 would denote the bottom card).  Since  3N  is  x-B  modulo 13,  N  is  -4(x-B)  modulo 13  and we have:

N   =   13 bezout (13,4) (y-S)  -  4 bezout (4,13) 4 (x-B)

This boils down to the following easy-to-memorize formula:

 N   =   13 (y-S)  -  4 (x-B)     (modulo 52)
The existence of such a formula makes the above far more flexible than other stacking schemes which lack arithmetic regularity  (including the infamous "Eight Kings CHaSeD" stack, which is merely based on the mnemonic sentence:  "Eight Kings threatened to save nine fair ladies for one sick knave"   standing for the ordering  8KT2794Q4A7J).

For example, if the bottom card is the jack of diamonds  (B=11, S=0)  then the queen of hearts  (x=12, y=2)  is found at the following position  (modulo 52):

N   =   13 (2-0)  -  4 (12-11)   =   22

The king of spades is at   N   =   13 (3-0)  -  4 (13-11)   =   31

The queen of diamonds is at   N   =   13 (0-0)  -  4 (12-11)   =   -4   =   48

The ace of clubs is at   N   =   13 (1-0)  -  4 (1-11)   =   53   =   1   (Isn't it?)

Preparation :   Here's a quick method to arrange the deck as above :

1. Sort separately the 13 cards of each suit face up, highest on top.
2. Cut the 4 heaps so their respective top cards are:  A§4©,  7ª  10¨
3. Build the whole deck (face up) from top cards in the order:  § © ª ¨

Mother of All Card Tricks Revealed  by  Furrukh Jamal   (Video)

(2009-01-11)   Magic Age Cards
Tell the age of people (beween 0 and 63) from the cards they pick.

Some traditional  magic age cards  forgo the numbers 61, 62 and 63  (so that only 29 or 30 numbers per card are required, which are printed in a  5 by 6  pattern,  with or without a star in the 30th position).  Full-range cards  (with 32 numbers printed on each card)  are more satisfying.  Here are those 6 cards:

 32  33  34  35 36  37  38  39 40  41  42  43 44  45  46  47 48  49  50  51 52  53  54  55 56  57  58  59 60  61  62  63 16  17  18  19 20  21  22  23 24  25  26  27 28  29  30  31 48  49  50  51 52  53  54  55 56  57  58  59 60  61  62  63 08  09  10  11 12  13  14  15 24  25  26  27 28  29  30  31 40  41  42  43 44  45  46  47 56  57  58  59 60  61  62  63 04  05  06  07 12  13  14  15 20  21  22  23 28  29  30  31 36  37  38  39 44  45  46  47 52  53  54  55 60  61  62  63 02  03  06  07 10  11  14  15 18  19  22  23 26  27  30  31 34  35  38  39 42  43  46  47 50  51  54  55 58  59  62  63 01  03  05  07 09  11  13  15 17  19  21  23 25  27  29  31 33  35  37  39 41  43  45  47 49  51  53  55 57  59  61  63

Effect :   A spectator thinks of a number (up to 63) and tells you on what cards it is.

You call the exact number!

Secret :   The  weight  of each card is the smallest number printed on it.  Any number is equal to the sum of the  weights  of the cards it appears on.  For example:

52   =   32 + 16 + 4

This is just a straight consequence of binary numeration.  Each card actually shows all the numbers which have a "1" in their respective binary representations at a given position.  The binary representation of 52 being 110100, it appears on 3 cards and is equal to the sum of the 3 relevant powers of  2.  Voilà.

Magic Age Cards  (\$1.29 Party Trick)   |   Number Guessing Game  at Cut-the-Knot

(2009-01-14)   Michon's Ternary Cards
Tell the age of people (beween 0 and 80) from the colors they pick.

This is my own new improvement  (2009-01-14)  over traditional  "age cards".

The introduction of black and red colors allows a larger range of numbers  (80 instead of 63)  using fewer cards  (just 4 cards instead of 6).

 01  02  04  05  07  08 10  11  13  14  16  17 19  20  22  23  25  26 28  29  31  32  34  35 37  38  40  41  43  44 46  47  49  50  52  53 55  56  58  59  61  62 64  65  67  68  70  71 73  74  76  77  79  80

 03  04  05  06  07  08 12  13  14  15  16  17 21  22  23  24  25  26 30  31  32  33  34  35 39  40  41  42  43  44 48  49  50  51  52  53 57  58  59  60  61  62 66  67  68  69  70  71 75  76  77  78  79  80

Effect :   A spectator thinks of a number (up to 80) and tells you its color  (red or black)  on each card where it appears.

You call the exact number!

Secret :   For each color called by the spectator, add the smallest number of the  same color  on the card.  The total will be the secret number.

For example:

52   =   1 + 6 + 18 + 27

 09  10  11  12  13  14 15  16  17  18  19  20 21  22  23  24  25  26 36  37  38  39  40  41 42  43  44  45  46  47 48  49  50  51  52  53 63  64  65  66  67  68 69  70  71  72  73  74 75  76  77  78  79  80
 27  28  29  30  31  32 33  34  35  36  37  38 39  40  41  42  43  44 45  46  47  48  49  50 51  52  53  54  55  56 57  58  59  60  61  62 63  64  65  66  67  68 69  70  71  72  73  74 75  76  77  78  79  80

Those cards are based on  ternary  numeration:  In base 3, all numbers less than 81 are represented by 4 digits or less.  For each digit position, one of the cards gives all the 54 numbers which have a nonzero digit at that position.  If the digit is 1, the number is listed in  red  if the digit is 2, the number is listed in  black.

(2009-04-05)   Magical 21
Ask  3  questions to find one card among 27 (or fewer).

This is a classic no-brainer.  Deal any odd number of cards up to 27 in three equal piles  (this means you're dealing 15, 21 or 27 cards, according to taste).  Ask what pile the chosen card belongs to and collate the cards so the chosen pile is in the middle.  Deal and collate again in the same way.  Deal one last time.  The chosen card will be in the middle of the selected row.  Reveal it in whatever dramatic way you like...

For a very fast effect, use just 9 cards and deal only twice  (although the underlying math for this 2-step trick becomes rather obvious).

Video 1   |   Video 2   |   Video 3

(2009-01-13)   Boolean Magic
You have two choices.  Choose  either  2  or  3...

Multiply your chosen number by  any  odd number and multiply the number you did not choose by  any  even number.  Add those two products together...

From that result, how can a magician  determine which number was chosen?

(2009-03-26)   Faro Shuffles   (cf. A024222)
8 perfect faro shuffles leave a deck of 52 cards unchanged.

### Even number of cards :

In a perfect faro shuffle of an  even  number of cards, the deck is split into equal halves which are then interweaved.

There are two ways to do the interweaving.  In an  out shuffle,  both the top card and the bottom card remain unchanged  In a so-called  in shuffle  neither does  (the top card becomes second and the bottom card becomes next-to-last).

Out-shuffling  2n+2  cards is equivalent to in-shuffling the inner  2n  cards.

Faro Shuffle Tutorial   |   Faro Shuffle Explained

### Shuffling decks with an odd number of cards :

When the deck consists of an  odd  number of cards, the deck is split into a pack of  n+1  cards and a pack of  n  cards.

If the larger pack is on the bottom, then the bottom card always remains unchanged and we are simply faced with a faro shuffling of only the  2n  top cards.  So, only the case where the top pack is larger need be considered.  For an  out shuffle  that case is equivalent to an  out shuffle  of  2n+2  cards  (in an outshuffle of an even number of cards, the bottom card stays in place).  All told, the only case where the faro shuffling of an odd number of cards does not reduce trivially to the shuffling of an even number of cards is the following one:

In-shuffling of  2n+1  cards, cutting  n+1  cards from the top.

In such a shuffle, there is a pair of adjacent cards from the middle of the pack which remain adjacent at the bottom of the pack after the shuffle.  It's much less regular than the other type of faro shuffling.  Yet, some patterns appear:

The number  s  of such shuffles that are needed to return a deck of  n  cards to its original state is a complicated function of  n.  Remarkably, when  n  is  3  units below a power of  2,  then  s  is a simple quadratic function of the exponent  (usually, the ratio  s/n  is then much smaller than for any lesser values of  n).

   n   s   n   s 5 13 29 61 125 253 509 1021 2045 4093 ... 2k - 3 6 12 20 30 42 56 72 90 110 132 ... (k-1) k 7 15 31 63 127 255 511 1023 2047 4095 ... 2k - 1 10 56 90 132 182 240 306 380 462 552 ... 2 k (2k-1)