Carries, , and an Amazing Matrix Author(s): Persi Diaconis and Jason Fulman Source: The American Mathematical Monthly, Vol. 116, No. 9 (Nov., 2009), pp. 788-803 Published by: Mathematical Association of America Stable URL: http://www.jstor.org/stable/40391298 . Accessed: 19/10/2011 15:21

Your use of the JSTOR archive indicates your acceptance of the Terms & Conditions of Use, available at . http://www.jstor.org/page/info/about/policies/terms.jsp

JSTOR is a not-for-profit service that helps scholars, researchers, and students discover, use, and build upon a wide range of content in a trusted digital archive. We use information technology and tools to increase productivity and facilitate new forms of scholarship. For more information about JSTOR, please contact [email protected].

Mathematical Association of America is collaborating with JSTOR to digitize, preserve and extend access to The American Mathematical Monthly.

http://www.jstor.org Carries,Shuffling, and an AmazingMatrix PersiDiaconis and JasonFulman

1. INTRODUCTION. In a wonderfularticle in this Monthly, JohnHolte [22] foundfascinating in the usual process of "carries"when addinginte- gers.His articlereminded us of themathematics of shufflingcards. This connectionis developedbelow. Consideradding two 40-digit binary numbers (the top row,in italics,comprises the carries): i oiiio oiooo ooooi 00111win ooooo00111 ino 10111 00110 00000 10011 11011 10001 00011 11010 10011 10101 11110 10001 01000 11010 11001 01111 1 01010 11011 11111 00101 00100 01011 11101 01001

For thisexample, 19/40 = 47.5% of thecolumns have a carryof 1. Holte showsthat if thebinary digits are chosen at random,uniformly, in the limit50% of all thecar- ries are zero. This holds no matterwhat the base. More generally,if one adds n in- tegers(base b) thatare producedby choosingtheir digits uniformly at randomin {0, 1, . . . , b - 1}, the sequence of carriesk0 = 0, k', k2,. . . is a Markovchain tak- ing values in {0, 1, 2, . . . , n - 1}. The Markovproperty holds because to computethe amountcarried to thenext column, one onlyneeds to knowthe carry and numbersin thecurrent column: the past does notmatter. We let P(i, j) - F(k' - j | k = i) de- notean entryof thetransition matrix between successive carries k and k' . Holtefound thefollowing: (HI) ForO

For example,for n = 2 and all b,

