Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , ,...

21
1 COS 341 Discrete Mathematics Generating Functions

Transcript of Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , ,...

Page 1: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

1

COS 341 Discrete Mathematics

Generating Functions

Page 2: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

2

Administrative Issues• Homework 1 has been graded• Median score: 77

Page 3: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

3

Generating functions

2

0

0 1( , , , ) : sequence of real numbersof this sequence is

the power serie

Gene

s

rating function

( ) iiia a

a

x x

a a

== ⋅∑

Page 4: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

4

Operations on power series• Addition

• Multiplication by fixed real number

• Shifting the sequence to the right

• Shifting to the left

0 0 1 1 has generating function( , , ) ( ) ( ) a b a b a x b x+ + +…

0 1 has generating functi( , , ) (on )a a a xα α α…

0 1 has generating fu(0, 0 ncti, , on , ) ( )n

n

a a x a x×

… …

1

01 has generating f

(unction

)( , , )

k iii

k k n

a x a xa a

x

=+

− ⋅∑…

Page 5: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

5

• Substituting αx for x

• Substitute xn for x

0 1 21 1

has ge( ,0, 0, nerati,0, 0, ng function ) ( )nn n

a a a a x−× −×

… … …

20 1 2 has generating funct( , , ion) ( ) a a a a xα α α…

Page 6: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

6

• Differentiation

• Integration

• Multiplication of generating functions

1 2 3 has generating function ( , 2 ,3 ) ( ) (or )'( )da a a a x a xdx

1 10 1 22 3

0

has generating function (0, , , ) ( )x

a a a f t dt∫…

( )( ) ( )0 0 0

0

n n nn n nn n n

nn k n kk

a x b x c x

c a b

∞ ∞ ∞

= = =

−=

⋅ ⋅ = ⋅

= ⋅

∑ ∑ ∑∑

Page 7: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

7

Applying the toolkit2 2 2

2

What is the generating function for (1 ,2 ,th 3 ,e seque(

nce ))

1ka k= +

2 3 41 11

x x x xx= + + + + +

−2 3

2

1 1 1 2 3 4(1 ) 1

d x x xx dx x

= = + + + + − −

2 33 2

2 1 1 2 3 2 4 3 5.4(1 ) (1 )

d x x xx dx x

= = ⋅ + ⋅ + ⋅ + + − −

2 33 2

2 1 1 1 2 2 3 3 4 4(1 ) (1 )

x x xx x

− = ⋅ + ⋅ + ⋅ + ⋅ +− −

Page 8: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

8

An alternate derivation:Generalized Binomial Theorem

2 3r r r r

0 1 2 3(1 )r x x xx + + + +

+ = …

( 1)( 2) ( 1)

!

r r r r r k

k k

− − − +=

1 1( 1) ( 1)

1k k

n n k n k

k k n

− + − + −= − = −

( 1)( 2) ( 1)

!

( 1)( 2) ( 1)( 1)

!

k

n n n n n k

k k

n n n n k

k

− − − − − − − − +=

+ + + −−=

Page 9: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

9

An alternate derivation:Generalized Binomial Theorem

2 3r r r r

0 1 2 3(1 )r x x xx + + + +

+ = …

1 1( 1) ( 1)

1k k

n n k n k

k k n

− + − + −= − = −

0 0

-1 -1(1 ) ( 1) ( 1)

1n k k k k

k k

n k n kx x x

k n

∞−

= =

∞ + ++ = − = −

∑ ∑

0 0

-1 -1(1 ) ( 1) )

1 1(n k k k

k k

n k n kx x x

n n−

= =

∞ ∞+ +− = − =

− −

− ∑ ∑

Page 10: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

10

An alternate derivation:Generalized Binomial Theorem

0 0

-1 -1(1 ) ( 1) )

