## Cise.ufl.edu

Data Structures, Algorithms, & Applications in C++

**CHAPTER 53**
**_________**
**RECURRENCE EQUATIONS**
**This material is essentially Chapter 7 of the book ***Concepts in Discrete Mathematics*

**by Sartaj Sahni, ***Camelot Publishing***, 1985. It is reproduced here with permission of**

the publisher.
**INTRODUCTION**
The computing time of an algorithm (particularly a recursive algorithm) is ofteneasily expressed recursively (i.e., in terms of itself). This was the case, forinstance, for the function
rSum (Program 1.26). We had determined that

*trSum *(

*n*) =

*c +trSum *(

*n *−1) where

*c *is some constant. The worst-case computing
, of the merge sort method is easily seen to satisfy the inequality:

*M *(

*n /*2 )

*+tM *(

*n /*2 )

*+c *4

*n n >*1

**2 Chapter 53 Recurrence Equations**
We expect the recurrence (53.1) to be difficult to solve because of the pres-
ence of the ceiling and floor functions. If we attempt to solve (53.1) only forvalues of n that are a power of 2 (

*n =*2

*k*), then (53.1) becomes:

*M *(

*n /*2)

*+c *4

*n n >*1 and

*a * *power * *of * 2
If the inequality of (53.2) is converted to the equality:
2

*t´M*(

*n /*2)

*+c *4

*n n>1 and a power of 2*
*M *(

*n *) is an upper bound on

*tM *(

*n *). So, if

*tM *(

*n*) =

*f *(

*n*) then

*tM *(

*n*) = Ο(

*f *(

*n *)).

Since it is also the case that there exist constants

*c *5 and

*c *6 such that:

*M *(

*n /*2)

*+c *6

*n n>1 and n a power of 2*
*M *(

*n *) = Ω(

*f *(

*n*)). Hence,

*tM *(

*n *) = Θ(

*f *(

*n *)).

The entire discussion concerning the worst case complexity

*tw*
repeated with respect to the best case complexity (i.e. the minimum time spenton any input of n numbers). The conclusion is that

*tbM*(

*n*) = Θ(

*f *(

*n*)). Since boththe best and worst case complexities are Θ(

*f *(

*n*)), it follows that

*taM*(

*n*) = Θ(

*f *(

*n*))and

*tM*(

*n*) = Θ(

*f *(

*n*)).

when analyzing quick sort, we see that the partitioning into left (

*L*) and
right (

*R*) segments can be done in Θ(n) time. So,

*c *2

*+tQ*( |

*L *| )

*+tQ*( |

*R *| )

*n >*1
In (53.4),

*Q *has been used as an abbreviation for QuickSort . |

*L *| can be anynumber in the range 0 to

*n *−1. For random instances, |

*L *| equals each of 0, 1, .,

*n *−1 with equal probability. So, for the average complexity of QuickSort ,we obtain:
[

*tQ*(

*i*)

*+tQ*(

*n *−

*i*))]

*n >*1

**Section 53.1 Introduction 3**
The worst case for QuickSort is when one of

*L *and

*R *is empty at all
levels of the recursion. In this case, we obtain the recurrence:
2

*n +tQ *(

*n *−1)

*n >*1
The best case for QuickSor is when |

*L *| ≈ |

*R *| at all levels of the recursion.

The recurrence for this case is:
A function

*g *(

*n*) such that

*tbQ*(

*n*) = Θ(

*g *(

*n*)) for

*n *a power of 2 can be obtained bysolving the recurrence:
2

*n+*2

*tQ *(

*n /*2)

*n>1 and a power of 2*
For select (Program 19.8), the worst case is when

*k *= 1 and |

*R *| = 0 at
all levels of the recursion. So, the worst-case computing time of select isgiven by the recurrence:
2

*n +tselect *(

*n *−1)

*n >*1
To obtain the recurrence for the average computing time of select, we
need to introduce some new functions. First, we shall assume that all the ele-ments are distinct. Let

*t k*(

*n*) be the average time to find the

*k*th smallest element.

This average is taken over all

*n*! permutations of the elements. The averagecomputing time of select is given by:
Define

*R *(

*n*) to be the largest

*t k*(

*n*). That is,

*R *(

*n*) = max {

*t k*(

*n*)}

**4 Chapter 53 Recurrence Equations**
It is easy to see that

*taselect *(

*n*) ≤

*R *(

*n*).

With these definitions in mind, let us proceed to analyze select for the
case when all elements are distinct. For random input, there is an equal probabil-ity that |

*L *| = 0, 1, 2, .,

*n *−1. This leads to the following inequality for

*t k*(

*n*):
[ Σ

*tk*(

*j *−1)

*+ *Σ

*tk*−

*j*(

*n *−

*j*)]

*n *≥2

*R *(

*n*) ≤

*cn* *+* max{ Σ

*R *(

*j *−1)

*+ *Σ

*R *(

*n *−

*j*)}, n≥2
Since

*R *is an increasing function of

*n*,
If

*R *(

*n*) = Θ(

*f *(

*n*)), then it follows from our earlier observation

*select *(

*n *) ≤

*R *(

*n*)) that

*tselect *(

*n *) = Ο(

*f *(

*n*)). We shall later see that

*R *(

*n*) = Θ(

*n*).

This together with the observation

*taselect *(

*n*) = Ω(

*n*) leads to the conclusion that

*taselect *(

*n*) = Θ(

*n*).

Even though binarySearch (Program 3.1) is not a recursive algorithm,
its worst-case time complexity is best described by a recurrence relation. It is nottoo difficult to see that the following recurrence is correct:

**Section 53.1 Introduction 5**
When

*n *is a power of 2, (53.11) simplifies to:
2

*+tB *(

*n /*2)

*n>1 and a power of 2*
Hopefully, these examples have convinced you that recurrence relations
are indeed useful in describing the time complexity of both iterative and recur-sive algorithms. In each of the above examples, the recurrence relations them-selves were easily obtained. Having obtained the recurrence, we must now solveit to determine the asymptotic growth rate of the time complexity. We shall con-sider four methods of solving recurrence relations:
(a) substitution(b) induction(c) characteristic roots(d) generating functions.

**SUBSTITUTION**
In the substitution method of solving a recurrence relation for f(n), the recurrencefor

*f *(

*n*) is repeatedly used to eliminate all occurrences of

*f *() from the righthand side of the recurrence. Once this has been done, the terms in the right handside are collected together to obtain a compact expression for

*f *(

*n*). Themechanics of this method are best described by means of examples.

**Example 53.1 **Consider the recurrence:

*c *2

*+t *(

*n *−1)

*n *≥1
When

*c *1 =

*c *2 = 2,

*t *(

*n*) is the recurrence for the step count of rSum (Program1.9). If

*n *> 2 then

*t *(

*n *−1) =

*c *2

*+t *(

*n *−2). If

*n *> 3 then

*t *(

*n *−2) =

*c *2

*+t *(

*n *−3) etc.

These equalities are immediate consequences of (53.13) and are used in the fol-lowing derivation of a nonrecursive expression for

*t *(

*n*):
=

*c *2+

*c *2+

*c *2+t(n-3).

.

.

**6 Chapter 53 Recurrence Equations**
So, we see that

*t *(

*n*) =

*c *2n+

*c *1, n ≥ 0. From this, we obtain

*trSum*(

*n*) = 2n+2.

**Example 53.2 **Recurrence (53.12) may be solved by substitution. Observe that

(53.12) defines

*tw*
*B *(

*n *) only for values of n that are a power of 2. If n is not a power
of 2, then the value of

*t *(

*n*) is not defined by (53.12). For example, if n = 5 then

*tw*
*B *(2.5) appears on the right hand side of (53.12). But

*tB *is a function whose
domain is the natural numbers. If n = 6, then from (53.12) we obtain (t is used asan abbreviation for

*tw*
But, t(1.5) is undefined. When n is a power of 2, t(n) is always defined (i.e.,using the recurrence 7.12).

*t *(

*n*) is of course defined for all n∈N-{1} when(53.11) is used. Assuming n is a power of 2 (say, n = 2

*k*), the substitution methodleads to the following series of equalities:

*t *(

*n*) =

*c *2 +

*t *(

*n /*2)
=

*c *2

*+* *c *2

*+* *t *(

*n /*4)
=

*c *2

*+* *c *2

*+* *c *2

*+* *t *(

*n /*8).

.

.

=

*kc *2

*+* *t *(

*n /*2

*k*)
=

*c *1

*+* *c *2log

*n*,

*n *a power of 2
Unless otherwise specified, all logarithms in this chapter are base 2. At thispoint, we only have an expression for

*tw*
*B *(n) for values of n that are a power of 2.

If n is between 2

*k *and 2

*k +*1, then

*tw*
*B *(n) will be between t(2

*k *) and t(2

*k +*1 ). So,
1 +

*c *2 logn ≤

*tB c *1 +

*c *2 log n
for all n. This implies that

*tB*(n) = Θ(log n).

**Example 53.3 **Consider the recurrence:

*a*t *(

*n /b*)

*+cn n *≥2

**Section 53.2 Substitution 7**
This recurrence defines

*t *(

*n*) only for values of n that are a power of b. Therecurrence (53.3) is the same as (53.14) when

*c *1 =

*c *4 = c, and a = b = 2. Eventhough (53.3) is not an instance of (53.14) (as

*c *≠
(53.14) with a = 2 and b = 2 does give us a function g(n) such that

*t´M*(n) =
Ο(g(n)). And, from the discussion following (53.3) it should be clear that

*twM*(n) =
Θ(g(n)). When c =

*c*1, and a = b = 2, (53.14) becomes the same as (53.8).

Assume that n =

*b k *for some natural number k. Solving (53.14) by the sub-
=

*a *2[a*t(n/

*b *3)+c(n/

*b *2)]+cn[a/b+1]
=

*a *3t(n/

*b *3)+cn(

*a *2

*/b *2)+cn[a/b+1]
=

