◍ Hidden Spheres · exhibit nº 40

The Perfect Shuffle

eight flawless shuffles, and the deck is exactly as it began

Cut a deck of cards exactly in half. Now let the two halves fall together perfectly: one card from the left, one from the right, one from the left, all the way down. Gamblers call it a faro shuffle, and a practised hand can really do it. After one, the deck looks mixed. Keep going and see what eight of them do.

a fresh deck, in order

For the curious kid.

The colours are there so you can see the order. A fresh deck runs smoothly from blue at the top to gold at the bottom. One perfect shuffle turns it into stripes: a blue card, a middling one, a blue one, a middling one. The second shuffle makes the stripes finer, and by the fourth the deck looks like confetti. Nobody watching would call it anything but shuffled.

But a perfect shuffle has no luck in it. Every card goes exactly where the rule sends it, and the rule is simple. Count places from the top, starting at nought. A card at place 1 goes to place 2. A card at place 2 goes to 4, then 8, then 16, then 32. Its place doubles every time. When doubling would carry it off the bottom of the deck, it wraps round to the top and carries on. The gold outline follows one card, and the strip under the deck shows where it has been.

So the question "when does the deck come back?" is a question about doubling. Double a number eight times and you have multiplied it by 256. For a deck of 52, places wrap round every 51, and 256 is exactly five lots of 51 with 1 left over. So after eight shuffles every card's place has been multiplied by 1, which leaves it where it began. Press Keep going until it comes back.

Now change the size of the deck. Add the two jokers, to make 54 cards, and it takes 52 shuffles and not 8. Take twelve cards away, to make 64, and it takes only 6. There is no simple rule. The chart at the bottom shows the number for every deck up to 120 cards, and it jumps about like a seismograph.

Deeper.

With n cards, an out shuffle (top card stays on top) sends place i to place 2i modulo n − 1, and the bottom card stays put. The deck returns after k shuffles when 2k leaves remainder 1 on division by n − 1. The smallest such k is called the order of 2 modulo n − 1. For 51 it is 8, for 53 it is 52, for 63 it is 6. The bars in the chart were computed that way, by arithmetic alone. The dots were found by shuffling a deck of each size until it came back. They agree for every size.

Nobody has a formula for the order of 2. For 32 of the 200 even decks up to 400 cards it is as large as it could possibly be, n − 2 shuffles. Emil Artin guessed in 1927 that such decks never run out, however large the decks get, and nobody has proved it. For a deck of 2k cards the answer is simply k, which is why 64 cards need 6 and 256 need 8. Fifty-two is one of only four decks up to 400 that need exactly 8: the others have 18, 86 and 256 cards.

The deck does not wait until the eighth shuffle to show its hand. The top and bottom cards never move. The cards at places 17 and 34 change places with each other on every shuffle, so they are home after any even number. The other 48 cards travel in six separate rings of eight. That is why the count of cards in their own place goes 2, 4, 2, 4, 2, 4, 2, and then 52.

The other perfect shuffle, where the top card goes second, sends place i to 2i + 1 modulo n + 1. For 52 cards that needs 52 shuffles to come home, and after 26 of them the deck is exactly upside down. The two shuffles together are a magician's instrument. Type the surname of the Scottish magician who worked out what they can do: Alex, seven letters, beginning with E.

This room has a sister. The Ghost in the Deck is about ordinary, sloppy shuffles, where seven are enough to lose a deck's order for good. A perfect shuffle loses nothing at all. Everything that mixes a deck is in the imperfections.

A shuffle with no mistakes in it is not a shuffle. It is a clock.