0% found this document useful (0 votes)
179 views35 pages

Dmchap 10

The document discusses first-order and second-order linear recurrence relations with constant coefficients. It provides examples of recurrence relations for geometric sequences, the Fibonacci sequence, counting subsets and binary sequences. The general solutions to homogeneous recurrence relations involve determining the characteristic roots and expressing the terms as combinations of exponential or trigonometric functions raised to the power of n. Initial or boundary conditions are needed to determine the specific sequence. Higher order recurrence relations can also be solved using this approach.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
179 views35 pages

Dmchap 10

The document discusses first-order and second-order linear recurrence relations with constant coefficients. It provides examples of recurrence relations for geometric sequences, the Fibonacci sequence, counting subsets and binary sequences. The general solutions to homogeneous recurrence relations involve determining the characteristic roots and expressing the terms as combinations of exponential or trigonometric functions raised to the power of n. Initial or boundary conditions are needed to determine the specific sequence. Higher order recurrence relations can also be solved using this approach.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 35

10.

1 The First-Order Linear Recurrence Relation

geometric progression
If a 0 , a1 , a 2 , is a geometric progression, then
a1 a 2 a 3 a n1
      r , the common ratio.
a 0 a1 a 2 an
For example, a n+1  3a n , n  0. (or a n+1  3a n  0)

a first-order, linear, and homogeneous recurrence relation


(difference equation) with constant coefficient
The arithmetic progression a n1  a n  3 is nonhomogeneous.
10.1 The First-Order Linear Recurrence Relation

There are many sequences that satisfy a n1  3a n , n  0.


For example, 5,15,45,135,... or 7,21,63,189,.... To pinpoint
the particular sequence described, we need to know one of the
terms of the sequence. (boundary condition, or initial condition
since usually a0 is specified)
a n1  3a n , n  0, a 0  5 determines the sequence 5,15,45,135,...

The general solution of the recurrence relation a n+1  da n ,


n  0, d is a constant, and a 0  A, is unique and is given by
a n  Ad n , n  0.
10.1 The First-Order Linear Recurrence Relation

Ex. 10.2 A bank pays 6% (annual) interest on savings, compounding


the interest monthly. If Boonie deposits $1000 on the first day of
May, how much will this deposit be worth a year later?
Let pn denote the value of deposit at the end of n months.
Then pn+1=pn+(6%/12)pn=1.005pn. With p0=$1000, we have
pn=p0(1.005)n. The answer is p12=$1000(1.005)12=$1061.68.
A nonlinear recurrence relation
Ex. 10.3 Find a12 if a n2+1 = 5a n2 , where a n > 0 for n  2, and a 0 = 2.
Let bn = a n2 . Then bn+1  5bn and b0  4.
10.1 The First-Order Linear Recurrence Relation
nonhomogeneous linear recurrence relation
Ex. 10.4 time complexity of bubble sort algorithm
an=an-1+(n-1), n>1, a1=0, where
an=the number of comparisons to sort n numbers
an- an-1= n-1
an-1- an-2= n-2
an-2- an-3= n-3


+ a2- a1= 1
an =1+2+3+...+(n-1)=(n2-n)/2
10.1 The First-Order Linear Recurrence Relation

find the recurrence pattern nonconstant coefficients


Ex. 10.5
Ex. 10.6
a0=0 a1- a0=2
a1=2 a n  n  a n1 ,
a2 -a1=4 where n  1 and a 0  1.
a2=6
a3=12 a3- a2=6
a4=20 a4- a3=8 The answer is a n  n !.

 
+ an- an-1=2n
an=n2+n
10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients
The equation: Cn a n  C n1a n1  C n 2 a n 2  0, n  2,
substituting a n  cr n , where c  0 and r  0, into the recurrence
relation, we obtain Cn cr n  C n1cr n1  C n 2 cr n 2  0. With
c, r  0, this becomes C n r 2  Cn1r  Cn 2  0, which is called
the characteristic equation of the recurrence relation.

three cases for the characteristic roots:


n n
( r
(a) distinct real numbers 1 2 , r ): a n  c r
1 1  c r
2 2
n n
(b) complex conjugates 1 2( r , r ): a n  c r
1 1  c r
2 2
n
( r
(c) duplicate roots 1 1 , r ): a n  ( c1  c 2 n ) r1
Case (A): distinct real roots
Ex. 10.8 a n  a n 1  6a n  2  0, where n  2 and a 0  1, a1  2 .
Characteristic equation: r 2  r  6  0, (r + 3)(r - 2) = 0,
 a n  c1 2 n  c2 ( 3) n , with a 0  1, a1  2, c1  1, c2  0
 a n  2 n is the unique solution.
Ex. 10.9 (Fibonacci relation) Fn +2  Fn 1  Fn , where n  0,
and F0  0, F1  1.
n 2 1 5
Let Fn  cr . The c.e. is r  r  1  0 with root .
2
n n
 1  5  1  5
The general solution is c1    c2   .
 2   2 
 n n
1  1  5  1  5
With F0  0, F1  1, Fn       
5  2   2  

Case (A): distinct real roots
Ex. 10.10 For n  0, let S = {1,2,3, , n} (when n = 0, S =  ),
and let a n denote the number of subsets of S that contain no
consecutive integers. Find and solve a recurrence relation for a n.

If A  S and A is to be counted in a n , there are two possibilities:


(a) n  A: When this happens ( n - 1)  A , and A - {n} would be
counted in a n-2 . (In other words, for all sets counted in a n-2 ,
we can add n to that set for it to be counted in a n .)
(b) n  A: A is also counted in a n-1 .
Therefore, a n  a n1  a n 2 (Fibonacci relation!). Together with
a 0  1 ( ) and a1  2 ( ,{1}), we have
 n 2 n 2 
1  1  5  1  5
an       , n  0.
5  2   2  

Case (A): distinct real roots
Ex. 10.11 number of legal arithmetic expressions, without
parentheses, that are made up of the digits 0,1,2,...,9 and the binary
operator +,*,/.
Let an be the number of expressions made up of n symbols. Then
a1=10 (0,1,...,9), a2=100 (00,01,...,99). For n>2, two cases:
(a) the last two symbols are digits: remove the last digit, we have a
legal expression for an-1. (10an-1)
(b) the last two symbols are operator and digit: remove the two
symbols, we have a legal expression for an-2 (29an-2, no /0)
Therefore, an=10an-1+29an-2, and a1=10, a2=100.
5  n n
an 
3 6  5  3 6    5  3 6  

, n  1.
Case (A): distinct real roots
Ex. 10.13 Find a recurrence relation for the number of binary
sequences of length n that have no consecutive 0's.
Let an be the number of such sequences with length n,n>0.
Then a1=2, a2=3. There are two cases for an:
(1) the nth symbol is 1: the preceding n-1 symbols sequence is
counted in an-1
(2) the nth symbol is 0: an ends in 10 and the preceding n-2 symbols
sequence is counted in an-2.
Therefore, an=an-1+an-2.
 n 2 n 2 
1  1  5  1  5
an      , n  0
5  2   2  

10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients
Be careful not to draw conclusions from a few (or even,
perhaps, many) particular instances.
Ex. 10.14 Arrange pennies contiguously in each row where each
penny above the bottom row touches two pennies in the row
below it.

a1=1,a2=1,a3=2,a4=3,a5=5,a6=8,... Is an=Fn? NO
10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients

extend to higher order

Ex. 10.15 2a n+3  a n 2  2a n1  a n , n  0, a 0  0, a1  1, a 2  2.


The C. E. is 2r 3  r 2  2r  1  0  (2r  1)(r  1)(r  1).
n
1
 
 a n  c1 (1) n  c2 (1) n  c3   . From a 0  0, a1  1, a 2  2,
 2