(P(l'j)) = 2b{b-l b + l)' and forn = 3 and all b,

. /b2 + 3b + 2 Ab2-A b2-2,b + 2' (P(i, j)) = -A b2-' Ab2+ 2 b2-' bb '. 'b2-3b + 2 Ab2-A b2 + 3b + 2j In the special case whenb - 2, forany n, Holte derivesthe simplerex- pression

doi:10.4169/000298909X474864

788 © THE MATHEMATICAL ASSOCIATION OF AMERICA [Monthly 116 The matricesof (HI) are the"amazing matrices" of Holte's title,and we also denote themby Pb. Amongmany things, Holte shows: (H2) The matrixPb has stationaryvector n (lefteigenvector with eigenvalue 1) independentof thebase b:

whereA(n, j) is an Euleriannumber. The n' in thedenominator is to make theentries of theleft eigenvector sum to 1. The Euleriannumber A(n, j) maybe definedas thenumber of permutationsin the symmetricgroup Sn withj descents.Recall thato e Sn has a descentat positioni if a (i + 1) < cr(i). So 5 1 324 has two descents.Note thatwe writepermutations as sequences,where the fth number in thesequence denotes a(i). Whenn = 2, A(2, 0) = A(2, 1) = 1, and thustt(O) = tt(1) = 1/2 is the limiting frequencyof carrieswhen two long integersare added. When n = 3, A (3, 0) = 1, A(3, 1) = 4, and A(3, 2) = 1, givingtt(O) = 1/6,n(') = 2/3, and tt(2) = 1/6. We mentionthat Eulerian numbers make many mathematical appearances, e.g., in thetheory of sorting[26] and in jugglingsequences [10]. For furtherbackground on theirproperties, the reader can consult[12]. Holte furtherestablishes the remarkable: (H3) The matrixPb has eigenvalues1, l/b, l/è2, . . . , l/bn~{ withexplicitly com- putableleft and righteigenvectors independent of b. (H4) PaPb = Pabfor all reala and b. Whenwe saw properties(H2), (H3), and (H4), we hollered"Wait, this is all about shufflingcards!" Readerswho knowus may well think,"For thesetwo guys,every- thingis aboutshuffling cards." While thereis some truthto thesethoughts, we justify ourclaim in thenext section. Following this we showhow theconnection between car- ries and shufflingcontributes to each subject.The rateof convergenceof theMarkov chain(HI) to thestationary distribution n is givenin Section4: theargument shows thatthe matrix Pb is totallypositive of order2. Finally,we showhow thesame matrix occursin takingsections of generatingfunctions [9], discusscarries for multiplication, and describeanother "amazing matrix." Our developmentsdo notexhaust the material in Holte's article,which we enthu- siasticallyrecommend. A "highermath" perspective on arithmeticcarries as cocycles [23] suggestsmany further projects. We havetried to keepthe presentation elementary, and mentionthe (more technical)companion paper [15] whichanalyzes the carries chainusing symmetric function theory and givesanalogs of ourmain results for other Coxetergroups.

2. SHUFFLING CARDS. How manytimes should a deck of n cardsbe riffleshuf- fledto thoroughlymix it? For an introductionto thissubject, see [2, 27]. The main theoreticaldevelopments are in [5, 16] withfurther developments in [18, 19]. A survey of themany connections and developmentsis in [14]. The basic shufflingmechanism was suggestedby [20]. It givesa realisticmathematical model for the usual methodof riffleshuffling n cards: • Cut offC cardswith probability (nc)/2n, 0

November2009] carries, shuffling,and an amazing matrix 789 thebottom of thefirst part with probability A/(A + B) and fromthe bottom of the secondpart with probability B/(A + B). • Continueuntil all cardsare dropped.

Let Q(cr) be theprobability of generatingthe permutation a afterone shuffle,starting fromthe identity, and let Qh(a) denotethe corresponding quantity after h successive shuffles.Repeated shuffling is modeledby convolution:

V ri

Thus to be at a aftertwo shuffles,the first shuffle goes to some permutationr] and the second mustbe to arfx , The uniformdistribution is U (a) = '/n'. Standardtheory showsthat

ßV) -> U(cr) as/*-*oo. (2)

The reference[5] gives usefulrates for the convergence in (2), showingthat for h = (3/2) log2n + c withc fixed,

'Y lßV)-tf(oO|-> '-2 oo. Roughlystated, it takes/* = (3/2) log2n + c shufflesto get 2~c close to random;when n = 52 and /z= 7, theabove distanceto uniformis about0.3 and tends to zero exponentiallythereafter. To explainthe connection with carries, it is usefulto have a geometricdescription of shuffling.Consider dropping n pointsuniformly at randominto [0, 1). Label these pointsin orderx(i) < x{2)• • • < x{n).The baker'stransformation x h> 2x mod 1 maps [0, 1) intoitself and permutesthe points. Let a be theinduced permutation. As shown in [5], the chance of o is exactly Q(cr). A naturalgeneralization of this shuffling schemeto "è-shuffles"is inducedfrom x h->bx mod 1 withb fixedin {1, 2, 3, . . . }. Thus ordinaryriffle shuffles are 2-shufflesand a 3-shuffleresults from dividing the deck into threepiles and droppingcards sequentiallyfrom the bottomof each pile withprobability proportional to packetsize. Let Qbip) be the probabilityof o aftera è-shuffle.Letting * be the convolution operatorused in equation(1), one can show [5] fromthe geometric description that

Qa * Qb = Qab- (3)

The keyis to checkthat the points ax{') mod 1, ax{2) mod 1, ... , ax{n)mod 1 have the same distributionas n uniformpoints in [0, 1), so the¿?-shuffle can be appliedto these pointswithout having to repositionthem at randomin [0, 1). Then (3) followssince b(aX(i) mod 1) mod 1 = abx^ mod 1. The physicalmodel of shufflingdescribed at the startof thissection is Q2 in this notationand we see thatQ' = Q2h. Thus to studyrepeated shuffles, we need only understanda singleè-shuffle. A mainresult of [5] is a simpleformula:

in+b-r' Qb{°) = ^±r~- (4)

Here r = r(a) = 1 + #{descentsin a"1}.

790 © THE MATHEMATICALASSOCIATION OF AMERICA [Monthly1 16 In additionto the similaritiesbetween (H4) and (3), [5] and [21] provedthat the eigenvaluesof the Markovchain inducedby Qb are also 1, l/b, l/è2, . . . , '/bn~x (thoughhere l/è* occurswith multiplicity equal to thenumber of permutationsin Sn withn - i cyclesinstead of withmultiplicity 1). This and theappearance of descents convincedus thatthere must be an intimateconnection between carries and shuffling. The mainresult of thisarticle (proved in Section3) makesthis precise.

Theorem2.1. The numberof descentsin successive b-shufflesof n cards formsa Markovchain on {0,1, ... , n - 1} withtransition matrix (P(i, j)) of (HI).

3. BIJECTIVE METHODS. Firstwe describesome notation to be used throughout. The numberof descentsof a permutationr is denotedby d(r). Label the columns of the n numbersto be added base b by Cu C2, C3, . . . , whereC' is the rightmost column. The mainpurpose of thissection is to give a bijectiveproof of thefollowing theo- rem,which implies Theorem 2.1.

Theorem3.1. Let Kj denotethe amount carried from column j to columnj + 1 when n m-digit base-b numbersare added, and thedigits are chosen uniformlyand inde- - pendentlyfrom {0, 1, • • -, b 1}. Let r7 be thepermutation obtained after the first j stepsof a sequenceof m b-shufflesofn cards,started at theidentity. Then

P(/d =!!,... ,^M=Iw)=P(d(T1) = !!,... ,d(Tm) = im) for all values ofi', . . . , im.

In preparationfor the proofof Theorem3.1, some definitionsand lemmas are - needed.To begin,note that Kj is determinedby the last j columnsCj- C'. Given a length-^list of j -digitbase-& numbers, one says thatthe list has a carryat positioni if theaddition of the (i + l)st numberon thelist to thesum of thefirst i numberson thelist increasesthe amountthat would be carriedto the (j + l)st column(it might seem morenatural to say thatthe carry is at position/ + 1, butour conventionwill be useful).For examplethe following list of 3-digitbase-3 numbers:

0 1 2 0 1 2 1 1 2 1 1 1 2 1 2 1 2 1 has a carryat positions3 and 4. Indeed012 + 012 = 101 whichdoesn't create a carry. Adding1 12 gives220 whichstill doesn't create a carry.Adding 1 1 1 gives 101 witha carry,so thereis a carryat position3. Adding212 gives020 witha carry,so thereis a carryat position4. Finallyadding 121 gives211, whichdoesn't create a carry. Note thatwhen there is a carryat position/, the carry is 1. This observationyields thefollowing lemma.

- • Lemma 3.2. Let k(Cj -C') denotethe numberof positionsi such thatwhen the • base-b numbersgiven by Cj • • C' are added, thereis a carryat position i. Then K(Cj.-d)=Kj.

November2009] carries, shuffling,and an amazing matrix 79 1 Givena length-nlist of j -digitbase-/? numbers, one says thatthe list has a descent at position/ if the (/ + l)st numberon thelist is smallerthan the /thnumber on the list.For examplethe following list of 3-digitbase-3 numbers:

0 1 2 1 0 1 2 2 0 1 0 1 0 2 0 2 1 1 has a descentat position3 since 220 is greaterthan 101, and a descentat position4 since 101 is greaterthan 020. For whatfollows we use a bijection,which we call thebar map,on length-nlists of y-digit base-è numbers.Letting a', . . . , an denotethe n numberson thislist, the bar map maybe describedas

(au ... ,ö„)h> {aua' + a2ia' + a2 + a3, . . . ,a'-' V an) whereaddition is mod bj . For example,

0 12 0 12 0 12 10 1 112 2 2 0 <-3<-2<-lr r r = >"> <-3<-2W - j | | 10 1" 2 12 0 2 0 12 1 2 11

Indeed 012 + 012 = 101 givingthe second line of C3C2CX.Then 101 + 112 = 220 givingthe third line, and 220 +111 = 101 (retainingonly the last 3 digits),giving the fourthline, etc. One can easilyinvert the bar map,so it is a bijection.

Remark.The bar map was shownto us by JimFill withthe suggestionthat it would lead to a bijectiveproof of Theorem3.1. Our analyticproof is recordedin [15].

The followinglemma is immediatefrom the above definitions.

• • • Lemma 3.3. C7- C' has a descentat positioni ifand onlyifCj • - • C' has a carry at positioni.

Given a length-nlist of y-digit base-è numbers,we definean associatedpermuta- tion7T by labelingthe n numbersfrom smallest to largest(considering the higher-up numberto be smallerin case of ties). For examplewith n = 6, j = 2, and b - 3, one wouldhave

/ 1 2 ' 4 2 1 5 1 0 3 n=n = 0 1 2 , 0 0 1 V 2 1 / 6

792 © THE MATHEMATICAL ASSOCIATION OF AMERICA [Monthly 1 16 since 00 is the smallest,followed by 01, 10, 12, thenthe uppermostcopy of 21, and finallythe lowermost copy of 21. Note that,by theconvention we use forwriting per- mutations,this means that n(') = 4, n(2) = 5, etc. We mentionthat this construction appearsin thetheory of inverseriffle shuffling [5].

Lemma 3.4. C, • • C' has a descentat positioni ifand onlyif the associated permu- • • • tation7t(Cj C') has a descentat positioni.

Proof This is immediatefrom the definition of n . ■

To proceedwe definea second bijection,called the starmap, on length-nlists of y-digitbase-è numbers.As above, it is usefulto thinkof such a listas a sequence of j length-«column vectors with entries in 0, 1, . . . , b - 1. The starmap sends col- -•• umn vectorsAj - -A' to (Aj A')* definedas follows.The rightmostcolumn of • • • (Ay -Ai)* is Ai. The second columnin (Aj Ai)* is obtainedby puttingthe en- triesof A2 in the orderspecified by the permutationcorresponding to the rightmost • columnof (Aj • • A')* (whichis A'); i.e., if n = 7t(A'), whatgets put in positionj is the7t(j)th entryof A2. Thenthe third column in (Aj • • • Ai)* is obtainedby putting the entriesof A3 in the orderspecified by thepermutation corresponding to the two rightmostcolumns of (Aj • • • Ai)*, and so on. For example, 12 2 0 12 12 1 10 1 2 0 0 2 2 0 A A A ,A A A'* = . A3A2Al =001^ (A3A2A0 1 0 1 2 10 0 2 0 0 11 2 11

Indeed,the rightmost column of (A3A2Ai)* is A'. The secondcolumn of (A3A2Ai)* is obtainedby takingthe entries of A2 (namely2, 2, 0, 0, 1, 1) and puttingthe first 2 nextto thesmallest element of A! (so thehighest 0), thenthe second 2 nextto the2nd smallestelement (so thesecond 0), thenthe first 0 nextto the3rd smallest element (so thehighest 1), thenthe second 0 nextto the4th smallestelement (so the second 1), thenthe first 1 nextto the5th smallest element (so thethird 1), and finallythe second 1 nextto the6th smallest element (so theonly 2), giving 1 2 0 1 2 0 ' 0 1 2 0 1 1

Then thethird column of (A3A2Ai)* is obtainedby takingthe entries of A3 (namely 1, 1, 2, 0, 2, 0) and puttingthe first 1 nextto thesmallest pair (so thehighest 01), then puttingthe second 1 nextto the 2nd smallestpair (so the second 01), thenthe first 2 nextto thethird smallest pair 11, thenthe first0 nextto the fourthsmallest pair 12, thenthe second 2 nextto thefifth smallest pair (the highest 20), and finallythe second 0 nextto thesixth smallest pair (the second 20). The starmap is straightforwardto invert (we leave thisas an exerciseto thereader), so it is a bijection.

November2009] carries, shuffling,and an amazing matrix 793 The crucialproperty of the starmap is givenby the followinglemma, the j = 2 case of whichis essentiallyequivalent to the"AB&B" formulain [27, Section9.4].

Lemma 3.5.

n(Aj)...7r(Aì) = n[(Aj'..Aì)*l wherethe product on theleft is theusual multiplicationof permutations.

As an illustration, 1 2 2 1 2 1 2 0 0 A A A = A3A2A{ 0 0 l 2 1 0 0 1 1 yieldsthe permutations

n(A3) jt(A2) ir{Ax) 3 5 6 4 6 3 5 1 1 . 1 2 4 6 3 2 2 4 5

Also as calculatedabove, 0 1 2 1 0 1 , * * a ,* 2 2 0 (^3^2^,)*= j 0 j 0 2 0 2 1 1 whichyields the permutations

ff[(A3A2A,n ;r[(A2A,r] »[(AO*] 1 4 6 3 1 3 6 5 1 4 2 4 2 6 2 5 3 5

We thus have the equalities jrJXAp]= 7r(Ai),n[(A2A1)*] = Tt{A2)n{A'), and jr[(A3A2Ai)*] = 7i(A3)n(A2)n(A'), and Lemma 3.5 gives thatthis happens in gen- eral.

Proofof Lemma 3.5. This is clearfor j = 1, so considerj = 2. Thenthe claim is per- haps easiestto see usingthe theory of inverseriffle shuffles. Namely, given a column

794 © THE MATHEMATICALASSOCIATION OF AMERICA [Monthly1 16 of n 1-digit base-è numbers,label cards 1, ... , n withthese numbers, then bring the cardslabeled 0 to thetop (cardshigher up remaininghigher up), thenbring the cards labeled 1 just beneaththem, and so on. For instance,

Card Label Card Label 12 3 0 2 1 5 0 3 0 h> 2 1 . 4 1 4 1 5 0 6 1 6 1 12

Note thatthe third column of thetable represents 7t(A')~l. Now repeatthis process, usingthe column 2 2 0 0 1 1 to label thecards, placing the labels just to theleft of thedigit already on each card.A moment'sthought shows that this is equivalentto a singleprocess in whichone labels the cards withpairs from(A2Ai)*. Thus 7r[(A2Ai)*]~1= 7r(A1)"17r(A2)~1,so that 7t[(A2Ai)*]= 7t(A2)7t(A1).The readerdesiring further discussion for the case of two columnsis referredto Section9.4 ofthe expository paper [27]. The argumentfor j > 3 is identical:just use theobservation that iterating the procedure three times is equiva- lentto a singleprocess in whichone labels thecards with triples from (A3A2Ai)*. ■

Withthe above preparationsin hand,Theorem 3.1 can be proved.

Proofof Theorem3.1. To begin,note that • • • KX= Ii, . . . , Km= Ím O K(Cj Ci) = ij (1 < j < m)

O d(Cj'--d) = ij (l

& d{n{Cj..-Cx)) = ij (l

The firststep used Lemma 3.2, the second step used Lemma 3.3, and the thirdstep used Lemma 3.4. Let Am• • • A! = (Cm• • • CO"*, where- * denotesthe inverse of thestar map. Then - - Aj"-A' = (Cj -C')~* forall 1 < j < m, and Lemma 3.5 impliesthat • - . d[n(Aj) - . -7t(Ax)] = d(7T[(Aj A0*]) =

O d[n(Aj) -• • niA,)] = ij (1 < j < m).

Now notethat if theentries of Cm• • • C' are chosenindependently from the uniform distributionon {0, 1, . . . , b - 1}, thenthe same is trueof Am• • • Ai since thebar and

November2009] carries, shuffling,and an amazing matrix 795 starmaps are bothbijections. Note thateach 7r(A¿)has thedistribution of a permuta- • • • tionafter a è-shuffle,so one may take ryto be theproduct n(Aj) n(A'), and the theoremis proved. ■

Remarkand example. The above constructionmay appearcomplicated, but we men- tionthat the star map (thoughuseful in theproof) is notneeded in orderto go fromthe numbersbeing added to the r 's. Indeed,from the proof of Theorem3.1 one sees that ther/s can be definedby x} = tv(Cj • • • Ci). Thus in therunning example,

r3 r2 ri 0 12 0 12 14 6 0 1 2 10 1 3 13 C3C2C1 = 1 1 2 h->C^Cx = 2 2 0 h> 6 5 1 . Ill 101 424 212 020 262 12 1 2 11 5 3 5

Observethat k' =3,k2 = 3,and/c3= 2, andthat d(t') = 3,¿/(r2)= 3,and¿/(r3)= 2, as claimed. As a corollaryof Theorem3.1, we deducethat the descent process after riffle shuf- flesis Markov(usually, a functionof a Markovchain is notMarkov).

Corollary3.6. Let a Markovchain on thesymmetric group begin at theidentity and proceed by successive independentb-shuffles. Then d{jt), the numberof descents, formsa Markovchain.

Proof This followsfrom Theorem 3.1 and thefact that the carries process is Markov. ■

4. APPLICATIONS TO THE CARRIES PROCESS. As in previoussections, let Kj be the amountcarried from column j to column j + 1 when n m-digit base-è numbersare added, and the digitsof thesenumbers are chosenuniformly and inde- pendentlyin {0, 1, ... , b - 1}.

Theorem 4.1. For 1 < j < m and n > 2, theexpected value ofKj is

The varianceof Kj is

Normalizedby itsmean and variance,for large nykj has a limitingstandard normal distribution.

Proof FromLemma 3.3, Kj is distributedexactly like thenumber of descentsamong the n rows of the rightmostj digitsof the randomarray. The distributionof these descentsis studiedin [8] wherethey are shownto be a 1-dependent process with the requiredmean and variance.The centrallimit theorem for 1-dependent processes is classical [3]. ■

796 © THE MATHEMATICALASSOCIATION OF AMERICA [Monthly1 16 Remarks.

1. Observe that /xyand aj are increasingto theirrespective limiting values (n - l)/2, (n + 1)/12 as j increases. A Markovchain P on the integersis called stochasticallymonotone if for anyup-set U (thatis, a set of theform Í7 = {/:/> k}), one has thatP(i, U) > > - P(h, U) whenever/ h. Here P(i, U) Yljeu ^0'» J) denotesthe probability thatthe chain is in a statein U at some step giventhat it was in state/ at the previousstep. The carrieschain is clearlystochastically monotone (starting with a carryof / ratherthan a carryof h < i can onlyincrease the carry at thenext step).This monotonicitywas used in our analysisof thetotal variation distance convergencerate of thecarries chain in thecompanion paper [15], and a referee notesthat it gives anotherproof that /xy+i > ¡jíj. Namely,since P is stochasti- cally monotone,so is each power Pj. Thus the distributionsP7(0, •) increase stochasticallyin j (meaningthat Pj+{(0, U) > Pj(0, U) forany up-set U). In- deed,

p;+1(0,U) = Y^ p(^ i)Pj(i, U)>J2 ^(0>0^(0, U) = Pj(0,U). i i

This preciselysays that the successive carryrandom variables k-} increase stochastically,so theirexpected values are nondecreasingtoo. 2. Let Sm= K' + K2+ • • • + Kmbe thetotal number of carries.By linearityof ex- pectationand Theorem4.1, thishas mean - - A"=^T1 (w FTT0 ¿0)• Whenn - 2, thiswas shownby Knuth[25, p. 278]. He also findsthe variance of Smwhen n = 2. For fixedn and b, the centrallimit theorem for finite state space Markovchains [7] showsthat Sm, normalized by its mean and variance, has a standardnormal limiting distribution. 3. The fineproperties of thenumber of carrieswithin a columnare studiedin [8] whereit is shownto be a determinantalpoint process.

As shownabove, the carries process k} : , 0 < j < m (withk0 = 0) is a Markovchain whichhas limitingstationary distribution n(j) = A(n,j)/n'. To studythe rate of convergenceto thelimit we firstprove a newproperty of theamazing matrix (P(/, j)) of (HI). Recall thata matrixis totallypositive of ordertwo (TP2) if all the 2 x 2 minorsare nonnegative(matrices in whichall minorsare positiveare called strictly totallypositive). The argumentfor Lemma 4.2 was suggestedby Alexei Borodin.

Lemma 4.2. For everyn and b, thematrix (P(i, j)) of (HI) is T P2.

Proof. As notedon [22, p. 140],

where[xk]f(x) is the coefficientof jc* in a polynomialf(x). Considerthe infinite • - - matrixMn with(/, y)-coordinate '/bn [x'~j] ((1 xb)/(' x))n . As thetranspose

November2009] carries, shuffling,and an amazing matrix 797 of P is a submatrixof Mn, it will sufficeto show thatMn is T P2. Since theproduct of TP2 matricesis TP2 and Mn = '/bn • (M0)rt+1, it is enoughto treatthe case n = 0. Now, Mo is lower triangularwith ones down the diagonal,ones on the nextlowest b - 1 diagonalsand zeros elsewhere.For example,when b = 3 therelevant matrix is /I 0 0 0 0 0 -A 11 0 0 0 0-.. 1110 0 0..- oí i i o o ... • 0 0 1110--. V ''- '•- "••' • "• '••/ Since (forgeneral b) the l's occurin consecutivediagonal bands, the matrices (ïi)(ïi)(iî)- cannotoccur as submatrices.As theseare theonly 2x2 zero-onematrices with neg- ativedeterminant, the lemma follows. ■

= = Remark.When b 2, the original (P(i,j)) (2~n(2"**+l)) is totallypositive (TP,»). Indeed,P(i, j) = 2-#i[jc2'-/+1](1+ x)n+l. LettingV = i + 1 and / = j + l9 thisbecomes 2~n[x2j~i'](i + x)n+l. Thus each minorof (P(/, j)) is a subminorof the matrixwith entries 2~n[xj'~if](l + je)"*1.This is totallypositive by theclassification of Polya frequencysequences due to Schoenbergand Edrei [24, Chapter8]. We have yetto settlewhether (P(i, j)) is T Pœ forgeneral b, butnote by (H4) thatsince the productof T Poomatrices is T P^, totalpositivity does hold whenb is a powerof 2.

Considerthe basic transitionmatrix (P(/, j)) forgeneral b and rc.This has station- arydistribution n(j), 0 < j < n - 1, givenin (H2). The carriesMarkov chain starts at 0 and therightmost carries tend to be smaller.This is seen in Theorem4.1 and Re- mark1 followingit. It is naturalto ask how farover one mustgo so thatthe carries processis stationary.If Pr (0, j) is thechance of a carryof j afterr steps,we measure theapproach to stationarityby theseparation r sep(r) = max 1 p^ojy]- - . J L n(j) J

Thus 0 < sep(r) < 1 and sep(r) is small providedPr(0, j) is close to n(j) forall j. See [2] or [14] forfurther properties of separation.The followingtheorem may be roughlysummarized as showingthat convergence requires r - 2 logbn.

Theorem 4.3. For any b > 2 and n > 2, thetransition matrix (P(i, j)) of (HI) sat- isfies: 1. For all r > 0, theseparation sep(r) of the carries chain afterr steps (started at 0) is attainedat thestate j = n - 1. 2. Forr= I2'ogb(n) + logfc(c)J,

sep(r) -> 1 - e~x/2c

ifc > 0 isfixed and n -> oo.

798 © THE MATHEMATICALASSOCIATION OF AMERICA [Monthly1 16 Proof. By Lemma 4.2, the matrix(P(/, j)) is TP2. Thus the matrixP* with(/, j)- entryP*(/, j) := [PO', 0^0)1/^0) is also 7P2, since every2x2 minorof P* is a positivemultiple of a 2 x 2 minorof P. Now considerthe vector whose ith component is /r(/) = Pr(0, i)/n(i). We claim thatP*fr = fr+[. Indeed,

[/>*/r](0= ^i>*(/,7)/r0')

~^^P(jJ)n(j) Pr(0J) y ^ ^ _ Pr+1(0,/)

= /r+l(0.

Now the"variation-diminishing property" [24, p. 22] impliesthat if / is monotone and P* is TP2, thenP*/ is monotone.Since /0 is monotone(the walk is startedat 0), it followsthat fr is monotone,i.e., thatthe separationsep(r) is attainedat the state n- 1. For the second assertion,note that by therelation between riffle shuffling and the carrieschain in Theorem3.1, Pr(0, n - 1) is equal to thechance of being at theunique - permutationwith n 1 descentsafter r iterationsof a è-shuffle;by equation(4) in Section2 thisis b~rnQ. Thus Pr(0,n-l) sep(r), N= 1 - 7T(n - 1) -B(-¿) -'-«»(g-O-p))- Letting¿/ = en2 withc > 0 fixed,this becomes '-«*(-g[¿ +*(£)])-' --*• as n -^ oo. ■

Remark.It is known[5] thatit takesr = 2 log¿w è-shufflesto makeseparation small on thesymmetric group. Via Theorem3.1, thisshows 2 log¿,n stepssuffice for the car- riesprocess. Of course,a priorifewer steps might suffice but Theorem 4.3 showsthe resultis sharpfor large n. In mildcontrast, it is known[1, 5] that(3/2) log2n "ordi- nary"(b - 2) riffleshuffles are necessaryand sufficefor total variation convergence. Ourcompanion paper [15] showsthat (1/2) log¿n carrysteps are necessaryand suffice fortotal variation convergence.

November2009] carries, shuffling,and an amazing matrix 799 5. THREE RELATED TOPICS. The "amazingmatrix" turns up in differentcon- texts(sections of generatingfunctions) in thework of Brentiand Welker[9]. Thereis an analog of carriesfor multiplication which has interestingstructure. Finally, there are quite differentamazing matrices having many of the same propertiesas Holte's. These threetopics are brieflydeveloped in thissection.

5.1. Sections of generatingfunctions. Some naturalsequences ak, 0 < k < oo have generatingfunctions

Ä h(x) (5) 2>*=(i.*=o u X),),.+■ withh(x) = ho + h'x H h hn+ìxn+xa polynomialof degreeat mostn + l. Forex- = = ample,the generating function of ak knhas thisform with h(x) X^>o ^(w» J)xJ+i withA(n, j) theEulerian numbers of (H2). Rationalgenerating functions character- ize sequences {ah} which satisfya constantcoefficient recurrence [28]. They arise naturallyas theHubert series of gradedalgebras [17, Chapter10.4]. Suppose we are interestedin everybth term {abk), 0 < /c< oo. It is nothard to see that Ä , = h^(x) La*x k=o ^(i-sv+i X) foranother polynomial h{b)(x) of degreeat mostn + 1. Brentiand Welker[9] show thatthe /th coefficient of h{b)(x) satisfies

