Discrete Structures
§4 Recurrence Relations
6 min read
A recurrence relation defines each term of a sequence from earlier terms. It is useful when a problem naturally breaks into a smaller copy of itself.
Recursive and explicit definitions
Let be a sequence, read as “the sequence indexed by the natural numbers.” A first-order recurrence uses only the preceding term. It needs two parts:
- a base case, such as ;
- a recurrence rule, such as
Here, is the index, is the preceding term, and is the rule that produces the next term.
An explicit formula, also called a closed form, gives directly from :
The symbol is the Greek letter phi, read “fee.” A recurrence tells us how to compute forward; a closed form lets us jump directly to any index.
Example: factorials
The factorial sequence has base case
and recurrence
For example,
Each substitution reduces the index until it reaches the base case.
Example: a geometric recurrence
Suppose
where is the initial value and is a fixed multiplier. Expanding several terms gives
The pattern leads to the closed form
A proposed closed form should satisfy both the base case and the recurrence. Those two checks confirm that it describes the same sequence.
Counting with a recurrence: Tower of Hanoi
The Tower of Hanoi puzzle has three pegs and disks of different sizes. All disks begin on the first peg, largest at the bottom. The goal is to move the entire stack to the third peg while following two rules:
- move only one disk at a time;
- never place a larger disk on top of a smaller one.
Let be the minimum number of legal moves needed for disks. The empty puzzle gives the base case
To solve the puzzle for :
- move the top disks to the middle peg, using moves;
- move the largest disk to the final peg, using one move;
- move the smaller disks onto it, using another moves.
One legal solution for n disks
Therefore,
The first values are
These values are one less than successive powers of two. To derive the pattern, add to both sides of the recurrence:
If , then and . This is a geometric recurrence, so . Hence
For the traditional puzzle with 64 disks,
moves. At one move per second, that is about seconds, or years—roughly 42 times the current age of the universe.
Linear first-order recurrences
A linear first-order recurrence has the form
where and are known functions. The term is called the nonhomogeneous term or forcing term.
Consider
Computing forward gives the sequence
To find a closed form, separate the recurrence into its homogeneous behavior and a particular response to the forcing term.
The homogeneous recurrence
Remove the forcing term to get the associated homogeneous recurrence:
For the example, this becomes
whose general solution is
where is an arbitrary constant.
A particular solution is any one sequence that satisfies the full recurrence. Suppose and are two particular solutions. Subtracting their equations cancels the forcing term:
Thus, the difference between any two particular solutions satisfies the homogeneous recurrence. Once one particular solution is known, every solution has the form
Finding a particular solution
For
the forcing term is a polynomial of degree one. Guess a particular solution of the same form:
where and are constants to determine. Substitute the guess into the recurrence:
Matching the coefficients of and the constant terms gives
Therefore,
so one particular solution is
Add the homogeneous solution:
Use the base case :
The closed form is
Checking gives , and substituting the formula into the recurrence gives .
Choosing the trial form
The trial-form shortcut below applies to a constant-coefficient recurrence
where is fixed. In this case, the shape of suggests a useful guess for :
| Forcing term | Trial particular solution |
|---|---|
| polynomial of degree | |
| a sum of terms | the sum of the corresponding trial forms |
| a product of a polynomial and | a polynomial of the same degree multiplied by |
For example, if
try
There is one important exception. If the trial already has the same form as a homogeneous solution, it will cancel during substitution. Multiply the trial by —and by a higher power of if necessary—until the forms no longer overlap. When is a sum, adjust only the overlapping part of the trial.
For this constant-coefficient case, the complete method is:
- solve the associated homogeneous recurrence to obtain ;
- choose a trial from the form of ;
- substitute into the original recurrence and solve for its coefficients;
- write ;
- use the base case to determine the remaining constant.
0 reads