1 1(n k k k

k k

n k n kx x x

n n

∞ ∞−

= =

+ +− = − =

− −

− ∑ ∑1

0 0

(1 )0

k k

k k

kx x x−

= =

∞ ∞

− = = ∑ ∑

2

0 0

1(1 ) ( 1)

1k k

k k

kx x k x−

= =

∞ ∞+− +

= = ∑ ∑

3

0 0

2(1 )

2( 2)( 1)

2k k

k k

kx x x

k k−

= =

∞ ∞+−

+ += = ∑ ∑

Page 11: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

11

An alternate derivation:Generalized Binomial Theorem

2

0 0

1(1 ) ( 1)

1k k

k k

kx x k x−

= =

∞ ∞+− +

= = ∑ ∑

3

0 0

2(1 )

2( 2)( 1)

2k k

k k

kx x x

k k−

= =

∞ ∞+−

+ += = ∑ ∑

3

0

22(1 ) ( 1)( 1)(1 ) k

k

x k k xx−

=

−∞

− + +− − =∑

Page 12: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

12

More toolkit examples

1 1 12 3 4

of theWhat is the g sequence(1,

enerating functio,

n, , )?

2 31 1 12 3 4

ln(1 1- ) x xxx

x+ + +− = +

Page 13: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

13

More toolkit examples2 3 41 1

1x x x x

x= + + + + +

2 3 4

0 0

(1 )1

x xdt t t t t dtt= + + + + +

−∫ ∫2 3 41 1 1

2 3 4ln(1 ) ln(1) x x xx x + + +− − + = +

2 31 1 12 3 4

ln(1 ) 1x

x x xx + + +− − = +

Page 14: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

14

Applications to counting

A box contains 30 red, 40 blue and 50 green balls.Balls of the same color are indistinguishable.

How many ways are there of selecting a collection of 70 balls from the box ?

2 30

2 4

2 5

0

7

0

0coefficient (1

of in

))

(

)

1(1 xx x

x

x

x x xxx

× +

+ +

+ ++

++ +

++

Page 15: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

15

Enter generating functions

2 3

70

2 50 40 2 0

coefficient of i(1 )( (1 )

n1 )x x x xx x xx

xx+ + ++ + + + + ++ ++

312 30 1(1 )

1xx x xx

−+ + + + =−

Sum of first n terms of a geometric series

2

3131 32 33

11

1

1

x xx

xx x x

x

= + + +−

= + + +−

Alternately

Page 16: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

16

Enter generating functions

2 3

70

2 50 40 2 0

coefficient of i(1 )( (1 )

n1 )x x x xx x xx

xx+ + ++ + + + + ++ ++

741

05131

coefficient of i ( (1 )(1 )n 11

1 1

)xx

x xx

xx

−−

−−

−−

31 41 513

31 41 51

0

1(1 )(1 )(1 )

(1 )

2(1 )

2k

k

x x xx

kx x x x

=

− − −−

+= − − − + ∑

70 2 70 31 2 70 41 2 70 51 21061

2 2 2 2+ − + − + − +

− − − =

Page 17: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

17

More tricks with generating functions

0( ) iiia x a x∞

== ⋅∑

0 nn iib a

==∑

0( )What s i i

iib x b x∞

== ⋅∑

( ) ( ) 1a xb x

x=

( )2 20 1 20

(1 )iiib x a a x a x x x

=⋅ = + + + + + +∑

Page 18: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

18

More tricks with generating functions2 2 2W (1 +2hat )is ?n+

2 33 2

2 1 1 1 2 2 3 3 4 4(1 ) (1 )

x x xx x

− = ⋅ + ⋅ + ⋅ + ⋅ +− −

0 nn iib a

==∑ ( ) ( )

1a xb x

x=

−2

0

2 21

2 2 22

1

1 2

1 2 3

bbb

== += + +

Page 19: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

19

More tricks with generating functions2 2 2W (1 +2hat )is ?n+

2 33 2

2 1 1 1 2 2 3 3 4 4(1 ) (1 )

x x xx x

− = ⋅ + ⋅ + ⋅ + ⋅ +− −

4 30

2 2 2

2 1(1 ) (1 )

1 2 ( 1)

nn

n

n

b xx x

b n=

∞− =

− −= + + + +

3 22

3 2n

n nb

+ + = −

1

2 12

3 2n

n nb −

+ + = −

Page 20: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

20

More tricks with generating functions2 2 2W (1 +2hat )is ?n+

2 2 21 1 2

2 12

3 22( 2)( 1) ( 1)

6 2(2 1)( 1)

6

nb nn n

n n n n n

n n n

− = + + + + + = − + + += −

+ +=

Page 21: Generating Functions - Princeton University Computer Science · 3 Generating functions 2 0 (01, , , ):sequence of real numbersof this sequence is the power serie Gene s rating function

21

More tricks with generating functions

0

(-1What is ?)m

k

k

nk=

∑The generating function for the sequence

( 1 ( ) () is 1 ) kk

nna a x

kx

= − = −

10

The generating function for the sequence

is ( ) (1 )1

m nm kk

a xc a xx

−=

= = −−∑

1 (coefficient of 1) =m

m mcm

xn

= − −