5 1 8
we have c1  , c2  , c3   .
2 6 3
10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients
Case (b) Complex Roots

DeMoivre's Theorem

(cos  i sin  ) n  cos n  i sin n , n  0.

If z = x + iy  C, z  0, then
 x y 
2 2   r (cos  i sin  )
z= x y i
 2 
 x  y2 x2  y2 
 z n  r n (cos n  i sin n ) x2  y2
y

x
Case (b) Complex Roots
Ex. 10.17 a n  2(a n1  a n 2 ), n  2, a 0  1, a1  2.
The C. E. is r 2  2r  2  0 with roots 1  i.
n
    
 a n  c1 (1  i ) n  c2 (1  i ) n  c1  2 cos  i sin   
  4 4 
n
     n n n 
c2  2 cos  i sin    c1  2  cos  i sin  
  4 4   4 4
n n n 
c2  2  cos  i sin  
 4 4
n n n 
 2 (c1  c2 ) cos 4  i (c1  c2 ) sin 4  . With a 0  1, a1  2,
we have c1  c2  1 and c1  c2   i . Therefore,
n n n 
a n   2  cos  sin  .
 4 4
Case (b) Complex Roots
Ex. 10.18 For b  R + , consider the n  n determinant Dn given by
b b 0 0 0 0  0 0 0 0 0
b b b 0 0 0  0 0 0 0 0
0 b b b 0 0  0 0 0 0 0 =bD n-1-b 2
Dn-2
0 0 b b b 0  0 0 0 0 0 b b
D1 |b|  b and D2  0
0 0 0 b b b  0 0 0 0 0 b b
           
n n 1 n 
0 0 0 0 0 0  b b b 0 0 n D  b  cos  sin
3 3 3 
0 0 0 0 0 0  0 b b b 0
0 0 0 0 0 0  0 0 b b b
0 0 0 0 0 0  0 0 0 b b
Case (c) Repeated Real Roots
Ex. 10.19 a n 2  4a n1  4a n , where n  0 and a 0  1, a1  3.
The C.E. is r 2  4r  4  0. Since it has only one root with
multiplicity 2, to have two linear independent solution, let' s
try a n  c1 2 n  c2 n2 n . With a 0  1 and a1  3, we have
n 1 n
a n  2  n2  2 n  n2 n1 .
2
In general, the solution corresponds to a root r with multiplicity
m has the form ( A0  A1n  A2 n 2  Am1r m1 )r n .
10.3 The Nonhomogeneous Recurrence Relation
Cn a n  Cn 1a n 1  Cn  2 a n 2  f (n)
Let a n  a n( h)  a n( p) , where a n( h) denotes the general solution
of the corresponding homogeneous solution and a n( p) denotes
a solution of the given nonhomogeneous solution (particular
( p)
solution). Then Cn (a n( h)  a n( p) )  Cn 1 (a n( h)1  a n 1 ) 
( p)
Cn 2 (a n( h)2  a n  2 )  (Cn a n( h)  Cn 1a n( h)1  Cn 2 a n( h)2 ) 
( p) ( p)
(Cn a n( p)  Cn 1a n 1  Cn 2 a n  2 )  0  f (n)  f (n), which
indicates that a n  a n( h)  a n( p) is indeed a general solution.
10.3 The Nonhomogeneous Recurrence Relation

Ex. 10.22 a n  3a n 1  5( 7n ), where n  1 and a 0  2.


a n( h )  c( 3n ). Since f (n) = 5(7 n ), let a n( p)  A( 7n ), which
n n 1 n 35
leads to A( 7 )  3A( 7 )  5( 7 ). So A = and
4
n 1 n 1
( p) 5( 7 ) n 5( 7 )
an  . The general solution a n  c( 3 )  .
4 4
27
With a 0  2, c = - .
4
10.3 The Nonhomogeneous Recurrence Relation

