The Mathematics of Juggling Matthew Wright slides also by John Chase 4 5 1 4 1 4 5 1 4 1 4 5 Basic Juggling Patterns Axioms: 1. The juggler must juggle at a constant rhythm. 2. Only one throw may occur on each beat of the pattern. 3. Throws on odd beats must be made from the right hand; throws on even beats from the left hand. 4. The pattern juggled must be periodic. It must repeat. It must repeat. 5. All balls must be thrown to the same height. Example: basic 3-ball pattern arcs represent throws dots represent beats 1 2 3 4 5 6 7 8 9 ∙∙∙ Basic 3-ball Pattern 1 2 3 4 5 6 7 8 9 ∙∙∙ Notice: balls land in the opposite hand from which they were thrown Basic 4-ball Pattern 1 2 3 4 5 6 7 8 9 ∙∙∙ Notice: balls land in the same hand from which they were thrown The Basic 𝒃-ball Patterns If 𝑏 is odd: • Each throw lands in the opposite hand from which it was thrown. • These are called cascade throws. If 𝑏 is even: • Each throw lands in the same hand from which it was thrown. • These are called fountain throws. Let’s change things up a bit… Axioms: 1. The juggler must juggle at a constant rhythm. 2. Only one throw may occur on each beat of the pattern. 3. Throws on even beats must be made from the right hand; throws on odd beats from the left hand. 4. The pattern juggled must be periodic. It must repeat. It must repeat. 5. All balls must be thrown to the same height. What if we allow throws of different heights? Axioms 1-4 describe the simple juggling patterns. Example Start with the basic 4-ball pattern: Concentrate on the landing sites of two throws. Now swap them! • The first 4-throw will land a count later, making it a 5-throw. • The second 4-throw will land a count earlier, making it a 3-throw. This is called a site swap. Juggling Sequences Site swaps allow us to obtain many simple juggling patterns, starting from the basic juggling patterns. We describe each simple juggling pattern by a juggling sequence: a sequence of integers corresponding to the sequence of throws in the juggling pattern. The length of a juggling sequence is its period. A juggling sequence is minimal if it has minimal period among all juggling sequences representing the same pattern. Example: the juggling sequence 441 4 4 4 4 4 1 1 2 3 4 1 4 5 6 1 7 8 9 ∙∙∙ Juggling Sequences 2-balls: 31, 312, 411, 330 3-balls: 441, 531, 51, 4413, 45141 4-balls: 5551, 53, 534, 633, 71 5-balls: 66661, 744, 75751 4 5 1 4 1 4 5 1 4 1 4 5 ∙∙∙ Is every sequence a juggling sequence? No. Consider the sequence 54. collision! 5 4 Clearly, a 5-throw followed by a 4-throw results in a collision. In general, an 𝑛-throw followed by an (𝑛 − 1)-throw results in a collision. How do we know if a given sequence is jugglable? For instance, is 6831445 a jugglable sequence? A juggling function is a function: 𝑗 ∶ ℤ → ℤ≥0 This function tells us what throw to make on each beat. That is, on beat 𝑖, we juggle a 𝑗(𝑖)-throw, for each integer 𝑖. The sequence described by this function is jugglable if and only if the function 𝑗+ : ℤ → ℤ 𝑗+ (𝑖) = 𝑖 + 𝑗(𝑖) is a permutation of the integers. Two important properties of juggling functions: 1. Height of the highest throw: height 𝑗 = max 𝑗(𝑖) 𝑖∈ℤ 2. Number of balls required to juggle the corresponding sequence: balls( 𝑗) = number of balls required to juggle 𝑗 How many balls are required to juggle a given sequence? The Average Theorem: Let 𝑗 be a juggling function with finite height. Then 𝑖∈𝐼 𝑗(𝑖) lim 𝐼 →∞ |𝐼| exists, is finite, and is equal to balls( 𝑗), where the limit is over all integer intervals 𝐼 = {𝑎, 𝑎 + 1, 𝑎 + 2, … , 𝑏}, and 𝐼 = 𝑏 − 𝑎 + 1 is the number of integers in 𝐼. Proof: balls(𝑗) 𝐼 + 1 − height(𝑗) ≤ |𝐼| 𝑖∈𝐼 𝑗(𝑖) |𝐼| balls(𝑗) 𝐼 − 1 + height(𝑗) ≤ |𝐼| height( 𝑗) height( 𝑗) interval 𝐼, with 𝐼 > height( 𝑗) minimum contribution of any particular ball to 𝑖∈𝐼 𝑗(𝑖) maximum contribution of any particular ball to 𝑖∈𝐼 𝑗(𝑖) Proof: balls(𝑗) 𝐼 + 1 − height(𝑗) ≤ |𝐼| 𝑖∈𝐼 𝑗(𝑖) |𝐼| balls(𝑗) 𝐼 − 1 + height(𝑗) ≤ |𝐼| The left and right expressions tend to balls( 𝑗) as |𝐼| tends to infinity. How many balls are required to juggle a given sequence? The Average Theorem: balls 𝑗 = lim 𝑖∈𝐼 𝑗(𝑖) |𝐼| Corollary: The number of balls necessary to juggle a juggling sequence equals its average. 𝐼 →∞ Application: A finite juggling sequence must have an integer average. Examples: 534 441 7531 75751 352 4-ball pattern 3-ball pattern 4-ball pattern 5-ball pattern not jugglable! How can we change one juggling sequence into another? We could perform a site swap. Consider the sequence 𝑆 of 𝑝 nonnegative integers: 𝑆: 𝑎0 , 𝑎1 , … , 𝑎𝑖−1 , 𝑎𝑖 , 𝑎𝑖+1 , … , 𝑎𝑖+𝑑−1 , 𝑎𝑖+𝑑 , 𝑎𝑖+𝑑+1 , … , 𝑎𝑝−1 If 0 < 𝑑 ≤ 𝑎𝑖 , we can swap the landing positions of the balls thrown on beats 𝑖 and 𝑖 + 𝑑 to obtain the sequence 𝑆′: 𝑆 ′ : 𝑎0 , 𝑎1 , … , 𝑎𝑖−1 , 𝑎𝑖+𝑑 + 𝑑, 𝑎𝑖+1 , … , 𝑎𝑖+𝑑−1 , 𝑎𝑖 − 𝑑, 𝑎𝑖+𝑑+1 , … , 𝑎𝑝−1 Notice: • The sequence 𝑆 is a juggling sequence if and only if 𝑆′ is. • The average of 𝑆 is the same as the average of 𝑆′. • If 𝑆 is a juggling sequence, then the number of balls used to juggle 𝑆 equals the number of balls used to juggle 𝑆′. How can we change one juggling sequence into another? We could perform a cyclic shift. Again, let 𝑆 be a sequence of 𝑝 nonnegative integers: 𝑆: 𝑎0 , 𝑎1 , 𝑎2 , … , 𝑎𝑝−1 Now move the last element, 𝑎𝑝−1 , to the beginning of the sequence to obtain the sequence 𝑆→ : 𝑆→ : 𝑎𝑝−1 , 𝑎0 , 𝑎1 , 𝑎2 , … , 𝑎𝑝−2 Notice: • The sequence 𝑆 is a juggling sequence if and only if 𝑆→ is. • The average of 𝑆 is the same as the average of 𝑆→ . • If 𝑆 is a juggling sequence, then the number of balls used to juggle 𝑆 equals the number of balls used to juggle 𝑆→ . The Flattening Algorithm Let 𝑆 be a sequence of 𝑝 ≥ 1 nonnegative integers: 𝑆: 𝑎0 , 𝑎1 , 𝑎2 , … , 𝑎𝑝−1 The flattening algorithm transforms 𝑆 into a new sequence as follows: 1. If 𝑆 is a constant sequence, stop and output this sequence. Otherwise, 2. use cyclic shifts to arrange the elements of 𝑆 such that a maximum integer in 𝑆, say 𝑚, is at position 0 and a nonmaximum integer in 𝑆, say 𝑛, is at position 1. If 𝑚 = 𝑛 + 1, stop and output this sequence. Otherwise, 3. perform a site swap of positions 0 and 1. Redefine 𝑆 to be the resulting sequence, and return to step 1. The Flattening Algorithm Example: start with the sequence 642 also jugglable! swap 642 shift 552 swap 525 shift 345 swap 534 444 jugglable! Example: start with the sequence 514 also not jugglable swap 514 shift 244 swap 424 shift 334 443 not jugglable Observe: • The Flattening Algorithm can be used to decide whether or not a sequence is jugglable. • If the input is a 𝑏-ball juggling sequence with period 𝑝, this algorithm outputs the basic 𝑏-ball sequence of period 𝑝. • If the input is not a juggling sequence, the program stops at step 2 and outputs a sequence of the form 𝑚, 𝑚 – 1, …. How do we know if a given sequence is jugglable? Theorem: Let 𝑆 = {𝑎𝑘 }, for 𝑘 = 0, 1, … 𝑝 − 1, be a sequence of nonnegative integers and let [𝑝] = {0, 1, 2, … , 𝑝 − 1}. Then, 𝑆 is a juggling sequence if and only if the function 𝜙𝑆 : 𝑝 → 𝑝 defined 𝜙𝑆 (𝑖) = 𝑖 + 𝑎𝑖 (mod 𝑝) is a permutation of the set 𝑝 . Example: Show 534 is a valid juggling sequence. Let 𝑆 = {5, 3, 4}. The period is 3, so 𝑝 = 3. Note 𝑝 = 0,1,2 . Then 𝜙𝑆 0 , 𝜙𝑆 1 , 𝜙𝑆 2 = 0 + 5, 1 + 3, 2 + 4 mod 3 = 5, 4,6 (mod 3) = 2, 1,0 This is a permutation of 𝑝 , so 534 is a valid juggling sequence. Theorem: Let 𝑆 = {𝑎𝑘 }, for 𝑘 = 0, 1, … 𝑝 − 1, be a sequence of nonnegative integers and let [𝑝] = {0, 1, 2, … , 𝑝 − 1}. Then, 𝑆 is a juggling sequence if and only if the function 𝜙𝑆 : 𝑝 → 𝑝 defined (𝑖) = 𝑖 + 𝑎𝑖 (mod Proof: The function 𝜙𝜙 if and𝑝) only if the vector 𝑆 𝑆is a permutation is a permutation the set 𝑝 . 𝑣 =of 𝜙 𝑆 0 , 𝜙𝑆 1 , 𝜙𝑆 2 , … , 𝜙𝑆 (𝑝 − 1) contains all of the integers from 0 to 𝑝 – 1. Suppose we apply site swaps and cyclic permutations to the sequence 𝑆 to obtain sequence 𝑆′ with corresponding vector 𝑣′. Then 𝑣′ contains all of the elements of 𝑝 if and only if 𝑣 does. Therefore, given a sequence 𝑆, apply the flattening algorithm to obtain 𝑆′. Then 𝑆 is a juggling sequence if and only if 𝑆′ is a constant sequence, if and only if 𝑣′ contains all of the elements of 𝑝 . How many ways are there to juggle? Infinitely many. (Consider the basic 𝑏-ball sequences for each integer 𝑏 ∈ ℕ.) How many 𝒃-ball juggling sequences are there with period 𝒑? How many 𝒏-ball juggling sequences are there of period 𝒏? 𝑛 = 1: There is one unique sequence, namely, 1. 1 𝑛 = 2: Starting with the sequence 22, we can perform site swaps to obtain two other sequences, 31 and 40 (unique up to cyclic shifts). 2 2 3 1 4 0 𝑛 = 3: Starting with 333 and performing site swaps, we (eventually) obtain 13 sequences (unique up to cyclic shifts). How many 𝒏-ball juggling sequences are there of period 𝒏? 3 3 1 5 3 3 4 2 4 4 0 4 0 7 2 1 0 5 3 3 6 5 2 2 0 8 1 1 0 9 0 1 7 1 2 6 3 0 6 𝑛 = 3: Starting with 333 and performing site swaps, we (eventually) obtain 13 sequences (unique up to cyclic shifts). Is there a better way to count juggling sequences? Suppose we have a large number of each of the following juggling cards: These cards can be used to construct all juggling sequences that are juggled with at most three balls. Example: juggling sequence 441 juggling diagram ∙∙∙ 4 4 1 4 4 1 4 4 1 ∙∙∙ 4 1 4 4 1 4 4 1 constructed with juggling cards 4 Counting Juggling Sequences With many copies of these four cards, we can construct any (notnecessarily minimal) juggling sequences that is juggled with at most three balls. Similarly, with many copies of 𝑏 + 1 distinct cards, we can construct any (not-necessarily minimal) juggling sequence that is juggled with at most 𝑏 balls. Lemma: The number of all juggling sequences of period 𝑝, juggled with at most 𝑏 balls, is: 𝑆 ≤ 𝑏, 𝑝 = 𝑏 + 1 𝑝 Counting Juggling Sequences Lemma: The number of all juggling sequences of period 𝑝, juggled with at most 𝑏 balls, is: 𝑆 ≤ 𝑏, 𝑝 = 𝑏 + 1 𝑝 It follows that: Lemma: The number of all 𝑏-ball juggling sequences of period 𝑝 is: 𝑆 𝑏, 𝑝 = 𝑆 ≤ 𝑏, 𝑝 – 𝑆 ≤ 𝑏 − 1, 𝑝 = 𝑏 + 1 𝑝 − 𝑏𝑝 However, we have counted each cyclic permutation of every sequence, as well as non-minimal sequences. How can we count the minimal 𝒃-ball juggling sequences of period 𝒑, not counting cyclic permutations of the same sequence as distinct? Counting Juggling Sequences Theorem: The number of all minimal 𝑏-ball juggling sequences of period 𝑝, with 𝑏 ≥ 1, is 1 𝑀 𝑏, 𝑝 = 𝑝 𝑑|𝑝 𝑝 𝜇 𝑑 𝑏+1 𝑑 − 𝑏𝑑 if cyclic permutations of juggling sequences are not counted as distinct. Here, 𝜇 denotes the Möbius function: 1 if 𝑛 has an even number of distinct prime factors, 𝜇 𝑛 = −1 if 𝑛 has an odd number of distinct prime factors, 0 if 𝑛 has repeated prime factors. Proof: If 𝑑 divides 𝑝, then each minimal juggling sequence of period 𝑑 gives rise to exactly 𝑑 sequences of period 𝑝. Thus, 𝑆 𝑏, 𝑝 = 𝑏 + 1 𝑝 − 𝑏𝑝 = 𝑑𝑀 𝑏, 𝑑 𝑑|𝑝 The expression for 𝑀 𝑏, 𝑝 follows by Möbius inversion. Questions? Reference: Burkard Polster. The Mathematics of Juggling. Springer, 2003. Juggling Simulators: • www.quantumjuggling.com • jugglinglab.sourceforge.net