h^ = J2C(iJ)hj 7=0 withC an (n + 2) x (n + 2) matrixwith (/, j ) -entry(0 < /,j < n + 1) equal to the numberof solutionsto a' + • • • + an+' = ib - j where0 < a¡ < b - 1 are integers. The carriesmatrix is closely relatedto theirmatrix. Indeed, remove from C the / = 0, n + 1 rowsand thej = 0, n + 1 columns.Let /' = / - 1, / = j - 1. This givesan ftx n matrixwith (f , /)-entry(0 < /',/ < n - 1) equal to thenumber of solutionsto ci' -' han+' = {V + ')b - (/ + 1) where0 < a¡ < b - 1 areintegers. Multiplying by b~n and takingtransposes gives the carries matrix for mod b additionof n numbers (see theformula for the carries matrix on [22, p. 140]). Brentiand Welker[9] and Beck and Stapledon[6] developsome propertiesof thetransformation C. We hope some of thefacts from the present development (in particularthe central limit theorems satisfied by the coefficientsand resultson convergencerates) will illuminatetheir algebraic applications;see [15] fora resultin thisdirection.

5.2. Carries for multiplication.Consider the processof base-è multiplicationof a randomnumber (digits chosen from the uniform distribution on {0, 1, . . . , b - 1}) by a fixednumber k > 0. We do notrequire that k is single-digit.Then thereis a natural way to definea carriesprocess, which is best definedby example.Let k = 26 and considermultiplying 1423 by 26 base 10. The zerothcarry is definedas k0 = 0. To computethe first carry, note that 26 x 3 = 78, so kx= 7. Then k' + 26 x 2 = 59, so k2 = 5. Next k2 + 26 x 4 = 109, so k3 = 10. Finally,k3 + 26 x 1 = 36, so k4 = 3. The carriesin this multiplicationprocess are equal to those arisingfrom adding k copies of thesame randomnumber (so 26 copies of 1423 in theexample).

