maths.free › Combinatorics & Graph Theory › 8. Generating Functions › Another look at distributing apples or folders
Another look at distributing apples or folders
A recurring problem so far in this book has been to consider problems that ask about distributing indistinguishable objects (say apples) to distinct entities (say children).
Another look at distributing apples or folders
A recurring problem so far in this book has been to consider problems that ask about distributing indistinguishable objects (say apples) to distinct entities (say children). We started in by asking how many ways there were to distribute \(40\) apples to \(5\) children so that each child is guaranteed to get at least one apple and saw that the answer was \(C(39,4)\). We even saw how to restrict the situation so that one of the children was limited and could receive at most \(10\) apples. In , we learned how to extend the restrictions so that more than one child had restrictions on the number of apples allowed by taking advantage of the . Before moving on to see how generating functions can allow us to get even more creative with our restrictions, let's take a moment to see how generating functions would allow us to solve the most basic problem at hand.
We could revisit an example from to see that if we wanted to limit a child to receive at most \(4\) apples, we would use \((x+x^2+x^3+x^4)\) as its generating function instead of \(x/(1-x)\), but rather than belabor that here, let's try something a bit more exotic.
The compact form of the solution to suggests that perhaps there is a way to come up with this answer without the use of generating functions. Thinking about such an approach would be a good way to solidify your understanding of a variety of the enumerative topics we have already covered.
The invocation of partial fractions in is
powerful, but solving the necessary system of equations and then hoping that the resulting
formal power series have expansions we immediately recognize can be a challenge. If had not asked about the general case with \(n\) on
the right-hand side of the equation but instead asked specifically about \(n=30\), you might
be wondering if it would just be faster to write some Python code to generate all the solutions
or more interesting to huddle up and devise some clever strategy to count them. Fortunately,
technology can help us out when working with generating functions. In SageMath, we can use the
series() method to get the power series expansion of a given function. The two arguments to
series are the variable and the degree of the terms you want to truncate. In the cell below,
we ask SageMath to expand the generating function from
by giving us all the terms of degree at most 30 and then collapsing the rest of the series into
its form of big-Oh notation, which we discard by storing the output from series() in a
polynomial f(x).
Let's see that the answer agrees with what our formula in the solution to gives us for \(n=30\):
Condensed — the full section is in Keller & Trotter, Applied Combinatorics.
Practice (2)
Try each one on paper first. Reveal the answer to check; verified ones can be opened in the solver for every step.
-
Suppose you are making a generating function for the number of ways to distribute some type of objects, as in the examples of this section. When a recipient can get no objects, what is the constant term in the factor of the generating function that corresponds to that recipient? What is the constant term when a recipient must get at least one object? Briefly explain your reasoning.
-
Suppose in the country Combinatoria, they use coins with values \(1\), \(2\), \(5\), \(10\), \(20\), \(50\), and \(100\). If you would like to write a generating function in which the coefficient on \(x^n\) is the number of ways to form a collection of coins worth \(n\) subject to the restriction that the number of coins of value \(5\) is one, three, four, or five, what factor would you introduce into your generating function? Briefly explain your reasoning.
Symbols used here
n × (n−1) × … × 1; the number of orderings of n things. 0! = 1.
Number of k-element subsets of n things: n!/(k!(n−k)!).
Add a_k for k = 1 up to n.
Multiply a_k for k = 1 up to n.
The set with no elements; the number of elements of A.
Questions people ask
Permutation or combination?
Ask whether order matters. A lock code is a permutation (order matters); a hand of cards is a combination (it does not).
What is a graph in this sense?
Dots (vertices) joined by lines (edges) — not a plot. Road maps, social networks and molecules are graphs; questions like "is there a route" and "how few colours" are graph theory.
የራስዎን ይሞክሩ
Parts of this page are adapted from Keller & Trotter, Applied Combinatorics (CC BY-SA 4.0). Condensed and re-explained here; errors are ours.
በ Combinatorics & Graph Theory
The counting principlesPigeonhole principle and inclusion–exclusionBinomial coefficients and Pascal's triangleRecurrences and generating functionsGraphs: vertices, edges, degreesPaths, cycles, trees, Euler and HamiltonColouring and planar graphs