The Gilbreath principle
Alternate the colors of a deck, deal any number of cards off the top, and riffle them back in. Every pair still comes out one red and one black. Arrange it in repeating suits instead and every group of four comes out holding one of every suit — colors are the same rule with a pattern two cards long.
Do it yourself
1 Choose how the deck starts out
2 Take some cards off the top
3 Riffle them back into the deck
Green edges are cards that fell from the packet you took off, red edges came from the rest of the deck. Watch the two packets go down while the riffled deck builds underneath in pairs, each one ticked as it completes.
0
failures in 10,000 deals · measured, not claimed
Most card tricks that survive a shuffle survive it by making sure no real shuffle happens. This one is the exception: the spectator genuinely riffles, as badly as they like, and the order they destroy is not the order the trick needs.
What is a Gilbreath shuffle?
The move you just did. Deal some cards off the top into a pile, then riffle that pile back into the rest of the deck — that is a Gilbreath shuffle, and it is named after Norman Gilbreath the same way the principle is.
The two names are for two different things, which is worth keeping straight because they get used interchangeably. The shuffle is the procedure: deal off, riffle back. The principle is what survives it: whatever pattern the deck was in, in repeating blocks, is still there in blocks of the same size when you finish.
So a Gilbreath shuffle is a real shuffle. Cards genuinely change position, the riffle is genuinely free, and somebody watching sees a deck being mixed. It is only from the inside that it is not mixing at all — which is the entire reason it is worth knowing.
Why it cannot fail
The mechanism is the deal, and it is worth being precise about why. Dealing cards one at a time into a pile reverses them. That is the whole trick; a cut, which does not reverse, behaves quite differently, and there is a button above to watch it misbehave.
Number the cards 1 to 52 from the top, so card 1 is red and card 52 is black. Deal k of them off. Now read the finished deck from the bottom up, which is the order the cards fell in during the riffle. It is an interleaving of two sequences:
the dealt pile, from its bottom → card 1, card 2, card 3, …
the rest of the deck, from its bottom → card 52, card 51, card 50, …
The first begins on card 1 and the second on card 52. In a deck of an even size whose colors alternate, those two are always opposite colors. That single fact is the whole proof, and the rest is bookkeeping:
At the start of a pair, the two piles are offering opposite colors — say red and black. One of them falls. If the red one fell, that pile now offers black, and the other pile was already offering black, so the next card is black whichever hand it comes from. The pair is one of each.
And now count what has been used. Either both cards came from the same pile, which has advanced two and so offers its original color again while the other pile has not moved; or one came from each, and both have advanced one. Either way the two piles are offering opposite colors again, which is exactly where the pair started. So it holds for the next pair, and the one after that, all the way down.
Why a cut only works half the time
A cut takes the same cards off the top but does not turn them over. So the two sequences read from their bottoms are:
the cut-off packet, from its bottom → card k, card
k−1, …
the rest of the deck, from its bottom → card 52, card 51, …
Now the first begins on card k rather than card 1. Card 52 is black, so the two start on opposite colors only when card k is red — which is to say only when k is odd. Cut an odd number and the principle holds, every time, for the same reason as before.
Cut an even number and it almost always fails. Almost, rather than always, and the gap is worth being honest about: across 50,000 even cuts it failed 96.1% of the time, so about one in twenty-five survived anyway. Those survivors are not a second principle hiding underneath. They are riffles that barely riffled.
| Cards cut off | Pairs survived anyway |
|---|---|
| 2 | 32.2% |
| 4 | 11.1% |
| 6 | 3.8% |
| 8 | 1.1% |
| 10 | 0.7% |
Cut two cards off and a third of riffles leave the pairs intact, because two cards very often fall as a single clump — and a packet that falls in one clump has not been interleaved at all, it has simply been put back. Cut ten and it is under one in a hundred. The tail of the deck behaves the same way by symmetry: cutting 50 survives 32% of the time as well.
So the ten-thousand-trial button reports no failures at all when the cards are dealt, and failures roughly half the time when they are cut — about half the numbers from 1 to 51 are even, and an even cut fails 96% of the time.
The second principle
Gilbreath published the general case eight years after the first. Arrange the deck in a repeating run of n cards — spades, hearts, diamonds, clubs, thirteen times over — deal any number off the top, riffle, and every consecutive group of four holds one of every suit. The alternating colors are simply the case where n is 2.
The proof is the same argument counted modulo n rather than modulo 2, and the demonstration above will run it: change the arrangement to repeating suits and press the same buttons.
Where this comes from
- The principle: Gilbreath, N. L., "Magnetic Colors", The Linking Ring 38(5), July 1958, p. 60 — the original publication, as a card trick rather than a theorem. The credit is recorded at Conjuring Credits.
- The general case: Gilbreath, N. L., "Second Gilbreath Principle", The Linking Ring, June 1966.
- The mathematics: Diaconis, P. and Graham, R., Magical Mathematics, Princeton University Press, 2011, chapter 5, "From the Gilbreath Principle to the Mandelbrot Set", pp. 61–83. Paperback from Amazon.
- The definition and its history: Gilbreath shuffle on Wikipedia.
- The zero failures: not an assertion. The button above runs ten thousand deals with a random number taken off and a random riffle each time, and checks every pair. The same trials run in this site's test suite on every change, so a counter-example would stop a release.
Questions people ask
What is a Gilbreath shuffle?
Deal some cards off the top into a pile, then riffle that pile back into the rest of the deck. That is a Gilbreath shuffle, named after Norman Gilbreath.
The shuffle is the procedure; the principle is what survives it. A Gilbreath shuffle is a real shuffle — cards move, and the riffle is genuinely free — but any pattern the deck was in, in repeating blocks, is still there in blocks of the same size afterwards.
What is the Gilbreath principle?
Arrange a deck so the colors alternate, red, black, red, black. Deal any number of cards off the top into a pile, then riffle that pile back into the rest of the deck.
Take the deck in pairs from the top and every pair holds one red card and one black one. It does not matter how many were dealt off, or how the riffle fell.
Why does the Gilbreath principle work?
Because dealing reverses. Read the finished deck from the bottom up and it is an interleaving of the original deck read forwards from card 1 and the same deck read backwards from card 52.
Those two start on opposite colors, so at the start of every pair the two piles offer opposite colors, and whichever falls first, only the other color is available to complete the pair.
Does the Gilbreath principle work if you cut instead of dealing?
Only about half the time. A cut does not reverse the packet, so the two piles begin on card k and card 52, and those are opposite colors only when k is odd.
Cut an odd number and it works every time. Cut an even number and it fails 96% of the time — the survivors are riffles that barely interleaved, and a two-card cut gets away with it a third of the time.
Dealing reverses, which is why dealing works whatever the number.
What is the second Gilbreath principle?
The general case, which Gilbreath published in 1966. Arrange the deck in a repeating run of n cards, such as the four suits over and over, deal any number off the top, and riffle.
Every consecutive group of n then holds one of each. The alternating colors are the case where n is 2.
Who was Norman Gilbreath?
An American mathematician and magician who published the principle as a card trick called "Magnetic Colors" in The Linking Ring in July 1958, and the general form in the same magazine in June 1966.
Mathematicians have studied it since. Persi Diaconis and Ron Graham give it a chapter of Magical Mathematics, which connects it to the Mandelbrot set.
More
This sits under mathematical card tricks, which collects the tricks that run on arithmetic rather than on sleight of hand. The shuffle that destroys nothing at all is the faro shuffle, and the size of what a real riffle destroys is on the 52 factorial page.