Professional Documents
Culture Documents
Mathematics
Chapter 7
Advanced Counting Techniques
H4 moves
an-1 種 1 ∴ an = an1+an2, n 3
a1=2 (string : 0,1)
an-2 種 1 0 a2=3 (string : 01,10,11)
Example 1 and 2.
fn = fn1 + fn2 (True, deg=2)
an = an5 (True, deg=5)
an = an1 + an22 (False, not linear)
(False , not linear)
an = nan1
(False, not homogeneous)
H = 2H + 1 Ch7-8
Theorem 1.
Let an = c1an1+ c2an2 be a recurrence relation
with c1,c2R.
If r2 c1r c2= 0 ( 稱為 characteristic equation)
has two distinct roots r1 and r2.
Then the solution of an is an = 1r1n + 2r2n ,
for n=0,1,2,…, where 1 , 2 are constants.
(1 , 2 可利用 a0, a1 算出 )
Ch7-9
Example 3.
What’s the solution of the recurrence relation
an = an1 + 2an2
with a0=2 and a1=7 ?
Sol :
The characteristic equation is r2 – r 2=0.
Its two roots are r1= 2 and r2 = 1.
Hence an=12n +2 (1)n .
∵a0 = 12 = 2, a1=212=7
∴1 = 3, 2 = 1 驗算: a2 = a1 + 2a0 =11
a = 32 1 =11
an = 32n (1)n.
2
2
Ch7-10
Example 4. Find an explicit formula for the
Fibonacci numbers.
Sol :
fn = fn1 + fn2 , n 2, f0=0 , f1=1.
The characteristic equation is r2 r 1=0.
1 5 1 5
r1 r2
Its two roots are 2 , 2 .
So we have f (1 5 ) n (1 5 ) n
n 1 2
2 2
1 5 1 5
f 0 1 2 0, f1 1 ( ) 2 ( ) 1
1 1 2 2
1 , 2
5 5
1 1 5 n 1 1 5 n
fn ( ) ( )
5 2 5 2 Ch7-11
Thm 2.
Let an = c1an1+c2an2 be a recurrence relation
with c1,c2R.
If r2 c1r c2= 0 has only one root r0 .
Then the solution of an is
an = 1 r0n + 2 n r0n
for n=0,1,2,…, where 1 and 2 are constants.
Ch7-12
Example 5.
What’s the solution of an= 6an1 9an2
with a0=1 and a1=6 ?
Sol :
The root of r2 6r + 9 = 0 is r0 = 3.
Hence an = 1 . 3n +2 . n . 3n .
∵a0 = 1 = 1
a 1 = 3 1 + 3 2 = 6
∴ 1 = 1 and 2 = 1
驗算: a2 = 6a1 9a0 =27
an = 3 + n . 3
n n
a2= 32 +2 32 =27
Ch7-13
Thm 3.
Let an = c1an1 + c2an2 + … + ckank be a
recurrence relation with c1, c2, …, ck R.
If rk c1rk-1 c2rk-2 … ck = 0 has k distinct roots
r1, r2,…, rk.
Then the solution of an is
an = 1r1n +2r2n + …+krkn, for n = 0, 1, 2, …
where 1, 2,…k are constants.
Ch7-14
Example 6 (k = 3)
Find the solution of an = 6an1 11an2 + 6an3
with initial conditions a0=2, a1=5 and a2=15 .
Sol :
The roots of r3 6r2 + 11r – 6 = 0 are
r1 = 1, r2 = 2, and r3 = 3
∴an = 1 1n + 2 2n + 3 3n
∵a0 = 1 + 2 + 3 = 2 1 = 1,
a1 = 1 + 22 + 33 = 5 2 = 1,
a2 = 1 + 42 + 93 = 15 3 = 2
驗算: a3 = 6a2 11a1+ 6a0 =47
∴an = 1 2 + 2 3
n n
a = 1 23 + 2 33 =47
3 Ch7-15
Thm 4.
Let an = c1an1 + c2an2 + … + ckank be a
recurrence relation with c1, c2, …, ck R.
If rk c1rk1 c2rk2 … ck = 0
has t distinct roots r1, r2, …, rt with
multiplicities m1, m2, …, mt respectively, where
mi 1,i, and m1+ m2 +…+ mt = k,
then
( 接下一頁 )
Ch7-16
m1 1 n
an (α1,0 α1,1 n ... α1,m1 1 n )r1
...
mi 1 n
(αi ,0 αi,1 n ... αi,mi 1 n ) ri
...
mt 1 n
(αt,0 αt,1 n ... αt,mt 1 n ) rt
where i,j are constants.
(1 i t , 0 j mi1)
Ch7-17
補充說明:
若特徵方程式的 root 為: 1 (2 重根 ),
2 (3 重根 ),
3 ( 無重根 )
則通解為:
an= (1+2n ) 1n+ (3+4n +5n2 ) (2) n+6 3n
( 變數的下標從開始排起只
, 要不重複就好
Ch7-18
Example 8. Find the solution to the recurrence
relation an = 3an1 3an2 an3 with initial conditions
a0 = 1, a1 = 2 and a2 = 1.
Sol :
r3 + 3r2 + 3r + 1 = 0 has a single root r0 = 1 of
multiplicity three.
∴ an = (1+2n+3n2) r0n = (1+2n+3n2)(1)n
∵ a0 = 1 = 1
a1 = (1+2+3) (1) = 2
a2 = (1+2+3) = 1 驗算: a3 = 3a2 3a1 a0 =8
a3= (1+33232)(1)3 =8
∴1 = 1, 2 = 3, 3 = 2
Exercise : 3,13,15,19
an = (1+3n2n2) (1)n Ch7-19
7.4 Generating Functions.
Def 1. The generating function for the sequence {an}
is the infinite power series.
G(x) = a0 + a1x +… + anxn +…
= k
k
a x
k 0
Ch7-20
Example 2. What is the generating function
for the sequence 1,1,1,1,1,1 ?
Sol :
G ( x) 1 x x ... x
2 5
(expansion ,展開式 )
x6 1
(closed form)
x 1
Ch7-21
Example 3.
m
Let mZ+ and ak k ,for k = 0, 1, …, m.
What is the generating function for the sequence
a0, a1,…, am ?
Sol :
G(x) = a0 + a1x + a2x2 + … + amxm
m m m 2 m m
x x x
0 1 2 m
Ch7-22
Example 5.
1
The function f (x) = is the generating
1 ax
Ch7-23
( 跳過 )
Def 2.
Let uR and kZ+∪{0}. Then the extended
u
binomial coefficient k is defined by
1
u u (u 1)(u 2)...(u k 1), if k 0
k!
k 1 if k 0
Ch7-24
( 跳過 )
Example 7.
2 12
Find and
3 3
Sol :
2 1
(2)(3)(4) 4
3 3!
12 1 1 1 3 1
3 3! 2 2 2 16
Ch7-25
( 跳過 )
k 0
Ch7-26
Example 9. ( 跳過 )
Find the generating functions for (1+x)n and (1x)n
where nZ+
Sol : By the Extended Binomial Theorem,
n
1
(1 x) x ( n)(n 1) ... (n k 1) x k
n k
k 0 k k 0 k!
(1) k
(n) (n 1) ... (n k 1) x k
k 0 k!
n k n k 1
k n k 1 k
(1) x Note : (1)
k 0 k k k
By replacing x by –x we have
n k 1 k
(1 x)
n
x
k 0 k
Ch7-27
※Using Generating Functions to solve
Recurrence Relations.
Example 16.
Solving the recurrence relation ak = 3ak1 for
k=1,2,3,… and initial condition a0 = 2.
Sol :
另法: (by 6.2 公式 )
r – 3 = 0 r = 3 an = 3n
∵ a0 = 2 =
∴ an = 2 3n
Ch7-28
Let G ( x) a0 a1 x a2 x ... ak x be the
2 k
k 0
generating function for {ak}.
First note that ak xk = 3ak1 xk
k k 1 k 1 k
k 1
a x k
3 a x k
3 x a x 3 x a x k
k 1 k 1 k 1 k 0
G(x) a0 = 3x G(x)
∵a0 = 2 G(x) 3x G(x) = G(x)(13x) = 2
2
G ( x) 2 (3x) k 2 3k x k
1 3x k 0 k 0
(3). A B C D ?
Ch7-30
Theorem 1.
A1, A2, …, An : sets
n
A1 A2 ... An Ai A A i j
i 1 1i j n
Exercise : 17 Ch7-31
7.6 Applications of Inclusion and
Exclusion
Example 2. How many onto functions are there
form set A={1, 2, 3, 4, 5, 6} to set B={a, b, c} ?
Sol : f : A → B
f (1)= {a, b, c} 不同的填法造出不同的函數
f (2)= 如何使 a,b,c 都出現 ?
︰ ︰
f (6)=
# of onto functions
= ( 所有函數個數 ) (a,b,c 中有一個沒被對應 )
+ (a,b,c 中二個沒被對應 ) (a,b,c 都沒被對應 )
= 6
3 2 1 0
3
1
6 3 6
2
3 6
3 Ch7-32
Thm 1. |A| = m , |B| = n
There are
n
m
n 1 (n 2) (n 3)
n
1
m n
2
m n
3
m
...
(1) 1
n 1 n
n 1
m
onto functions f : A → B.
pf :
A = {a1, a2, …, am}. B = {b1, b2, …, bn}
f (a1)=
f (a2)= b1, b2, …, bn
︰ ︰
f (am)= Ch7-33
( 跳過 )
※Derangements 亂序
Def.
A derangement is a permutation of
objects that leaves no object in its
original position.
Ch7-34
( 跳過 )
Example 5. 21453, 23451, 34512, …
are derangements of 12345 :
Def.
Let Dn be the number of derangements of n objects.
D4 = ( 所有 4 個元素的 permutation 數 )
(4 個元素有一個在原位置的 permutation 數 )
+ (4 元素中有二個在原位置的個數 )
(4 個元素中有三個在原位置的個數 )
+ (4 元素都在原位置的個數 )
4 4 4 4
= 4! 3! 2! 1! 0!
1 2 3 4
Ch7-35
( 跳過 )
Theorem 2. ( 亂序公式 )
Dn n! n1 (n 1)! n2 (n 2)! ... (1) n nn 0!
n! (n 1)! n! (n 2)!
n! (1 ...
1!(n 1)! n! 2!(n 2)! n!
n! 0!
(1)
n
)
n!0! n!
1 1 n 1
n! ( 1 ... (1) )
1! 2! n!
Exercise : 8, 13 Ch7-36