This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

A look at generalized perfect shuffles

Samuel Johnson, Lakshman Manny,
Cornelia A. Van Cott, QiYu Zhang
Abstract.

Standard perfect shuffles involve splitting a deck of 2n2n cards into two stacks and interlacing the cards from the stacks. There are two ways that this interlacing can be done, commonly referred to as an in shuffle and an out shuffle, respectively. In 1983, Diaconis, Graham, and Kantor determined the permutation group generated by in and out shuffles on a deck of 2n2n cards for all nn. Diaconis et al. concluded their work by asking whether similar results can be found for so-called generalized perfect shuffles. For these new shuffles, we split a deck of mnmn cards into mm stacks and similarly interlace the cards with an in mm-shuffle or out mm-shuffle (denoted ImI_{m} and OmO_{m}, respectively). In this paper, we find the structure of the group generated by these two shuffles for a deck of mkm^{k} cards, together with mym^{y}-shuffles, for all possible values of mm, kk, and yy. The group structure is completely determined by k/gcd(y,k)k/\gcd(y,k) and the parity of y/gcd(y,k)y/\gcd(y,k). In particular, the group structure is independent of the value of mm.

1. Introduction

When handed an unshuffled deck of cards, most of us respond in the same way. We attempt (however feebly) to do a so-called perfect shuffle. A perfect shuffle splits a deck of cards into two equal stacks and then perfectly interlaces the cards from the two stacks one after the other. Only experienced gamblers and magicians can perform perfect shuffles reliably, and yet the mathematics behind perfect shuffles has a rich history, including everything from mathematical card tricks to sophisticated research.

Refer to caption
Figure 1. Starting with a deck of 12 cards, we split the deck and perform (a) an out shuffle and (b) an in shuffle.

There are two ways that the interlacing of a perfect shuffle can be done. The out shuffle (denoted OO) is the instance in which the original top card remains at the top, while the in shuffle (denoted II) is the instance in which the original top card becomes the second card, lying underneath the top card of the second stack. See Figure 1 for an example. Perfect shuffles are permutations of the set of 2n2n cards, so the group generated by the in shuffle and out shuffle I,O\langle I,O\rangle is a subgroup of the symmetric group S2nS_{2n}. In 1983, Persi Diaconis, Ron Graham, and William Kantor determined the group I,O\langle I,O\rangle for a deck of 2n2n cards for all nn [4]. (The development of this paper by Diaconis et al. was nicely described in narrative form in Science [8].)

One might expect that the order of these shuffle groups I,O\langle I,O\rangle would grow with the size of the deck, but this is not the case. Compare, for example, decks with 30 cards and 32 cards, respectively. With 30 cards, the group generated by in and out shuffles has order 15!21415!\cdot 2^{14}, which is over 21 quadrillion. And yet, with 2 more cards (32 cards total), the shuffle group has order 160160. (As we will see later, when the deck size is a power of 2, the shuffle group is always relatively small.)

Several colorful variations on perfect shuffles have since been studied, including flip shuffles, horseshoe shuffles, Monge shuffles, and milk shuffles, to name a few [2, 3, 4, 9]. At the conclusion of their paper, Diaconis et al. mentioned another natural variation – the so-called generalized perfect shuffles. We describe these shuffles here.

Suppose one has a deck of mnmn cards. A generalized perfect shuffle (also called an mm-shuffle) is performed first by dividing the cards into mm equal stacks (the first stack contains the first nn cards, the second stack contains the next nn cards, and so on). Place these mm stacks side by side in order from left to right. A priori, there are m!m! different patterns which one can use to interlace the cards from these mm stacks to reassemble the deck. We consider two interlacing patterns which directly generalize the standard in and out perfect shuffles:

  • Out mm-shuffle (denoted OmO_{m}). Pick up the cards from the mm stacks from left to right. In this case, the original top card will remain the top card when the shuffle is complete.

  • In mm-shuffle (denoted ImI_{m}). Pick up the cards from the mm stacks from right to left. In this case, the original top card will now be the mthm^{th} card when the shuffle is complete.

See Figure 2 for examples of 3-shuffles. With this perspective, the standard perfect shuffles studied by Diaconis et al. are a special case, being 2-shuffles.

A variety of results have already been discovered about generalized perfect shuffles (or, mm-shuffles, as we will call them). The group generated by an mm-shuffle and the simple cut was investigated by Morris and Hartwig [12]. They found the group in most cases to be either the full symmetric group of the deck or the alternating group of the deck. Working even more generally, others have considered allowing all m!m! interlacing patterns of the mm stacks rather than restricting to the in and out mm-shuffles. The groups generated in this broader context have been determined for several infinite families [1, 10].

Here in this work, we return to the original question posed by Diaconis et al. [4] and which was posed again in [10]. Namely, we seek to find the group generated by in and out mm-shuffles Im,Om\langle I_{m},O_{m}\rangle. The solution to the analogous question for the group I,O\langle I,O\rangle of standard perfect shuffles was a mathematical and computational tour de force requiring many cases. We expect the situation with generalized shuffles to be similarly complex. Here in this paper, we restrict to decks of size mkm^{k} for some m,k>1m,k>1. With this card deck, we consider mym^{y}-shuffles for some y<ky<k.

A natural starting place is to consider 2-shuffles on decks of size 2k2^{k}. This special case fits into the setting of standard perfect shuffles and was studied by Diaconis et al. They proved the following.

Theorem 1.

[4] Consider a deck of 2k2^{k} cards for some k1k\geq 1. The 2-shuffle group I2,O2\langle I_{2},O_{2}\rangle has order 2kk2^{k}k and is isomorphic to 2kk\mathbb{Z}^{k}_{2}\rtimes\mathbb{Z}_{k}, where k\mathbb{Z}_{k} acts on 2k\mathbb{Z}^{k}_{2} by a cyclic shift.

