**Stirling Numbers and Surjective Functions**

Stirling numbers are closely related to the problem of counting the number of surjective (onto) functions from a set with n elements to a set with k elements. However, they are not the same because:

The number of surjective (onto) functions from a set of size n to a set of size k equals the total number of ways for distributing n distinct objects into k **distinct**, non-empty bins; while the Stirling number S(n,k) counts the total number of ways for distributing n distinct objects into k **indistinct**, non-empty bins.

So, the total number of possible surjective (onto) functions from a set of size n to a set of size k equals **S(n,k)*k!**, that is a multiple of the Stirling number S(n,k) by a factor of k!.

**Stirling Numbers in Discrete Math Homework Problems**

Example Problem (1)

A group of 14 people go walking in the desert. After a while, they get lost and they get randomly separated into 5 smaller (nonempty) groups. In how many ways can this happen if we consider an isolated person as a possible group?

Answer:

S(14,5) = 40,075,035 different ways.

Explanation:

The 15 people are obviously different from each other, while the difference between any two groups is solely determined by the people who are in them. No indication is given to assume that the groups could be labeled, distinguished or identified by any external factors. In this sense we can consider the people in this problem as 14 distinct "objects", and the 5 groups as indistinct "bins."

Example Problem (2)

In how many ways can a boss assign 8 different tasks to 5 employees, in such a way that each employee is responsible for at least one of these tasks, and no task is shared between employees?

Answer:

S(8,5)*5! = 126,000 different ways.

Explanation:

This is a problem of counting all possible surjective functions from a set with 8 elements (the tasks) onto a set with 5 elements (the employees), because tasks are not to be shared. Therefore the applicable formula is S(n,k)*k!. The problem explicitly states that the tasks are different, so we have 8 distincts "objects" (the tasks) being distributed into 5 distinct "non-empty bins" (the employees). In this situation, even if the 5 task bundles were the same, we can still tell between different assignations by who is working on what task bundle. That is why the answer is not just S(8,5) but we need to multiply this number times (5!).

Example Problem (3)

In how many ways can the number 2,310 be expressed as the product of three whole numbers, each greater than 1? (Note: Rearranging the same three factors into a different order does not count as a different factorization)

Answer:

S(5,3) = 25 such factorizations.

Explanation:

Completely factoring out 2,310 into prime factors, we find its prime factorization is 2,310 = (2)(3)(5)(7)(11).

This is a square-free number, because its prime factors are not repeated. So we can basically consider this number as the set of its five prime factors, {2, 3, 5, 7, 11}, and then partition it into three non-empty subsets, because each of the required factorizations needs to consist of three factors greater than one. Since the order of the factors does not matter, we can view this problem as distributing 5 distinct "objects" (the prime factors) into 3 indistinct "bins" (the 3 factors required in each factorization).

Example Problem (4)

In how many ways can 4 fund-raising teams be formed from 8 people? The teams are to compete against each other on the shortest time to reach the same fund-raising goal, and each team can have anywhere from a single member, up to 5 members.

Answer:

S(8,4) = 1,701 ways to form the teams.

Explanation:

Here all the teams have the same function (fund-raising). The teams will be non-empty because they must have at least one member. Mentioning the 5-member upper limit is just a redundant distraction since a 6-member team would be ruled out because there are only 8 people available to form the teams. Also, the problem does not specify any possible way to distinguish the teams before they are formed. Therefore we can consider this situation as one of distributing 8 distinct "objects" (the people), into 4 indistinct non-empty "bins" (the teams). That is why the answer is directly the Stirling number S(8,4).

**Set Theory Example:
**

Stirling Numbers S(4,1), S(4,2), S(4,3), S(4,4) and the corresponding partitions of a set with 4 elements:

Let M be the set with four elements M = {a, b, c, d}.

We will list all partitions of the set M, grouping them by k, the number of subsets of M they include.

Here the notation P_{n,k,j} will refer to the j-th partition with k subsets of a set with n elements. The sub-index j is only to distinguish different k-partitions. The order in our list is rather arbitrary, it is not fixed according to any set criteria.

**S(4,1) = 1**

Four objects going into one bin. The only partition of {a, b, c, d} into one subset is the "whole set" partition:

P_{4,1,1} = { {a, b, c, d} }.

**S(4,2) = 7**

Four objects going into two bins. These are the seven bi-partitions of set {a, b, c, d} :

P_{4,2,1} = { {a}, {b, c, d} }

P_{4,2,2} = { {b}, {a, c, d} }

P_{4,2,3} = { {c}, {a, b, d} }

P_{4,2,4} = { {d}, {a, b, c} }

P_{4,2,5} = { {a, b}, {c, d} }

P_{4,2,6} = { {a, c}, {b, d} }

P_{4,2,7} = { {a, d}, {b, c} }

**S(4,3) = 6**

Four objects going into three bins. These are the six tri-partitions of set {a, b, c, d} :

P_{4,3,1} = { {a, b}, {c}, {d} }

P_{4,3,2} = { {a, c}, {b}, {d} }

P_{4,3,3} = { {a, d}, {b}, {c} }

P_{4,3,4} = { {a}, {b, c}, {d} }

P_{4,3,5} = { {a}, {b, d}, {c} }

P_{4,3,6} = { {a}, {b}, {c, d} }

**S(4,4) = 1**

Four objects going into four bins. The only partition of {a, b, c, d} into four subsets is the "total split" partition: