A magician's trick turns out to be based on a very hard
mathematics problem. Three researchers now have solved the problem Persi Diaconis, a slow-talking statisti- card of the deck into a particular posi- that mathematicians devised to deter- cian from Stanford, takes a deck of cards tion, say the fourteenth from the top of mine the order of a group with a given set from his briefcase. He has come to talk the deck, all he had to do was express of generators-a problem analogous to about the mathematics of perfect shuffles the number 14 - 1, or 13, in binary the problem of the perfect shuffle. Ham- and, he says, "You can't talk about a notation, as O's and l's. Then if he ilton and Diaconis decided to use one of perfect shuffle without seeing one." He thought of each 0 as an out shuffle and these algorithms developed by Charles divides the cards in two piles and then each 1 as an in shuffle and did that Sims of Rutgers University. The Sims quickly does a riffle shuffle. The two sequence of shuffles, the top card algorithm, Diaconis says, "is a totally stacks are perfectly interlaced in the showed up where he wanted it-in this non-obvious way of working with these shuffled deck. case, in position 14. objects [the generators of groups] on a Diaconis, who ran away from home at Diaconis was intrigued. He general- computer." Knuth, who by this time was age 14 to become a magician, is one of ized the problem and asked how one also intrigued by Diaconis' problem, only about 200 of the tens of thousands could follow the rearrangements of a made some improvements in Sims' algo- of magicians in the world who can do a deck that occur with sequences of in and rithm and they were set to go. perfect shuffle. And he is one of -only out shuffles. "I brooded on and off about Hamilton programmed the computer about 25 who can do eight perfect shuf- this problem for close to 25 years," he to calculate the order of the shuffle fles in a row to bring a 52-card deck back says. "It turns out to be a very hard group-how many different card combi- in order. His lifelong fascination with problem." nations can occur-for decks up to size these shuffles led him to an intrigu- He looked for clues in books on cheat- 52. Even with the Sims algorithm, this ing and very difficult mathematics prob- ing at cards and found that references to was a difficult problem, taking 4 hours of lem-How can you characterize all the cheating by means of perfect shuffles go computer time. possible arrangements of cards when a back to 1726. But no magicians or card "Now we had these lists of numbers deck, containing an arbitrarily chosen sharks ever solved the mathematical giving us the number of arrangements for number of cards, is perfectly shuffled problem that Diaconis posed. Then, last each deck size," Diaconis says. "We over and over again? year, Diaconis and other faculty mem- stared at them and tried to think what on Diaconis, working with Ronald Gra- bers at Stanford received a letter from earth is going on. There is a pattern but it ham of Bell Laboratories and William Donald Knuth, a computer science pro- doesn't start until after 24 cards. Before Kantor of the University of Oregon, has fessor at Stanford, saying that he had 24 cards, the numbers are chaotic. After spent the past 6 months working on and some students in a programming course 24 cards, the pattern repeats every 8 solving this problem. The solution turns who, as part of their course work, were cards." out to be related to problems in group to help solve faculty members' comput- To explain what kind of pattern they theory, one of the most theoretical areas ing problems. Diaconis and the other saw, Diaconis notes that magicians have of mathematics, and to problems in com- faculty members were asked if they had known for quite some time that both in puter science, one of the most applied any good problems for the students. and out shuffles preserve a certain sym- areas of mathematics. The story of how Diaconis immediately thought of his metry. The cards are rearranged as sets these researchers came upon and solved card-shuffling problem. "I just couldn't of pairs, each card of a pair being equally the perfect shuffle problem is one of touch that problem theoretically," he distant from the center of the deck. For coincidences and surprising interconnec- recalls, so he thought perhaps one of example, after an out shuffle the original tions in mathematics. And it illustrates, Knuth's students could make some prog- top and bottom cards of the deck remain says Kantor, that although "shuffling ress on a computer by brute force. on the top and the bottom. After an in sounds like a ridiculous thing to be paid "Persi's problem appealed to Eric shuffle, the original top and bottom cards to think about, it really isn't. It's not as Hamilton," says Knuth, explaining that are second from the top and second from silly as it sounds." Hamilton, an undergraduate student be- the bottom. Symmetric- pairs also can be Perfect shuffles, Diaconis explains, gan by programming the Stanford com- flipped in place by perfect shuffles. are of two types, called "in" and "out." puter to determine all possible card rear- It looked like every possible pattern of Both types start out the same. A deck of rangements resulting from perfect shuf- cards occurs subject to the constraint cards is divided exactly in half and the fles of decks of various sizes. But he that central symmetry must be pre- two halves are shuffled so that they are soon found that he could not go farth- served. In some cases the number of perfectly interlaced. An "out" shuffle, er than decks of ten cards because the patterns of cards would be one-half or leaves the original top card of the deck number of possibilities became so large. one-fourth of the total number possible on top of the shuffled deck. In an "in" Even for a deck of ten cards it took the with the symmetry constraint. Thus for shuffle, the original top card is the sec- computer 20 minutes to do the calcula- 52 cards, he guessed that there would be ond from the top of the shuffled deck. tions. 226 x 26! possible arrangements. For 2n "I have done perfect shuffles for The next step was to try to be more cards there would be 2' x n! conceiv- years," Diaconis says. ''When I was a clever about the computer programming. able arrangements, he guessed. kid, I noticed something interesting." In group theory, Diaconis remarks, there - But it is one thing tQ guess at an He found that if he wanted to get the top are some ingenious computer algorithms answer to a mathematical problem and it SCIENCE, VOL. 216, 30 APRIL 1982 0036-8075/82/0430-0505$01.00/0 Copyright 1982 AAAS 505 When Diaconis came to Bell Labs with The connection between card shuffling Hamilton's computer printout, Graham and groups intrigues John Conway of scrutinized the numbers of possible ar- Cambridge University, who is particular- rangements. He was struck by the small ly interested in enormous groups that number of arrangements for deck size have no apparent ties to anything con- E 24-the deck size starts. just before Graham said, the pattern "That number of crete. As far as anyone knows they are only creations of the minds of mathema- arrangements is so crazily low that ticians. But Conway has a hunch that something really funny must be going some of these groups may actually be on." He consulted with Robert Calder- shuffle groups and he is now trying to bank and Neil Sloane of Bell Labs who base a construction of one of the largest looked in a table of groups, computed by of these, called the Monster group, on Sims, to find what groups had that order. card shuffling. BtnArche It turned out that the shuffle for 24 Diaconis soon gave a talk on card is another thing to prove that your an- cards is a very famous group, called M12 shuffling at Massachusetts Institute of swer is correct. It took Diaconis and two or the Mathieu group of order 12, that Technology. To his surprise, quite a others 6 months to prove that their guess was discovered in 1861. It is one of the number of electrical engineers came to was correct. Why did they persevere? first finite simple groups to be discov- hear him speak. When he asked why One thing that motivated Diaconis was ered that is not a member of an infinite they were interested, he learned that his chance discovery that a great math- family. "The fact that M12 occurs in a they need to know about the mathemat- ematician, Paul Levy, had worked on a natural way from shuffling cards is just ics of card shuffling to interconnect com- variation of the same problem. Shortly amazing," Diaconis says. "Some gam- puters in networks for parallel process- after Hamilton had done the computer bler could have discovered it. It was ing. In fact, engineers had independently calculations Diaconis was browsing in constructed by mathematicians but there invented the results of Graham for out the Stanford Library and happened to was no way of explaining it." shuffles of decks that are powers of 2. pick up a book of Levy's collected Once Graham realized that M12 was Tom Leighton of MIT explains that works. To his surprise, Diaconis noticed "just sitting there," he, Diaconis, and computer scientists are well aware of the that Levy had worked on equations tell- Kantor were motivated to see what else connection between the design of com- ing how many perfect in shuffles or out was going on. "That was when we got puter networks for parallel processing shuffles are necessary before particular angry at the problem and decided to and card shuffling-they even call the cards in decks of various sizes come really grind it out," Diaconis says. Gra- networks "shuffle exchange graphs." back to their original position. He had ham agrees. "That's when we decided But, for now, computer scientists do not carefully calculated by hand the answers the problem was more interesting than need to know the shuffle groups for for some simple cases but did not solve we suspected," he recalls. decks that are other than a power of 2. the equations in general. The next morning, Graham called Nonetheless, Leighton says, Diaconis' "In his book, Levy never mentioned Kantor and asked him if he could solve work is of at least theoretical interest to why he was doing his work. He just the problem for deck sizes that are a computer scientists. presented it as a math problem and never multiple of 4. This was the most difficult Through all this work, Diaconis could tied it to card shuffling," Diaconis says. case and Kantor thought about it for a not stop thinking about what had moti- Diaconis was encouraged, however. month as he drove across the country vated Levy-why had he worked on "Often you work on math problems and from Bell Labs in New Jersey to his equations that are exactly tied in to the nobody cares about them but you. But home in Oregon. The way he finally card-shuffling problem? Diaconis wrote Levy's such a smart guy and he got so solved the problem was to realize how letters to people who had known Levy, many important results that I thought deck sizes that are a power of 2 differ asking if they had any ideas about where there was a good chance that this prob- from those that are not a power of 2 and those equations came from. Lucien La- lem is important," he says. why deck size 24 is such an anomaly. "I Cam of the University of California at Diaconis went to Bell Laboratories to had to find a pattern that did not include Berkeley and a former student of Levy work with Graham and Kantor, a visitor powers of 2 and did not include 24," told Diaconis that he recalled Levy at the labs. Graham and Diaconis had Kantor says. having written a couple of pages previously worked on the card-shuffling The proof of the theorem giving all the in his autobiography about those equa- problem and Graham had solved it for shuffle groups, however, relies on a com- tions. the special case of decks of cards num- puter calculation. The proof proceeds by Diaconis got a copy of Levy's autobi- bering a power of 2, such as 4, 8, 16, 32, induction but at the end it is necessary to ography and found the passage LaCam or 64. The shuffle group for these decks, prove that three different shuffles of 24 referred to. He learned that Levy says Graham, "is very small. Actually, cards can generate all (1/2) 24! possible worked on the equations because he was all you have to know [for decks of cards combinations. The easiest way to show fooled by a magician. "In 1901, Levy numbering a power of 2] is the top and this, Diaconis says, is to use a computer. was at a resort and he was fooled by a bottom card of the deck. That enables So in January of this year Diaconis and card trick," Diaconis says, "Fifty years you to know where every other card is. Graham went to Xerox Parc in Palo Alto. later he was lying sick in bed and he In fact, knowing the top and bottom card Lyle Ramshaw of Xerox Parc wrote the remembered that card trick. He wrote tells you more than you need to know computer algorithm and the group stood out those equations to try and figure out to determine where all the other cards around the computer waiting to see what why it worked. "-GINA KOLATA are." But, Graham explains, these decks would come out. When the answer they Additional Reading are truly a special case-there are far wanted appeared, Diaconis recalls, "We more possible arrangements for decks of let out a big whoop. It meant our theo- P. Diaconis, R. L. Graham, W. M. Kantor, "The mathematics of perfect shuffles," Advances in Ap- other si7es. rem was proved." plied Mathematics, in press. 506 SCIENCE, VOL. 216
Perceptual Objective Listening Quality Assessment (POLQA), The Third Generation ITU-T Standard For End-to-End Speech Quality Measurement Part I-Temporal Alignment