Broadening this result, we find the structure of the mym^{y}-shuffle group on a deck of mkm^{k} cards, for all possible values of m,km,k, and yy. The result nicely generalizes the previous special case.

Theorem 2.

Consider a deck of mkm^{k} cards for some m,k>1m,k>1. Let yy be a positive integer such that y<ky<k and gcd[y,k]=c\gcd[y,k]=c. The group generated by in and out mym^{y}-shuffles on this deck Imy,Omy\langle I_{m^{y}},O_{m^{y}}\rangle can be described as follows.

  1. (1)

    If y/cy/c is odd, then the shuffle group is isomorphic to (2)k/ck/c(\mathbb{Z}_{2})^{k/c}\rtimes\mathbb{Z}_{k/c}, where k/c\mathbb{Z}_{k/c} acts by a cyclic shift on (2)k/c(\mathbb{Z}_{2})^{k/c}.

  2. (2)

    If y/cy/c is even, then the shuffle group is isomorphic to (2)kc1k/c(\mathbb{Z}_{2})^{\frac{k}{c}-1}\rtimes\mathbb{Z}_{k/c}, where k/c\mathbb{Z}_{k/c} acts on on (2)kc1(\mathbb{Z}_{2})^{\frac{k}{c}-1} as follows:

    ϕ(1)(a1,a2,,akc1)=(akc1,a1+akc1,a2+akc1,,akc2+akc1).\phi(1)\cdot(a_{1},a_{2},\ldots,a_{\frac{k}{c}-1})=(a_{\frac{k}{c}-1},~{}a_{1}+a_{\frac{k}{c}-1},~{}a_{2}+a_{\frac{k}{c}-1},~{}\ldots,~{}a_{\frac{k}{c}-2}+a_{\frac{k}{c}-1}).

Certainly a few examples will clarify this result, and so we discuss examples throughout. Note that the order and the structure of these shuffle groups in Theorem 2 are independent of the value of mm.

Refer to caption
Figure 2. Starting with a deck of 12 cards, we divide the deck into 3 stacks and perform generalized 3-shuffles: (a) an out 3-shuffle and (b) an in 3-shuffle.

2. Standard perfect shuffles

We begin by reviewing some of the beautiful mathematics underlying standard perfect shuffles (see [4] for the proofs). We only fit in a sampling of results here; further interesting patterns (and mathematical card tricks to impress your friends) are plentiful and provide ample opportunity for reading and investigation [5, 6, 11, 13, 14].

Suppose we have a deck of 2n2n cards. Index each card by its distance from the top of the deck from 0 to 2n12n-1. Simple formulas give the location of each card after performing a standard perfect shuffle. The out shuffle fixes the cards with index 0 and 2n12n-1. And, for any card with index i<2n1i<2n-1, the card’s position after an out shuffle OO is as follows:

O:i2i(mod2n1)O:i\longrightarrow 2i\!\!\!\pmod{2n-1}

It follows, then, that the order of the out shuffle is given by the order of 22 in 2n1\mathbb{Z}_{2n-1}. An in shuffle II moves the card with index ii as follows:

I:i2i+1(mod2n+1)I:i\longrightarrow 2i+1\!\!\!\pmod{2n+1}

From this, one can show that the order of the in shuffle is the order of 22 in 2n+1\mathbb{Z}_{2n+1}.

For example, consider a deck of 52 cards. One needs to do only 8 out shuffles to bring the deck back to its original order, since 2 has order 8 in 51\mathbb{Z}_{51}. On the other hand, one must do 52 in shuffles before the deck returns to its original order, as 2 has order 52 in 53\mathbb{Z}_{53}.

Perfect shuffles preserve several types of symmetry in a deck of cards. Consider a pair of cards which are each located the same distance from the center of the deck. After an in or out shuffle, these two cards will both move to positions which are again the same distance from the center of the deck. Because of this, we say that in and out shuffles preserve central symmetry.

