I am interested in magic tricks whose explanation requires deep mathematics. The trick should be one that would actually appeal to a layman. An example is the following: the magician asks Alice to choose two integers between 1 and 50 and add them. Then add the largest two of the three integers at hand. Then add the largest two again. Repeat this around ten times. Alice tells the magician her final number $n$. The magician then tells Alice the next number. This is done by computing $(1.61803398\cdots) n$ and rounding to the nearest integer. The explanation is beyond the comprehension of a random mathematical layperson, but for a mathematician it is not very deep. Can anyone do better?

54$\begingroup$ I am informed that Persi Diaconis is the correct person to answer this question. $\endgroup$– Sam NeadDec 26, 2009 at 0:09

20$\begingroup$ I have discussed this question with Persi. He could not come up with anything significant (though he did not think about it very long). $\endgroup$– Richard StanleyDec 26, 2009 at 16:30

23$\begingroup$ I've also heard Persi talk about this subject, and my guess is that he would say that the requirements of "deep mathematics" and "would actually appeal to a layman" are nearly incompatible in practice. $\endgroup$– Mark MeckesDec 27, 2009 at 13:54

12$\begingroup$ Whenever I see this question's title, I can hardly resist opening a complementary "Deep mathematics based on magic tricks" community wiki. $\endgroup$– Torsten SchoenebergMay 16, 2013 at 7:51