800 © THE MATHEMATICALASSOCIATION OF AMERICA [Monthly1 16 It is notdifficult to see thatthe above processis a Markovchain on thestate space {0, 1, . . . , k - 1}. For example,if b - 10 and k - 1, thetransition matrix is "2121211" 2 12 112 1 j 2 112 12 1 K(iJ) = - 12 12 12 1 1U 12 12 112 12 112 12 _ 1 1 2 1 2 1 2 _

The matrixK above does nothave all eigenvaluesreal, but the following properties do holdin general: • K is doublystochastic, meaning that every row and columnsums to 1. • K is a generalizedcirculant matrix, meaning that each columnis obtainedfrom the previouscolumn by shiftingit downwardby b mod k. • Fix k and let Ka and Kb be thebase-a and base-/?transition matrices for multiplica- tionby k. Then Kab = KaKb.

The firsttwo properties are at thelevel of undergraduateexercises, and [13, Chapter 5] is a usefulreference for generalized circulants. The thirdproperty holds for the same reasonthat it does forHolte's matrix(see theexplanation on [22, p. 143]). Since K is doublystochastic, the carries chain formultiplication has theuniform distributionon {0, 1, . . . , k - 1} as itsstationary distribution. Concerning convergence rates,one has thefollowing simple upper bound for total variation distance.

Proposition5.1. Let Kr0denote the distribution of the carries chain for multiplication byk base-b afterr steps,started at thestate 0. Let n denotethe uniform distribution on{0, 1,... ,Jk- 1}. Then

LU ¿Í>orü)-*ü)i<¿r-7=0

