In
combinatorics
Combinatorics is an area of mathematics primarily concerned with counting, both as a means and as an end to obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many ...
, stars and bars (also called "sticks and stones", "balls and bars", and "dots and dividers"
) is a graphical aid for deriving certain
combinatorial
Combinatorics is an area of mathematics primarily concerned with counting, both as a means and as an end to obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many ...
theorems. It can be used to solve a variety of
counting problems, such as how many ways there are to put indistinguishable balls into distinguishable bins. The solution to this particular problem is given by the binomial coefficient
, which is the number of subsets of size that can be formed from a set of size .
If, for example, there are two balls and three bins, then the number of ways of placing the balls is
. The table shows the six possible ways of distributing the two balls, the strings of stars and bars that represent them (with stars indicating balls and bars separating bins from one another), and the subsets that correspond to the strings. As two bars are needed to separate three bins and there are two balls, each string contains two bars and two stars. Each subset indicates which of the four symbols in the corresponding string is a bar.
Statements of theorems
The stars and bars method is often introduced specifically to prove the following two theorems of elementary combinatorics concerning the number of solutions to an equation.
Theorem one
For any pair of
positive integer
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positiv ...
s and , the number of -
tuple
In mathematics, a tuple is a finite sequence or ''ordered list'' of numbers or, more generally, mathematical objects, which are called the ''elements'' of the tuple. An -tuple is a tuple of elements, where is a non-negative integer. There is o ...
s of positive integers whose sum is is equal to the number of -element subsets of a set with elements.
For example, if and , the theorem gives the number of solutions to (with ) as the
binomial coefficient
In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers and is written \tbinom. It is the coefficient of the t ...
:
where
is the number of
combinations of elements taken at a time.
This corresponds to
compositions of an integer.
Theorem two
For any pair of positive integers and , the number of -
tuple
In mathematics, a tuple is a finite sequence or ''ordered list'' of numbers or, more generally, mathematical objects, which are called the ''elements'' of the tuple. An -tuple is a tuple of elements, where is a non-negative integer. There is o ...
s of non-negative integers whose sum is is equal to the number of
multisets of size taken from a set of size , or equivalently, the number of multisets of size taken from a set of size , and is given by
:
For example, if and , the theorem gives the number of solutions to (with ) as
:
where the
multiset coefficient is the number of multisets of size , with elements taken from a set of size .
This corresponds to
weak compositions of an integer. With fixed, the numbers for are those in the st diagonal of
Pascal's triangle
In mathematics, Pascal's triangle is an infinite triangular array of the binomial coefficients which play a crucial role in probability theory, combinatorics, and algebra. In much of the Western world, it is named after the French mathematician Bla ...
. For example, when the th number is the st
triangular number, which falls on the second diagonal, 1, 3, 6, 10, ....
Proofs via the method of stars and bars
Theorem one proof
The problem of enumerating ''k''-tuples whose sum is ''n'' is equivalent to the problem of counting configurations of the following kind: let there be ''n'' objects to be placed into ''k'' bins, so that all bins contain at least one object. The bins are distinguished (say they are numbered 1 to ''k'') but the ''n'' objects are not (so configurations are only distinguished by the ''number of objects'' present in each bin). A configuration is thus represented by a ''k''-tuple of positive integers.
The ''n'' objects are now represented as a row of ''n'' stars; adjacent bins are separated by bars. The configuration will be specified by indicating the boundary between the first and second bin, the boundary between the second and third bin, and so on. Hence bars need to be placed between stars. Because no bin is allowed to be empty, there is at most one bar between any pair of stars. There are gaps between stars and hence positions in which a bar may be placed. A configuration is obtained by choosing of these gaps to contain a bar; therefore there are
configurations.
Example
With and , start by placing seven stars in a line:
Now indicate the boundaries between the bins:
In general two of the six possible bar positions must be chosen. Therefore there are
such configurations.
Theorem two proof
In this case, the weakened restriction of non-negativity instead of positivity means that we can place multiple bars between stars and that one or more bars also be placed before the first star and after the last star. In terms of configurations involving objects and bins, bins are now allowed to be empty.
Rather than a -set of bar positions taken from a set of size as in the proof of Theorem one, we now have a -multiset of bar positions taken from a set of size (since bar positions may repeat and since the ends are now allowed bar positions). An alternative interpretation in terms of multisets is the following: there is a set of bin labels from which a multiset of size is to be chosen, the multiplicity of a bin label in this multiset indicating the number of objects placed in that bin. The equality
can also be understood as an equivalence of different counting problems: the number of -tuples of non-negative integers whose sum is equals the number of -tuples of non-negative integers whose sum is , which follows by interchanging the roles of bars and stars in the diagrams representing configurations.
To see the expression
directly, observe that any arrangement of stars and bars consists of a total of symbols, of which are stars and of which are bars. Thus, we may lay out slots and choose of these to contain bars (or, equivalently, choose ''n'' of the slots to contain stars).
Example
When and , the tuple (4, 0, 1, 2, 0) may be represented by the following diagram:
If possible bar positions are labeled 1, 2, 3, 4, 5, 6, 7, 8 with label corresponding to a bar preceding the th star and following any previous star and 8 to a bar following the last star, then this configuration corresponds to the -multiset , as described in the proof of Theorem two. If bins are labeled 1, 2, 3, 4, 5, then it also corresponds to the -multiset , also as described in the proof of Theorem two.
Relation between Theorems one and two
Theorem one can be restated in terms of Theorem two, because the requirement that each variable be positive can be imposed by shifting each variable by −1, and then requiring only that each variable be non-negative.
For example:
:
with
is equivalent to:
:
with
where
for each
.
Further examples
Example 1
If one wishes to count the number of ways to distribute seven indistinguishable one dollar coins among Amber, Ben, and Curtis so that each of them receives at least one dollar, one may observe that distributions are essentially equivalent to tuples of three positive integers whose sum is 7. (Here the first entry in the tuple is the number of coins given to Amber, and so on.) Thus Theorem 1 applies, with and , and there are
ways to distribute the coins.
Example 2
If , , and the bin labels are , then ★, ★★★, , ★ could represent either the 4-
tuple
In mathematics, a tuple is a finite sequence or ''ordered list'' of numbers or, more generally, mathematical objects, which are called the ''elements'' of the tuple. An -tuple is a tuple of elements, where is a non-negative integer. There is o ...
, or the multiset of bar positions , or the multiset of bin labels . The solution of this problem should use Theorem 2 with stars and bars to give
configurations.
Example 3
In the proof of Theorem two there can be more bars than stars, which cannot happen in the proof of Theorem one.
So, for example, 10 balls into 7 bins gives
configurations, while 7 balls into 10 bins gives
configurations, and 6 balls into 11 bins gives
configurations.
Example 4
The graphical method was used by
Paul Ehrenfest and
Heike Kamerlingh Onnes—with symbol ε (quantum energy element) in place of a star and the symbol 0 in place of a bar—as a simple derivation of
Max Planck
Max Karl Ernst Ludwig Planck (; ; 23 April 1858 – 4 October 1947) was a German Theoretical physics, theoretical physicist whose discovery of energy quantum, quanta won him the Nobel Prize in Physics in 1918.
Planck made many substantial con ...
's expression for the number of "complexions" for a system of "resonators" of a single frequency.
By complexions (
microstates) Planck meant distributions of energy elements ε over resonators.
The number of complexions is
:
The graphical representation of each possible distribution would contain copies of the symbol ε and copies of the symbol 0. In their demonstration, Ehrenfest and Kamerlingh Onnes took and (''i.e.'', combinations). They chose the 4-tuple (4, 2, 0, 1) as the illustrative example for this symbolic representation:
εεεε0εε00ε.
Relation to generating functions
The enumerations of Theorems one and two can also be found using
generating functions involving simple rational expressions. The two cases are very similar; we will look at the case when
, that is, Theorem two first. There is only one configuration for a single bin and any given number of objects (because the objects are not distinguished). This is represented by the generating function
:
The series is a geometric series, and the last equality holds analytically for , but is better understood in this context as a manipulation of
formal power series
In mathematics, a formal series is an infinite sum that is considered independently from any notion of convergence, and can be manipulated with the usual algebraic operations on series (addition, subtraction, multiplication, division, partial su ...
. The exponent of indicates how many objects are placed in the bin.
Each additional bin is represented by another factor of
; the generating function for bins is
:
,
where the multiplication is the
Cauchy product
In mathematics, more specifically in mathematical analysis, the Cauchy product is the discrete convolution of two infinite series. It is named after the French mathematician Augustin-Louis Cauchy.
Definitions
The Cauchy product may apply to infin ...
of formal power series.
To find the number of configurations with objects, we want the coefficient of
(denoted by prefixing the expression for the generating function with