The set of all permutations in S2nS_{2n} that preserve central symmetry form a subgroup of S2nS_{2n}, which we denote by BnB_{n}. Observe that BnB_{n} has order n!2nn!~{}\!2^{n}, and so it follows that the shuffle group I,O\langle I,O\rangle on 2n2n cards has order at most n!2nn!~{}\!2^{n}. In fact, the group I,O\langle I,O\rangle is isomorphic to BnB_{n} if and only if n2(mod4)n\equiv 2\pmod{4} and n>6n>6. A deck of 52 cards (n=26(n=26) is one example of this. Save for a few exceptional cases, the remaining shuffle groups I,O\langle I,O\rangle can be described as a kernel (or an intersection of kernels) of different homomorphisms from BnB_{n} to 2\mathbb{Z}_{2} (see [4] for details). The significant exceptional case is when the number of cards is a power of 2 (say, 2k2^{k}). In this case, the shuffle group has order 2kk2^{k}k and has structure 2kk\mathbb{Z}_{2}^{k}\rtimes\mathbb{Z}_{k}, as stated in Theorem 1.

Let’s consider a specific example to illustrate Theorem 1. Begin with just 4 cards. A priori, we might be able to reach any of 2424 different card arrangements by shuffling these 4 cards. But Theorem 1 tells us that we only reach 8 card arrangements with standard perfect shuffles, and the shuffle group is isomorphic to (2×2)2(\mathbb{Z}_{2}\times\mathbb{Z}_{2})\rtimes\mathbb{Z}_{2}. (This group is more commonly recognized as the dihedral group of a square, D4D_{4}.)

This group’s Cayley graph nicely illustrates the relationships among the card arrangements and shuffles. Let us consider each of these 8 possible card arrangements to be vertices on a graph. If one card arrangement can be obtained from another by an in shuffle or out shuffle, we draw a directed edge between the two associated vertices. In this example, the resulting graph is a cube. See Figure 3.

Refer to caption
Figure 3. Four cards (numbered in original order as 0, 1, 2, 3) can be shuffled with out shuffles (red) and in shuffles (blue) to reach eight different possible orderings total.

3. Generalized perfect shuffles

Now we expand our perspective to consider a deck of mnmn cards, together with in and out mm-shuffles (denoted ImI_{m} and OmO_{m}, respectively). We begin by studying the basic properties of these shuffles. The following lemma (also proved in [10]) provides the critical information of where cards end up after an mm-shuffle.

Lemma 3.

Consider a deck of mnmn cards. Index each card in the deck by its distance from the top of the deck from 0 to mn1mn-1.

  1. (1)

    The out mm-shuffle OmO_{m} fixes the cards with index 0 and mn1mn-1, and for i<mn1i<mn-1, the index of the ithi^{th} card after an out mm-shuffle is:

    Om:imi(modmn1)O_{m}:i\longrightarrow mi\pmod{mn-1}

    As such, the order of OmO_{m} is the order of mm in mn1.\mathbb{Z}_{mn-1}.

  2. (2)

    The index of the ithi^{th} card of the deck after an in mm-shuffle ImI_{m} is:

    Im:imi+(m1)(modmn+1)I_{m}:i\longrightarrow mi+(m-1)\pmod{mn+1}

    Thus the order of ImI_{m} is the order of mm in mn+1\mathbb{Z}_{mn+1}.

Proof.

Starting with the deck of cards indexed 0 to mn1mn-1, we divide the cards into mm equal stacks and place the stacks in order side by side from left to right. The cards are then in the following array:

(6) 0n2n(m1)n1n+12n+12n+22n+2n12n13n1mn1\displaystyle~{}\begin{array}[]{cccccccccc}0&&&n&&&2n&&\cdots&(m-1)n\\ 1&&&n+1&&&2n+1&&\cdots&\vdots\\ 2&&&n+2&&&2n+2&&\cdots&\vdots\\ \vdots&&&\vdots&&&\vdots&&\vdots&\vdots\\ n-1&&&2n-1&&&3n-1&&\cdots&mn-1\end{array}

Consider the card lying in row jj and column pp, for some jj and pp. If we pick up the cards so as to perform an out mm-shuffle, then (p1)+(j1)m(p-1)+(j-1)m cards will be picked up before this card. So then, the index of this card when the out mm-shuffle is finished will be: (p1)+(j1)m(p-1)+(j-1)m.

Note that before the cards were shuffled, the card lying in row jj and column pp in the above array had the following original index:

(7) i=(p1)n+j1.\displaystyle i=(p-1)n+j-1.

Careful arithmetic using Equation 7 yields (p1)+(j1)mmi(modmn1)(p-1)+(j-1)m\equiv mi\pmod{mn-1} for i<mn1i<mn-1, which proves the desired relationship in Part (1) of the lemma.

Observe, then, that performing OmO_{m} repeatedly rr times will move a card in position ii to the position mri(modmn1)m^{r}i\pmod{mn-1} for any i<mn1i<mn-1. Therefore, each card will be back in its original position exactly when mr1(modmn1)m^{r}\equiv 1\pmod{mn-1}. Hence the order of the shuffle is precisely the order of mm in mn1,\mathbb{Z}_{mn-1}, concluding the proof of Part (1) of the lemma.

Next we consider in mm-shuffles. As before, place the cards (indexed 0 to mn1mn-1) into mm stacks, as indicated in Array 6. If we do an in mm-shuffle, then (mp)+(j1)m(m-p)+(j-1)m cards will be picked up before the card that lies in row jj and column pp. So then the index of the card after the shuffle is complete will be: (mp)+(j1)m(m-p)+(j-1)m. If the card’s original index was ii, careful arithmetic using Equation 7 yields

(mp)+(j1)mmi+m1(modmn+1),(m-p)+(j-1)m\equiv mi+m-1\pmod{mn+1},

as desired.

Using this formula, we see that performing ImI_{m} a sequence of \ell times will move a card in position ii to position mi+m1(modmn+1).m^{\ell}i+m^{\ell}-1\pmod{mn+1}. Therefore each card will be back in its original position after \ell shuffles exactly when imi+m1(modmn+1)i\equiv m^{\ell}i+m^{\ell}-1\pmod{mn+1} for all ii. This will be the case if and only if m1(modmn+1)m^{\ell}\equiv 1\pmod{mn+1}. Part (2) of the lemma follows, as before. ∎

With these basic facts in place, we turn our focus to the special case where the size of the deck of cards is a power of mm, say, mkm^{k}. As before, we index each card in the deck by its distance from the top of the deck from 0 to mk1m^{k}-1. The index ii on each card can be naturally expressed in base-mm as a kk-tuple of digits: (x1,x2,,xk)(x_{1},x_{2},\ldots,x_{k}), where

i=x1mk1+x2mk2++xk1m+xk.i=x_{1}m^{k-1}+x_{2}m^{k-2}+\cdots+x_{k-1}m+x_{k}.

In Lemma 3, we discussed the effect of in and out mm-shuffles on a card’s index, but now we describe mm-shuffles’ effects on the base-mm index of a card.

Lemma 4.

Consider a deck of mkm^{k} cards. Index each card in the deck by its distance from the top of the deck from 0 to mk1m^{k}-1, and express this index in base-mm as a kk-tuple (x1,x2,,xk)(x_{1},x_{2},\ldots,x_{k}). Then mm-shuffles send a card with index (x1,x2,,xk)(x_{1},x_{2},\ldots,x_{k}) to a new position as follows:

(8) Om:(x1,x2,,xk)\displaystyle O_{m}:(x_{1},x_{2},\ldots,x_{k}) (x2,x3,,xk,x1)\displaystyle\longrightarrow(x_{2},x_{3},\ldots,x_{k},x_{1})
(9) Im:(x1,x2,,xk)\displaystyle I_{m}:(x_{1},x_{2},\ldots,x_{k}) (x2,x3,,xk,x¯1),\displaystyle\longrightarrow(x_{2},x_{3},\ldots,x_{k},\overline{x}_{1}),

where x¯1=(m1)x1.\overline{x}_{1}=(m-1)-x_{1}. Moreover, the shuffles OmO_{m} and ImI_{m} have order kk and 2k2k, respectively.

Remark 5.

We will refer to the operation xi¯=(m1)xi\overline{x_{i}}=(m-1)-x_{i} as flipping the entry xix_{i}. Observe that the flipping operation is of order two. That is, xi¯¯=xi\overline{\overline{x_{i}}}=x_{i}.

Proof.

This lemma is an exercise in applying Lemma 3 to the special case of a deck of mkm^{k} cards.

Lemma 3 tells us that the cards with index 0 or mk1m^{k}-1 are fixed by an out mm-shuffle OmO_{m}, and a card with index i<mk1i<m^{k}-1 is moved to index mi(modmk1)mi\pmod{m^{k}-1}. We compute:

mi\displaystyle mi =m(x1mk1+x2mk2++xk1m+xk)\displaystyle=m(x_{1}m^{k-1}+x_{2}m^{k-2}+\cdots+x_{k-1}m+x_{k})
=x1mk+x2mk1++xk1m2+xkm\displaystyle=x_{1}m^{k}+x_{2}m^{k-1}+\cdots+x_{k-1}m^{2}+x_{k}m
x2mk1++xk1m2+xkm+x1(modmk1)\displaystyle\equiv x_{2}m^{k-1}+\cdots+x_{k-1}m^{2}+x_{k}m+x_{1}\pmod{m^{k}-1}

Therefore, it follows that for all ii, the out mm-shuffle has the following effect on a card’s base-mm index: Om:(x1,x2,,xk)(x2,x3,,xk,x1)O_{m}:(x_{1},x_{2},\ldots,x_{k})\longrightarrow(x_{2},x_{3},\ldots,x_{k},x_{1}), as desired. Clearly, the shuffle must be repeated kk times in order for each kk-tuple to return to its original form, so OmO_{m} has order kk.

Now let us move to in mm-shuffles ImI_{m}. Lemma 3 tells us that a card with index ii is moved to index mi+(m1)(modmk+1)mi+(m-1)\pmod{m^{k}+1}. We compute this value:

mi+(m1)\displaystyle mi+(m-1) =m(x1mk1+x2mk2++xk1m+xk)+(m1)\displaystyle=m(x_{1}m^{k-1}+x_{2}m^{k-2}+\cdots+x_{k-1}m+x_{k})+(m-1)
=x1mk+x2mk1++xk1m2+xkm+(m1)\displaystyle=x_{1}m^{k}+x_{2}m^{k-1}+\cdots+x_{k-1}m^{2}+x_{k}m+(m-1)
x2mk1++xk1m2+xkm+(m1)x1(modmk+1)\displaystyle\equiv x_{2}m^{k-1}+\cdots+x_{k-1}m^{2}+x_{k}m+(m-1)-x_{1}\pmod{m^{k}+1}

Hence, the in mm-shuffle ImI_{m} has the following effect on a card’s base-mm index:
Im:(x1,x2,,xk)(x2,x3,,xk,x¯1),I_{m}:(x_{1},x_{2},\ldots,x_{k})\longrightarrow(x_{2},x_{3},\ldots,x_{k},\overline{x}_{1}), where x¯1=(m1)x1.\overline{x}_{1}=(m-1)-x_{1}. The shuffle clearly must be repeated 2k2k times in order for each kk-tuple to return to its original form, so ImI_{m} has order 2k2k.

With a deck of mkm^{k} cards, we can also consider m2m^{2}-shuffles, m3m^{3}-shuffles, and so on. But observe that an mym^{y}-shuffle for any positive y<ky<k is equivalent to repeating an mm-shuffle yy times. In light of Equations 8 and 9, it follows that mym^{y}-shuffles have the following effect on the base-mm expansion of the card’s index:

(10) Omy:(x1,x2,,xk)\displaystyle O_{m^{y}}:(x_{1},x_{2},\ldots,x_{k}) (xy+1,,xk,x1,,xy)\displaystyle\longrightarrow(x_{y+1},\ldots,x_{k},x_{1},\ldots,x_{y})
(11) Imy:(x1,x2,,xk)\displaystyle I_{m^{y}}:(x_{1},x_{2},\ldots,x_{k}) (xy+1,,xk,x1¯,,xy¯)\displaystyle\longrightarrow(x_{y+1},\ldots,x_{k},\overline{x_{1}},\ldots,\overline{x_{y}})

where xi¯=(m1)xi\overline{x_{i}}=(m-1)-x_{i}.

4. Generalized perfect shuffle groups for decks of size mkm^{k}

At last, we are ready to determine the structure of the group of mym^{y}-shuffles on a deck of mkm^{k} cards for all possible mm, kk, and yy. Alongside these discoveries, we give concrete examples of these groups. The tools used here are all standard group theory techniques.

We proceed in three cases, each of which is proved separately: Case (1) yy is odd and relatively prime to kk (Theorem 6), Case (2) yy is even and relatively prime to kk (Theorem 7), and Case (3) yy and kk are not relatively prime (Corollary 8). Together, these three results prove Theorem 2 stated in the introduction.

Theorem 6.

Consider a deck of mkm^{k} cards for some m,k>1m,k>1. Let yy be a positive odd integer such that y<ky<k and yy is relatively prime to kk. The mym^{y}-shuffle group is as follows: Imy,Omy2kϕk\langle I_{m^{y}},O_{m^{y}}\rangle\cong\mathbb{Z}^{k}_{2}\rtimes_{\phi}\mathbb{Z}_{k}, where k\mathbb{Z}_{k} acts by a cyclic shift on 2k\mathbb{Z}^{k}_{2}. That is,

ϕ(1)(a1,a2,,ak)=(ak,a1,a2,,ak1).\phi(1)\cdot(a_{1},a_{2},\ldots,a_{k})=(a_{k},a_{1},a_{2},\ldots,a_{k-1}).
Proof.

We first solve the problem in the special case y=1y=1. Then we will show that if y>1y>1, we can reduce the situation back down to this special case.

Consider mm-shuffles ImI_{m} and OmO_{m} acting on a deck of mkm^{k} cards. Using these two shuffles, we create the following set of shuffles:

{Bj=Omj1ImOmj|j=1,2,k}.\{B_{j}=O_{m}^{j-1}I_{m}O_{m}^{-j}~{}|~{}j=1,2,\ldots k\}.

(Note that we read the multiplication of shuffles from left to right.)

Now let’s consider the effect of each of the shuffles BjB_{j} on a card’s base-mm index. In light of Equations 8 and 9, the shuffle B1=ImOm1B_{1}=I_{m}O_{m}^{-1} flips the first entry of a card’s base-mm index and makes no other changes. The shuffle B2=OmImOm2B_{2}=O_{m}I_{m}O_{m}^{-2} only flips the second entry in the card’s index. This pattern continues for all BjB_{j}. For example, when k=5k=5, we have:

B1:(x1,x2,x3,x4,x5)\displaystyle B_{1}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1¯,x2,x3,x4,x5)\displaystyle\longrightarrow(\overline{x_{1}},x_{2},x_{3},x_{4},x_{5})
B2:(x1,x2,x3,x4,x5)\displaystyle B_{2}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1,x2¯,x3,x4,x5)\displaystyle\longrightarrow(x_{1},\overline{x_{2}},x_{3},x_{4},x_{5})
B3:(x1,x2,x3,x4,x5)\displaystyle B_{3}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1,x2,x3¯,x4,x5)\displaystyle\longrightarrow(x_{1},x_{2},\overline{x_{3}},x_{4},x_{5})
B4:(x1,x2,x3,x4,x5)\displaystyle B_{4}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1,x2,x3,x4¯,x5)\displaystyle\longrightarrow(x_{1},x_{2},x_{3},\overline{x_{4}},x_{5})
B5:(x1,x2,x3,x4,x5)\displaystyle B_{5}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1,x2,x3,x4,x5¯)\displaystyle\longrightarrow(x_{1},x_{2},x_{3},x_{4},\overline{x_{5}})