Proof Observethat

= iv ^kx< U + Dftr'0 < ^ < br}' . Kr0(j) ^'{x:b - The numberof integersx satisfyingjbr/k < x < (j + ')br /k is between(br/k) 1 - and (br/k) + 1. Hence 'Kq(j) n(j)' < '/br, and the resultfollows by summing overj . ■

Convergencerate lower bounds depend on thenumber-theoretic relation of k and b in a complicatedway. For instanceif k = b, theprocess is exactlyrandom after 1 step.

5.3. Anotheramazing matrix. Fromone pointof view,Holte's amazingmatrix ex- istsbecause thereis a "big" Markovchain on thesymmetric group Sn witheigenvalues 1, l/b, l/è2, . . . , l/è""1 and a functionT : Sn -> {0, 1, . . . , n - 1} suchthat the im- age of thisMarkov chain is Holte's Markovchain of carries.(The chain on Sn is the

November2009] carries, shuffling,and an amazing matrix 80 1 ¿7-shuffleMarkov chain, and thefunction T assignsto each permutationthe number of descents).Of course,the interpretation as "carries"remains amazing. Thereare manyfunctions of thebasic riffleshuffling Markov chain whichremain Markovchains. Here is a simpleone. Considerrepeated shuffling of a deck oïn cards usingthe ¿-shuffles described in Section2. The positionof the card labeled "one" gives a Markovchain on {1, 2, ... , n}. In [4] thetransition matrix of thischain is shownto be

