Monday, July 11th, 2011...3:19 pm
Computing magic
A clever use of mathematics can mystify audiences. A variety of resources divulge such secrets for a budding mathematically-inclined magician. Colm Mulcahy’s (Spelman College) column Card Colm on MAA Online reveals the mathematics behind a variety of tricks that
involve such topics as Fibonacci numbers and results of Paul Erdös.
Mathemagician Art Benjamin (Harvey Mudd College) unveils secrets of rapid mental calculation in his book, Secrets of Mental Math. How magical such tricks appear is correlated to one’s insight into the underlying mathematics.
Last week, I started following Colm on Twitter at @cardcolm and began wondering about YouTube videos on math-based card magic. I quickly bumped into this one:
As evident in the video, and soon verified with a deck of cards in my office, the trick does not rely on any specific ordering. As I reflected on the mathematics behind the magic, I noticed, of course, that the trick relies on placing the chosen card ninth from the bottom. There are 52 cards so the chosen card is 43 from the top. Initially, this seemed one card off. However, then I imagined capping all 4 piles. In this case, the last pile IS capped with the chosen card. However, in every other case, the trick works the same way. You sum the cards that are face up and count that many cards down. If the sum is 10, for example, the tenth card is the chosen card. Why does the trick work? I’m going to leave that to your mathematical exploration, mainly due to my repeated inability at writing a clear, succinct answer.
Unless you cap all four piles, you are able to add up the sum of the cards that are face up and count that many cards down to unveil the chosen card. If you cap all four piles, there are no cards face up. In such a case, the “zero” card (rather than the first or thirteenth card, for instance) is the chosen card. Granted, a magician, such as yourself, could finesse unveiling such a “zero card,” which would be the card to cap the fourth pile. In my mind, this is less magical than counting down and finding the chosen card. I found myself wondering, “What is the probability of this even happening?” Feeling quite nerdy but not minding (much), I grabbed a pencil and paper and begin trying to compute such a probability. Soon, it appeared I would need to cover several cases or sit until I perceived another approach. Then, I laughed in the realization, “I’m a mathematician and computer scientist! Let the computer do the computing!”
I quickly coded a MATLAB program to perform the trick. I created a deck and randomly permuted the cards to serve as my shuffle. Then, I simply performed the trick 100,000 times keeping track of how often I capped all four piles in the trick. The first time I ran the computation, this occurred 1352 times. The second time I (via MATLAB) performed the trick 100,000 times capping all four piles 1336 times.
So, I would have about a 1.3% chance of this happening! Given I rarely perform magic, this is a pretty small chance. If I decided to perform the trick more often, could I live with that probability? Would you? It may partially depend on what you do when the case arises. Frankly, I might just put the chosen card as the 8th card from the bottom and then count down the desired number of cards and the next card is your card. In such a case, if every deck is capped, the next card is your card. The math is easier to perceive though…But, I often perform math-based magic tricks so people can learn and struggle with the math. Yet, maybe that’s precisely why the original trick is compelling! I, for instance, sat that long, coded a MATLAB program to perform the trick, and am now blogging about it! Were the card the 8th from the bottom, maybe once I saw the trick, I might have even forgotten about it several hours later. I guess, now that I think about it, I can live with that 1.3% chance in the hopes that someone else enjoys a similar mathematical journey. And then again, maybe I’m the only one who might not be that great at finessing a zeroth card!
What choice would you make?
33 Comments
July 15th, 2011 at 9:38 am
You could post some figures of your results. A histogram showing the counts of how many cards you were from the 43rd. Maybe a CDF. Fit it to a discrete distribution and understand why the distribution is the right one. There has to exist an analytic proof demonstrating the distribution, but making the computer do a stochastic simulation is sometimes a lot easier.
August 29th, 2011 at 4:19 am
Magic tricks use more of a math foundation, specifically the laws of probability and statistics. Magic tricks like this one are based on the probability of people choosing certain cards.
August 30th, 2011 at 1:10 am
Yeah doing math was like doing magic it seemed.. Good of Davidson to point this out, lol.
August 31st, 2011 at 10:17 am
I love magic tricks. I have a party this weekend and I’m going to entertain guests using these neat card tricks. Thanks!
September 2nd, 2011 at 6:13 am
Magic tricks like this one are based on the probability of people choosing certain cards.
September 16th, 2011 at 12:17 am
Lots of magic tricks are based on the principles of science. Magic really is a cool field of interest.
October 7th, 2011 at 2:52 am
The magic is a show that make me happy and fun but i need to know how to make a magic