Observe that BiBj=BjBiB_{i}B_{j}=B_{j}B_{i} for all i,ji,j. Hence the group B1,B2,,Bk\langle B_{1},B_{2},\ldots,B_{k}\rangle is abelian. Moreover every element in the group has order 2, since xi¯¯=xi\overline{\overline{x_{i}}}=x_{i}. Finally, note that the generating set for the group B1,B2,,Bk\langle B_{1},B_{2},\ldots,B_{k}\rangle cannot be reduced in size, since each shuffle changes a disjoint part of a card’s base-mm index. Thus it follows that B1,B2,,Bk2k\langle B_{1},B_{2},\ldots,B_{k}\rangle\cong\mathbb{Z}_{2}^{k}.

This group B1,B2,,Bk\langle B_{1},B_{2},\ldots,B_{k}\rangle intersects the group generated by the out mm-shuffle Om\langle O_{m}\rangle only at the identity shuffle. Moreover, the product of the two groups contains both OmO_{m} and ImI_{m} and hence generate the whole group Im,Om\langle I_{m},O_{m}\rangle. Finally, observe that Om\langle O_{m}\rangle has order kk, and OmO_{m} acts on the shuffles BjB_{j} via a cyclic shift:

OmBjOm1={Bj+1 if j=1,,k1B1 if j=k.\displaystyle O_{m}B_{j}O_{m}^{-1}=\begin{cases}B_{j+1}&\textrm{ if }j=1,\ldots,k-1\\ B_{1}&\textrm{ if }j=k.\end{cases}

Therefore we conclude that the mm-shuffle group on mkm^{k} cards Im,Om\langle I_{m},O_{m}\rangle is isomorphic to 2kk\mathbb{Z}^{k}_{2}\rtimes\mathbb{Z}_{k}, where the generator of k\mathbb{Z}_{k} acts on 2k\mathbb{Z}_{2}^{k} by a cyclic shift. So we have proved the theorem in the special case y=1y=1.

Now we consider the situation of doing mym^{y}-shuffles on mkm^{k} cards, where y>1y>1 is odd and relatively prime to kk. As we noted in the previous section, the shuffles OmyO_{m^{y}} and ImyI_{m^{y}} can be expressed as repeated application of mm-shuffles:

Omy=(Om)yandImy=(Im)y.O_{m^{y}}=(O_{m})^{y}\hskip 14.22636pt\text{and}\hskip 14.22636ptI_{m^{y}}=(I_{m})^{y}.

Moreover, recall that the mm-shuffles OmO_{m} and ImI_{m} have orders kk and 2k2k, respectively. Since yy is relatively prime to both of these values, it follows that

Omy=(Om)y=Om\langle O_{m^{y}}\rangle=\langle~{}(O_{m})^{y}~{}\rangle=\langle O_{m}\rangle

and

Imy=(Im)y=Im.\langle I_{m^{y}}\rangle=\langle~{}(I_{m})^{y}~{}\rangle=\langle I_{m}\rangle.

Hence we have Omy,Imy=Im,Om\langle O_{m^{y}},I_{m^{y}}\rangle=\langle I_{m},O_{m}\rangle, which proves that this group Omy,Imy\langle O_{m^{y}},I_{m^{y}}\rangle has the same structure as the case y=1y=1, as desired.

Lest we lose the forest for the trees, let’s look at an example that illustrates the theorem we have just proved. Suppose we have m2m^{2} cards, for some natural number m>1m>1. Theorem 6 tells us that we are only able to reach a total of 8 card orderings with mm-shuffles on these m2m^{2} cards. The shuffle group is (2×2)2(\mathbb{Z}_{2}\times\mathbb{Z}_{2})\rtimes\mathbb{Z}_{2}. (This group is more commonly known as the dihedral group of the square, D4D_{4}.) The associated Cayley graph illustrates the relationship among the shuffles. In this case, the graph is a cube, as shown in Figure 4. Observe that the group is no different from the special case of 2-shuffles on a deck of 4 cards which we discussed earlier. Indeed, the group structure is independent of the value of mm.

Refer to caption
Figure 4. A deck of m2m^{2} cards can be shuffled with out mm-shuffles (red) and in mm-shuffles (blue) to reach eight different possible orderings total. Before shuffling, each card’s position can be expressed in base mm as (x1,x2)(x_{1},x_{2}), and after any mm-shuffle, each card’s position can be described in this format as well, where xi¯=mxi\overline{x_{i}}=m-x_{i}.

We now consider the case where yy is even and relatively prime to kk. The theorem and proof are reminiscent of the previous case when yy is odd, with a few necessary twists.

Theorem 7.

Consider a deck of mkm^{k} cards for some m,k>1m,k>1. Let yy be a positive even integer with y<ky<k and yy is relatively prime to kk. Then the mym^{y}-shuffle group is as follows: Imy,Omy2k1ϕk\langle I_{m^{y}},O_{m^{y}}\rangle\cong\mathbb{Z}^{k-1}_{2}\rtimes_{\phi}\mathbb{Z}_{k}, where the action of k\mathbb{Z}_{k} on 2k1\mathbb{Z}^{k-1}_{2} is given by:

ϕ(1)(a1,a2,,ak1)=(ak1,a1+ak1,a2+ak1,,ak2+ak1).\phi(1)\cdot(a_{1},a_{2},\ldots,a_{k-1})=(a_{k-1},~{}~{}a_{1}+a_{k-1},~{}~{}a_{2}+a_{k-1},~{}\ldots,~{}~{}a_{k-2}+a_{k-1}).
Proof.

To begin, we make some simplifying observations. Recall that since the out mm-shuffle OmO_{m} has order kk and since yy is relatively prime to kk, it follows that

Omy=(Om)y=Om.\langle O_{m^{y}}\rangle=\langle~{}(O_{m})^{y}~{}\rangle=\langle O_{m}\rangle.

And furthermore, since the in mm-shuffle ImI_{m} has order 2k2k and gcd(y,2k)=2\gcd(y,2k)=2, we observe

Imy=(Im)y=(Im)2=Im2.\langle I_{m^{y}}\rangle=\langle~{}(I_{m})^{y}~{}\rangle=\langle(I_{m})^{2}\rangle=\langle I_{m^{2}}\rangle.

Hence, Imy,Omy=Im2,Om\langle I_{m^{y}},O_{m^{y}}\rangle=\langle I_{m^{2}},O_{m}\rangle. Therefore, it suffices to show that the group Im2,Om\langle I_{m^{2}},O_{m}\rangle has the structure described above in the statement of the theorem.

To accomplish this, we create a new set of shuffles using Im2I_{m^{2}} and OmO_{m}. Consider the following:

{Cj=Omj1Im2Om(j+1)|j=1,2,,k}.\{C_{j}=O_{m}^{j-1}I_{m^{2}}O_{m}^{-(j+1)}~{}|~{}j=1,2,\ldots,k\}.

Despite their complicated appearance at first glance, we can easily describe the effect of these shuffles CjC_{j} on the deck of cards. Using Equations 10 and 11, we observe that the shuffle C1=Im2Om2C_{1}=I_{m^{2}}O_{m}^{-2} flips the first 2 entries of a card’s base-mm index (x1x_{1} and x2x_{2}), leaving everything else unchanged. The shuffle C2=OmIm2Om3C_{2}=O_{m}I_{m^{2}}O_{m}^{-3} only flips the entries x2x_{2} and x3x_{3}. This pattern continues, with CjC_{j} only flipping the entries xjx_{j} and xj+1x_{j+1} for j=1,2,k1j=1,2,\ldots k-1. The final shuffle CkC_{k} flips the entries x1x_{1} and xkx_{k}. For example, in the case of k=5k=5, we have:

C1:(x1,x2,x3,x4,x5)\displaystyle C_{1}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1¯,x2¯,x3,x4,x5)\displaystyle\longrightarrow(\overline{x_{1}},\overline{x_{2}},x_{3},x_{4},x_{5})
C2:(x1,x2,x3,x4,x5)\displaystyle C_{2}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1,x2¯,x3¯,x4,x5)\displaystyle\longrightarrow(x_{1},\overline{x_{2}},\overline{x_{3}},x_{4},x_{5})
C3:(x1,x2,x3,x4,x5)\displaystyle C_{3}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1,x2,x3¯,x4¯,x5)\displaystyle\longrightarrow(x_{1},x_{2},\overline{x_{3}},\overline{x_{4}},x_{5})
C4:(x1,x2,x3,x4,x5)\displaystyle C_{4}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1,x2,x3,x4¯,x5¯)\displaystyle\longrightarrow(x_{1},x_{2},x_{3},\overline{x_{4}},\overline{x_{5}})
C5:(x1,x2,x3,x4,x5)\displaystyle C_{5}:(x_{1},x_{2},x_{3},x_{4},x_{5}) (x1¯,x2,x3,x4,x5¯)\displaystyle\longrightarrow(\overline{x_{1}},x_{2},x_{3},x_{4},\overline{x_{5}})

