The magic of fixed points
A few days ago my wife received the following through VKontakte, the Russian clone of Facebook:
Find out your phone number on the calculator!
- Take the calculator.
- Enter the first 3 digits of your phone number.
- Multiply by 80.
- Add 1.
- Multiply by 250.
- Add the last 4 digits of your phone number.
- Add the last 4 digits of your phone number again.
- Subtract 250.
- Divide by 2.
I was amused to see my wife getting amazed by this, arguably trivial, arithmetic trick. I leave it to you as an easy exercise to figure out how it works. However, this trick has reminded me of the following, a lot more sophisticated trick, which I learned when I was a kid.
Select any 21 cards from a complete set of playing cards. Give the deck of cards to your spectator, let her pick one card, and ask her to remember it. Let your spectator shuffle the cards. Now deal the deck, opening the cards one by one from the top, in the following pattern: place the first card into the first, leftmost pile; place the second card into the second, middle pile; place the third card into the third, rightmost pile; place the fourth card into the first pile again, and so on. Ask your spectator to watch you deal the cards and to show you the pile containing her card. Collect the cards, sticking that pile between the other two piles, and repeat the whole procedure 2 more times. Then open the cards one by one. The card of your spectator is always going be the 11th card in the deck.
When I was a kid, I was fascinated by this trick. I still think it is pretty neat. I was very proud then to have figured out how it works. Although I don’t remember the proof anymore, I remember that it was terribly complicated, and included some lengthy case analysis. Today I would like to present a simple and elegant proof.
For brevity, let us call the card your spectator has chosen the secret card. Let be its position in the deck, counted from the top. Let us compute the new position of the secret card in the deck after the cards have been dealt and collected back. It is easy to convince yourself that relative to its pile the secret card is going to end up at position counted from the bottom of the pile, or equivalently at position counted from the top of the pile. Here denotes the ceiling function of , i.e., the smallest integer not less than . Because the pile containing the secret card is placed between the other two piles, each of which consists of 7 cards, it follows that relative to the whole deck the secret card is going to land at position
from the top of the deck.
Let us summarize: if the secret card is the -th card in the deck, counted from the top, then dealing the cards once will place the card at position from the top in the deck. Dealing the cards the second time will place the secret card at position . Finally, dealing the cards the third time will place the secret card at position . We have a function from the set to itself given by the formula , and in order to justify the trick we must prove that for any holds .
What is special about 11? It is the middle of the deck, but it is also a (unique) fixed point of the function :
Therefore, we have to show that for any , the sequence of iterations , , , … converges to the fixed point 11, and in fact in at most 3 steps. Let us see why this is the case. The key observation here is that the function is clearly non-increasing, i.e., if . Because lies between 1 and 21, it follows that
Iterating this argument, we find that
so that is necessarily equal to 11. Q.E.D.
Exercise. Use this technique to generalize the trick. For example, if you take 33 cards instead of 21, and deal the cards 4 times instead of 3, then the secret card will be the 17th card in the deck.
Fortunately, this kind of heavy artillery is not necessary here.