Stirling Numbers #
This file defines Stirling numbers of the first and second kinds, proves their fundamental recurrence relations, and establishes some of their key properties and identities.
The Stirling numbers of the first kind #
The unsigned Stirling numbers of the first kind, represent the number of ways
to partition n
distinct elements into k
non-empty cycles.
The Stirling numbers of the second kind #
The Stirling numbers of the second kind, represent the number of ways to partition
n
distinct elements into k
non-empty subsets.
Main definitions #
Nat.stirlingFirst
: the number of ways to partitionn
distinct elements intok
non-empty cycles, defined by the recursive relationship it satisfies.Nat.stirlingSecond
: the number of ways to partitionn
distinct elements intok
non-empty subsets, defined by the recursive relationship it satisfies.
References #
- [Knuth, The Art of Computer Programming, Volume 1, §1.2.6][knuth1997]
Nat.stirlingFirst n k
is the (unsigned) Stirling number of the first kind,
counting the number of permutations of n
elements with exactly k
disjoint cycles.
Equations
- Nat.stirlingFirst 0 0 = 1
- Nat.stirlingFirst 0 n.succ = 0
- n.succ.stirlingFirst 0 = 0
- n.succ.stirlingFirst k.succ = n * n.stirlingFirst (k + 1) + n.stirlingFirst k
Instances For
Nat.stirlingSecond n k
is the Stirling number of the second kind,
counting the number of ways to partition a set of n
elements into k
nonempty subsets.
Equations
- Nat.stirlingSecond 0 0 = 1
- Nat.stirlingSecond 0 n.succ = 0
- n.succ.stirlingSecond 0 = 0
- n.succ.stirlingSecond k.succ = (k + 1) * n.stirlingSecond (k + 1) + n.stirlingSecond k