Advanced Counting Techniques
In this chapter, we will see that many counting problems can be solved using formal power series, called generating functions, where the coefficients of powers of
Applications of Recurrence Relations
We can use recurrence relations to model a wide variety of problems, such as finding compound interest, counting rabbits on an island, determining the number of moves in the Tower of Hanoi puzzle, and counting bit strings with certain properties.
Rabbits and the Fibonacci Numbers:
Consider this problem, which was originally posed by Leonardo Pisano, also known as Fibonacci, in the thirteenth century. A young pair of rabbits (one of each sex) is placed on an island. A pair of rabbits does not breed until they are 2 months old. After they are 2 months old, each pair of rabbits produces another pair each month. Find a recurrence relation for the number of pairs of rabbits on the island after
Solution:
Denote by
The rabbit population can be modeled using a recurrence relation. At the end of the first month, the number of pairs of rabbits on the island is
Consequently, the sequence
Parenthesis Problem:
Find a recurrence relation for
Solution:
To develop a recurrence relation for
Algorithms and Recurrence Relations
We conclude this section by introducing another algorithmic paradigm known as dynamic programming, which can be used to solve many optimization problems efficiently.
An algorithm follows the dynamic programming paradigm when it recursively breaks down a problem into simpler overlapping subproblems, and computes the solution using the solutions of the subproblems. Generally, recurrence relations are used to find the overall solution from the solutions of the subproblems. In this section we will illustrate the use of dynamic programming by constructing an algorithm for solving a scheduling problem.
We formalize this problem by supposing that we have
We first sort the talks in order of increasing end time. After doing this, we renumber the talks so that
To develop a dynamic programming algorithm for this problem, we first develop a key recurrence relation. To do this, first note that if
Case
Case
Combining cases
-
Algorithm: Dynamic Programming Algorithm for Scheduling Talks procedure
: start times of talks; : end times of talks; : number of attendees to talks) sort talks by end time and relabel so that for
to if no job with is compatible with job else and job is compatible with job for to return is the maximum number of attendees
Solving Linear Recurrence Relations
One important class of recurrence relations can be explicitly solved in a systematic way. These are recurrence relations that express the terms of a sequence as linear combinations of previous terms.
- Definition:
A linear homogeneous recurrence relation of degree
with constant coefficients is a recurrence relation of the form where are real numbers, and .
A consequence of the second principle of mathematical induction is that a sequence satisfying the recurrence relation in the definition above is uniquely determined by this recurrence relation and the
Solving Linear Homogeneous RR with Constant Coefficients
We can use two key ideas to find all solutions of linear homogeneous recurrence relations. First, these recurrence relations have solutions of the form
We claim
The other key observation is that a linear combination of two solutions of a linear homogeneous recurrence relation is also a solution. To see this, suppose that
We will now state the general result about the solution of linear homogeneous recurrence relations with constant coefficients, where the degree may be greater than two, under the assumption that the characteristic equation has distinct roots.
- Theorem: The General Case
Let
be real numbers. Suppose that the characteristic equation has distinct roots . Then a sequence is a solution of the recurrence relation if and only if for where are constants.
We now state the most general result about linear homogeneous recurrence relations with constant coefficients, allowing the characteristic equation to have multiple roots.
The key point is that for each root
- Theorem: The General Case
Let
be real numbers. Suppose that the characteristic equation has distinct roots with multiplicities respectively, so that for and . Then a sequence is a solution of the recurrence relation if and only if for where are constants for and .
Linear Nonhomogeneous RR with Constant Coefficients
Let’s look at an example of linear nonhomogeneous recurrence relation with constant coefficients. For example,
-
Theorem: If
is a particular solution of the nonhomogeneous linear recurrence relation with constant coefficients then every solution is of the form , where is a solution of the associated homogeneous recurrence relation We see that the key to solving nonhomogeneous recurrence relations with constant coefficients is finding a particular solution. Then every solution is a sum of this solution and a solution of the associated homogeneous recurrence relation. Although there is no general method for finding such a solution that works for every function there are techniques that work for certain types of functions such as polynomials and powers of constants. -
Theorem: Suppose that
satisfies the linear nonhomogeneous recurrence relation where are real numbers, and where and are real numbers. When is not a root of the characteristic equation of the associated linear homogeneous recurrence relation, there is a particular solution of the form When is a root of this characteristic equation and its multiplicity is there is a particular solution of the form
Generating Functions
Generating functions are used to represent sequences efficiently by coding the terms of a sequence as coefficients of powers of a variable
Generating functions can be used to solve recurrence relations by translating a recurrence relation for the terms of a sequence into an equation involving a generating function. This equation can then be solved to find a closed form for the generating function. From this closed form, the coefficients of the power series for the generating function can be found, solving the original recurrence relation.
Generating functions can also be used to prove combinatorial identities by taking advantage of relatively simple relationships between functions that can be translated into identities involving the terms of sequences.
- Theorem:
The generating function for the sequence
of real numbers is the infinite series
When generating functions are used to solve counting problems, they are usually considered to be formal power series. We will now state some widely important facts about infinite series used when working with generating functions.
- Theorem:
Let
and . Then
Theorem above is valid only for power series that converge in an interval. However, the theory of generating functions is not limited to such series. In the case of series that do not converge, the statements in Theorem above can be taken as definitions of addition and multiplication of generating functions.
To use generating functions to solve many important problems, we will need to apply the binomial theorem for exponents that are not positive integers. Before we state an extended version of the binomial theorem, we need to define extended binomial coefficients.
-
Definition: Let
be a real number and a nonnegative integer. Then the extended binomial coefficient is defined by -
Theorem: Let
be a real number with and let be a real number. Then
Here is the table for useful generating functions:
Inclusion-Exclusion
How many elements are in the union of two finite sets?
Previously we showed that the number of elements in the union of the two sets
- Theorem: The Principle of Inclusion-Exclusion
Let
be finite sets. Then
Applications of Inclusion–Exclusion
Many counting problems can be solved using the principle of inclusion–exclusion. For instance, we can use this principle to find the number of primes less than a positive integer.
An Alternative Form:
There is an alternative form of the principle of inclusion–exclusion that is useful in counting problems. In particular, this form can be used to solve problems that ask for the number of elements in a set that have none of
Let
- Theorem:
Let
and be positive integers with . Then, there are onto functions from a set with elements to a set with elements.
An onto function from a set with
Consequently, the number of onto functions from a set with
A derangement is a permutation of objects that leaves no object in its original position. To solve the problem of similar kind we will need to determine the number of derangements of a set of
- Theorem:
The number of derangements of a set with
elements is