Enter the total number of objects (n) and the number of subsets/blocks (k) into the calculator to determine the Stirling number of the second kind. This calculator helps in combinatorial mathematics to find the number of ways to partition a set of n objects into k non-empty subsets.
Related Calculators
- Reduction Formula Calculator
- Generalized Power Rule Calculator
- Fractional Index Calculator
- Sum Product Calculator
- All Math and Numbers Calculators
Stirling Number Formula
The Stirling number of the second kind counts how many ways n distinct objects can be partitioned into k non-empty groups when the groups are unlabeled. This makes the calculator useful for set partitions, team formation, clustering, occupancy problems, and many combinatorial counting tasks where order does not matter.
S(n,k)=k\,S(n-1,k)+S(n-1,k-1)
This recurrence has a direct interpretation: the newest object either joins one of the existing groups, or it starts a new group by itself.
What the Inputs Mean
- n = total number of distinct objects
- k = number of required non-empty groups
- Result = number of valid set partitions
Base Cases and Valid Inputs
These rules define the recursion and explain the most common edge cases:
S(0,0)=1
S(n,1)=1
S(n,n)=1
S(n,0)=0 \text{ for } n>0S(n,k)=0 \text{ for } k>n- If the number of groups is larger than the number of objects, the answer is zero.
- If there is only one group, every object must go into that same group.
- If the number of groups equals the number of objects, each object forms its own singleton group.
- Negative values and non-integer inputs do not represent valid set partitions.
Alternative Closed Form
For direct computation and theoretical work, Stirling numbers of the second kind can also be written using inclusion-exclusion:
S(n,k)=\frac{1}{k!}\sum_{i=0}^{k}(-1)^{k-i}\binom{k}{i}i^nThis form is especially useful when connecting the calculator result to surjective functions and occupancy models with no empty boxes.
How to Use the Calculator
- Enter the total number of distinct objects.
- Enter the number of non-empty groups you want to create.
- Make sure the number of groups does not exceed the number of objects.
- Read the result as the number of possible partitions of the set.
Example Interpretation
If 5 distinct objects are split into 3 non-empty unlabeled groups, the number of valid partitions is:
S(5,3)=25
You can also see the same result from the recurrence:
S(5,3)=3\,S(4,3)+S(4,2)=3\cdot 6+7=25
Common Values for Quick Checks
S(3,2)=3
S(4,2)=7
S(5,2)=15
S(5,3)=25
S(6,3)=90
Related Counting Results
If the groups are labeled instead of unlabeled, multiply by the number of label assignments:
k!\,S(n,k)
If you want the total number of partitions across every possible group count, sum the Stirling numbers to get the Bell number:
B_n=\sum_{k=0}^{n}S(n,k)Connection to Falling Factorials
Stirling numbers of the second kind also convert ordinary powers into falling factorials:
x^n=\sum_{k=0}^{n}S(n,k)(x)_k(x)_k=x(x-1)\cdots(x-k+1)
This identity is one reason Stirling numbers appear in combinatorics, finite differences, and polynomial expansions.
Where Stirling Numbers Are Used
- Partitioning a set of labeled objects into unlabeled non-empty groups
- Counting surjective mappings after adjusting for group labels
- Analyzing clustering and grouping problems in discrete mathematics
- Building recurrence-based algorithms in combinatorics
- Relating powers, Bell numbers, and falling factorial expressions
Common Point of Confusion
Stirling numbers are different from Stirling’s approximation. Stirling’s approximation estimates factorial size, while Stirling numbers count set partitions.