Ofc(i,7)= (6) ¿xbn n~j yy(j~l)( ih'ib-hy-^'ih-iy-^'ib-h + i)*-»-«-'-»

- - - where the inner sum is fromI = max(0, (/ + j) (n + 1)) to u - min(/ 1,7 1). For example, when n = 2 and 3 the matrices are

]_ (b + 1 b-'' 2b'b-' b+l)'

1 /(b+l)(2b+l) 2(b2-l) (b-l)(2b-')' - 2(b2-l) 2(b2 + 2) 2{b2-') . bb '(b-')(2b-') 2{b2-') (6+l)(26+l)/

Ciucu [11] (see also [4]) provesthat Qb satisfies: • Qb has eigenvalues1, '/b, l/b2,. . . , l/bn~l. • The eigenvectorsof Qb do notdepend on è; in particular,the stationary distribution is uniform:n(i) = '/n, 1 < / < n. • QaQb= Qab.

We suspectthat Qb has othernice propertiesand appearances.

ACKNOWLEDGMENTS. We thankAlexei Borodinfor help withtotal positivity, Francesco Brenti for tellingus aboutsections of generating functions, Jim Fill forgiving us hisdiscovery of the crucial bar map, and PhilHanlon for daring to suggestthat the two Markov chains were the same. We thanktwo careful referees for theircomments. The workof Diaconis was supportedby NSF grantDMS-0505673 and thechair d'excellence at theUniversity of Nice, Sophia-Antipolis. The workof Fulmanwas supportedby NSF grantDMS-0503901.

REFERENCES

1. D. Aldous,Random walks on finitegroups and rapidlymixing Markov chains, in Séminairede Prob- abilitésXVII, LectureNotes in Mathematics,vol. 986, Springer,, 1983, 243-297. doi: 10.1007/BFb0068322 2. D. Aldousand P. Diaconis,Shuffling cards and stoppingtimes, this MONTHLY 93 (1986) 333-348. doi : 10.2307/2323590 3. T. W. Anderson,The Statistical Analysis of TimeSeries, John Wiley, New York,1971. 4. S. Asaf,P. Diaconis,and K. Soundararajan,A ruleof thumb for riffle shuffling (preprint), Department of Statistics,, Stanford, CA, 2008. 5. D. Bayerand P. Diaconis,Trailing the dovetail shuffle to itslair, Ann. Appi Probab.2 (1992) 294-313. doi : 10 . 1214/aoap/1177005705 6. M. Beck andA. Stapledon,On thelog-concavity of Hubert series of Veronese subrings and Ehrhart series (2008), availableat http : //xxx. lanl . e;ov/abs/0804. 3639. 7. P. Billingsley,Probability and Measure,John Wiley, New York,1986.

802 © THE MATHEMATICALASSOCIATION OF AMERICA [Monthly1 16 8. A. Borodin,P. Diaconis,and J.Fulman, On addinga listof numbers(and otherone-dependent determi- nantalprocesses) (2009), availableat http : //xxx. lanl . gov/abs/0904. 3740. 9. F. Brentiand V. Welker,The Veroneseconstruction for formal power series and gradedalgebras, Adv. in Appi Math.42 (2009) 545-556. doi : 10 . 1016/j . aam. 2009 . 01 . 001 10. J. Buhler,D. Eisenbud,R. Graham,and C. Wright,Juggling drops and descents,this Monthly 101 (1994) 507-5 19. doi : 10 . 2307/2975316 11. M. Ciucu, No-feedbackcard guessingfor dovetail shuffles, Ann. Appi Probab. 8 (1998) 1251-1269. doi : 10 . 1214/aoap/1028903379 12. L. Comtet,Advanced Combinatorics, D. Reidel,Dordrecht, 1974. 13. P. Davis, CirculantMatrices, John Wiley, New York,1 979. 14. P. Diaconis,Mathematical developments from the analysis of riffle-shuffling,in Groups, Combinatorics and Geometry,A. Ivanov,M. Liebeck,and J.Saxl, eds.,World Scientific, River Edge, NJ, 2003, 73-97. 15. P. Diaconis and J.Fulman, Carries, shuffling, and symmetricfunctions, Adv. in Appi Math.43 (2009) 176-196.doi: 10. 1016/i .aam. 2009. 02. 002 16. P. Diaconis,M. McGrath,and J.Pitman, Riffle shuffles, cycles and descents,Combinatorica 15 (1995) 11-29. doi : 10 . 1007/BF01294457 17. D. Eisenbud,Commutative Algebra with a ViewToward Algebraic Geometry, Springer- Verlag, New York, 2004. 18. J. Fulman,Applications of the Brauercomplex: card shuffling,permutation statistics, and dynamical systems,J. Algebra 243 (2001) 96-122. doi : 10 . 1006/jabr . 2001 . 8814 19. , Applicationsof symmetricfunctions to cycleand increasingsubsequence structure after shuf- fles,J. Algebraic Comb. 16(2002) 165-194. doi: 10. 1023/A:1021177012548 20. E. Gilbert,Theory of shuffling,Technical Report MM-55-1 14-44, Bell TelephoneLaboratories, Murray Hill,NJ, 1955. 21. P. Hanlon,The actionof Sn on thecomponents of the decomposition of Hochschild homology, Michigan Math.J. 37 (1990) 105-124. doi : 10 . 1307/mmj/1029004069 22. J. Holte,Carries, combinatorics, and an amazingmatrix, this Monthly 104 (1997) 138-149. doi: 10.2307/2974981 23. D. Isaksen,A cohomologicalviewpoint on elementaryschool arithmetic,this Monthly 109 (2002) 796-805. doi : 10 . 2307/3072368 24. S. Karlin,Total Positivity, vol. 1, StanfordUniversity Press, Stanford, CA, 1968. 25. D. E. Knuth,The Art of Computer Programming, vol. 2, 3rded., Addison-Wesley, Reading, MA, 1997. 26. , TheArt of Computer Programming, vol. 3, 2nded., Addison-Wesley, Reading, MA, 1998. 27. B. Mann,How manytimes should you shufflea deck of cards?UMAP J. 15 (1994) 303-332; reprinted in J.L. Snell,ed., Topicsin ContemporaryProbability and ItsApplications, Probability and Stochastics Series,CRC Press,Boca Raton,FL, 1995,261-289. 28. R. P. Stanley,Enumerative Combinatorics I, 2nded., CambridgeUniversity Press, Cambridge, 1997.

PERSI DIACONIS shuffledhis firstdeck of cardsat theage of 5, and readhis firstprobability book at the age of 15. As a professionalmagician and mathematician,he has been shufflingand computingprobabilities eversince. He currentlyteaches at StanfordUniversity. Departmentof Mathematics and Statistics,Stanford University, Stanford, CA 94305

JASON FULMAN receivedhis Ph.D. fromHarvard University in 1997. He enjoysthe communication and discoveryof newmathematics, and currentlyteaches at theUniversity of SouthernCalifornia. Departmentof Mathematics, University of Southern California, Los Angeles,CA 90089-2532 fulman@ use.edu

November2009] carries, shuffling,and an amazing matrix 803