*a *3[a*t(n/

*b *4)+c(n/

*b *3)]+cn[

*a *2

*/b *2+a/b+1]
=

*a *4t(n/

*b *4)+cn[

*a *3/

*b *3+

*a *2/

*b *2+a/b+1].

.

.

(

*a /b*)

*i*, (

*b k *=

*b*
= cn Σ

*k *(

*a /b*)

*i*.

When a = b, Σ

*k*(

*a /b*)

*i *= k+1. When a ≠ b, Σ

*k *(

*a /b*)

*i *= ((

*a /b*)

*k+*1-1)/(a/b-1). If a<b
then a/b<1 and ((

*a /b*)

*k +*1-1)/(a/b-1) = (1-(

*a /b*)

*k +*1)/ (1-a/b)<1/(1-a/b).

**8 Chapter 53 Recurrence Equations**
(

*a /b*)

*i *= Θ(1). When a>b, ((

*a /b*)

*k +*1-1)/(a/b-1) = Θ((

*a /b*)

*k*) = Θ(

*a k/b*
*t *(

*n*)

*=* Θ(

*nlogn*)

*a =b*
From this and our earlier discussion, we conclude that

*tw*
Recurrence (53.14) is a very frequently occurring recurrence form in the
analysis of algorithms. It often occurs with the cn term replaced by such termsas c, or

*cn *2, or

*cn *3 etc. So, we would like to extend the result of Example 53.3and obtain a general form for the solution of the recurrence:

*t *(

*n*)

*=* *a*t *(

*n /b*)

*+g *(

*n*),

*n* ≥

*b* and

*n* *a* *power * *of* *b*,
where a and b are known constants. We shall assume that t(1) is also known.

Clearly, (53.15) reduces to (53.14) when t(1)= c and g(n) = cn. Using the substi-tution method, we obtain:
=

*a *2t(n/

*b *2)+ag(n/b)+g(n).

.

.

where

*k *= log

*bn*. This equation may be further simplified as below:
=

*a k*[

*t *(1)

*+ *Σ

*k a*−

*jg *(

*b j*)]

**Section 53.2 Substitution 9**
*b a *, the expression for

*t *(

*n*) becomes:

*b a *[t(1)+ Σ

*k a*−

*j *g(

*b j*)]

*b a *[t(1)+ Σ

*k {g *(

*b j*)

*/*(

*b j*)

*ba*}]

*b a *[t(1)+ Σ

*k h *(

*b j*)]

*b a *[

*t *(1)

*+f *(

*n*)]
where

*f *(

*n*) = Σ

*k h *(

*b j*) and h(n) = g(n)/

*n ba*. Figure 53.1 tabulates the asymp-
totic value of

*f *(

*n*) for various h(n)s. This table together with (53.16) allows oneto easily obtain the asymptotic value of

*t *(

*n*) for many of the recurrences oneencounters when analyzing algorithms.

Θ(((

*logn*)

*i+*1)

*/*(

*i +*1))

**Figure 53.1 ***f *(

*n*) values for various h(n) values.

Let us consider some examples using this table. The recurrence for

*tw*
and t(1) =

*c *1. Comparing with (53.15), we see that a=1, b=2, and g(n) =

*c *2. So,

*b *(

*a*) = 0 and h(n) = g(n)/

*n*
=

*c *2 =

*c *2(

*logn*)0 = Θ((

*logn*)0). From ?F7.1},
we obtain

*f *(

*n*) = Θ(log n). So,

**10 Chapter 53 Recurrence Equations**
t(n) = 7t(n/2)+18

*n *2, n≥2 and n a power of 2,
we obtain: a=7, b=2, and g(n) = 18

*n *2. So, log

*b*a = log27 ≈ 2.81 and h(n) =
= Ο(

*n r*) where r = 2-log27 < 0. So,

*f *(

*n*) = Ο(1). The
as t(1) may be assumed to be constant.

As a final example, consider the recurrence:
t(n) = 9t(n/3)+4

*n *6, n ≥ 3 and a power of 3.

Comparing with (53.15), we obtain a=9, b=3, and g(n) = 4

*n *6. So, log

*ba *= 2 andh(n) = 4

*n *6/

*n *2 = 4

*n *4 = Ω(

*n *4). From Figure 53.1, we see that

*f *(

*n*) = Θ(h(n)) =

**INDUCTION**
Induction is more of a verification method than a solution method. If we have anidea as to what the solution to a particular recurrence is then we can verify it byproviding a proof by induction.

**Example 53.4 **Induction can be used to show that

*t *(

*n*) = 3n+2 is the solution to

the recurrence:

For the induction base, we see that when n=0,

*t *(

*n*) = 2 and 3n+2 = 2. Assumethat

*t *(

*n*) = 3n+2 for some n, n = m. For the induction step, we shall show that

**Section 53.3 Induction 11**
*t *(

*n*) = 3n+2 when n = m+1. From the recurrence for t(n), we obtain t(m+1) =3+t(m). But from the induction hypothesis t(m) = 3m+2. So, t(m+1) = 3+3m+2= 3(m+1)+2.

**Example 53.5 **Consider recurrence (53.10). We shall show that R(n)<4cn, n≥1.

**Induction**
**Induction Hypothesis: **Let m be an arbitrary natural number, m≥3. Assume that

R(n)<4cn for all n, 1≤n<m.

**Induction Step: **For n = m and m even, (53.10) gives:

Since R(n)<4cn, R(n) = Ο(n). Hence, the average computing time of procedureselect is Ο(n). Since procedure select spends at least n units of time oneach input of size n,

*ta*
*select *(n) = Ω(n). Combining these two, we get

*tselect *(n) =

**Example 53.6 **Consider recurrence (53.9). Let

*t *(

*n*) denote

*tW*
2

*n*(

*n +*1)

*/ *2

*+c *1

*c *2 = Θ(

*n *2 ).

**Induction Base: **When

*n *= 1, (53.9) yields

*t *(

*n*) =

*c*
1 . Also,

*c *2

*n *(

*n +*1)

*/ *2

*+c *1

*c *2

**Induction Hypothesis: **Let

*m *be an arbitrary natural number. Assume that

*t *(

*n*)

**12 Chapter 53 Recurrence Equations**
2

*n *(

*n +*1)

*/ *2

*+c *1

*c *2 when

*n *=

*m*.

**Induction Step: **When

*n *=

*m +*1, (53.9) yields:

*t *(

*m +*1)

*=c *2(

*m +*1)

*+t *(

*m*)
2 (

*m +*1)

*+c *2

*m *(

*m +*1)

*/ *2

*+c *1

*c *2 (from the IH)
2 (

*m +*1)

*+c *2

*m*(

*m +*1)]

*/ *2

*+c *1

*c *2
2 (

*m +*1)(

*m +*2)

*/ *2

*+c *1

*c *2 .

As mentioned earlier, the induction method cannot be used to find the solu-
tion to a recurrence equation; it can be used only to verify that a candidate solu-tion is correct.

**CHARACTERISTIC ROOTS**
The recurrence equation of

*f *(

*n*) is a

**linear recurrence **iff it is of the form:

*f *(

*n*)

*=* Σ

*k gi*(

*n*)

*f *(

*n* −

*i*)

*+* *g *(

*n*)
where the

*gi*(

*n*), 1 ≤

*i* ≤

*k *and

*g *(

*n*) are functions of

*n *but not of

*f*. A linear

recurrence is of

**order ***k *iff it is of the form given above,

*k *is a constant, and

*gk*(

*n*) is not identically equal to zero. If

*gk*(

*n*) is zero for all

*n*, then the order of

the recurrence is less than

*k*. A linear recurrence of order

*k *is of

**constant**

coefficients iff there exists constants

*a *1,

*a *2, . . . ,

*ak *such that

*gi*(

*n*) =

*ai*,

1 ≤

*i* ≤

*k*. In this section, we are concerned only with the solution of linear

recurrences of order

*k *that have constant coefficients. These recurrences are of

the form:

*f *(

*n*)

*=* *a *1

*f *(

*n* − 1)

*+* *a *2

*f *(

*n* − 2)

*+* . . .

*+* *ak f *(

*n* −

*k*)

*+* *g *(

*n*),

*n* ≥

*k*
where

*ak* ≠ 0 and

*g *(

*n*) is a function of

*n *but not of

*f*. (53.17) is a

**homogeneous**

recurrence iff

*g *(

*n*) = 0. One may readily verify that for any set

*f *(0),

*f *(1), . . . ,

*f *(

*k* − 1) of initial values, the recurrence (53.17) uniquely determines

*f *(

*k*),

*f *(

*k* *+* 1), . . . .

Many of the recurrence equations we have considered in this book are
linear recurrences with constant coefficients. Using

*t *(

*n*) to denote

*t´M*, (53.3)takes the form:
2

*t*(

*n /*2)

*+c *4

*n n>=2 and a power of 2*
This isn’t a linear recurrence of order

*k *for any fixed

*k *because of the occurrenceof

*t *(

*n / *2) on the right side. However, since

*n *is a power of 2, (53.18) may be

**Section 53.4 Characteristic Roots 13**
2

*t*(2

*k *− 1)

*+c *42

*k k *≥1
Using

*h *(

*k*) to denote

*t *(2

*k*), (53.19) becomes:
2

*h*(

*k* − 1)

*+c *42

*k k *≥1
Recurrence (53.20) is readily identified as a linear recurrence with constatntcoefficients. It is of order 1 and it is not homogeneous. Since

*h *(

*k*) =

*t *(2

*k*) =

*t *(

*n*)for

*n *a power of 2, solving (53.20) is equivalent to solving (53.3).

Recurrence (53.5) is a linear recurrence. However, it is not of order

*k *for
any fixed

*k*. By performing some algebra, we can transform this recurrence intoan order 1 linear recurrence. We use

*t *(

*n*) as an abbreviation for

*taQ*(

*n*). With this,(53.5) becomes (for

*n* *>* 1):

*t *(

*n*)

*=* *c *2

*n* *+*
Multiplying (53.21) by

*n*, we obtain:

*nt *(

*n*)

*=* *c *2

*n *2

*+* 2 Σ
Substituting

*n* − 1 for

*n *in (53.22), we get:
(

*n* − 1)

*t *(

*n* − 1)

*=* *c *2(

*n* − 1)2

*+* 2 Σ

*nt *(

*n*) − (

*n* − 1)

*t *(

*n* − 1)

*=* (2

*n* − 1)

*c *2

*+* 2

*t *(

*n* − 1)

*nt *(

*n*)

*=* (2

*n* − 1)

*c *2

*+* (

*n* *+* 1)

*t *(

*n* − 1)

**14 Chapter 53 Recurrence Equations**
*t *(

*n* − 1)

*+* (2 − )

*c *2
Even though (53.24) is not a linear recurrence with constant coefficients, it
can be solved fairly easily. Recurrence (53.8) can be transformed into anequivalent constant coefficient linear recurrence of order 1 in much the same wayas we transformed (53.3) into such a recurrence. (53.9) is already in the form of(53.17). The recurrence:

*F *(

*n*)

*=* *F *(

*n* − 1)

*+* *F *(

*n* − 2),

*n* ≥ 2
defines the Fibonacci numbers when the initial values

*F *(0) = 0 and

*F *(1) = 1 areused. This is an order 2 homogeneous constant coefficient linear recurrence.

Linear recurrences of the form (53.17) occur frequently in the analysis of
computer algorithms, particularly in the analysis of divide-and-conquer algo-rithms. These recurrences can be solved by first obtaining a general solution for

*f *(

*n*). This general solution caontains some unspecified constants and has the
property that for any given set

*f *(0),

*f *(1), . . . ,

*f *(

*k* − 1) of initial values, we canassign values to the unspecified constants such that the general solution definesthe unique sequence

*f *(0),

*f *(1), . . . .

Consider the recurrence

*f *(

*n*)

*=* 5

*f *(

*n* − 1) − 6

*f *(

*n* − 2),

*n* ≥ 2. Its general
solution is

*f *(

*n*)

*=* *c *12

*n* *+* *c *23

*n *(we shall soon see how to obtain this). Theunspecified constants are

*c *1 and

*c *2. If we are given that

*f *(0) = 0 and

*f *(1) = 1,then we substitute into

*f *(

*n*) =

*c *12

*n* *+* *c *23

*n *to determine

*c *1 and

*c *2. Doing this,we get:

*f *(0)

*=* *c *1

*+* *c *2

*=* 0 and

*f *(1)

*=* 2

*c *1

*+* 3

*c *2

*=* 1
Solving for

*c *1 and

*c *2, we get

*c *1 = −

*c *2 = −1. Therefore,

*f *(

*n*) = 3

*n* − 2

*n*,

*n* ≥ 0, isthe solution to the recurrence

*f *(

*n*)

*=* 5

*f *(

*n* − 1) − 6

*f *(

*n* − 2),

*n* ≥ 2 when

*f *(0) = 0and

*f *(1) = 1. If we change the initial values to

*f *(0) = 0 and

*f *(1) = 10, then weget:

*f *(0)

*=* *c *1

*+* *c *2

*=* 0 and

*f *(1)

*=* 2

*c *1

*+* 3

*c *2

*=* 10
Solving for

*c *1 and

*c *2, we get

*c *1 = −

*c *2 = −10. Therefore,

*f *(

*n*) = 10(3

*n* − 2

*n*),

*n* ≥ 0.

The general solution to any recurrence of the form (53.17) can be
represented as the sum of two functions

*fh*(

*n*) and

*fp*(

*n*);

*fh*(

*n*) is the general solu-tion to the homogeneous part of (53.17):

*fh*(

*n*)

*=* *a *1

*fh*(

*n* − 1)

*+* *a *2

*fh*(

*n* − 2)

*+* . . .

*+* *ak fh*(

*n* −

*k*)
and

*fp*(

*n*) is a particular solution for:

**Section 53.4 Characteristic Roots 15**
*fp*(

*n*)

*=* *a *1

*fp*(

*n* − 1)

*+* *a *2

*fp*(

*n* − 2)

*+* . . .

*+* *ak fp*(

*n* −

*k*)

*+* *g *(

*n*)
While at first glance it might seem sufficient to determine

*fp*(

*n*), it should be
noted that

*fp*(

*n*)

*+* *fh*(

*n*) is also a solution to (53.17). Since the methods used todetermine

*fp*(

*n*) will give us an

*fp*(

*n*) form that does not explicitly contain all
zeroes of

*f *(

*n*) (i.e., all solutions to

*f *(

*n*) − Σ

*k ai f *(

*n* −

*i*)

*=* 0), it is necessary to
determine

*fh*(

*n*) and add it to

*fp*(

*n*) to get the general solution to

*f *(

*n*).

**Solving For ***fh*(

*n*)

To determine

*fh*(

*n*) we need to solve a recurrence of the form:

*fh*(

*n*)

*=* *a *1

*fh*(

*n* − 1)

*+* *a *2

*fh*(

*n* − 2)

*+* . . .

*+* *ak fh*(

*n* −

*k*)

*fh*(

*n*) −

*a *1

*fh*(

*n* − 1) −

*a *2

*fh*(

*n* − 2) − . . . −

*ak fh*(

*n* −

*k*)

*=* 0
We might suspect that (53.25) has a solution of the form

*fh*(

*n*) =

*Ax n*. Sub-

*A *(

*x n* −

*a *1

*x n *−1 −

*a *2

*x n *− 2 − . . . −

*akx n *−

*k*)

*=* 0
We may assume that

*A* ≠ 0. So we obtain:

*x n *−

*k*(

*x k* − Σ

*k aixk *−

*i*)

*=* 0
The above equation has

*n *roots. Because of the term

*x n *−

*k*,

*n* −

*k *of these rootsare 0. The remaining

*k *roots are roots of the equation:

*x k* −

*a *1

*x k *−1 −

*a *2

*x k *− 2 − . . . −

*ak* *=* 0
(53.26) is called the

**characteristic equation **of (53.25). From elementary

polynomial root theory, we know that (53.26) has exactly

*k *roots

*r *1,

*r *2, . . . ,

*rk*.

*x *2 − 5

*x* *+* 6

*=* 0
are

*r *1 = 2 and

*r *2 = 3. The characteristic equation

**16 Chapter 53 Recurrence Equations**
*x *3 − 8

*x *2

*+* 21

*x* − 18

*=* 0
has the roots

*r *1 = 2,

*r *2 = 3, and

*r *3 = 3. As is evident, the roots of a characteris-

tic equation need not be distinct. A root

*ri *is of

**multiplicity ***j *iff

*ri *occurs

*j*

times in the collection of

*k *roots. Since the roots of (53.27) are distinct, all have

multiplicity 1. For (53.28), 3 is a root of multiplicity 2, and the multiplicity of 2

is 1. The distinct roots of (53.28) are 2 and 3. Theorem 53.1 tells us how to

determine the general solution to a linear homogeneous recurrence of the form

(53.25) from the roots of its characteristic equation.

**Theorem 53.1 **Let the distinct roots of the characteristic equation:

*x k* −

*a *1

*x k *−1 −

*a *2

*x k *− 2 − . . . −

*ak* *=* 0

*fh*(

*n*)

*=* *a *1

*fh*(

*n* − 1)

*+* *a *2

*fh*(

*n* − 2)

*+* . . .

*+* *ak fh*(

*n* −

*k*)
be

*t *1,

*t *2, . . . ,

*ts*, where

*s* ≤

*k*. There is a general solution

*fh*(

*n*) which is of theform:

*fh*(

*n*)

*=* *u *1(

*n*)

*+* *u *2(

*n*)

*+* . . .

*+* *us*(

*n*)

*i *(

*n*)

*=* (

*ci * *+* *c n * *+* *c n *2

*+* . . .

*+* *c*
Here,

*w *is the multiplicity of the root

*ti*.

**Proof **See the references for a proof of this theorem.

The characteristic equation for the recurrence

*f *(

*n*)

*=* 5

*f *(

*n* − 1) − 6

*f *(

*n* − 2),

*n* ≥ 2

*x *2 − 5

*x* *+* 6

*=* 0
The roots of this characteristic equation are 2 and 3. The distinct roots are

*t *1 = 2and

*t *2 = 3. From Theorem 53.1 it follows that

*f *(

*n*) =

*u *1(

*n*)

*+* *u *2(

*n*), where

*u *1(

*n*) =

*c *12

*n *and

*u *2(

*n*) =

*c *23

*n*. Therefore,

*f *(

*n*) =

*c *12

*n* *+* *c *23

*n*.

**Section 53.4 Characteristic Roots 17**
(53.28) is the characteristic equation for the homogeneous recurrence:

*f *(

*n*)

*=* 8

*f *(

*n *− 1) − 21

*f *(

*n *− 2)

*+* 18

*f *(

*n *− 3)
Its distinct roots are

*t *1 = 2 and

*t *2 = 3.

*t *2 is a root of multiplicity 2. So,

*u *1(

*n*) =

*c *12

*n*, and

*u *2(

*n*) = (

*c *2

*+* *c *3

*n*)3

*n*. The general solution to the recurrence is

*f *(

*n*) =

*c *12

*n* *+* (

*c *2

*+* *c *3

*n*)3

*n*.

The recurrence for the Fibonacci numbers is homogeneous and has the
characteristic equation

*x *2 −

*x* − 1

*=* 0. Its roots are

*r *1 = (1

*+* √5 )

*/ *2 and

*r *2 =(1 − √5 )

*/ *2. Since the roots are distinct,

*u *1(

*n*) =

*c *1((1

*+* √5 )

*/ *2)

*n *and

*u *2(

*n*) =

*c *2((1 − √5 )

*/ *2)

*n*. Therefore
is a general solution to the Fibonacci recurrence. Using the initial values F(0) = 0and F(1) = 1, we get

*c *1+

*c *2 = 0 and

*c *1(1+5)/2+

*c *2(1-5)/2 = 1. Solving for

*c *1 and

*c *2, we get

*c *1 = -

*c *2 = 1/5. So the Fibonacci numbers satisfy the equality:
Theorem 53.1 gives us a straightforward way to determine a general solu-
tion for an order k linear homogeneous recurrence with constant coefficients. Weneed only determine the roots of its characteristic equation.

**Solving For ***fp *(

*n*)

There is no known general method to obtain the particular solution

*fp*(n). Theform of

*fp*(n) depends very much on the form of g(n). We shall consider onlytwo cases. One where g(n) is a polynomial in n and the other where g(n) is anexponential function of n.

When g(n) = 0, the particular solution is

*fp*(n) = 0.

0, the particular solution is of the form:

*fp*(

*n*)

*=* *p *0

*+* *p *1

*n* *+* *p *2

*n *2

*+* . . .

*+* *pd +mn d +m*
where m = 0 if 1 is not a root of the characteristic equation corresponding to thehomogeneous part of (53.17). If 1 is a root of this equation, then m equals themultiplicity of the root 1.

**18 Chapter 53 Recurrence Equations**
To determine

*p *0,

*p *1, .,

*pd +m*, we merely substitute the right hand side of
(53.29) into the recurrence for

*fp*( ); compare terms with like powers of n on theleft and right hand side of the resulting equation and solve for

*p *0,

*p *1,

*p *2, .,

*pd +m*.

*f *(

*n*)

*=* 3

*f *(

*n *−1)

*+* 6

*f *(

*n *−2)

*+* 3

*n* *+* 2
g(n) = 3n+2. The characteristic equation is

*x *2-3x-6 = 0. 1 is not one of its roots.

So, the particular solution is of the form:

*fp* (

*n*)

*=* *p *0

*+* *p *1

*n*
*p *0

*+p *1

*n *= 3(

*p *0

*+* *p *1 (

*n *−1))

*+* 6(

*p *0

*+* *p *1 ∗ (

*n *−2))

*+* 3

*n* *+* 2
= 3

*p *0

*+* 3

*p *1

*n* − 3

*p *1

*+* 6

*p *0

*+* 6

*p *1

*n* − 12

*p *1

*+* 3

*n* *+* 2
= (9

*p *0 − 15

*p *1

*+* 2)

*+* (9

*p *1

*+* 3)

*n*
Comparing terms on the left and right hand sides, we see that:
So,

*p *1 = -3/8 and

*p *0 = -61/64. The particular solution for (53.30) is therefore:

*f *(

*n*)

*=* 2

*f *(

*n* − 1) −

*f *(

*n* − 2) − 6
The corresponding characteristic equation is

*x *2−2

*x +*1 = 0. Its roots are

*r *1 =

*r *2= 1. So,

*fp*(

*n*) is of the form:

*fp*(

*n*)

*=* *p *0

*+* *p *1

*n* *+* *p *2

*n *2

**Section 53.4 Characteristic Roots 19**
*p *0+

*p *1n+

*p *2

*n *2
2(

*p *0+

*p *1n-

*p *1+

*p *2(

*n *2-2n+1))-

*p *0-

*p *1n+2

*p *1-
= (2

*p *0-2

*p *1+2

*p *2-

*p *0+2

*p *1-4

*p *2-6)+(2

*p *1-4

*p *2-

*p *1+4

*p *2)n+

*p *2

*n *2
= (

*p *0-2

*p *2-6)+

*p *1n+

*p *2

*n *2
So,

*fp*(n) =

*p *0+

*p *1n-3

*n *2.

*fh*(n) = (

*c *0+

*c *1n)(1)

*n*. So,

*f *(

*n*) =

*c *0+

*c *1n+

*p *0+

*p *1n-3

*n *2=

*c *2

*+c *3n-3

*n *2.

*c *2 and

*c *3 can be determined once the intial values f(0) and f(1)have been specified.

When g(n) is of the form c

*a n *where c and a are constants, then the particu-
lar solution

*fp*(n) is of the form:

*fp*(

*n*)

*=*(

*p *0

*+* *p *1

*n* *+* *p *2

*n *2

*+* . . .

*+* *pwn w*)

*a n*
where

*w *is 0 if a is not a root of the characteristic equation corresponding to thehomogeneous part of (53.17) and equals the multiplicity of a otherwise.

*f *(

*n*)

*=* 3

*f *(

*n *−1)

*+* 2

*f *(

*n *−4) − 6 ∗ 2

*n*
The corresponding homogeneous recurrence is:

*fh*(n) = 3

*fh*(n-1)+2

*fh*(n-4)
We may verify that 2 is not a root of this equation. So, the particular solution to(53.32) is of the form:
Substituting this into (53.32), we obtain:

*p *02

*n *= 3

*p *02

*n *−1+2

*p *02

*n *−4-6*2

*n*
**20 Chapter 53 Recurrence Equations**
Dividing out by 2

*n *−4, we obtain:
16

*p *0 = 24

*p *0+2

*p *0-96 = 26

*p *0-96
So,

*p *0 = 96/10 = 9.6. The particular solution to (53.32) is

*fp*(

*n*) = 9.6*2

*n*
The characteristic equation corresponding to the homogeneous part of the

*f *(

*n*)

*=* 5

*f *(

*n *−1) − 6

*f *(

*n *−2)

*+* 4 ∗ 3

*n*
is

*x *2 − 5

*x* *+* 6 = 0. Its roots are

*r *1 = 2 and

*r *2 = 3. Since 3 is a root of multipli-city 1 of the characteristic equation, the particular solution is of the form:

*fp*(n) = (

*p *0+

*p *1n)3

*n*.

*p *03

*n*+

*p *1

*n *3

*n*= 5(

*p *0

*+p *1(

*n *−1))3

*n *−1-6(

*p *0+

*p *1(n-2))3

*n *−2+4*3

*n*
9

*p *0+9

*p *1n = 15

*p *0+15

*p *1n-15

*p *1-6

*p *0-6

*p *1n+12

*p *1+36
= (9

*p *0-3

*p *1+36)+9

*p *1n
These equations enable us to determine that

*p *1 = 12. The particular solution to(53.33) is:

*fp*(

*n*) = (

*p *0+12n)3

*n*
*fh*(n) =

*c *12

*n*+

*c *23

*n*
**Section 53.4 Characteristic Roots 21**
The general solution for

*f *(

*n*) is therefore:
=

*c *12

*n*+(

*c *2+

*p *0)3

*n*+12n3

*n*
=

*c *12

*n*+

*c *33

*n*+12n3

*n*
Given two initial values, f(0) and f(1), we can determine

*c *1 and

*c *3.

**Obtaining The Complete Solution**
We know that

*fh*(n)+

*fp*(n) is a general solution to the recurrence:

*f *(

*n*)

*=* *a *1

*f *(

*n*−1)

*+a *2

*f *(

*n*−2)

*+* . . .

*+ak f *(

*n*−

*k*)

*+g *(

*n*),

*n* ≥

*k*
By using the initial values f(0), f(1), ., f(k-1), we can solve for the k undeter-mined coefficients in

*fh*(n) +

*fp*(n) to obtain the unique solution of (53.34) forwhich f(0),.,f(k-1) have the given values.

The characteristic roots method to solve the linear recurrence (53.34) consists ofthe following steps:

*x k* − Σ

*k aixk*−

*i* *=* 0
Determine the distinct roots

*t *1,

*t *2,

*.*,

*ts *of the characteristic equation.

Determine the multiplicity

*mi *of the root

*ti*, 1≤i≤s.

Write down the form of

*fh*(n). I.e.,

*fh*(

*n*)

*=* *u *1(

*n*)

*+* *u *2(

*n*)

*+* . . .

*+* *us*(

*n*)

*i *(

*n *)

*=* (

*ci * *+* *c n* *+* *c n *2

*+* . . .

*+* *c*
and w =

*mi *= multiplicity of the root

*ti*.

**22 Chapter 53 Recurrence Equations**
Obtain the form of the particular solution

*fp*(n).

(a)

*fp*(

*n*)

*=* *p *0

*+* *p *1

*n* *+* *p *2

*n *2

*+* . . .

*+* *pd +mn d +m*
where m = 0 if 1 is not a root of the characteristic equation. m is themultiplicity of 1 as a root of the characteristic equation otherwise.

*fp*(

*n*)

*=* (

*p *0

*+* *p *1

*n* *+* *p *2

*n *2

*+* . . .

*+* *pwn w*)

*a n*
where w is zero if a is not a root of the characteristic equation. If a isa root of the characteristic equation, then w is the multiplicity of a.

If g(n) ≠ 0, then use the

*fp*(n) obtained in (4) above to eliminate alloccurrences of f(n-i), 0≤i≤k from (53.34). This is done by substituting thevalue of

*fp*(n-i) for f(n-i), 0≤i≤k in (53.34). Following this substitution, asystem of equations equating the coefficients of like powers of n isobtained. This system is solved to obtain the values of as many of the

*pi*sas possible.

Write down the form of the answer. I.e.,

*f *(

*n*) =

*fh*(

*n*)

*+fp*(

*n*). Solve for theremaining unknowns using the initial values f(0), f(1), ., f(k-1).

**Theorem 53.2 **The six step procedure outlined above always finds the unique

solution to (53.34) with the given initial values.

**Proof **See the text by Brualdi that is cited in the reference section.

**EXAMPLES**
**Example 53.7 **The characteristic equation for the homogeneous recurrence:

Its roots are

*r *1 = 3+√5 and

*r *2 = 3-√5 . The roots are distinct and so

*t *(

*n*) =

*c *1(3

*+*√5 )

*n*+

*c *2(3−√5 )

*n*. Suppose we are given that t(0) = 0 and t(1) = 4√5 .

**Section 53.4 Characteristic Roots 23**
Substituting n = 0 and 1 into t(n), we get:
The first equality yields

*c *1 = -

*c *2. The second then gives us 45 =

*c *1(3+5-3+5) =25

*c *1 or

*c *1 = 2. The expression for t(n) is therefore:

*t *(

*n*) = 2(3+5)

*n *- 2(3-5)

*n*,n≥0.

**Example 53.8 **In this example we shall obtain a closed form formula for the sum

s(n) = Σ

*n i*. The recurrence for s(n) is easily seen to be:
Its characteristic equation is x-1 = 0. So,

*sh*(n) =

*c *1(1)

*n *=

*c *1. Since g(n) = n and1 is a root of multiplicity 1, the particular solution is of the form:

*sp*(n) =

*p *0

*+p *1

*n+p *2

*n *2
Substituting into the recurrence for s(n), we obtain:

*p *0

*+p *1

*n+p *2

*n *2 =

*p *0

*+p *1(

*n*−1)

*+p *2(

*n *−1)2

*+n*
=

*p *0

*+p *1

*n*−

*p *1

*+p *2

*n *2−2

*p *2

*n+p *2

*+n*
0

*p *1

*+p *2 )

*+* (

*p *1 2

*p *2

*+*1)

*n* *+* *p *2

*n *2
Equating the coefficients of like powers of n and solving the resulting equations,we get

*p *1 =

*p *2, and 2

*p *2 = 1 or

*p *2 = 1/2. The particular solution is

*sp*(n) =

*p *0

*+n /*2

*+n *2

*/*2 The general solution becomes s(n) = (

*c *1

*+p *0)

*+* *n /*2

*+* *n *2/2.

Since s(0) = 0,

*c *1

*+p *0 = 0. Hence, s(n) = n(n+1)/2, n≥0.

**Example 53.9 **Consider the recurrence:

f(n) = 5f(n-1) - 6f(n-2) + 3

*n *2, n≥2

**24 Chapter 53 Recurrence Equations**
The characteristic equation for the homogeneous part is:
Its roots are

*r *1 = 2 and

*r *2 = 3. The general solution to the homogeneous part istherefore:

*fh*(

*n*)

*=* *c *12

*n* *+* *c *23

*n *.

Since g(n) = 3

*n *2 and 1 is not a root of the characteristic equation, the particularsolution has the form:

*fp*(

*n*)

*=* *p *0

*+p *1

*n+p *2

*n *2
Substituting into the recurrence for f( ), we obtain:

*p *0

*+p *1

*n+p *2

*n *2
= 5(

*p *0

*+p *1(

*n *−1)

*+p *2(

*n *−1)2) − 6(

*p *0

*+p *1(

*n*−2)

*+p *2(

*n*−2)2)

*+* 3

*n *2
1

*p *0 19

*p *2 )

*+* (14

*p *2

*p *1 )

*n* *+* (3−

*p *2 )

*n *2

*p *0 = 7

*p *1-

*p *0-19

*p *2
Hence,

*p *2 = 1.5,

*p *1 = 7

*p *2 = 10.5, and

*p *0 = 22.5. So, the general solution for
f(n) =

*c *12

*n* *+* *c *23

*n* *+* 22.5

*+* 10.5

*n* *+* 1.5

*n *2
Since f(0) and f(1) are known to be 2.5 and 4.5, respectively, we obtain:
2.5 =

*c *1

*+* *c *2 + 22.5
4.5 = 2

*c *1

*+* 3

*c *2 + 34.5
Solving for

*c *1 and

*c *2, we get:

*c *1 = -30 and

*c *2 = 10. The solution to our

**Section 53.4 Characteristic Roots 25**
f(n) = 22.5 + 10.5n + 1.5

*n *2 - 30*2

*n *+ 10*3

*n*.

**Example 53.10 **Let us solve the recurrence:

f(n) = 10f(n-1)-37f(n-2)+60f(n-3)-36f(n-4)+4, n≥4

*x *4−10

*x *3

*+*37

*x *2−60

*x+*36

*=* 0
(

*x*−2)2(

*x*−3)2

*=* 0
The four roots are

*r *1

*=* *r *2 = 2, and

*r *3 =

*r *4 = 3. Since each is a root of multipli-city 2,

*u *1(n) = (

*c *1

*+c *2n)2

*n *and

*u *2(n) = (

*c *3

*+c *4n)3

*n*. The solution to the homo-geneous part is:

*fh*(n) = (

*c *1

*+c *2

*n*)2

*n* *+* (

*c *3

*+c *4

*n*)3

*n*
Since g(n) = 4 = 4*

*n *0 and 1 is not a root of the characteristic equation,

*fp*(n) is ofthe form:
Substituting into the recurrence for f(n), we get:
0

*=* 10

*p *0 37

*p *0

*+*60

*p *0 36

*p *0

*+*4
The general solution for

*f *(

*n*) is:
f(n) = (

*c *1

*+c *2

*n*)2

*n* *+* (

*c *3

*+c *4

*n*)3

*n *+ 1
Substituting for n = 0, 1, 2, and 3, and using f(0) = f(1) = f(2) = f(3) = 1, we get:

**26 Chapter 53 Recurrence Equations**
0

*=* *c *1

*+* *c *3
0

*=* 2

*c *1

*+* 2

*c *2

*+* 3

*c *3

*+* 3

*c *4
0

*=* 4

*c *1

*+* 8

*c *2

*+* 9

*c *3

*+* 18

*c *4
0

*=* 8

*c *1

*+* 24

*c *2

*+* 27

*c *3

*+* 81

*c *4
Solving for

*c *1,

*c *2,

*c *3, and

*c *4, we obtain

*c *1 =

*c *2 =

*c *3 =

*c *4 = 0. So,

*f *(

*n*) = 1,n≥1.

We may verify that

*f *(

*n*) = 1, n≥0 does indeed satisfy the given recurrence.

We proceed by induction. For the induction base, we need to show that

*f *(

*n*) = 1,0≤n≤3. This is true by definition of f(). So, let m be an arbitrary natural numbersuch that m≥3. Assume

*f *(

*n*) = 1, for n≤m. When n = m+1, f(m+1) = 10f(m) -37f(m-1) + 60f(m-2) - 36f(m-3) + 4 = 10-37+60-36+4 = 1.

Let us change the initial values to f(0) = f(1) = f(2) = 1, and f(3) = 4. Now,
only equation (53.35d) changes. It becomes:
3

*=* 8

*c *1

*+* 24

*c *2

*+* 27

*c *3

*+* 81

*c *4
Solving (53.35 a to c) and (53.35e) for

*c *1,

*c *2,

*c *3, and

*c *4, we obtain

*c *1 = 6,

*c *2 =1.5,

*c *3 = -6, and

*c *4 = 1. So,

*f *(

*n*)

*=* (6

*+*1.5

*n*)2

*n* *+* (

*n *−6)3

*n* 1,

*n* ≥ 0
Once again, one may verify the correctness of this formula using induction on n.

**Solving Other Recurrences**
Certain non-linear recurrences as well as linear ones with non constantcoefficients may also be solved using the method of this section. In all cases, weneed to first perform a suitable transformation on the given recurrence so as toobtain a linear recurrence with constant coefficients. For example, recurrences ofthe form:

*f c*(

*n*)

*=* Σ

*k ai fc*(

*n *−

*i*)

*+* *g *(

*n*), n≥k
may be solved by first substituting

*f c*(

*n*) = q(n) to obtain the recurrence:

*q *(

*n*)

*=* Σ

*k aiq *(

*n *−

*i*)

*+* *g *(

*n*), n≥k

**Section 53.4 Characteristic Roots 27**
This can be solved for q(n) as described earlier. From q(n) we may obtain

*f *(

*n*)by noting that

*f *(

*n*) = (

*q *(

*n*))1

*/c*.

*nf *(

*n*)

*=* Σ

*k *(

*n *−

*i*)

*ai f *(

*n *−

*i*)

*+* *g *(

*n*), n≥k
may be solved by substituting q(n) = nf(n) to obtain:

*q *(

*n*)

*=* Σ

*k aiq *(

*n *−

*i*)

*+* *g *(

*n*), n≥k
Since

*f *(

*n*) = q(n)/n,

*f *(

*n*) is determined once q(n) is.

**GENERATING FUNCTIONS**
A generating function G(z) is an infinite power series

*G *(

*z*)

*=* Σ

*cizi*
We shall say that the generating function

*G *(

*z*) corresponds to the function f: N -> R iff

*ci *= f(i), i≥0.

**Example 53.11 **G(z) = Σ2

*zi *generates the function

*f *(

*n*) = 2, n≥0; G(z) = Σ

*izi*
generates the function

*f *(

*n*) = n, n≥0; G(z) = Σ2

*zi *generates the function:
A generating function may be specified in two forms. One of these is
called the

*power series *form. This is the form given in equation (53.36). Theother form is called the

*closed form*. In this form there are no occurrences of thesymbol Σ.

**Example 53.12 **The power series form for the generating function for

*f *(

*n*) = 1,

n≥0 is G(z) = Σ

*zi*. So, zG(z) = Σ

*zi*. Subtracting, we obtain: G(z) - zG(z) =

*z i* − Σ

*zi *= 1. So, G(z) =
. The closed form for the power series Σ

*zi *is

**28 Chapter 53 Recurrence Equations**
= Σ

*zi *only for those values of z for which the series Σ

*zi*
converges. The values of z for which this series converges are not relevant toour discussion here.

**Example 53.13 **Let n be an integer and i a natural number. The

*binomial*
*i *(

*i *−1)(

*i *−2).(1)
A more general form of the binomial theorem is:
where

*m *=

*n *if

*n *≥ 0 and

*m *= ∞ otherwise.

(53.37) leads us to some important closed forms. When n = -2, we obtain:
______

*=* Σ(−1)

*i*(

*i+*1)

*zi*
**Section 53.5 Generating Functions 29**
Substituting −

*z *for

*z *in (53.38), we obtain:
is the closed form for Σ(

*i +*1)

*zi*. (53.37) may be used to obtain
As we shall soon see, generating functions can be used to solve recurrence
relations. First, let us look at the calculus of generating functions.

**Generating Function Operations**
*Addition and Subtraction: *If

*G *1(z) = Σ

*cizi *and

*G*2(z) = Σ

*dizi *are the generat-
ing functions for

*f *1 and

*f *2, then the generating function for

*f *1 +

*f *2 is:

*G *3(z) = Σ(

*ci*+

*di*)

*zi*
4 (

*z *)

*=* Σ (

*ci di*)

*z i *.

These two equalities follow directly from the definition of a generating function.

*Multiplication: *If

*G *1(z) = Σ

*cizi *is the generating function for f, then

*G*2(z) =
a

*G *1(z) = Σ(

*aci*)

*zi *is the generating function for a*f (a is a constant).

Since

*z kG *1(z) = Σ

*cizk+i*, it is the generating function for a function g such
that g(j) = 0, 0≤j<k and g(j) = f(j - k), j≥k. So, multiplying a generating functionby

*z k *corresponds to shifting the function it generates by k.

**Example 53.14 **In Example 53.13, we showed that

*=* Σ(

*i +*1)

*zi*. Multi-

*=* Σ(

*i +*1)

*zi+*1

*=* Σ

*izi*. So,
the closed form for the generating function for f(i) = i, i≥0.

**30 Chapter 53 Recurrence Equations**
The product

*G *1(z)*

*G *2(z) of the two generating functions

*G *1(z) = Σ

*cizi*
and

*G *2(

*z*)

*=* Σ

*dizi *is a third generating function

*G*3(z) = Σ

*eizi*. One may ver-

*ei* *=* Σ

*i cjdi*−

*j*,

*i* ≥ 0
Note that * is commutative (i.e.,

*G *1(z) *

*G *2(z) =

*G *2(z) *

*G *1(z)).

An examination of (53.39) indicates that the product of generating func-
tions might be useful in computing sums. In particular, if

*G *2(z) = Σ

*zi *= 1−

*z*
(Example 53.11) (i.e.,

*di *= 1, i≥0), then (53.39) becomes

**Example 53.15 **Let us try to find the closed form for the sum s(n) = Σ

*n i*. From

is the closed form for the generating func-
tion for f(i) = i, i≥0. Also, from Example 53.12, we know that
is the closed form for ( Σ

*izi*)(Σ

*zi*). Let
be Σ

*eizi*. From (53.40), it follows that

*en* *=* Σ

*n i *= s(n), n≥0. Let us proceed to determine

*en*. Using the binomial
The coefficient of

*z n *−1 in the expansion of (1-z)−3 is therefore:

*=* (

*n*−1)(

*n*−2).(1)

**Section 53.5 Generating Functions 31**
So, the coefficient

*en *of

*z n *in the power series form of

*Differentiation: *Differentiating (53.36) with respect to z gives:
___

*G *(

*z*)

*=* Σ

*icizi*−1

*G *(

*z*)

*=* Σ(

*ici*)

*zi*
**Example 53.16 **In Example 53.13, the binomial theorem was used to obtain the

closed form for Σ(

*i +*1)

*zi*. This closed form can also be obtained using

differentiation. From Example 53.12, we know that

*Integration: *Integrating (53.36), we get
∫

*G*(

*u*)

*du* *=* Σ

*cj*−1

*zj/j*
**Example 53.17 **The closed form of the generating function for

*f *(

*n*) = 1/n, n≥1

can be obtained by integrating the generating function for

*f *(

*n*) = 1. From Exam-

ple 53.12, we obtain:

**32 Chapter 53 Recurrence Equations**
∫_ 1___

*du* *=* −

*ln*(1−

*z*)
So, the generating function for

*f *(

*n*) = 1/n, n≥1 and f(0) = 0, is -ln(1-z).

The five operations: addition, subtraction, multiplication, differentiation,
and integration prove useful in obtaining generating functions for f:N → R.

Figure 53.2 lists some of the more important generating functions in both

**Solving Recurrence Equations**
The generating function method of solving recurrences is best illustrated by anexample. Consider the recurrence:
The steps to follow in solving any recurrence using the generating functionmethod are:
Let G(z) = Σ

*aizi *be the generating function for F(). So,

*ai* *=* *F *(

*i*), i≥0.

Replace all occurrences of F() in the given recurrence by the corresponding

*ai*. Doing this on the example recurrence yields:

*an* *=* 2

*an *−1 + 7, n≥1

**Section 53.5 Generating Functions 33**
*i =*0m = n if n≥0m = ∞ otherwise

**Figure 53.2 **Some power series.

Multiply both sides of the resulting equation by

*z n *and sum up both sidesfor all n for which the equation is valid. For the example, we obtain:
Σ

*anzn* *=* 2Σ

*an*−1

*zn* *+* Σ7

*zn*
Replace all infinite sums involving the

*ai*s by equivalent expressionsinvolving only G(z), z, and a finite number of the

*ai*s. For a degree krecurrence only

*a *0,

*a *1,

*.*,

*ak *−1 will remain. The example yields:

*G *(

*z*) −

*a *0

*=* 2

*zG *(

*z*)

*+* Σ 7

*zn*
Substitute the known values of

*a *0,

*a *1,

*.*,

*ak *−1 (recall that F(i) =

*ai*, 0≤i<k.

G(z) = 2

*zG *(

*z*)

*+* Σ 7

*zn*
**34 Chapter 53 Recurrence Equations**
Solve the resulting equation for G(z). The example equation is easilysolved for G(z) by collecting the G(z) terms on the left and then dividingby the coefficient of G(z). We get:

*G *(

*z*)

*=* Σ 7

*zn* ∗ 1−2

*z*
Determine the coefficient of

*z n *in the power series expansion of the expres-sion obtained for G(z) in step 6. This coefficient is

*an *= F(n). For ourexample, we get:
The coefficient of

*z n *in the above series product is:
Σ

*n*7

***2

*n*−

*i* *=* 7(2

*n*−1)
The next several examples illustrate the technique further.

**Example 53.18 **Let us reconsider the recurrence for the Fibonacci numbers:

Let G(z) = Σ

*cizi *be the generating function for F. From the definition of a gen-
erating function, it follows that F(j) =

*cj*, j≥0. So, F(n) =

*cn*, F(n-1) =

*cn *−1, and
F(n-2) =

*cn *−2. From the recurrence relation for F, we see that:

*cn* *=* *cn *−1

*+* *cn*−2, n≥2
Multiplying both sides by

*z n *and summing from n=2 to ∞, we get:
Σ

*cnzn@=@*Σ

*cn*−1

*zn* *+* Σ

*cn*−2

*zn*
**Section 53.5 Generating Functions 35**
Observe that the sum cannot be performed from n = 0 to ∞ as the recurrence F(n)= F(n-1) + F(n-2) is valid only for n≥2. (53.43) may be rewritten as:
G(z)-

*c *1z-

*c *0 = z Σ

*cn*−1

*zn*−1 +

*z*2 Σ

*cn*−2

*zn*−2
=

*z *Σ

*cizi* *+* *z*2 Σ

*cizi*
=

*zG *(

*z*)−

*c *0

*z+z *2

*G *(

*z*)
Collecting terms and substituting

*c *0 = F(0) = 0 and

*c *1 = F(1) = 1, we get:
From Figure 53.2, we see that the power series expansion of (1-az)−1 is Σ(

*az*)

*i*.

**Example 53.19 **Consider the recurrence:

*at *(

*n *−1)

*+bn n *≥1
Let G(Z) = Σ

*cizi *be the generating function for t(n). So,

*t *(

*n*) =

*cn*, n≥0. From

**36 Chapter 53 Recurrence Equations**
*cn* *=* *acn *−1

*+* *bn*, n≥1
Multiplying both sides by

*z n *and summing from n=1 to ∞ yields:
Σ

*cnzn* *=* Σ

*acn*−1

*zn *+ Σ

*bnzn*
G(z)-

*c *0 =

*az *Σ

*cn*−1

*zn*−1 + Σ

*bnzn*
Substituting

*c *0 = 0 and collecting terms, we get:
Using the formula for the product of two generating functions, we obtain:

*cn *=

*b *Σ

*n ian*−

*i*
Hence,

*t *(

*n*) = b

*a n *Σ

*n*
**Example 53.20 **In the previous example, we determined that

*cn *= b

*a n *Σ

*n*
closed form for

*cn *can be obtained from a closed form for

*dn* *=* Σ

*n*
let us find the generating function for f(i) = i/

*a i*. We know that (1-z)−1

*=* Σ

*zi*.

So, (1-z/a)−1 = Σ(

*z /a*)

*i*. Differentiating with respect to z, we obtain:

**Section 53.5 Generating Functions 37**
(

*z /a*)

*i* *=* Σ

*zi*−1
The generating function for Σ

*n i /ai *can now be obtained by multiplying by 1/(1-

*a *(1−

*z /a*)2(1−

*z*)
We now need to find the form of the coefficient of

*z n *in the expansion of

*a *(1−

*z /a*)2(1−

*z*)
Σ(

*z /a*)

*i *Σ(

*z /a*)

*i *Σ

*zi*
*a *(1−

*z /a*)2(1−

*z*)

*a *(1

*/a* − 1)

*i =*0

*a n*
**38 Chapter 53 Recurrence Equations**
When a = 1,

*dn* *=* Σ

*n i *= n(n+1)/2. Observe that the recurrence for

*dn *is:

*dn* *=* *dn *−1

*+*
Since the general form of the particular solution is not known when g(n) = n/

*a n*,it would be difficult to obtain the solution for

*dn *using the characteristic rootsmethod.

**Example 53.21 **An alternate approach to obtain the power series form of G(z) =

( Σ

*bnzn*)

*/*(1−

*az*) (see Example 53.19) is:

G(z) = ( Σ

*bnzn*)

*/*(1−

*az*)
= (

*b *Σ

*nzn*)

*/*(1−

*az*).

**Section 53.5 Generating Functions 39**
= A Σ

*izi* *+* *B*Σ(

*i +*1)

*zi* *+* *C*Σ

*aizi*
The coefficient of

*z n *is therefore:
t(n) =

*An* *+* *B *(

*n +*1)

*+* *Ca n*
Σ

*i*(

*i+*1)

*zi *(Example 53.15)
So,

*f *(

*n*) = bn(n+1)/2, n≥0, a=1.

**Example 53.22 **Consider the recurrence:

Let G(z) = Σ

*cizi *be the generating function for f. So,

*f *(

*n*) =

*cn*, f(n-1) =

*cn*−1

*cn* *=* 5

*cn *−1 − 6

*cn *−2

*+* 2

*n *, n≥2

**40 Chapter 53 Recurrence Equations**
*cnz n* *=* 5

*cn *−1

*z n* − 6

*cn *−2

*z n* *+* 2

*nz n*, n≥2
Σ

*cnzn *= 5z Σ

*cn*−1

*zn*−1 − 6

*z*2 Σ

*cn*−2

*zn*−2

*+* Σ 2

*nzn*
G(z)-

*c *1

*z*−

*c *0

*=* 5

*z *(

*G *(

*z*)−

*c *0) − 6

*z *2

*G *(

*z*)

*+* Σ 2

*nzn*
Substituting

*c *1 =

*c *0 = 0, we get:
= Σ 2

*jz j*[3Σ3

*izi* − 2Σ2

*izi*]
The coefficient

*cn *of

*z n *is now seen to be:

*cn *= Σ

*n *6

*j*3

*n*−

*j* − Σ

*n *4

*j*2

*n*−

*j*
= 6

** *3

*n *Σ

*n *(

*j /*3

*j*) − 4

** *2

*n *Σ

*n j /*2

*j*
**Section 53.5 Generating Functions 41**
*cn *= −3

*n*−4.5

*+*4.5

** *3

*n*−2

** *3

*n+*4

*n+*8−8

** *2

*n+*2

** *2

*n*
*=* *n+*3.5

*+*2.5

** *3

*n*−6

** *2

*n*
So,

*f *(

*n*) =

*n+*3.5

*+*2.5

** *3

*n*−6

** *2

*n*, n≥0.

**REFERENCES AND SELECTED READINGS**
Figure 53.1 is due to J. Bentley, D. Haken, and J. Saxe. They presented it in theirsolution of recurrence (53.15). Their work appears in the report

*A generalmethod for solving divide-and-conquer recurrences*, by J. Bentley, D. Haken,and J. Saxe,

*SIGACT News*, 12(3), 1980, pp. 36-44.

A proof of Theorem 53.3 may be found in

*Introductory combinatorics*, by
R. Brualdi, Elsevier North-Holland Inc., New York, 1977.

Source: http://www.cise.ufl.edu/~sahni/dsaac/enrich/c19/recur.pdf

SOCIAL PHOBIA Pavo Filakovi 1, Veljko or evi 2, Elvira Koi 3 and Lana Mu ini 4. 1Psychiatric Clinic, University Hospital Osijek; 3Psychiatric Department, General Hospital Virovitica; ABSTRACT Social anxiety disorder (Social phobia) is an irrational fear of being observed and judged by other people in various social settings. It is often a chronic, disabling condition that is character

PATIENT SUMMARY OF INFORMATION ABOUT This summary contains important information about VIAGRA®. It is not meant to take the place of your doctor’s instructions. Read this information carefully before you start taking VIAGRA. Ask your doctor or pharmacist if you do not understand any of this information or if you want to know more about VIAGRA. This medicine can help many men when i