Number · the experiment runs in your browser
What the Juggler Is Counting
A juggling pattern can be written as a row of numbers — 3, 531, 97531. This is siteswap. Most explanations stop at the notation. But the row hides three exact facts: a sequence is jugglable only if it's a permutation; the number of balls is always the average of the numbers; and the patterns can be counted exactly. Type a row and watch it fly — or collide.
The pattern, juggled
Each number is how many beats until that ball is next thrown. A higher number is a higher throw (the height grows as the square of the number, exactly as gravity requires). Odd numbers cross to the other hand; even numbers return to the same hand; a 0 is an empty hand — a gap. The hands take turns, right then left.
Pillar 1 — a pattern is a permutation
Number the beats 0, 1, 2, …. The throw at beat i has value aᵢ, so the ball it throws lands at beat i + aᵢ. For the pattern to repeat with period n, only the landing beat modulo n matters. The rule for a jugglable pattern is then brutally simple:
the map i ↦ (i + aᵢ) mod n must hit every beat exactly once.
If two throws would land on the same beat, two balls arrive at one hand at one instant — a collision. That's not a juggling pattern; it's a drop. So the valid patterns are precisely the sequences whose landing map is a permutation of {0, 1, …, n−1}.
The landing test
Each throw is an arc from its beat to where it lands (mod n). A red beat is hit twice — a collision.
Pillar 2 — the ball count is the average
Here is a fact that sounds like a coincidence and isn't: the number of balls equals the mean of the numbers. For 531 the mean is (5+3+1)/3 = 3 — three balls. For 97531 it's 25/5 = 5 — five. Try to break it below; you can't.
Why it must be true: over one full period, every ball that is in the air gets thrown exactly once and lands exactly once. The total "air-time" dealt out by the n throws is a₀ + a₁ + … + a₍ₙ₋₁₎ beats. That air-time is shared among the b balls over n beats, so Σaᵢ = b·n — and the average Σaᵢ / n is exactly b. A corollary falls out for free: the sum of the throws must be divisible by the period, or the row can't be a pattern at all. (It's necessary, not sufficient — 321 averages a clean 2, yet all three throws pile onto one beat.)
The average, live
The average theorem, handed to the kernel
The panel above tries the average on whatever you type, and the offline verifier tries it on every valid pattern up to period 6. But "up to period 6" is a census, and a census, however far it runs, only ever settles finitely many patterns. The universal statement, for every period and every valid pattern the sum of the throws is divisible by the period, is now proved once and for all in Lean 4 with zero imports: no Mathlib, no Std, so the only thing trusted is the proof kernel itself.
The proof, in one line
Add up i + aᵢ across one period, two ways. The division algorithm splits each term as i + aᵢ = n·⌊(i+aᵢ)/n⌋ + ((i+aᵢ) mod n). The remainders are exactly the landing beats, and when the pattern is valid they are a permutation of {0,…,n−1}, so they add to the same 0+1+…+(n−1) the plain indices do. That common total cancels from both sides, leaving Σaᵢ = n · (Σ quotients). So the period divides the sum, and the ball count is the exact average, for every n at once.
ballCount_exact · n · balls = Σ throws (no rounding)
valid_landings_nodup · a valid pattern's landings are distinct (the collision test)
#print axioms → [propext, Quot.sound]. No sorry, no Classical.choice, no native_decide.
Reproduce it from a clean checkout: bash research/siteswap/lean/install-lean-nix.sh, then bash research/siteswap/lean/verify.sh. lean Siteswap.lean printing no errors is the whole proof. The source is research/siteswap/lean/Siteswap.lean, and verify.mjs §5 typechecks it live and asserts the axiom footprint.
Pillar 3 — how many patterns are there?
Now the surprise. Fix a period n and a ceiling of b balls. How many different jugglable patterns are there? You might expect a gnarly answer. Instead, in 1994, Buhler, Eisenbud, Graham, and Wright proved it is exactly
(b + 1)n.
Period 2, up to 3 balls? 4² = 16. Period 4, up to 2 balls? 3⁴ = 81. The count of patterns using exactly b balls is the difference, (b+1)ⁿ − bⁿ. The theorem is clean enough to feel like a magic trick — so don't take it on faith. The panel below actually enumerates every sequence for the n and b you choose, tests each for the permutation property, and tallies them. The brute-force count and the formula sit side by side.
Count them yourself
Show the check. Nothing here is asserted on trust:
- The validity test, the average readout, and the counting table are all computed live in this page from the pattern you type — refresh and they recompute from scratch.
- Offline, research/siteswap/verify.mjs asserts all of it (24/24 green): validity by the mod-n permutation test is checked against an independent 20-period simulation over 9,330 sequences (0 mismatches); the average theorem holds for every valid pattern up to period 6; and the (b+1)ⁿ / (b+1)ⁿ−bⁿ counts match brute-force enumeration across every (n,b) cell up to n=4, b=3.
- The exactly-2-ball column is 3ⁿ−2ⁿ = 1, 5, 19, 65, 211, 665, 2059 — the catalogued sequence OEIS A001047, reproduced here as a calibration, not claimed as new.
- The average theorem is not merely sampled: research/siteswap/lean/Siteswap.lean proves n ∣ Σaᵢ for every period and every valid pattern in Lean 4, zero imports, axiom footprint [propext, Quot.sound]. §5 of the verifier typechecks it live and confirms the footprint on each run.
Sources & honest boundaries.
The counting theorem is J. Buhler, D. Eisenbud, R. Graham, C. Wright, "Juggling Drops and Descents," American Mathematical Monthly 101 (1994), 507–519 — the paper that founded siteswap as mathematics. The validity-as-permutation condition and the average theorem are folklore from the same circle (Tiemann, Klimek, and Donald, mid-1980s, independently devised the notation).
This page treats vanilla siteswap: one ball caught and thrown per hand per beat, hands strictly alternating. It deliberately leaves aside the richer dialects — multiplex (several balls in a hand at once), synchronous (both hands on the same beat), and passing patterns between jugglers — where the counting changes. The deeper question of counting prime patterns (whose juggling-state cycle never repeats a state) is genuinely hard and still active: see Chung & Graham, "Primitive juggling sequences" (Amer. Math. Monthly, 2008), and Banaian et al., "Counting prime juggling patterns" (Graphs & Combinatorics, 2016). We don't reproduce those counts here, to avoid conflating them with the simpler primitive-string count.
The animation is a faithful drawing of the schedule, not a claim about any specific human's technique: throw height is drawn proportional to the square of the throw value (correct for constant gravity), and hand parity follows the period exactly. It is a diagram that moves, and it never shows a pattern doing something its numbers forbid.
A pattern is a permutation; a permutation is a pattern. Somewhere in that small sentence is the whole reason juggling turned out to have a mathematics at all — and why a row of three digits can be checked, animated, and counted without anyone having to throw a single ball.