Ex 10.23 a n  3a n 1  5(3n ), n  1, a 0  2.
a n( h)  c( 3n ), and since 3 is a characteristic root, a n( p)  Bn3n .
Substitute a n( p ) into the given relation yields
Bn3n  3B (n  1)3n 1  5(3n ), or Bn - B (n - 1) = 5, so B = 5.
Hence a n  (c  5n)3n . With a 0  2, c  2.
peg 1 peg 2 peg 3
Ex. 10.24 The Tower of Hanoi Problem
a n = the number of moves required for n disks.
a n +1  2a n  1 and a 0  0.
 a n( h)  c(2 n ), a n( p )  A(1n ) n+1 disks
a n  2 n  1. move to
rule: one disk at a time
larger one must not on top of a smaller one
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.25 Pauline takes out a loan of S dollars that is to be paid
back in T periods of time. If i is the interest rate per period for the
loan, what constant payment P must she make at the end of each
period?
an:the amount still owed on the loan at the end of the nth
period (following the nth payment)
a n 1  a n  ia n  P,0  n  T  1, a 0  S , a T  0.
a n( h)  c(1  i ) n , a n( p )  A.
P  P n P
A  , a n   S   (1  i )  . Example:
i  i i
 P T P S=5,000,000
Since 0 = a T   S   (1  i )  , i=10%/12
 i i
T=20 years=240 months
 
P  ( Si ) 1  (1  i )  T 1
. P=48251
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.27 The snowflake curve

1 1
3
2

1
3
area: a 0 
4 2
2
3 3  1 3  1 2 
a1   3    a 2  a1  4  3     
4 4  3 4  3 
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.27 The snowflake curve
2 n
  
a n 1  a n  4 n (3)   
3  
 4  3  n
1
1

  an 
1  4
 
4 3  9

n
 4 
a n( h)  A(1) n  A, a n( p)  B 
 9
1   4  n 1 
an  6    .
5 3   9  
6 3 1   4 n 3 1 1
lim a n        
n 5 3 4 4 3 n 0  9 4 4 3 4
1
9
Summary
f ( n) a n( p)
c, a constant A, a constant
n A1n  A0
n2 A2 n 2  A1n  A0
n t , t Z+ At n t  At 1n t 1  A1n  A0
rn , r R Ar n
sin n A sin n + B cosn
r=1 cosn A sin n + B cosn
n t rn r n ( At n t  At 1n t 1  A1n  A0 )
r n sin n r n ( A sin n + B cosn)
r n cosn r n ( A sin n + B cosn)
1. Linear combinations work.
2. If f(n) contains rn and r is a characteristic root of multiplicity k,
then multiply by nk.
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.30 For n>1 suppose that there are n people at a party and
that each of these people shakes hands (exactly one time) with all
of the other people there (and no one shakes hands with himself
or herself). If an counts the total number of handshakes, then
an+1=an+n, a2=1, n>1, because when the (n+1)th person arrives,
he or she will shake hands with the n other people already arrived.
a n( h)  c(1) n  c
a n( p)  n( A1n  A0 )
n( n  1)  n
The result is a n   
2  2
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.31 a n +2  10a n 1  21a n  f (n), n  0
a n( h)  c1 3n  c2 7 n

f ( n) a n( p)
5 A0
3n 2  2 A3 n 2  A2 n  A1
7(11) n A4 11n
31r n , r  3,7 A5 r n
6(3) n A6 n3n
2(3) n  8(9) n A7 n3n  A8 9 n
4(3) n  3( 7) n A9 n3n  A10 n 7n
10.4 The Method of Generating Functions
Ex. 10.32 a n  3a n 1  n, n  1, a 0  1.
a n x n  3a n 1 x n  nx n
  
n n n
 a n x  3  a n 1 x   nx
n 1 n 1 n 1

Let f ( x) =  a n x n
n 0
x
f ( x)  a 0  3xf ( x) 
(1  x) 2
1 x 7 / 4 1 / 4 1 / 2
f ( x)     
1  3x (1  x) (1  3x) 1  3x 1  x (1  x) 2
2