These shuffles CjC_{j} are all order 2 and commute with each other, so it follows that C1,C2,,Ck(2)d\langle C_{1},C_{2},\ldots,C_{k}\rangle\cong(\mathbb{Z}_{2})^{d}, for some dkd\leq k.

Consider the product of all of these shuffles: C1C2C3CkC_{1}C_{2}C_{3}\cdots C_{k}. This shuffle flips all entries in each card’s base-mm index exactly 2 times. The net result, then, is that the shuffle returns every card to its original position. Therefore, we have C1C2Ck=IdC_{1}C_{2}\cdots C_{k}=Id, where IdId denotes the identity shuffle. We can rearrange this relation as: Ck=C1C2Ck1C_{k}=C_{1}C_{2}\cdots C_{k-1}. Hence the generators of the subgroup C1,C2,,Ck\langle C_{1},C_{2},\ldots,C_{k}\rangle can be reduced: C1,C2,,CkC1,C2,,Ck1\langle C_{1},C_{2},\ldots,C_{k}\rangle\cong\langle C_{1},C_{2},\ldots,C_{k-1}\rangle.

We now claim that the generating set cannot be further reduced in size. That is, we claim that there are no nontrivial relations among C1,C2,,Ck1C_{1},C_{2},\ldots,C_{k-1}. Since these shuffles CiC_{i} all commute and have order 2, the only possible further nontrivial relation would be a product of a subset of {C1,C2,,Ck1}\{C_{1},C_{2},\ldots,C_{k-1}\}, but any such product cannot be trivial because it will leave at least one entry xix_{i} flipped. Hence, we conclude that C1,C2,,Ck1(2)k1\langle C_{1},C_{2},\ldots,C_{k-1}\rangle\cong(\mathbb{Z}_{2})^{k-1}

