Mathematical Representation and Formal Proofs of Card Tricks
Elba A
Published on: 2021-05-08
Abstract
Card tricks can be entertaining to audiences. Magicians apply them, but an in-depth knowledge of why they work the way they do is necessary, especially when constructing new tricks. Mapping a trick to its corresponding mathematical operations can be helpful in analysis, and the vice-versa process can help create new tricks and make them accessible to magicians.
Keywords
Card tricks; Matrix operations; Formal proofs; PythonIntroduction
We will present a simple card trick - the card sandwith trick - and then analyze it to represent it mathematically in terms of matrices. Further, the computational code will be provided in Python together with a formal proof by cases. Different variants of the trick are possible, however, we will use a simpler variant with only 9 cards.
A magician starts by picking 9 random cards. Then, another person is asked to pick a card, remember it, and put it back into the deck without the magician knowing which card it is. The magician starts dealing the deck into 3 piles. Then the person is asked which pile their card appeared in. They can answer 1, 2, or 3. Whatever the answer, it is important to keep that pile as a ”sandwich” between the other two piles when the card piles are grabbed back together. For example, if they said 1, then the magician would first grab either pile 2 or 3, then pile 1, then either pile 3 or 2. Repeat this process one more time, and the cards will be ordered in a way such that the 5th card will be the card picked by the person.
For example, the available cards are (1, 2, 3, 4, 5, 6, 7, 8, 9). A person picks card 4 without the magician knowing this. The magician lays these cards in 3 piles: ((1, 4, 7), (2, 5, 8), (3, 6, 9)). The person answers pile 1. The magician grabs the second pile, then the first pile, then the third pile. The next lay on the table will be these 3 piles: ((2, 1, 3), (5, 4, 6), (8, 7, 9)). The person answers pile 2. The magician grabs the first pile, then the second pile, then the third pile. The fifth card will be 4.
After trying a couple of more cases manually, it will become obvious that matrix operations with rotations and column/ row swaps are involved. We will present these operations, together with an example calculation program in Python and a proof of correctness.
The piles can be seen as columns in a matrix. The gist of the trick is getting the coordinate by asking two questions about columns’ position, rather than asking one question about x (row position) and one about y (column position).