7(3) n 1  (n  1)
an   
4 4 2
10.4 The Method of Generating Functions
Ex. 10.33 a n +2  5a n 1  6a n  2, n  0, a 0  3, a1  7.
a n  2 x n  2  5a n 1 x n  2  6a n x n  2  2 x n  2
   
n2 n2 n2
 a n2 x  5  a n 1 x  6  an x  2  x n2
n 0 n 0 n 0 n 0
2
2 2x
( f ( x)  a 0  a1 x)  5x( f ( x)  a 0 )  6x f ( x) 
1 x
10x 2  11x  3 2 1
f ( x)   
(1  x)(1  2 x)(1  3x) 1  3x 1  x
a n  2(3) n  1, n  0.
10.4 The Method of Generating Functions
Ex. 10.35 a n+1  2a n  bn , bn 1  a n  bn , a 0  1, b0  0
 
Let f ( x)   a n x , g ( x)   bn x n
n
n 0 n 0
  
n 1 n 1
 a n 1 x  2  an x   bn x n 1
n 0 n 0 n 0
  
n 1 n 1
 bn 1 x   an x   bn x n 1
n 0 n 0 n 0
f ( x)  a 0  2 xf ( x)  xg ( x), g ( x)  b0  xf ( x)  xg ( x)
1 x x
f ( x)  , g ( x) 
2
x  3x  1 x 2  3x  1
10.5 A Special Kind of Nonlinear Recurrence Relation

If f ( x) =  a i x i is the generating function for a 0 , a1 ,  ,
i 0
then f 2 ( x) generates a 0 a 0 , a 0 a1  a1a 0 , a 0 a 2  a1a1  a 2 a 0 ,
 , the convolution of the sequence a 0 , a1 ,  with itself.

Ex. 10.36 Count the number of rooted ordered binary trees


on n vertices. For n = 3, there are 5 trees.
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.36 (continued)
for n+1 vertices:bn+1

Hence, for n  0,
bn +1  b0bn  b1bn 1 bn 1b1  bn b0

n 1
 bn 1 x  f (x )  b0 
select one as root n0

n 1
b0 bn  (b0bn  b1bn 1 bn 1b1  bn b0 )x
n0
b1 bn-1 2 1  1  4x
 xf (x ) So f (x ) 

 
2x

bn b 0
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.36 (continued)
  1 / 2
1/ 2 n
1  4x  1  4x     (  4x )
n0  n 
1  1  1  1 
 1   1    2    n  1 
  (4) n  2 2    2   2  n
(  4 )
 2 n!
 n
n 1 1 1 3 2n  3
(1)  (1) n 4 n n
222 2 (  1) 2  1  3(2n  3)
 
n! n!
(1)2 n n ! 1  3(2n  3)  (2n  1) (1)(2n )!
 
n ! n !(2n  1) (2n  1)n ! n !
1  2n
  
2n  1  n 
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.36 (continued)

1    1  2n n  
f (x )  1  1     x 
2x   n 1 2n  1  n   
 1  2n n
n +1
and bn is half the coefficient of x in   x .
n 1 2n  1  n 
1 1  2(n  1) 1  2n
So bn       
2 2(n  1)  1  n  1  n  1 n 

bn is called the Catalan number.


10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.37 Use stacks to permute the ordered list 1,2,...,n.

output 1,2,...,n input

We can generate 1,2 or 2,1 from 1,2.


We can not generate 3,1,2 from 1,2,3.
stack
Let an count the number of ways to
permute 1,2,...,n using this method.
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.37 Use stacks to permute the ordered list 1,2,...,n.
Suppose the output list for 1,2,...,n,n+1is:

1
j numbers k numbers j+k=n
0 n
1 n-1

 
n 0
 a n1  a 0 a n  a1a n1  a n1a1  a n a 0 , a 0  1
1  2n
an   
n  1 n 
Exercise:P423:10
P432,433:1,6
P444: 12
P457: 6

You might also like