The group C1,C2,,Ck1\langle C_{1},C_{2},\ldots,C_{k-1}\rangle intersects the group generated by the out mm-shuffle Om\langle O_{m}\rangle only at the identity, and the elements of the two groups together generate both OmO_{m} and Im2I_{m^{2}}. Moreover, observe that Om\langle O_{m}\rangle has order kk, and OmO_{m} acts on the shuffles CjC_{j} as follows:

(12) OmCjOm1={Cj+1 if j=1,,k2Ck=C1C2Ck1 if j=k1\displaystyle~{}O_{m}C_{j}O_{m}^{-1}=\begin{cases}C_{j+1}&\textrm{ if }j=1,\ldots,k-2\\ C_{k}=C_{1}C_{2}\cdots C_{k-1}&\textrm{ if }j=k-1\end{cases}

Thus, Im2,Om\langle I_{m^{2}},O_{m}\rangle is isomorphic to the group 2k1ϕk\mathbb{Z}_{2}^{k-1}\rtimes_{\phi}\mathbb{Z}_{k}, where ϕ\phi is given by

ϕ(1)(a1,a2,,ak1)=(ak1,a1+ak1,a2+ak1,,ak2+ak1),\phi(1)\cdot(a_{1},a_{2},\ldots,a_{k-1})=(a_{k-1},~{}a_{1}+a_{k-1},~{}a_{2}+a_{k-1},~{}\ldots,~{}a_{k-2}+a_{k-1}),

as desired. ∎

As an example of the above theorem, suppose that we have m3m^{3} cards for some natural number m>1m>1. If we do in and out m2m^{2}-shuffles on the deck, we are only able to reach 12 card orderings regardless of the value of mm. By Theorem 7, the shuffle group is (2×2)ϕ3(\mathbb{Z}_{2}\times\mathbb{Z}_{2})\rtimes_{\phi}\mathbb{Z}_{3}, where ϕ(1)(a1,a2)=(a2,a1+a2)\phi(1)(a_{1},a_{2})=(a_{2},a_{1}+a_{2}). This group is isomorphic to the alternating group A4A_{4}. The associated Cayley graph takes the shape of the cuboctahedron as in Figure 5.

Refer to caption
Figure 5. A deck of m3m^{3} cards can be shuffled with out m2m^{2}-shuffles (red) and in m2m^{2}-shuffles (blue) to reach twelve different possible orderings total. Before shuffling, each card’s position can be expressed in base mm as (x1,x2,x3)(x_{1},x_{2},x_{3}), and after any m2m^{2}-shuffle, each card’s position can be described in this format as well, where we write xi¯\overline{x_{i}} to denote mxim-x_{i}.

We conclude by considering the case where kk and yy are not relatively prime. This case follows as a corollary of the previous two results and, together with Theorems 6 and 7, completes the proof of Theorem 2.

Corollary 8.

Consider a deck of mkm^{k} cards for some m,k>1m,k>1. Let yy be a positive integer with y<ky<k and gcd[y,k]=c>1\gcd[y,k]=c>1. The group generated by in and out mym^{y}-shuffles on this deck Imy,Omy\langle I_{m^{y}},O_{m^{y}}\rangle can be described as follows.

  1. (1)

    If y/cy/c is odd, then the shuffle group is isomorphic to 2k/ck/c\mathbb{Z}^{k/c}_{2}\rtimes\mathbb{Z}_{k/c}, where the action of k/c\mathbb{Z}_{k/c} is a cyclic shift as in Theorem 6.

  2. (2)

    If y/cy/c is even, then the shuffle group is isomorphic to 2kc1k/c\mathbb{Z}^{\frac{k}{c}-1}_{2}\rtimes\mathbb{Z}_{k/c}, where the action of k/c\mathbb{Z}_{k/c} is as in Theorem 7.

Proof.

Previously, we had considered each card’s index in terms of its base-mm expansion. But now, we will consider each card’s position in terms of its expansion in base mcm^{c}. As such, the card indices (which range from 0 to mk1m^{k}-1) can be expressed as a (k/c)(k/c)-tuple in base mcm^{c}: (x1,x2,,xk/c)(x_{1},x_{2},\ldots,x_{k/c}).

Recall that performing an mym^{y}-shuffle is the same as performing an mm-shuffle yy times. Equivalently, an mym^{y} shuffle can be accomplished by doing an mcm^{c}-shuffle y/cy/c times. Using this and the formulas in Lemma 4, the effect of perfect mym^{y}-shuffles on a card’s index written in base-mcm^{c} is given as follows:

Omy:(x1,x2,,xk/c)\displaystyle O_{m^{y}}:(x_{1},x_{2},\ldots,x_{k/c}) (xyc+1,,xk/c,x1,x2,,xy/c)\displaystyle\longrightarrow(x_{\frac{y}{c}+1},\ldots,x_{k/c},x_{1},x_{2},\ldots,x_{y/c})
Imy:(x1,x2,,xk/c)\displaystyle I_{m^{y}}:(x_{1},x_{2},\ldots,x_{k/c}) (xyc+1,,xk/c,x1¯,x2¯,,xy/c¯),\displaystyle\longrightarrow(x_{\frac{y}{c}+1},\ldots,x_{k/c},\overline{x_{1}},\overline{x_{2}},\ldots,\overline{x_{y/c}}),

where xi¯=(mc1)xi\overline{x_{i}}=(m^{c}-1)-x_{i}.

Notice that the above two equations are identical to the equations for of performing perfect my/cm^{y/c}-shuffles on a deck of mk/cm^{k/c} cards, as in Equations 10 and 11. Thus in this case, the structure of mym^{y}-shuffle group on mkm^{k} cards is exactly the same as that of my/cm^{y/c}-shuffles on mk/cm^{k/c} cards. And, since y/cy/c and k/ck/c are relatively prime, we can describe this group structure using our previous results.

Therefore, if y/cy/c is odd, then Imy,Omy2k/ck/c\langle I_{m^{y}},O_{m^{y}}\rangle\cong\mathbb{Z}_{2}^{k/c}\rtimes\mathbb{Z}_{k/c}, where the action of k/c\mathbb{Z}_{k/c} is a cyclic shift as in Theorem 6. If y/cy/c is even, then Imy,Omy2(k/c)1k/c\langle I_{m^{y}},O_{m^{y}}\rangle\cong\mathbb{Z}^{(k/c)-1}_{2}\rtimes\mathbb{Z}_{k/c}, where the action of k/c\mathbb{Z}_{k/c} is the action described in Theorem 7. ∎

Size of deck mm Order of Im,Om\langle I_{m},O_{m}\rangle
4 2 8
6 2 24
6 3 48
8 2 24
8 4 12
9 3 8
10 2 1920
10 5 960
12 2 7680
12 3 60
12 4 120
12 6 7680
14 2 322560
14 7 645120
15 3 384
15 5 384
16 2 64
16 4 8
16 8 64
Figure 6. The orders of mm-shuffle groups Im,Om\langle I_{m},O_{m}\rangle for small deck sizes.

5. Parting observations

A natural next step in this investigation, of course, is to understand the situation for deck sizes which are not equal to mkm^{k}. We wrote a computer program to determine the order of mm-shuffle groups for small deck sizes. See Figure 6 for this information.

Another natural question returns to the idea of symmetry and shuffle groups. As mentioned previously, the standard perfect shuffle group I,O\langle I,O\rangle for a deck of 2n2n cards cannot be larger than 2nn!2^{n}n!, since all elements in the group preserve central symmetry. Similarly, the mm-shuffle groups Im,Om\langle I_{m},O_{m}\rangle on a deck of 2n2n (or 2n+12n+1) cards also preserve central symmetry and hence can be no larger than 2nn!2^{n}n!, as well [10]. In their work on standard shuffles, Diaconis et al. described precisely the values of nn for which the standard shuffle group on 2n2n cards reaches this maximum value [4]. We ask whether such a result can be generalized? For example, consider a deck of 66 cards. The maximum order possible is 4848, which is achieved with the 3-shuffle group. With a deck of 12 cards, however, the maximum order is 46,080, which is not realized by any mm-shuffle group. What is the pattern?

Acknowledgements: We thank Kent Morrison for his insightful comments on an early draft of this paper.

References

  • [1] Carmen Amarra, Luke Morgan, and Cheryl E. Praeger. Generalised shuffle groups, 2019. https://arxiv.org/abs/1908.05128.
  • [2] Dave Bayer and Persi Diaconis. Trailing the dovetail shuffle to its lair. Ann. Appl. Probab., 2(2):294–313, 1992.
  • [3] Steve Butler, Persi Diaconis, and Ron Graham. The mathematics of the flip and horseshoe shuffles. Amer. Math. Monthly, 123(6):542–556, 2016.
  • [4] Persi Diaconis, R. L. Graham, and William M. Kantor. The mathematics of perfect shuffles. Adv. in Appl. Math., 4(2):175–196, 1983.
  • [5] Persi Diaconis and Ron Graham. The solutions to Elmsley’s problem. Math Horizons, 14(3):22–27, 2007.
  • [6] Doug Ensley. Unshuffling for the imperfect magician. Math Horizons, 11(3):13–16, 2004.
  • [7] Solomon W. Golomb. Permutations by cutting and shuffling. SIAM Rev., 3:293–297, 1961.
  • [8] Gina Kolata. Perfect shuffles and their relation to math. Science, 216(4545):505–506, 1982.
  • [9] Arne Ledet. The Monge shuffle for two-power decks. Math. Scand., 98(1):5–11, 2006.
  • [10] Steve Medvedoff and Kent Morrison. Groups of perfect shuffles. Math. Mag., 60(1):3–14, 1987.
  • [11] S. Brent Morris. Magic tricks, card shuffling and dynamic computer memories. MAA Spectrum. Mathematical Association of America, Washington, DC, 1998. With an introduction by Martin Gardner.
  • [12] S. Brent Morris and Robert E. Hartwig. The generalized faro shuffle. Discrete Math., 15(4):333–346, 1976.
  • [13] Sarnath Ramnath and Daniel Scully. Moving card ii to position jj with perfect shuffles. Math. Mag., 69(5):361–365, 1996.
  • [14] John W. Rosenthal. Card shuffling. Math. Mag., 54(2):64–67, 1981.