10$\begingroup$ Isn't it risky to do magic tricks that require a member of the audience to carry out a computation? What do you do if Alice botches the computation? $\endgroup$– bofDec 8, 2014 at 7:04
47 Answers
This is a trick that I designed years ago and I have used it in many different occasions for amusement only or educational purpose or both. It is indeed the finial difference method to find a polynomial. Ask the person to write down a polynomial without you knowing the polynomial and even the degree of the polynomial. To keep your life easy, it would be better to keep the degree less than or equal 3. (It wouldn't be hard to let a layman know what a polynomial is just by giving two or three examples). Then you ask for some information that is essentially the value of the polynomial for 0, 1, 2, 3. As soon as you take one of the value you should calculate the difference. And in a few seconds after taking the last information, you announce not only the degree of the polynomial but also the exact polynomial.
Note 1: Finding the degree is a very important part of this trick since it convinces more knowlegable persons that you are not just solving a simultaneous equation quickly.
Note 2: I used this trick in my Calculus classes to give this seemingly paradoxical idea that "if you don't know what the function is, try to figure out how it changes."
Note 3: Of course, one can use it in many different classes for different purposes.
Note 4: I've just search the internet to see if Martin Gardner ever introduced this trick. Damn it! The answer was yes, here: "The calculus of finite differences". However, I still love to keep the credit of telling the degree for my self :)

1$\begingroup$ It is similar to Shamir's secret sharing: en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing $\endgroup$ May 15, 2013 at 20:50

2$\begingroup$ If you instruct the person writing down the polynomial to only use nonnegative coefficients, then in fact two evaluations (at integral points) suffice for you to uniquely infer the polynomial, irrespective of its degree. $\endgroup$ Aug 12, 2016 at 20:02
My favourite example, the rope and two carabiner trick http://blogs.scientificamerican.com/guestblog/amazingropetrick/
I also offer up my variation of the Dirac belt trick https://m.youtube.com/watch?v=UtdljdoFAwg
Here is a trick much in the spirit of the original numberadding example; moreover I'm sure Richard will appreciate the type of "deep mathematics" involved.
On a rectangular board of a given size $m\times n$, Alice places (in absence of the magician) the numbers $1$ to $mn$ (written on cards) in such a way that rows and columns are increasing but otherwise at random (in math term she chooses a random rectangular standard Young tableau). She also chooses one of the numbers say $k$ and records its place on the board. Now the she removes the number $1$ at the top left and fills the empty square by a "jeu de taquin" sequence of moves (each time the empty square is filled from the right or from below, choosing the smaller candidate to keep rows and columns increasing, and until no candidates are left). This is repeated for the number $2$ (now at the top left) and so forth until $k1$ is gone and $k$ is at the top left. Now enters the magician, looks at the board briefly, and then points out the original position of $k$ that Alice had recorded. For maximum surprise $k$ should be chosen away from the extremities of the range, and certainly not $1$ or $mn$ whose original positions are obvious.
All the magician needs to do is mentally determine the path the next slide (removing $k$) would take, and apply a central symmetry with respect to the center of the rectangle to the final square of that path.
In fact, the magician could in principle locate the original squares of all remaining numbers (but probably not mentally), simply by continuing to apply jeu de taquin slides. The fact that the tableau shown to the magician determines the original positions of all remaining numbers can be understood from the relatively well known properties of invertibility and confluence of jeu de taquin: one could slide back all remaining numbers to the bottom right corner, choosing the slides in an arbitrary order. However that would be virtually impossible to do mentally. The fact that the described simple method works is based on the less known fact that the Schútzenberger dual of any rectangular tableau can be obtained by negating the entries and applying central symmetry (see the final page of my contribution to the Foata Festschrift).
You may ask the person to encode something by RSA, then you decode it (you have the private key)
OR
To divide two 40digit integers and give you the decimal result to 100 digits, you then use continued fractions to find the original fraction (reduced)
OR
To compute pq and pr where p,q,r are prime, you then find p,q,r by the Euclidean algorithm (no very deep, but it's the best i've got)
Here's a couple of wellknown simple topology tricks:
Tie ends of a long enough piece of rope to your wrists, while wearing a loosely fitting jacket or sweatshirt. With your arms tied like that, take the jacket off your back and put it back on inside out. It's easier to figure out how to do it than to explain it in words, so I'll skip the explanation. The more risque version is to tie the ankles and do the trick with pants.
The other one I haven't tried, but maybe it can be done at a party if you have a stick and some plasticine around.

$\begingroup$ The one with the plasticine is more of an exercise for mathematicians to figure out what is wrong with the method. $\endgroup$– Adam GalJul 13, 2010 at 6:37
A variant on Anton Geraschenko answer above say you are in a fourth grade school that for some reason let these poor kids use calculators. you ask them to pick for themselves a 3 digit number say abc. Tell them to write it twice in their calculator ,i.e., abcabc and then divide by 77. Then by 13. What did you get? do it again with 143 and then by 7? What did you get. again with...
It teaches them about prime decomposition, about the decimal structure, about consecutive division etc.
I learnt it from Avraham Arcavi.

1$\begingroup$ The title is, "Magic trick based on deep mathematics." I don't think that was meant to be taken as "deep to 4th graders." $\endgroup$ Nov 17, 2010 at 0:05
Destination Unknown is a magic trick that makes use of Combinatorics. It really fools people.
See http://themagicwarehouse.com/cgibin/findit.pl?x_item=SP2453&keyword=DESTINATION
Although one of the answers mentions Kruskal count, I would like to add more about it. Kruskal count not just works in the case of a paragraph as well. If you start from one of the first ten words of a paragraph, go to the word which is away from the previous word by number of words exactly equal to the letters of the previous word, you'll land up on the same word in the end! For more discussion, you can refer this link
Apart from tricks based on numbers, there are topological objects whose properties can seem quite magical, like the Möbius strip or the unknot.
E.g. take a standard page of paper, show that it has two sides (number them with a pen, show that any straight pen path meets a boundary). Next, cut out a long strip from it (not needed of course, but adds to the drama), and ask the audience "and how many sides does this have?". They reply "two". Then you put the the two small ends of the strip together to form a ring and you ask "and now, how many sides?", they still reply "two!". At this point do a little diversion, like putting a pair of scissors on the table saying out loud "I'll use this in a minute". Now do a halftwist with the strip before putting the small ends together and ask again "for the last time people, how many sides?". They answer "twoo!!", and you say "the magic has worked people, there's only one side!" (you show that now the pen paths along the long direction never meet a boundary and come back). Most laymen are quite bemused. Now do two halftwists and ask again, some won't dare an answer...

$\begingroup$ I agree that the Mobius strip is magic. But it is not a trick! $\endgroup$– Sam NeadDec 28, 2009 at 14:21

$\begingroup$ Someone posted something similar earlier, but I guess they deleted it. My complaint was that, while it is perhaps counterintuitive at first sight, it isn't very deep mathematically. $\endgroup$ Dec 29, 2009 at 16:10

1$\begingroup$ Have an assistant cut a cylinder in half along its median circle. Then cut a Mobius strip along its median. $\endgroup$ Jan 17, 2010 at 23:08

1$\begingroup$ How is orientability not a deep mathematical concept? $\endgroup$ Jun 22, 2012 at 11:31
If you are not mathematically inclined, this game can drive you crazy. http://www.transience.com.au/pearl.html
The "casting out nines" sanity check of calculations is dead simple to use (a small child can do it), but the proof requires a deeper knowledge of mathematics (more precisely of arithmetic ; my own students don't have access to it even though they know what series are and can diagonalize matrices!).

$\begingroup$ I wouldn't consider "casting out nines" deep mathematics, and it should be relatively easy giving your students access to it, if you wanted. Certainly it would fit well into a first abstract algebra course. $\endgroup$– Todd Trimble ♦Sep 15, 2012 at 12:18

$\begingroup$ First, notice I didn't write it was deep mathematics  I wrote "deepER" ; I explained that it can be used by children, but understanding why it works is more difficult. So I stand by my statement as I wrote it :) Second, I definitely can't do arithmetic with my students : I'm teaching in a scientific CPGE, so the quotient (syllabus content)/(time to cover it) is already very high [see: en.wikipedia.org/wiki/…  where they mention the years as "intensive" which is quite an understatement]. $\endgroup$ Sep 15, 2012 at 18:43

$\begingroup$ Don't worry; I noticed. :) As for the rest, that's too bad. I was thinking that it's something that could be easily explained in a few minutes to a bright and curious youngster during office hours, but maybe those opportunities don't exist for your situation? $\endgroup$– Todd Trimble ♦Sep 16, 2012 at 15:30

$\begingroup$ Those opportunities are rare enough that I would like to move on and get back to university... :/ $\endgroup$ Sep 16, 2012 at 19:34
Matt Baker's book The Buena Vista Shuffle Club might tick the boxes. He is a math professor and card magician and the book uses a lot of math principles. It's published by Vanishing Inc.
Lay out 21 cards face up in three vertical lines. Have a friend pick out any card without telling you which card he/she has chosen. Have your friend tell you which line of cards the selected card is in, and make three stacks of cards, each stack being made from each line of cards. stack the three stacks on top of each other, placing the stack with the selected card between the other two stacks (IMPORTANT!). lay out the cards again in the exact same set up (3 lines of 7 all face up) but here is the trick: when laying out the cards, flip them face up in a line every time. In other words, don't make one line at a time, but put a card in every line one at a time. Have your friend again tell you which line has the selected card. Stack the cards again, the exact same way you did the first time. One more time, lay out the cards the exact same way as the last time, one card per line, and again have your friend tell you which line has the selected card. Stack all the cards again one last time, again placing the line with the selected card between the other stacked cards. now lay out all the cards face down, one at a time. while you're doing this, remember to count, because the 11th card you place down is the selected card. from this point you can do whatever you can think of to make the trick "magical" and shock your friend by suddenly coming up with his/her card.
Start with a deck of 32 cards. Then the player should take a card and tell a number $n$ between 1 and 32 then you divide the stack in 2 smaller stacks and the player has to tell which of the stacks contains his chosen card. according to a rule dependend on that number you put that stack above or below the other stack. After repeating this 5 times the chosen card should be exactly at position $n$. The rule has to depend on the way you want to deal cards (whether you turn around the deck and start dealing from the bottom, or you deal from the top and turn each single card around or you deal at first and then turn bost stacks around). In one of the cases the rule was take $N11$, find the representation in the system with base $2$ and revert that presentation. ($0$ tells you to put the stack containing the chosen card on top, etc.). I dont remeber this trick properly, it should not be too difficult to express the final position depending on the choices in some formula; but it is the only situation I know, in which the $2$system is useful.
i was about the to post another trick based on binary encoding in radices (or hamming codes) which has already been posted (see comment as well)
So i will post another one based on cyclic orderings (known also as "The Fitch Cheney FiveCard Trick")
excerpt (from here):
You hand a deck of cards to an audience and tell them to choose any five cards they wish. You collect the ve cards, look at them quickly, and then ask a volunteer to hide one of the cards after showing it to the audience. You place the remaining four cards face up in a line. You then tell someone in the room to go to the door and fetch your partner, who has been waiting outside. You take a seat in the back of the room somewhere out of sight. Your partner enters, takes a look at the four cards displayed, and correctly calls out the hidden card! Applause follows.

2

Requirements for audience: pen, paper, and calculator. You have nothing. Offer the following instructions:
 Write down a whole number of any size without showing you.
 Just below it, write the same digits in a mixed up order.
 Subtract the smaller from the larger, and write down the result.
 In the resulting number, circle any digit which is not a 0.
 Ask them to tell you the other digits in the number which are not circled.
 You tell them the circled digit.
The key of course is that the resulting number in step 3 must be a multiple of 9 (obvious to readers here.) As the audience is reciting the digits in step 5, just keep track of the sum modulo 9. Take the result and subtract from 9 and that is the circled digit (except when the result is 0 then the circled digit is 9.)

1$\begingroup$ Are you sure that this mathematics is deep? $\endgroup$ Apr 12, 2019 at 0:56

1$\begingroup$ Perhaps not by your standards, but in the context of the OP I think it's at least appropriate to mention. "The explanation is beyond the comprehension of a random mathematical layperson, but for a mathematician it is not very deep. Can anyone do better?" $\endgroup$– MattApr 12, 2019 at 13:31

2

1$\begingroup$ No, that one isn't dumb, but it's more about psychology than about mathematics (like most tricks with cards). $\endgroup$ Feb 7, 2010 at 13:58