Number of ways to partition a set into k even subsets

combinatoricsset-partitionstirling-numbers

Stirling numbers of the second kind give the number of ways to partition a set of $n$ objects into $k$ non-empty subsets. I wondered if it is instead possible to calculate the number of ways of partitioning a set of $n$ objects into $k$ non-empty subsets of even carnality only.

For example, for $\{x_1,x_2,x_3,x_4\}$ i.e. $n=4$ and $k=2$ there are $3$: $\{\{x_1,x_2\},\{x_3,x_4\}\}$, $\{\{x_1,x_3\},\{x_2,x_4\}\}$ and $\{\{x_1,x_4\},\{x_2,x_3\}\}$.

This question discusses a generating function for the number of partitions of a set into even classes, but without the restriction to $k$ subsets.

Best Answer

The number of ways to partition a set of size $n$ into $k$ even subsets is given by this formula: $$ n!\cdot [x^n]\frac1{k!}\left(\frac{e^x+e^{-x}}2-1\right)^k $$ Here, $[x^n]f(x)$ means the coefficient of $x^n$ in the power series $f(x)$.

This follows from the theory of exponential generating functions. The egf for a single non-empty, even subset is $\frac{e^x+e^{-x}}2-1=\cosh(x)-1$. Raising this to the $k$ gives the egf for an ordered sequence of $k$ disjoint subsets whose union is $\{1,\dots,n\}$, then dividing by $k!$ makes this an unordered partition.

This is analgous to the formula $$ S_2(n,k)={n\brace k}=n!\cdot [x^n] \frac1{k!}(e^x-1)^k $$ for the Stirling numbers of the second kind. Changing $e^x$ to $(e^x+e^{-x})/2$ has the effect of eliminating the option of odd subsets.