Discrete Mathematics Discrete Mathematics
- - Chapter 9: Generating Function
Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University
Discrete Mathematics Discrete Mathematics -- Chapter 9: Generating - - PowerPoint PPT Presentation
Discrete Mathematics Discrete Mathematics -- Chapter 9: Generating Function Hung-Yu Kao ( ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U Outline Calculational Techniques
Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University
Calculational Techniques Partitions of Integers Partitions of Integers The Exponential Generating Function The Summation Operator
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
2
Chapter 1: c1+c2+c3+c4=25, where ci>= 0 Chapter 8: c +c +c +c =25 where 10>c >= 0 Chapter 8: c1+c2+c3+c4=25, where 10>ci>= 0 In chapter 9, c2 to be even and c3 to be a multiple
the coefficient xy2 in (x+y)3
4 i ( + 2)( 2+ 3+ 4)(1+ +2 2)
the coefficient x4 in (x+x2)(x2+x3+x4)(1+x+2x2)
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
3
f th hild G M for three children, Grace, Mary, and Frank.
but Frank gets no more than five.
f( ) ( 4+
5+ 6+ 7+ 8)( 2+ 3+ 4+ 5+ 6)( 2+ 3+ 4+ 5)
5 2 and , 2 , 4 where , 12
3 2 1 3 2 1
≤ ≤ ≤ ≤ = + + c c c c c c
f(x) = (x4+ x5+ x6+ x7+ x8)(x2+ x3+x4+ x5+ x6)(x2+ x3+x4+ x5) product xjxjxk → every triple (i, j, k)
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
4
f( ) y
beans. beans.
even number of white beans and at least six black ones?
f(x) = (1+ x1+ x2+….+ x23+ x24)2(1+ x2+ x4+….+ x22+ x24) f(x) (1 x x …. x x ) (1 x x …. x x ) (x6+ x7+….+ x23+ x24)
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
5
H ti i t l ti th f
c1+c2+c3+c4 = 25?
four children?
f(x) = (1+ x1+ x2+…+ x24+ x25)4 (polynomial)
can also generate the answer
∞
∞ =
− = ) ( ) (
n n n
c x a x f
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
6
p p p y
n n n n n n n
2 2 1
2 1 n n n n n
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
7
a)
(1 - xn+1)/(1 - x) is the generating function for the sequence 1, 1, 1,…, 1, 0, 0, 0,…, where the first n+1 terms are 1.
b)
1/(1 x) is the generating function for the sequence 1 1 1
). 1 )( 1 ( ) 1 (
2 1 n n
x x x x x + ⋅ ⋅ ⋅ + + + − = −
+
Q
b)
1/(1-x) is the generating function for the sequence 1, 1, 1, 1,…
c)
1/(1-x)2 is the generating function for the sequence 1, 2, 3,
⋅ ⋅ ⋅ + + + + = <
− 3 2 1 1
1 , 1 | | while x x x x
x
Q
)
( ) g g q , , , 4,…
⋅ ⋅ ⋅ + + + + = ⋅ ⋅ ⋅ + + + + = = − − − = − =
− − − 3 2 3 2 ) 1 ( 1 2 1 1 1
4 3 2 1 ) 1 ( ) 1 ( ) 1 )( 1 ( ) 1 (
2
x x x x x x x x
dx d x dx d x dx d
Q
d)
x/(1-x)2 is the generating function for the sequence 0,1,2,3,….
− ) 1 (
) (
dx x 4 3 2
4 3 2 1
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
8
⋅ ⋅ ⋅ + + + + + =
− 4 3 2 ) 1 (
4 3 2 1
2
x x x x
x x
Q
e)
(x+1)/(1-x)3 is the generating function for the sequence
2 2 2 2
12, 22, 32, 42,…
⋅ ⋅ ⋅ + + + + =
− 3 2 ) 1 (
) 3 2 (
2
x x x
dx d x x dx d
Q
2
2 ) 1 (
) 1 (
d d x x dx d
x x
− −
− = Q
⋅ ⋅ ⋅ + + + + =
− + 3 2 2 2 2 ) 1 ( 1
4 3 2 1
3
x x x
x x
3 3
1 2 ) 1 ( 3 2
) 1 ( ) 1 )( 2 ( ) 1 ( ) (
x x x dx
x x x
+ + − − −
= = − − − + − =
3 3
) 1 ( ) 1 ( x x − −
f)
x(x+1)/(1-x)3 is the generating function for the sequence 02, 12, 22, 32, 42,…
+ 3 2 2 2 ) 1 (
3 2 1
x x
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
9
⋅ ⋅ ⋅ + + + + =
− + 3 2 2 2 ) 1 ( ) 1 (
3 2 1
3
x x x
x x x
Q
g)
Further extensions:
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
10
a)
1/(1 - ax) is the generating function for the sequence a0, a1, a2,
)
( ) g g q , , , a3,…
b)
f(x) = 1/(1- x) is the generating function for the sequence 1, 1, 1, 1,… Then
sequence 1 1 0 1 1 1 sequence 1, 1, 0, 1, 1, 1,…
sequence 1, 1, 1, 3, 1, 1,… sequence 1, 1, 1, 3, 1, 1,…
c)
Can we find a generating function for the sequence 0, 2, 6, 12, 20, 30, 42,…?
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
11
c)
20,... 12, 6, 2, 0, Observe , 3 3 12 , 2 2 6 , 1 1 2 , , , , , ,
2 3 2 2 2 1 2
a a a a + = = + = = + = = + = = , 4 4 20 , 3 3 12 , 2 2 6
2 2 4 3 2
n n a a a a + = ∴ ⋅ ⋅ ⋅ + = = + + 3 ) 1 ( 2 3 ) 1 ( ) 1 ( ) 1 ( 2 ) 1 ( 3 ) 1 ( ) 1 ( x x x x x x x x x x x x n n an − = − − + + = − + − + + ∴ function. generating the is ) 1 ( ) 1 ( ) 1 ( ) 1 ( x x x x
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
12
⎞ ⎛
n n n n n n
x x x x + ⋅ ⋅ ⋅ + + + = +
2 2 1
) 1 (
! ) 1 )...( 2 )( 1 ( )! ( ! ! r r n n n n r n r n r n + − − − = − = ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛
! ) 1 )...( 2 )( 1 ( r r n n n n r n + − − − = ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ ⎞ ⎛
− + + − + − − − − − − − = ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛− r n n n r r n n n n r n
r
) 1 ) ( 1 )( ( ) 1 ( ! ) 1 )...( 2 )( 1 )( ( ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − + − = − + − = + + = r n r n r r n n n
r r
1 ) 1 ( ) ( )! 1 ( ) 1 ( ! ) 1 )...( 1 )( ( ) 1 (
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
13
⎠ ⎜ ⎝ − r r n ) ( ! )! 1 (
(1-x)-n ?
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
14
7 7 ∞
5 7 7
∞ = − −
r r r
5 11 5 1 5 7 5 5 5 7
− + −
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
15
C( 4 7)( 1)7 = ( 1)7C(4+7 1 7)( 1)7 = C(10 7) = 120 C(-4, 7)(-1)7 = (-1)7C(4+7-1, 7)(-1)7 = C(10, 7) = 120.
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
16
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
17
check n=1
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
18
h i f th t bj t ( l t ) choices for that object (namely none, one, two,…)
(1+x+x2+…)n
∞
⎞ ⎛ − + ⎞ ⎛ 1 1 1
n
i n
( )
=
⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − + = − = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ − = ⋅ ⋅ ⋅ + + +
2
. 1 ) 1 ( 1 1 1 ) 1 (
i i n
x i i n n x x x x
r n 1 − +
r r n 1 − +
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
19
Th d ( 1+
2+ 3+ 4+
)3 [ /(1 )]3 ffi i t f
4
3
−
4 1
)] 1 /( [
i i
x x
)] ( [
i
How about n=5?
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
20
following generating function. g g g
∞ = ∞ =
− = + + +
1 1 3 2 1
)] 1 /( [ ...) (
i i i i
x x x x x
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
21
shells to four police officers, so that each officer gets at least three h ll b t t th i ht shells but not more than eight.
= x12(1+x+x2+x3+x4+x5)4 = x12[(1-x6)/(1-x)]4 x [(1 x )/(1 x)]
2 4 4 4 24 18 4 12 4 6 4
] ) ( ) ( ][ 1 [
2 2 4 1 4 4 24 18 3 4 12 2 4 6 1 4
⋅ ⋅ ⋅ + − + − + + − + − =
− − −
x x x x x x 125 ] 4 9 4 15 [ ] 4 4 ) 1 ( 4 4 ) 1 ( 4 [
6 12
= ⎞ ⎜ ⎜ ⎛ + ⎞ ⎜ ⎜ ⎛ ⎞ ⎜ ⎜ ⎛ ⎞ ⎜ ⎜ ⎛ = ⎞ ⎜ ⎜ ⎛− ⎞ ⎜ ⎜ ⎛ + ⎞ ⎜ ⎜ ⎛− ⎞ ⎜ ⎜ ⎛ ⎞ ⎜ ⎜ ⎛−
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
22
125 ] 2 6 1 12 [ ] 2 ) 1 ( 6 1 ) 1 ( 12 [ = ⎠ ⎜ ⎜ ⎝ + ⎠ ⎜ ⎜ ⎝ ⎠ ⎜ ⎜ ⎝ − ⎠ ⎜ ⎜ ⎝ = ⎠ ⎜ ⎜ ⎝ ⎠ ⎜ ⎜ ⎝ + − ⎠ ⎜ ⎜ ⎝ ⎠ ⎜ ⎜ ⎝ − − ⎠ ⎜ ⎜ ⎝
1
. ) 2 )( 3 ( 1 in
2 8
− − x x x
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
23
E 9 17 H
Solution
difference 0, 2, 4, 3, 5, difference sum = 14.
where 0 ≤ c1, c5 and 2 ≤ c2, c3, c4.
f(x) = (1+x+x2+x3+ )(x2+x3+x4+ )3(1+x+x2+x3+ ) f(x) = (1+x+x +x +…)(x +x +x +…) (1+x+x +x +…) = x6(1-x)-5
495 8 12 8 1 8 5 8 ) 1 ( 8 5 = ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − + = − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛−
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
24
for the sequence b = k2
= a0b0 + (a0b1+a1b0)x + (a0b2+a1b1+a2b0)x2 + …, for the sequence ck = a0bk+a1bk-1+a2bk-2+ …+ak-2b2+ak-1b1+akb0
) (
2
− =
k i k
i k i c
c0= 0×02 c 0 12 +1 02
c1= 0×12 +1×02 = 0 c2= 0×22 +1×12+2×02 = 1 c3= 6
a2, … and b0, b1, b2, …
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
25
= 1/[(1 x)(1+x)] = 1/(1 x2) = 1+x2+x4+x6+ = 1/[(1-x)(1+x)] = 1/(1-x2) = 1+x2+x4+x6+ …
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
26
( ) th b f titi i iti i t
1
2 3 4
1+x+x2+x3+x4+….
1+x2+x4+x6+x8+….
1+x3+x6+x9+x12+….
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
27
=(1+x+x2+x3+…)(1+x2+x4+x6+…)(1+x3+x6+x9+…)… ( …)( …)( …)… (1+x10+x20+…)
) 1 ( 1 ) 1 ( 1 ) 1 ( 1 ) 1 ( 1 ) 1 ( 1 ) (
10 1 10 3 2 i i
x x x x x x f ∏ = ⋅ ⋅ ⋅ =
=
(0) (1) (2) (3)
) 1 ( ) 1 ( ) 1 ( ) 1 ( ) 1 ( x x x x x − − − − −
) 1 ( 1 1
) (
i i
x P
∞ =
∏ =
p(0), p(1), p(2), p(3), …
) 1 ( 1 i x i − Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
28
advertising agent can purchase n minutes of air time if the time slots come in blocks of 30 60 or 120 seconds slots come in blocks of 30, 60, or 120 seconds.
Solution
f(x)= (1+x+x2+x3+x4+…)(1+x2+x4+x6+x8+…)( 1+x4+x8+x12+…) =
. ) 1 ( 1 ) 1 ( 1 ) 1 ( 1
4 2
x x x − − −
1’s, 2’s, and 4’s.
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
29
a positive integer n into distinct summands.
6 = 1+5 6 = 1+2+3
i i i i dd d
6 1+2+3 6 = 2+4
a positive integer n into odd summands.
6 = 1+1+1+3 6 1 1 1 3 6 = 1+5 6 = 3+3
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
30
Solution
6 = 1+1+1+3 6 1+5
f(x) = (1+x+x3+x5+ …)(1+x3+x9+x15+ …) (1+x5+x15+x25+ …)…
6 = 1+5 6 = 3+3
= ∏
∞ = ∞ = + +
) 1 2 )( 1 2 (
k i i k
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
31
4
4
The number of partitions of an integer n into m summands is equal to the number
4
q
m is the largest summand.
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
32
http://mathworld.wolfram.com/FerrersDiagram.html
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
33
∞ 3 2 i
∞ =
0 !
i x
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
34
arranged?
Solution Solution
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
35
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
36
blue and black. Twelve flags are placed on a vertical pole to communicate signal to other ships.
and an odd number of black flags?
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
37
flag at all?
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
38
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
39
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
40
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
41
Summation
1
1,…
1, 1+1, 1+1+1,… ⇒ 1, 2, 3,… + 2 i th ti f ti f th 0 1 1 0 0
0,…
1 2 2 2 2 1, 2, 2, 2, 2, …
5, 7, 9, 11, …
9, 16, 25, 36, …
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
42
2 2 2 2
n. Solution Solution
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
43
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
44
9.1: 9 2: 9.2: 9.3: 9.4: 9 5: 9.5:
Discrete Mathematics Discrete Mathematics – – CH9 CH9 2009 Spring 2009 Spring
45