Contents / Combinatorics / Special Sequences
Chapter 4
Special Sequences
Fibonacci, Catalan, Stirling, Bell, Eulerian and the partition numbers — what each counts and how each is computed.
Introduction
Fibonacci, Catalan, Stirling, Bell, Eulerian and the partition numbers — what each counts and how each is computed.
4.1Linear Recurrences: Fibonacci and Lucas Numbers
The Fibonacci numbers are the smallest interesting example of a linear recurrence, and everything the general theory can say is already visible in them: a closed form built from the roots of a quadratic, a rational generating function, an exponential growth rate, and a supply of identities that all descend from a single matrix.
Definition 4.1 (Fibonacci and Lucas numbers). The Fibonacci numbers are defined by
Pitfall. Indexing conventions differ between books. Here and , so . Sources that start the sequence at shift every index by one, and every identity below then acquires an off-by-one. Fix the convention first and check it against a known value — is a convenient anchor — before using a formula you did not derive yourself.
Both sequences satisfy the same recurrence, and that recurrence is linear and homogeneous with constant coefficients. Such recurrences can be solved in complete generality, and it costs nothing to do the general case.
Theorem 4.2 (Solution of a second-order linear recurrence). Let be complex numbers with and suppose the characteristic polynomial has two distinct roots . Then a sequence satisfies
Proof. () If then, because and ,
() The recurrence determines for all from the two values , so it suffices to find matching those two values; the two sequences then agree everywhere by induction. The system
The characteristic polynomial of the Fibonacci recurrence is , whose roots are the golden ratio and its conjugate,
Theorem 4.3 (Binet's formula). For all ,
Proof. Both sequences satisfy the recurrence with , whose characteristic roots are distinct, so Theorem Solution of a second-order linear recurrence applies and it remains only to match two initial values for each sequence.
For : the proposed formula gives and .
For : it gives and .
Since the initial values match and both sides obey the same recurrence, the two sides agree for every .∎
That an integer sequence has a closed form built out of is less strange than it looks: the irrational parts of and are equal and opposite, so they cancel in the difference. The formula is genuinely useful in practice, because the second term is tiny.
Corollary 4.4 (Rounding form and growth rate). For every , is the nearest integer to . Consequently as .
Proof. By Binet, , and , so
For the ratio, divide Binet's formula for by the one for and factor out :
Intuition. Binet's formula says the Fibonacci numbers are one geometric sequence with a vanishing tremor on top. The term is the whole story; the term is a correction that alternates in sign and shrinks by a factor of each step. That is why settles down to the golden ratio so fast — the ratio is already right to four decimal places at .
Generating functions give a second derivation, and one that generalises to recurrences of any order.
Proposition 4.5 (Fibonacci and Lucas generating functions). As formal power series,
Proof. Write . Then
The denominator is the characteristic polynomial written backwards, and that is the general phenomenon: a sequence satisfies a linear recurrence with constant coefficients if and only if its generating function is a rational function whose denominator is the reversed characteristic polynomial.
The Fibonacci numbers are not merely an analytic object. They count something, and the combinatorial reading proves identities that would be tedious algebraically.
Theorem 4.6 (Fibonacci numbers count tilings). Let be the number of ways to tile a strip of unit cells with squares () and dominoes (). Then for all . Equivalently, is the number of compositions of into parts equal to and , and is the number of subsets of containing no two consecutive integers.
Proof. For the tilings: (the empty tiling of the empty strip) and . For , classify a tiling by its leftmost piece. If it is a square, the rest is an arbitrary tiling of the remaining cells, and there are of those; if it is a domino, the rest is an arbitrary tiling of cells, giving . The two cases are disjoint and exhaustive, so . With and , induction gives .
Reading a tiling left to right as the sequence of its piece-lengths is a bijection with compositions of into s and s, which proves the second statement.
For the third, let be the number of subsets with no two consecutive elements and split on whether . If , the rest is any such subset of : choices. If , then and the rest is any such subset of : choices. So with and , whence .∎
Intuition. "Split on the first piece" is the whole of the combinatorial proof, and it explains why the Fibonacci numbers appear whenever a structure is built left to right out of two kinds of step, one short and one long: binary strings with no two consecutive s, coin-flip sequences with no two heads in a row, ways up a staircase taking one or two steps at a time. They are all the same count wearing different clothes.
Example 4.7 (A staircase with a broken step). A staircase has steps and you climb one or two at a time. How many routes are there, and how many of them avoid landing on step , which is broken?
Solution. The number of routes up steps is the number of compositions of into s and s, which is by Theorem Fibonacci numbers count tilings. For this is .
A route avoiding step must step from to , since a stride has length at most . So such a route consists of a route up to step , the stride , and a route covering the remaining steps: routes.
Sanity check: routes that do land on step number , and ✓.□
The matrix form packages the recurrence so tightly that several classical identities fall out of a single determinant.
Proposition 4.8 (Matrix form). Let . Then for all ,
Proof. For the right-hand side is . Assuming the formula for ,
Corollary 4.9 (Cassini's identity). For all , .
Proof. Take determinants in Proposition Matrix form. Since and the determinant is multiplicative, , while the displayed matrix has determinant .∎
Corollary 4.10 (Addition formula). For and ,
Proof. Compare the entries in . On the left that entry is ; on the right it is
Setting gives , and by Lemma Lucas from Fibonacci. Keeping but replacing the second index by gives .∎
Lemma 4.11 (Lucas from Fibonacci). For all , .
Proof. By Binet,
Now , so
Proposition 4.12 (Summation identities). For ,
Proof. Each is a telescope. For the first, , so the sum collapses to .
For the second, , so the sum collapses to .
For the third, , and the sum collapses to .∎
Theorem 4.13 (The Fibonacci numbers are a strong divisibility sequence). For all , . In particular whenever .
Proof. First, consecutive Fibonacci numbers are coprime: a prime dividing both and would divide , and descending, it would divide . So , and likewise .
Next, by Corollary Addition formula, . Every common divisor of and therefore divides , and being coprime to it divides ; conversely every common divisor of and divides . The two gcds thus divide each other:
Example 4.14 (A divisibility question answered by indices). Compute without computing either number.
Solution. By Theorem The Fibonacci numbers are a strong divisibility sequence, .
Sanity check on a case where the numbers are visible: , and indeed ✓.□
Theorem 4.15 (Zeckendorf representation). Every integer has exactly one representation as a sum of non-consecutive Fibonacci numbers drawn from : that is, with and for every .
Proof. Existence, by strong induction on . Let be the largest Fibonacci number with , so . If we are done. Otherwise set ; since we get , so by induction is a sum of non-consecutive Fibonacci numbers, all of them smaller than and hence of index at most . Prepending preserves the gap condition.
Uniqueness. We claim that a sum of non-consecutive Fibonacci numbers with largest term is strictly less than . The largest such sum is , terminating at or ; using the sum telescopes to in the first case and to in the second, so every such sum is at most . Now suppose had two different representations. Their largest terms cannot differ, for if they were and with then the first representation would be at most , contradicting that it equals . So the largest terms agree; subtract them and induct on the number of terms.∎
Example 4.16 (Zeckendorf in practice). Write as a sum of non-consecutive Fibonacci numbers.
Solution. Greedily subtract the largest Fibonacci number that fits, exactly as in the existence proof.
The largest Fibonacci number is , leaving . The largest is , leaving . And , so we stop.
Hence . The indices have gaps and , both at least ✓, and ✓.□
4.2Catalan Numbers and What They Count
The Fibonacci recurrence adds two earlier terms. The next step up in complexity is a recurrence that multiplies two earlier terms and sums over how the object splits — a convolution — and the sequence it produces is the Catalan sequence, the most ubiquitous in combinatorics after the binomial coefficients.
Definition 4.17 (Catalan number). For an integer the th Catalan number is
Proposition 4.18 (The subtraction form). For , .
Proof. Expanding factorials,
That is an integer at all is not obvious from the definition — need not be divisible by for any structural reason one can see at a glance — but the subtraction form settles it immediately, since it is a difference of two integers. The reason behind both forms is a family of paths.
Definition 4.19 (Dyck path and Dyck word). A Dyck path of semilength is a sequence of steps, each or , starting at the origin, ending at , and never going below the horizontal axis. Writing as ( and as ) turns a Dyck path into a Dyck word: a string of opening and closing brackets in which every prefix has at least as many openings as closings.
Theorem 4.20 (Catalan objects). For every the following families all have exactly members.
- Dyck paths of semilength , equivalently balanced bracket strings with pairs.
- Monotone lattice paths from to using unit east and north steps that never rise strictly above the diagonal .
- Plane binary trees with internal nodes (equivalently leaves).
- Triangulations of a convex -gon by non-crossing diagonals.
- Non-crossing partitions of points arranged on a circle.
- Permutations of avoiding the pattern — equivalently, the stack-sortable permutations.
Proof. We prove that the six families all satisfy the same recurrence and the same initial value; Theorem The Catalan recurrence in the next section shows that this recurrence together with determines the sequence, and the section after that identifies its solution with .
(1) (2) is a relabelling: replace by east and by north — a path that stays weakly below is one whose every prefix has at least as many east steps as north steps.
(1) The first-return decomposition. A non-empty Dyck path begins with and has a first later moment at which it returns to height ; that return step is a . Cutting there writes the path uniquely as where is a Dyck path of some semilength and a Dyck path of semilength . The decomposition is reversible, so the count of Dyck paths satisfies with .
(3) A plane binary tree with internal nodes consists of a root together with an ordered pair of subtrees with and internal nodes; the same recurrence and the same initial value follow. (Explicitly, the bijection with (1) is: traverse the tree in preorder, writing at each internal node and at each leaf but the last.)
(4) Fix an edge of the convex -gon as the base. In any triangulation exactly one triangle contains ; its apex is one of the remaining vertices, and splits the rest of the polygon into an -gon and a -gon with , each triangulated independently. Again the same recurrence, with the -gon contributing the empty triangulation and counting as .
(5) A non-crossing partition of the points on a circle decomposes by the block containing point : the arcs between consecutive elements of must each be partitioned among themselves, so the count is a convolution of the same shape. The bookkeeping gives once more; we omit the routine index chase.
(6) For -avoiding permutations, split at the position of the value . Avoiding forces every entry left of to be smaller than every entry right of — otherwise a larger left entry, , and a smaller right entry would form a pattern. So is determined by a -avoiding permutation of the smallest values on the left and one of the remaining values on the right, giving the convolution again. That the -avoiding permutations are exactly the stack-sortable ones is Knuth's theorem; we use it only as a name here, and its proof (an induction on the stack discipline) is left aside.∎
Intuition. All six families are secretly the same recursive shape: an object is an atom together with two smaller objects of the same kind, split in every possible way. A bracket string is a matched pair wrapping one object and followed by another; a tree is a root with a left and a right subtree; a triangulation is a triangle on the base edge with a polygon hanging off each of its two other sides. Once you see the shape, the fact that the counts agree is not a coincidence to be memorised but a single theorem with six costumes.
Example 4.22 (The five bracket strings). List the Dyck words of semilength and check the count against the formula.
Solution. The formula gives .
Now list the strings and verify each is balanced, tracking the running count of openings minus closings, which must stay and finish at :
— counts ✓ — counts ✓ — counts ✓ — counts ✓ — counts ✓
There is no sixth: any other arrangement of three openings and three closings begins with ) or contains a prefix such as ())( whose running count reaches . So the count is ✓.□
Example 4.23 (Triangulating a hexagon). How many triangulations does a convex hexagon have?
Solution. A hexagon is the -gon with , so the answer is .
Using the recurrence from the proof of Theorem Catalan objects,
Cross-check against the closed form: and ✓. Each triangulation of a hexagon uses exactly triangles and diagonals, which is the general fact that a triangulated -gon has triangles and diagonals.□
Pitfall. Only plane (ordered) binary trees are counted by . If the two children of a node are unordered, or if the tree is unrooted, the count is a different and much harder sequence — the unlabelled rooted trees are counted by Otter's sequence , which has no closed form. Likewise, counts triangulations of a convex polygon with labelled vertices; identifying triangulations that differ by a rotation gives smaller counts.
Remark. Several close relatives share the Catalan style of recursion and are easy to confuse with it. The Motzkin numbers count lattice paths with up, down and flat steps staying weakly above the axis; the large Schröder numbers allow a diagonal step; the Fine numbers count Dyck paths with no return to the axis after an initial ascent of height one. When a count is close to but not equal to a Catalan number, one of these is usually the correct sequence.
4.3The Reflection Principle and the Catalan Formula
The previous section established the recurrence and left the closed form unproved. There are three standard routes to : the reflection principle, the cycle lemma, and the generating function. All three are worth knowing, because each generalises in a different direction, and we give all three.
Theorem 4.24 (Reflection principle). Let be lattice points and let be a horizontal line. The number of lattice paths from to with steps and that touch equals the total number of such paths from to , where is the reflection of in , provided and lie strictly on the same side of .
Proof. Let be the set of paths touching and the set of all paths . Given , let be the first time touches and reflect the portion of before time in the line , keeping the rest unchanged. The reflected initial portion is a legitimate path from to the touch point, since reflection in a horizontal line turns steps into steps and back, so the result is a path : a member of .
The map is injective because reflecting the initial portion again recovers . It is surjective because any path from to must cross — its endpoints lie on opposite sides — so it has a first touching time , and reflecting its initial portion produces a path from to touching at time that the map sends back to . A bijection between and gives .∎
Theorem 4.25 (Closed form for the Catalan numbers). The number of Dyck paths of semilength is
Proof. A path of -steps and -steps in any order goes from to , and there are of them: choose which of the step positions are . Such a path fails to be a Dyck path exactly when it goes below the axis, that is, when it touches the line .
By Theorem Reflection principle with , and — both endpoints lie strictly above — the number of bad paths equals the number of all paths from to . Such a path has steps with a net rise of , so it has up-steps and down-steps with and , giving ; there are of them.
Therefore the number of Dyck paths is , which equals by Proposition The subtraction form.∎
Intuition. The reflection is a trick mirror for counting cheaters. You cannot count the bad paths directly, but every bad path has a first moment of disgrace, and flipping everything that happened before that moment turns it into a path starting from a mirrored origin — a path with no constraint at all, and therefore easy to count. Nothing is lost, because flipping twice puts you back where you started. The whole content of the argument is that "first time it touches " is a well-defined moment, which is why the principle is also called the reflection at the first passage.
Pitfall. Reflect in the forbidden line , not in the axis itself. Reflecting in the axis is not a bijection onto anything useful, because a bad path may touch the axis many times and the axis is not forbidden. The rule is: the mirror is the first line the path is not allowed to reach.
The second route to the formula produces the factor directly instead of as the outcome of a subtraction, and it is the one that generalises to -ary trees.
Theorem 4.27 (Cycle lemma). Let be integers with for every and . Then exactly of the cyclic shifts of the sequence have all their partial sums positive.
Proof. Extend the sequence periodically to an infinite sequence with , and let , so and the partial-sum path drifts upward with slope . Call an index a record if for all . Because the path drifts up, records occur infinitely often, and because every step changes by at most , each record exceeds the previous one by exactly : the record values are consecutive integers. In any window of consecutive indices the sum increases by exactly , so exactly records lie in each window of length .
Now the shift starting at index has all partial sums positive precisely when for every with , which — using periodicity and the upward drift — happens precisely when is a record. So the number of good shifts among any consecutive starting points is the number of records there, namely . Finally, distinct starting indices in a window give distinct shifts, since a repetition would force the period to divide properly and hence to be a proper multiple of itself.∎
Corollary 4.28 (Second proof of the closed form). The number of Dyck paths of semilength is .
Proof. Consider sequences of entries equal to and entries equal to ; there are of them, and each sums to . By Theorem Cycle lemma with and , exactly one cyclic shift of each has all partial sums positive, and the shifts of a given sequence are distinct (a repeated shift would make the sum a proper multiple of times a divisor, impossible when ). So the sequences with all partial sums positive number .
Deleting the first entry of such a sequence — necessarily — leaves entries and entries with all partial sums : a Dyck path. The map is a bijection, since prefixing inverts it. Finally
The third route is generating functions, and it is the one that shows where the square root in the Catalan generating function comes from.
Theorem 4.29 (The Catalan recurrence). With , the Catalan numbers satisfy
Proof. The recurrence is the first-return decomposition established in the proof of Theorem Catalan objects, applied to the family of Dyck paths, which Theorem Closed form for the Catalan numbers identifies with . Uniqueness is immediate: the right-hand side involves only , so the values are forced one at a time.∎
Theorem 4.30 (Catalan generating function). The formal power series satisfies and
Proof. Multiplying the recurrence by and summing over ,
To confirm that this really expands to the Catalan numbers, apply Newton's binomial series to . With one computes, for ,
Example 4.31 (Parenthesising a product). In how many ways can the product of five factors be parenthesised, if the order of the factors is fixed and each multiplication combines two adjacent factors?
Solution. Each full parenthesisation corresponds to a plane binary tree whose leaves are the factors in order, and whose internal nodes are the multiplications. By Theorem Catalan objects(3), trees with internal nodes number .
Check against the recurrence by splitting at the last multiplication performed, which separates the factors into a left block of and a right block of :
Example 4.32 (The ballot problem). In an election candidate receives votes and candidate receives votes. If the ballots are counted in a uniformly random order, what is the probability that is strictly ahead throughout the count?
Solution. Encode the count as a path with for each -vote and for each -vote: there are orders, all equally likely, and we want those whose partial sums are all positive.
Every sequence here sums to and has entries , so Theorem Cycle lemma applies with : exactly of the cyclic shifts of each sequence are good. Grouping the sequences into cyclic classes, the proportion of good ones is therefore
Remark (Asymptotics). Applying Stirling's approximation to gives , and hence
4.4Stirling Numbers of the Second Kind
We move from sequences to triangles: two-parameter families whose rows record a refinement of a count. The Stirling numbers of the second kind refine the count of set partitions by the number of blocks, and they are simultaneously the coefficients that convert ordinary powers into falling factorials — a coincidence that is really a theorem, and one of the most useful in the subject.
Definition 4.33 (Stirling number of the second kind). For integers , — also written — is the number of set partitions of into exactly non-empty blocks. The blocks are unordered and unlabelled. By convention , for , and for .
Theorem 4.34 (Recurrence). For ,
Proof. Classify the partitions of into blocks by the fate of the element .
If is a block on its own, the remaining elements form a partition into blocks, and every such partition arises exactly once: possibilities.
Otherwise sits in a block with other elements; deleting leaves a partition of into blocks, and could have been inserted into any one of those blocks. Each (partition of into blocks, choice of block) pair gives a distinct partition of , so this case contributes .
The cases are disjoint and exhaustive.∎
The recurrence fills a triangle quickly.
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|---|
| 0 | 1 | ||||||
| 1 | 0 | 1 | |||||
| 2 | 0 | 1 | 1 | ||||
| 3 | 0 | 1 | 3 | 1 | |||
| 4 | 0 | 1 | 7 | 6 | 1 | ||
| 5 | 0 | 1 | 15 | 25 | 10 | 1 | |
| 6 | 0 | 1 | 31 | 90 | 65 | 15 | 1 |
Intuition. Think of handing distinct people into rooms that carry no names: all you record is who is with whom. counts the ways to fill exactly rooms leaving none empty. The recurrence is the newcomer's decision: either they take a fresh room — which uses one of the rooms up and leaves the old crowd to fill — or they join one of the rooms already occupied, and there are ways to do that. Painting names on the rooms afterwards multiplies every count by , which is why counts surjections onto a labelled set of size .
Proposition 4.35 (Surjections). For the number of surjective functions is .
Proof. A surjection determines the set partition of into the non-empty fibres , which has exactly blocks. Conversely, a partition into blocks together with a bijection from its blocks to reconstructs , and there are such bijections. So surjections correspond to (partition, labelling) pairs, of which there are .∎
Theorem 4.36 (Explicit formula). For and ,
Proof. By Proposition Surjections it suffices to count surjections by inclusion–exclusion. For let be the set of functions missing the value . A function is a surjection exactly when it lies in none of the . For a set of size , the functions avoiding all values in are the functions into the remaining values, and there are of them. Inclusion–exclusion gives
Example 4.37 (Two ways to ). Compute by classifying block shapes, and again from the explicit formula.
Solution. By shape. A partition of into two blocks has block sizes or .
Sizes : the partition is determined by the singleton, so there are . Sizes : the block containing is determined by choosing 's partner, ways, and the other two elements form the second block; since the blocks are unlabelled this counts each partition once, giving .
Total .
By formula. ✓.□
Example 4.38 (Distributing tasks). Five distinct tasks are assigned to three distinct employees so that nobody is idle. How many assignments are there?
Solution. The employees are distinguishable, so this counts surjections , which by Proposition Surjections is .
From the table, , so the answer is .
Cross-check by inclusion–exclusion directly: ✓.□
The following theorem explains why these numbers are called Stirling numbers at all: they were introduced as coefficients in a polynomial identity, and only later recognised as counting partitions.
Theorem 4.39 (Powers in terms of falling factorials). For every integer , as an identity of polynomials in ,
Proof. Both sides are polynomials in of degree , so it is enough to prove that they agree at every positive integer ; a non-zero polynomial of degree has at most roots, so agreement at infinitely many points forces equality.
Fix and count functions . There are of them. Classify them by the size of the image. A function with image of size exactly is determined by the partition of into its fibres — choices — together with an injection from those blocks into , of which there are . Summing over gives .∎
Example 4.40 (The identity at ). Expand in falling factorials and verify at .
Solution. Row of the table is , , , so
Expanding the right-hand side: ✓.
At : ✓. Read combinatorially, this says that the functions split into with a -element image, with a -element image and injective ones.□
Proposition 4.41 (Exponential generating function of a column). For fixed ,
Proof. Substitute the explicit formula and exchange the two (absolutely convergent, for each fixed ) sums:
Intuition. The generating function is the "set of blocks" recipe read off directly: is the exponential generating function for a single non-empty block, raising it to the makes an ordered list of blocks, and dividing by forgets the order. Every exponential generating function in this chapter is assembled from that one rule.
Pitfall. already treats the blocks as indistinguishable, so do not divide by a second time. The test question to ask is whether the containers have names. Balls into unlabelled boxes, no box empty: . Balls into labelled boxes, no box empty: . Balls into labelled boxes, empties allowed: . Three different answers to three questions that sound almost identical.
4.5Stirling Numbers of the First Kind
The second kind refines set partitions by block count. The first kind refines permutations by cycle count, and converts in the opposite direction: falling factorials back into powers.
Definition 4.42 (Stirling numbers of the first kind). For , the unsigned Stirling number of the first kind — also — is the number of permutations of whose disjoint-cycle decomposition has exactly cycles, fixed points counting as -cycles. The signed Stirling numbers of the first kind are . By convention and for or ( and ).
Theorem 4.43 (Recurrence). For ,
Proof. Classify permutations of with cycles by the cycle containing .
If is a fixed point, deleting it leaves a permutation of with cycles: possibilities.
Otherwise lies in a cycle of length ; deleting from that cycle (splicing its neighbours together) leaves a permutation of with cycles. To reverse this, must be inserted immediately after one of the elements, and each of the choices gives a different permutation. So this case contributes .∎
| 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|
| 1 | 1 | |||||
| 2 | 1 | 1 | ||||
| 3 | 2 | 3 | 1 | |||
| 4 | 6 | 11 | 6 | 1 | ||
| 5 | 24 | 50 | 35 | 10 | 1 | |
| 6 | 120 | 274 | 225 | 85 | 15 | 1 |
Corollary 4.44 (Row sums). For , .
Proof. Every permutation of has some number of cycles between and , and the classes are disjoint, so the row sums the whole symmetric group.∎
Theorem 4.45 (Rising factorials in terms of powers). For , as polynomials in ,
Proof. Induct on . For both sides are . Assume the first identity for . Then
For the second identity, substitute for in the first: , so
Intuition. Every permutation is a set of loops: follow until you return, and you have traced a cycle. So asks how many of the permutations break into exactly loops. At : the identity is three -loops, each of the three transpositions is one -loop plus a fixed point, and each of the two -cycles is a single loop — giving , , , summing to as the row sum demands.
Example 4.46 (Counting permutations with two cycles). Show that by direct enumeration of cycle shapes.
Solution. Two cycles covering four elements have lengths or .
Shape : choose the fixed point in ways; the remaining three elements can be arranged into a cycle in ways. That is permutations.
Shape : split four elements into two unordered pairs in ways, and each pair determines its transposition uniquely: permutations.
Total ✓, matching the table.
Row check: ✓.□
Proposition 4.47 (Boundary entries). For ,
Proof. : the only permutation with cycles is the identity. : a permutation with cycles has exactly one -cycle and the rest fixed, so it is a transposition, and there are of them. : a single -cycle can be written starting from the element , after which the other elements appear in any order, so there are of them.
For , use the recurrence: . Dividing by ,
Harmonic numbers enter here for a reason, not by accident, and they recur throughout the analysis of permutations. Their asymptotic behaviour is worth stating precisely.
Theorem 4.48 (Harmonic asymptotics). The sequence converges as to a constant , the Euler–Mascheroni constant. Hence , and in particular like .
Proof. Since is decreasing, for each ,
The sequence is non-increasing. Using the left inequality with ,
The sequence is bounded below. Summing the right inequality over gives , hence .
A non-increasing sequence bounded below converges, and its limit is by definition .
The sharper expansion follows from the Euler–Maclaurin summation formula and is beyond the scope of this chapter; we use only the statement proved above.∎
Theorem 4.49 (Cycles of a random permutation). Let be a uniformly random permutation of and let be its number of cycles. Then
Proof. By Theorem Rising factorials in terms of powers, the polynomial equals . Since the row sums to , the expectation is
Example 4.50 (How many cycles in a shuffled deck?). Estimate the expected number of cycles of a random permutation of cards, and compare with the expected number of cycles of a random permutation of objects.
Solution. By Theorem Cycles of a random permutation the expectation is ; the exact value confirms the estimate.
For , , and , about low — the discrepancy is the term of the sharper expansion ✓.
The moral is that cycle counts grow only logarithmically: a shuffled deck typically decomposes into a handful of long cycles, not into many short ones.□
Pitfall. Three sign and labelling traps live in this section. First, and differ by ; a formula quoted for "the Stirling numbers of the first kind" may mean either. Second, the first kind counts cycles in permutations and the second counts blocks in set partitions — the names carry no mnemonic, so check against versus , which unhelpfully agree, and then against versus , which do not. Third, the unsigned first-kind triangle uses multiplier in its recurrence while the second-kind triangle uses ; swapping them silently produces a plausible-looking wrong triangle.
4.6The Two Triangles Are Inverse
The two Stirling triangles convert between the same two bases of the polynomial ring, in opposite directions. That single observation gives an orthogonality relation, an inversion formula for sums, and a clean way to move between ordinary and factorial moments in probability.
Theorem 4.51 (Stirling orthogonality). For all ,
Proof. The polynomials and are both bases of the vector space of polynomials in over : the second family is a triangular combination of the first with all leading coefficients .
Theorem Powers in terms of falling factorials says the matrix is the change-of-basis matrix expressing in the falling-factorial basis, and Theorem Rising factorials in terms of powers says expresses in the power basis. Composing the two change-of-basis maps in either order is the identity, which is exactly the two displayed identities.
Explicitly, for the first: substituting the second identity into the first,
Corollary 4.52 (Stirling inversion). For sequences and ,
Proof. Assume the left identity and compute, using Theorem Stirling orthogonality,
Theorem 4.53 (Bell numbers are Stirling row sums). For every the number of set partitions of satisfies
Proof. Every set partition of has exactly one number of blocks with , and the partitions with blocks number by definition. Summing over the disjoint classes gives every partition exactly once. (For the empty partition is the unique one, and the sum is .)∎
Example 4.54 (Reading off and ). Compute and from the second-kind table.
Solution. Row is , so .
Row is , so .
Sanity check against the known Bell sequence ✓. Row gives ✓.□
Ordering the blocks instead of forgetting their order produces a different and equally classical sequence.
Definition 4.55 (Fubini numbers). The th Fubini number (or ordered Bell number) is the number of ordered set partitions of — equivalently the number of ways to rank candidates allowing ties, or the number of weak orderings of an -set:
Proposition 4.56 (Fubini recurrence). For , , with .
Proof. Classify an ordered set partition by its first block, which is a non-empty subset of of some size . There are choices of that block, and the remaining elements carry an arbitrary ordered set partition, of which there are .∎
Example 4.57 (Ranking with ties). Three runners finish a race; ties are possible. How many outcomes are there?
Solution. An outcome is an ordered set partition of the three runners: the blocks are the groups tied at each place, and the order of the blocks is the finishing order. So the answer is .
Check by the formula. ✓.
Check by the recurrence: ✓, using (the outcomes , , and the tie).□
The change of basis also has a probabilistic reading that is used constantly in applications.
Proposition 4.58 (Moments and factorial moments). Let be a random variable with finite moments up to order . Then
Proof. Apply Theorem Powers in terms of falling factorials pointwise to the random variable and take expectations, which is legitimate because the sum is finite and every term is integrable.
For the Poisson case, .∎
Intuition. Factorial moments are the natural currency for counting variables: is the expected number of ordered -tuples of distinct successes, which is usually a one-line computation, while rarely is. The Stirling numbers of the second kind are the exchange rate, and the fact that for a Poisson variable with makes — which is the probabilistic face of Dobinski's formula in the next section.
4.7Bell Numbers and Dobinski's Formula
Definition 4.59 (Bell number). The th Bell number is the number of set partitions of , equivalently the number of equivalence relations on an -element set. By convention . The sequence begins
Intuition. For three people the groupings are: all together ( way); one pair and a loner ( ways: , , ); all separate ( way). That is . What makes the count grow so fast is that nothing is fixed in advance — not the number of groups, not their sizes.
Theorem 4.60 (Bell recurrence). For , with ,
Proof. Classify the partitions of by the block containing the element . Write , so that consists of together with of the other elements, chosen in ways. The remaining elements carry an arbitrary partition, of which there are . Since lies in exactly one block, each partition is counted exactly once, and summing over exhausts the possibilities.∎
Example 4.61 (Climbing the recurrence). Compute and from the recurrence.
Solution. Starting from , , , :
Both agree with the Stirling row sums computed earlier ✓.□
Theorem 4.62 (Exponential generating function).
Proof. Let . All manipulations below are identities of formal power series, where convergence plays no role.
Differentiating term by term, . On the other hand, the product of two exponential generating functions is the binomial convolution:
Intuition. Read as a recipe. The series is the exponential generating function of "one non-empty block", since there is exactly one way to make a single block out of a given set of labels. Wrapping a generating function in is the exponential formula's way of saying "take an unordered collection of these" — and an unordered collection of non-empty blocks covering the labels is precisely a set partition.
Theorem 4.63 (Dobinski's formula). For every ,
Proof. The series converges absolutely, since for large and converges by the ratio test; so rearrangement below is legitimate.
By Theorem Powers in terms of falling factorials, for every integer . Therefore
Example 4.64 (Dobinski numerically). Verify Dobinski's formula for by summing enough terms.
Solution. The terms for are
The partial sum through is , and the remaining terms contribute about . Dividing by : .
And ✓. Notice how concentrated the sum is: the terms peak near , which is the analytic shadow of the fact that a random partition of a small set has few blocks.□
Remark (Probabilistic restatement). Dobinski's formula says exactly that for , since that expectation is . Proposition Moments and factorial moments gives the same conclusion from a different direction: , which at is the Bell row sum. The two derivations are genuinely independent and agree, which is a useful check on both.
Method 4.65 (The Bell triangle). The Bell numbers can be generated without binomial coefficients.
- Start the first row with the single entry .
- Begin each new row with the last entry of the previous row.
- Fill each subsequent entry by adding the entry to its left and the entry above-left (the entry in the previous row in the same relative position).
- The first entry of each row — equivalently the last entry of the previous row — is a Bell number.
Reading the left column gives — the Bell numbers.
Note. The triangle is Aitken's array (also attributed to Peirce and to Bell). That its left column really is the Bell sequence can be proved by identifying the entry in position of row with a count of partitions of subject to a restriction on where the largest elements sit; we take the construction here as a verified computational device and do not prove it. Everything the chapter uses about Bell numbers is proved from Theorem Bell recurrence instead.
Pitfall. counts partitions of a set whose elements are distinguishable. If the objects are identical, the count is the integer-partition number of the next section, which is vastly smaller: but . And if the blocks are to be labelled or ordered, the counts are and the Fubini number respectively — . Four different questions, four different answers.
4.8Partitions of a Set and of an Integer
Counting set partitions by their shape connects the Bell numbers to the other kind of partition: partitions of the integer . The two are linked by one formula, and then the integer partitions take on a life of their own.
Definition 4.66 (Partition of an integer). A partition of a positive integer is a weakly decreasing sequence of positive integers, the parts, with . We write , and for the number of partitions of , with . The sequence begins
Theorem 4.67 (Set partitions of a given shape). Let have parts equal to for each . Then the number of set partitions of whose multiset of block sizes is equals
Proof. Write the elements of in a row: orders. Cut the row into consecutive segments of the sizes prescribed by , taking the sizes in a fixed order. Every set partition of shape arises this way, but each arises many times: the elements within a block of size can be permuted in ways without changing the block, accounting for the factor , and the blocks of the same size can be permuted among themselves, accounting for . Dividing by the total overcount gives the formula. Summing over all shapes counts every set partition once, which is the second statement.∎
Example 4.68 ( by shapes). Recompute by summing over the five partitions of .
Solution.
| shape | count | value |
|---|---|---|
Total: ✓. Note that the five shapes are the integer partitions of , and the set partitions are the of the previous section — the same computation displays both numbers at once.□
Definition 4.69 (Ferrers diagram and conjugate). The Ferrers diagram of is the left-justified array of dots with dots in row . The conjugate partition is obtained by reading the diagram in columns: .
Theorem 4.71 (Conjugation). Conjugation is an involution on the partitions of . Consequently, for every , the number of partitions of into at most parts equals the number of partitions of into parts each at most ; and the number of partitions of into exactly parts equals the number whose largest part is exactly .
Proof. Reflecting a Ferrers diagram in its main diagonal exchanges rows and columns, so it sends the diagram of to that of ; the reflected array is still left-justified with weakly decreasing row lengths, so is a partition of the same , and reflecting twice restores . Hence conjugation is a bijection of with itself and is its own inverse.
Under conjugation the number of rows of becomes the largest part of and vice versa. So "at most rows" corresponds to "largest part at most ", and "exactly rows" to "largest part exactly ".∎
Example 4.72 (Conjugating a partition). Conjugate and check the involution.
Solution. The diagram of has rows of lengths . Column lengths: column meets all rows, column meets rows (length ), column meets only row , column meets only row .
So , and ✓.
Conjugating again: the rows of are ; column meets rows, column meets , column meets , column meets , giving ✓.
Consistent with Theorem Conjugation: has parts and has largest part ✓.□
Theorem 4.73 (Euler's generating function). As formal power series in ,
Proof. Expand each factor as a geometric series, , the term recording that the part is used times. Multiplying the factors and collecting the coefficient of selects all families of non-negative integers with — precisely the partitions of . The product is a legitimate formal power series because only the factors with can contribute to the coefficient of , so each coefficient is a finite sum.
The restricted versions are the same argument with the same factors omitted or truncated: keeping only forbids the other parts, and replacing by allows each part at most once.∎
Theorem 4.74 (Euler: odd parts and distinct parts). For every , the number of partitions of into odd parts equals the number of partitions of into distinct parts.
Proof. By Theorem Euler's generating function the two counts are generated by and respectively, so it suffices to show these products are equal. Using ,
Example 4.75 (Checking Euler's theorem at ). List both families for .
Solution. Odd parts (only are available): ; ; ; ; . That is partitions.
Distinct parts: ; ; ; ; . That is partitions.
Both counts are ✓, and note that they are different partitions — the theorem asserts equality of counts, and the bijection behind it (Glaisher's: repeatedly merge equal parts) is not the identity.□
Theorem 4.76 (Euler's pentagonal number theorem). As formal power series,
Proof. Sketch (Franklin's involution). Expanding the product, the coefficient of is the number of partitions of into an even number of distinct parts minus the number into an odd number of distinct parts. Franklin's involution pairs off almost all such partitions: given a partition into distinct parts, let be its smallest part and the length of the maximal run of consecutive parts starting from the largest. If , remove the smallest part and add to each of the largest parts; if , do the reverse. Each move changes the number of parts by one and so flips the sign, and the two moves are mutually inverse wherever both are defined. They fail to be defined exactly for the partitions where the smallest part sits inside the top run and or , which forces and leaves a single unpaired partition of sign . That is the stated right-hand side. The full case analysis is in any treatment of partitions and we do not reproduce it here.∎
Corollary 4.77 (A fast recurrence for ). For ,
Proof. Multiply Theorem Euler's generating function by Theorem Euler's pentagonal number theorem: the product of and is . Reading off the coefficient of for gives over generalised pentagonal numbers , with the term equal to ; rearranging gives the statement. The number of is because grows quadratically in .∎
Example 4.78 (Computing ). Use the pentagonal recurrence to compute from earlier values.
Solution. The generalised pentagonal numbers up to are , with signs in the recurrence's alternating pattern : contributes and contributes .
Using :
Sanity check with the same recurrence one step earlier: ✓.□
Remark (The size of ). The partition numbers grow sub-exponentially: Hardy and Ramanujan proved
Pitfall. Keep the three "partition" words apart. A composition of is ordered ( and are different, and there are of them). An integer partition of is unordered (). A set partition of groups labelled elements (). Compositions are exponential, integer partitions are sub-exponential, set partitions are super-exponential — and a problem that mixes them up is usually off by orders of magnitude, not by a constant.
4.9Derangements, Eulerian Numbers and Growth Rates
The last two families refine the count of permutations in two further ways — by fixed points, and by descents — and the section closes by putting every sequence in the chapter on a single scale.
Definition 4.79 (Derangement). A derangement of is a permutation with no fixed point. The number of derangements is (also written ), with . The sequence begins
The derangement numbers admit two derivations that share nothing but the answer: one sieves, one recurs. Having both is worth the space, because the sieve gives the closed form and the recurrence gives the arithmetic.
Theorem 4.80 (First derivation: inclusion–exclusion). For ,
Proof. For let be the set of permutations of fixing . A permutation is a derangement exactly when it lies in no . For a subset with , the permutations fixing every element of are the arbitrary permutations of the other elements, so , a number depending only on . Inclusion–exclusion gives
Theorem 4.81 (Second derivation: a recurrence). For ,
Proof. Let be a derangement of and let ; there are choices of . Split into two cases according to whether .
If , then and form a -cycle and the rest of is a derangement of the other elements: possibilities.
If , delete and define on by for and . Then is a permutation of with no fixed point — the only candidate for a new fixed point would be , excluded precisely by the case assumption — and the construction is reversible given . So this case contributes .
Multiplying by the choices of proves the first recurrence. For the second, rewrite it as and induct: the quantity flips sign at each step and equals at , hence equals .∎
The two derivations agree, as they must: satisfies by inspection of the partial sums. The closed form immediately gives the famous limit.
Corollary 4.82 (The hat-check probability). For , , so is the nearest integer to ; and the probability that a uniformly random permutation of is a derangement satisfies
Proof. The series is alternating with terms decreasing in absolute value, so truncating after commits an error smaller than the first omitted term:
Intuition. The striking fact is that the derangement probability barely depends on : it is at , at , and for every to six decimal places. The reason is the sieve: fixing a particular point costs a factor of about , and there are about points to fix, so the corrections at each order are , independent of . The answer is the sum of that series — a Poisson probability with mean , and indeed the number of fixed points of a random permutation converges in distribution to .
Proposition 4.83 (Permutations with a prescribed number of fixed points). The number of permutations of with exactly fixed points is , and . The expected number of fixed points of a uniformly random permutation is for every .
Proof. Choose the set of fixed points in ways and derange the rest in ways; the two choices are independent and reconstruct the permutation. Summing over counts every permutation once.
For the expectation, write the number of fixed points as . Each indicator has expectation because is uniform on , so by linearity the expectation is , regardless of .∎
Example 4.84 (The hat-check problem). Five guests check five distinct hats and receive them back at random. What is the probability that nobody gets their own hat, and what is the probability that exactly two guests do?
Solution. Total permutations: .
Nobody: by the recurrence, . The probability is . Compare ✓, and , whose nearest integer is ✓.
Exactly two: , probability .
Check the whole distribution: ✓.□
Descents are the other classical permutation statistic, and they generate the Eulerian triangle.
Definition 4.85 (Eulerian numbers). A descent of a permutation of is a position with . The Eulerian number , also written , is the number of permutations of with exactly descents, for .
| 1 | 1 | ||||
| 2 | 1 | 1 | |||
| 3 | 1 | 4 | 1 | ||
| 4 | 1 | 11 | 11 | 1 | |
| 5 | 1 | 26 | 66 | 26 | 1 |
Theorem 4.86 (Eulerian recurrence and symmetry). For and ,
Proof. Build a permutation of by inserting the value into a permutation of , at any of the available positions (before the first entry, between two entries, or after the last). Since is the largest value, inserting it into an existing descent position, or at the very end, keeps the number of descents unchanged: there are descents to insert into plus the final position, so positions preserve the descent count. Inserting anywhere else — into one of the ascent positions of or at the front — creates exactly one new descent; there are such positions when has descents, but the bookkeeping is cleaner stated the other way: to obtain descents we either start from with descents and use one of the neutral positions, or start from with descents and use one of the descent-creating positions. Summing the two disjoint cases gives the recurrence.
Symmetry: reversing a permutation, , turns every descent into an ascent and vice versa. A permutation of has consecutive positions in all, so a permutation with descents maps to one with descents, and the map is an involution.
The row sum is because every permutation has a well-defined number of descents.∎
Theorem 4.87 (Worpitzky's identity). For every , as polynomials in ,
Proof. Both sides are polynomials of degree , so it suffices to verify the identity at every positive integer , and there we may count.
Count the words . To each word associate the permutation of that sorts it: list the positions in increasing order of their values, breaking ties by putting the smaller position first, so that and the inequality is strict at every descent of — for if while , the tie-break would have ordered them the other way.
Conversely, given with descents, the words sorted by correspond to the chains that are strict at the descent positions. Subtracting from for each descent position turns those strict inequalities into weak ones and lowers the ceiling from to , so such chains are in bijection with weakly increasing sequences in , of which there are .
Therefore . Finally apply the symmetry of Theorem Eulerian recurrence and symmetry and substitute to rewrite the right-hand side as .∎
Example 4.88 (Worpitzky at ). Verify at and .
Solution. Row of the Eulerian triangle is , so the claim is as displayed.
At : ✓.
At : ✓.
Row check: ✓, as Theorem Eulerian recurrence and symmetry requires.□
Example 4.89 (Building the Eulerian row for ). Derive row from row .
Solution. Row is , , , and the recurrence is .
. . . .
Row: , which sums to ✓ and is symmetric ✓. Note that is a numerical coincidence between two different triangles — a good reminder to check which statistic is being counted.□
Intuition. Eulerian numbers describe how "shuffled" a permutation is. Exactly one permutation of has no descent (the identity) and exactly one has (the reversal), and the bulk of the permutations sit near the middle with about descents. The triangle is the discrete ancestor of the bell curve for this statistic, and Worpitzky's identity is what lets one convert a sum like into a sum of binomial coefficients, which telescopes.
Summary (Where the sequences sit). All the sequences of this chapter counted at , together with their growth laws:
| sequence | meaning | value at | growth |
|---|---|---|---|
| integer partitions | , | ||
| Fibonacci | , | ||
| compositions of | |||
| Catalan | |||
| set partitions | super-exponential, sub-factorial | ||
| derangements | |||
| permutations | |||
| ordered set partitions |
The one genuinely delicate entry is , which sits strictly between exponential and factorial: from Dobinski's formula a saddle-point analysis gives
Example 4.90 (Ordering the growth rates). Without computing large values, order , , and by eventual size, and say which comparison is not settled by an elementary argument.
Solution. for large , since and swamps the polynomial factor.
eventually: while , which already exceeds for large — more cleanly, grows faster than the linear .
eventually, since and while , and the term is the decisive deficit.
So the order is for all large . The last comparison is the one that needs the quoted saddle-point asymptotic for ; the others follow from Stirling's approximation alone.□
- Forgetting the in the Catalan formula. counts all sequences of ups and downs; counts only the ones that stay non-negative. If your answer is off by a factor of roughly , this is why.
- Reflecting in the wrong line. In Theorem Reflection principle the mirror is the first forbidden line, for Dyck paths, not the axis . Reflecting in the axis is not injective onto anything you can count.
- Off-by-one in Catalan indexing. goes with bracket pairs, internal tree nodes, an -gon and factors in a product. Anchor on before trusting an index.
- Confusing the two kinds of Stirling number. First kind counts cycles in permutations, second kind counts blocks in set partitions. They are not two notations for one triangle: while .
- Dividing by twice. already has unlabelled blocks. Surjections onto a labelled -set are ; functions with empties allowed are .
- Mixing up sign conventions for . The signed numbers are the ones that expand the falling factorial; the unsigned ones expand the rising factorial. A formula that produces a negative count has used the wrong family.
- Treating and as the same thing. Bell numbers partition a set of distinguishable elements; partitions an integer. but .
- Losing the empty object. , , , and . Every recurrence in this chapter breaks at its first step if the empty object is dropped.
- Assuming a derangement probability depends on . It is from onwards. If your answer drifts with , you have probably counted permutations with at least one fixed point by summing over fixed points without inclusion–exclusion.
- Using where the count is . The tiling and composition counts are shifted by one from the Fibonacci index; check against , where there is exactly one tiling and .