Calculate C N 2 Stirling Number
The Stirling number of the second kind, denoted as c(n, k), represents the number of ways to partition a set of n objects into k non-empty subsets. This calculator specifically computes c(n, 2), which counts the number of ways to divide n distinct objects into exactly 2 non-empty subsets.
What is a Stirling Number of the Second Kind?
Stirling numbers of the second kind are a type of combinatorial number that count the number of ways to partition a set of n distinct objects into k non-empty, indistinct subsets. The notation c(n, k) is used to represent the Stirling number of the second kind for n objects and k subsets.
For c(n, 2), the formula simplifies to counting the number of ways to divide n distinct objects into exactly 2 non-empty subsets. This is equivalent to counting the number of ways to choose a subset of size k from n objects, which is given by the binomial coefficient C(n, k).
Stirling numbers of the second kind are different from Stirling numbers of the first kind, which count the number of permutations of n objects with exactly k disjoint cycles.
Formula for c(n, 2)
The formula for c(n, 2) is derived from the general Stirling number of the second kind formula:
c(n, k) = (1/k!) Σ (from i=0 to k) (-1)^(k-i) C(k, i) i^n
For c(n, 2), this simplifies to:
c(n, 2) = (1/2!) Σ (from i=0 to 2) (-1)^(2-i) C(2, i) i^n
c(n, 2) = (1/2) [C(2, 0) * 0^n + C(2, 1) * 1^n + C(2, 2) * 2^n]
c(n, 2) = (1/2) [1 + 2 * n + n^2]
c(n, 2) = (n^2 + 2n + 1)/2
This simplified formula shows that c(n, 2) is equal to the sum of the first n natural numbers, which is the triangular number T(n) = n(n+1)/2.
Worked Examples
Example 1: n = 3
Calculate c(3, 2).
Using the simplified formula:
c(3, 2) = (3^2 + 2*3 + 1)/2 = (9 + 6 + 1)/2 = 16/2 = 8
Alternatively, listing all possible partitions of 3 objects into 2 subsets:
- {1}, {2,3}
- {2}, {1,3}
- {3}, {1,2}
- {1,2}, {3}
- {1,3}, {2}
- {2,3}, {1}
- {1,2,3}, {} (invalid as subsets must be non-empty)
- {}, {1,2,3} (invalid as subsets must be non-empty)
Valid partitions: 6 (excluding the two invalid cases). However, the formula gives 8, which suggests the formula counts ordered partitions. For unordered partitions, the correct count is 3 (since each pair of subsets is counted twice in the ordered count).
This discrepancy shows the importance of carefully considering whether the formula counts ordered or unordered partitions.
Example 2: n = 4
Calculate c(4, 2).
Using the simplified formula:
c(4, 2) = (4^2 + 2*4 + 1)/2 = (16 + 8 + 1)/2 = 25/2 = 12.5
This result is not an integer, which is impossible for a combinatorial count. This indicates that the simplified formula may not be correct for c(n, 2).
The correct formula for c(n, 2) is actually the binomial coefficient C(n, 2), which counts the number of ways to choose 2 elements from n elements:
c(n, 2) = C(n, 2) = n(n-1)/2
For n=4: c(4, 2) = 4*3/2 = 6
Applications
Stirling numbers of the second kind have applications in various areas of mathematics and computer science, including:
- Combinatorics: Counting the number of ways to partition a set into subsets
- Graph theory: Counting the number of ways to partition the edges of a graph into cycles
- Algorithms: Analyzing the complexity of algorithms that involve partitioning data
- Statistics: Modeling the distribution of data into groups
For c(n, 2), the primary application is counting the number of ways to divide a set of n distinct objects into exactly 2 non-empty subsets. This is equivalent to counting the number of ways to choose a subset of size k from n objects, which is given by the binomial coefficient C(n, k).