<<

Generating Functions ITT9131 Konkreetne Matemaatika

Chapter Seven Domino Theory and Change Basic Maneuvers Solving Recurrences Special Generating Functions Exponential Generating Functions Dirichlet Generating Functions Contents

1 Convolutions Fibonacci m-fold convolution Catalan numbers

2 Exponential generating functions Next section

1 Convolutions Fibonacci convolution m-fold convolution Catalan numbers

2 Exponential generating functions Convolutions

Given two :

hf0,f1,f2,...i = hfni and hg0,g1,g2,...i = hgni

The convolution of hfni and hgni is the

* + * + f g f g f g f g f g f g f g f g h 0 0, 0 1 + 1 0, 0 2 + 1 1 + 2 0,...i = ∑ k n−k = ∑ k ` . k k+`=n

If F (z) and G(z) are generating functions on the sequences hfni and hgni, then their convolution has the generating F (z) · G(z). Three or more sequences can be convolved analogously, for example:

* + f g h f g h h nih nih ni = ∑ j k ` j+k+`=n

and the generating function of this three-fold convolution is the product F (z) · G(z) · H(z). Convolutions

Given two sequences:

hf0,f1,f2,...i = hfni and hg0,g1,g2,...i = hgni

The convolution of hfni and hgni is the sequence

* + * + f g f g f g f g f g f g f g f g h 0 0, 0 1 + 1 0, 0 2 + 1 1 + 2 0,...i = ∑ k n−k = ∑ k ` . k k+`=n

If F (z) and G(z) are generating functions on the sequences hfni and hgni, then their convolution has the generating function F (z) · G(z). Three or more sequences can be convolved analogously, for example:

* + f g h f g h h nih nih ni = ∑ j k ` j+k+`=n

and the generating function of this three-fold convolution is the product F (z) · G(z) · H(z). Convolutions

Given two sequences:

hf0,f1,f2,...i = hfni and hg0,g1,g2,...i = hgni

The convolution of hfni and hgni is the sequence

* + * + f g f g f g f g f g f g f g f g h 0 0, 0 1 + 1 0, 0 2 + 1 1 + 2 0,...i = ∑ k n−k = ∑ k ` . k k+`=n

If F (z) and G(z) are generating functions on the sequences hfni and hgni, then their convolution has the generating function F (z) · G(z). Three or more sequences can be convolved analogously, for example:

* + f g h f g h h nih nih ni = ∑ j k ` j+k+`=n

and the generating function of this three-fold convolution is the product F (z) · G(z) · H(z). Next subsection

1 Convolutions Fibonacci convolution m-fold convolution Catalan numbers

2 Exponential generating functions Fibonacci convolution

To compute ∑k fk fn−k use Fibonacci generating function (in the form given by Theorem 1 and considering that n 1 zn 1 ): ∑( + ) = (1−z)2

 1  1 1 2 F 2 z √ ( ) = 1 z − 5 − Φ 1 − Φbz 1 1 2 1 ! = − + 5 1 z 2 2 ( − Φ ) (1 − Φz)(1 − Φbz) (1 − Φbz) 1 2 1 n 1 nzn f zn n 1 nzn = 5 ∑ ( + )Φ − 5 ∑ n+1 + 5 ∑ ( + )Φb n>0 n>0 n>0 1 2 n 1 n n zn f zn = 5 ∑ ( + )(Φ + Φb ) − 5 ∑ n+1 n>0 n>0 1 2 n 1 2f f zn f zn = 5 ∑ ( + )( n+1 − n) − 5 ∑ n+1 n>0 n>0 1 2nf n 1 f zn = 5 ∑ ( n+1 − ( + ) n) n>0 Hence 2nf n 1 f f f n+1 − ( + ) n ∑ k n−k = 5 k Fibonacci convolution (2)

On the previous slide the following was used:

Property For any n 0: n n 2f f > Φ + Φb = n+1 − n Proof

n n 1 n n 1 The equalities ∑n Φ z = 1 z , ∑n Φb z = , and Φ + Φb = 1 are used in the −Φ 1−Φbz following derivation:

1 1 1 z 1 z n n zn − Φb + − Φ ∑(Φ + Φb ) = 1 z + = = n − Φ 1 − Φbz (1 − Φz)(1 − Φbz) 2 − z 2 z z = = · − = 1 − z − z2 z 1 − z − z2 1 − z − z2 2 n n n−1 n = ∑fnz − ∑fnz = 2∑fnz − ∑fnz = z n n n n 2 f zn f zn = ∑ n+1 − ∑ n = n n 2f f zn = ∑( n+1 − n) n

Q.E.D. Fibonacci convolution (2)

On the previous slide the following was used:

Property For any n 0: n n 2f f > Φ + Φb = n+1 − n

Proof (alternative) We know from Exercise 6.28 that

n n Φ + Φb = Ln = fn+1 + fn−1 ,

with the convention f−1 = 1, is the nth , which is the solution to the recurrence: L0 = 2; L1 = 1; L L L n 2 n = n−1 + n−2 ∀ > .

By writing the for Fibonacci numbers in the form fn−1 = fn+1 − fn (which, incidentally, yields f−1 = 1), we get precisely Ln = 2fn+1 − fn. Q.E.D. Next subsection

1 Convolutions Fibonacci convolution m-fold convolution Catalan numbers

2 Exponential generating functions Spanning trees for fan

Example: the fan of order 5:

Spanning trees: Spanning trees for fan

Example: the fan of order 5:

Spanning trees: Spanning trees for fan (2)

How many spanning trees can we make? We need to connect 0 to each of the four blocks: two ways to join 0 with {9,10}, one way to join 0 with {8}, four ways to join 0 with {4,5,6,7,}, three ways to join 0 with {1,2,3}, There is altogether 2 · 1 · 4 · 3 = 24 ways for that.

In general: sn = ∑ ∑ k1k2 ···km m 0 > k1 + k2 + ··· + km = n k1,k2,...,km > 0 Spanning trees for fan (2)

How many spanning trees can we make? We need to connect 0 to each of the four blocks: two ways to join 0 with {9,10}, one way to join 0 with {8}, four ways to join 0 with {4,5,6,7,}, three ways to join 0 with {1,2,3}, There is altogether 2 · 1 · 4 · 3 = 24 ways for that.

In general: sn = ∑ ∑ k1k2 ···km m 0 > k1 + k2 + ··· + km = n k1,k2,...,km > 0

For example

f4 = 4 + 3 · 1 + 2 · 2 + 1 · 3+2 · 1 · 1 + 1 · 2 · 1 + 1 · 1 · 2+1 · 1 · 1 · 1 = 21 | {z } | {z } Spanning trees for fan (2)

How many spanning trees can we make? We need to connect 0 to each of the four blocks: two ways to join 0 with {9,10}, one way to join 0 with {8}, four ways to join 0 with {4,5,6,7,}, three ways to join 0 with {1,2,3}, There is altogether 2 · 1 · 4 · 3 = 24 ways for that.

In general: sn = ∑ ∑ k1k2 ···km m 0 > k1 + k2 + ··· + km = n k1,k2,...,km > 0

This is the sum of m-fold convolutions of the sequence h0,1,2,3,...i. Spanning trees for fan (3)

Generating function for the number of spanning trees:

The sequence h0,1,2,3,...i has the generating function z G(z) = . (1 − z)2

Hence the generating function forhfni is

G(z) S(z) = G(z) + G 2(z) + G 3(z) + ··· = 1 − G(z) z = 1 z 2 1 z ( − ) ( − (1−z)2 ) z = (1 − z)2 − z z = . 1 − 3z + z2 Spanning trees for fan (3)

Generating function for the number of spanning trees:

The sequence h0,1,2,3,...i has the generating function z G(z) = . (1 − z)2

Hence the generating function forhfni is

G(z) S(z) = G(z) + G 2(z) + G 3(z) + ··· = 1 − G(z) z = 1 z 2 1 z ( − ) ( − (1−z)2 ) z = (1 − z)2 − z z = . 1 − 3z + z2

Consequently sn = f2n Next subsection

1 Convolutions Fibonacci convolution m-fold convolution Catalan numbers

2 Exponential generating functions Dyck language

Denition The Dyck language is the language consisting of balanced strings of parentheses '[' and ']'.

Another denition If X = {x,x} is the alphabet, then the Dyck language is the subset D of words u of X ∗ which satisfy

1 u|x = |u|x , where |u|x is the number of letters x in the word u, and ∗ 2 if u is factored as vw, where v and w are words of X , then |v|x > |v|x . Dyck language (2)

Let Cn be the number of words in the Dyck language D having exactly n pairs of parentheses. If u = vw for u ∈ D, then the prex v ∈ D i the sux w ∈ D Then every word u ∈ D of length > 2 has a unique writing u = [v]w such that v,w ∈ D (possibly empty) but [p 6∈ D for every prex p of u (including u itself). Hence, for any n > 0

Cn = C0Cn−1 + C1Cn−2 + ··· + Cn−1C0

The number hCni is called Catalan numbers, from the Belgian mathematician Eugène Catalan. Let us derive the closed formula for Cn in the following slides. Catalan numbers

Step 1 The recurrent equation of Catalan numbers for all integers

C C C n 0 n = ∑ k n−1−k + [ = ]. k

n Step 2 Write down C(z) = ∑n Cnz :

C z C zn C C zn n 0 zn ( ) = ∑ n = ∑ k n−1−k + ∑[ = ] n k,n n

C zk z C zn−1−k 1 = ∑ k ∑ n−1−k + k n

k n = ∑Ck z z ∑Cnz + 1 k n

= zC 2(z) + 1 Catalan numbers

Step 1 The recurrent equation of Catalan numbers for all integers

C C C n 0 n = ∑ k n−1−k + [ = ]. k

n Step 2 Write down C(z) = ∑n Cnz :

C z C zn C C zn n 0 zn ( ) = ∑ n = ∑ k n−1−k + ∑[ = ] n k,n n

C zk z C zn−1−k 1 = ∑ k ∑ n−1−k + k n

k n = ∑Ck z z ∑Cnz + 1 k n

= zC 2(z) + 1 Catalan numbers (2)

Step 3 Solving the quadratic equation zC 2(z) − C(z) + 1 = 0 for C(z) yields directly: √ 1 1 4z C z ± − ( ) = 2z . (Solution with "+" isn't proper as it leads to C0 = C(0) = ∞.) Step 4 From the binomial theorem we get:

√ 1/2 k 1 −1/2 k 1 − 4z = (−4z) = 1 + (−4z) ∑ k ∑ 2k k − 1 k>0 k>1

−1/2 n2n Using the equality for binomials n = (−1/4) n we nally get √ 1 − 1 − 4z 1 −1/2 k 1 C(z) = = (−4z) − 2z ∑ k k − 1 k>1 n −1/2 (−4z) = ∑ n n + 1 n>0 2n zn = ∑ n n + 1 n>0 Catalan numbers (2)

Step 3 Solving the quadratic equation zC 2(z) − C(z) + 1 = 0 for C(z) yields directly: √ 1 1 4z C z ± − ( ) = 2z . (Solution with "+" isn't proper as it leads to C0 = C(0) = ∞.) Step 4 From the binomial theorem we get:

√ 1/2 k 1 −1/2 k 1 − 4z = (−4z) = 1 + (−4z) ∑ k ∑ 2k k − 1 k>0 k>1

−1/2 n2n Using the equality for binomials n = (−1/4) n we nally get √ 1 − 1 − 4z 1 −1/2 k 1 C(z) = = (−4z) − 2z ∑ k k − 1 k>1 n −1/2 (−4z) = ∑ n n + 1 n>0 2n zn = ∑ n n + 1 n>0 −1/2 n2n Proof that n = (−1/4) n

We prove a bit more: for every r ∈ R and k > 0,

k 2k  1  (2r) r k · r − = 2 22k −1/2 n2n Proof that n = (−1/4) n

We prove a bit more: for every r ∈ R and k > 0,

k 2k  1  (2r) r k · r − = 2 22k

Indeed,

 1 k  1   3   1  r k r r r r 1 r r k 1 r k 1 · − 2 = · − 2 · ( − ) · − 2 ···( − − ) · − 2 − + 2r 2r − 1 2r − 2 2r − 3 2r − 2k − 2 2r − 2k + 1 = 2 · 2 · 2 · 2 ··· 2 · 2 2k (2r) = 22k −1/2 n2n Proof that n = (−1/4) n

We prove a bit more: for every r ∈ R and k > 0, k 2k  1  (2r) r k · r − = 2 22k Indeed,  1 k  1   3   1  r k r r r r 1 r r k 1 r k 1 · − 2 = · − 2 · ( − ) · − 2 ···( − − ) · − 2 − + 2r 2r − 1 2r − 2 2r − 3 2r − 2k − 2 2r − 2k + 1 = 2 · 2 · 2 · 2 ··· 2 · 2 2k (2r) = 22k Then for r = k = n, dividing by (n!)2 and using nn = n!, n n − 1/2  1  2n n = 4 n :

k k and as r k = (−1)k (−r) = (−1)k (−r + k − 1) , −1/2 n − (n − 1/2) − 1 (−1)n 2n n = n = 4n n Q.E.D. Resume Catalan numbers

Formulae for computation

C 2(2n+1) C , with C 1 n+1 = n+2 n 0 = C 1 2n n = n+1 n C 2n 2n  2n−1 2n−1 n = n − n−1 = n − n+1 √ 1− 1−4z Generating function: C(z) = 2z Eugéne Charles Catalan (18141894)

Cn lim = 4 n →∞ Cn−1

n 0 1 2 3 4 5 6 7 8 9 10 Cn 1 1 2 5 14 42 132 429 1 430 4 862 16 796 Applications of Catalan numbers

Number of complete binary trees with n + 1 leaves is Cn

The Dyck language consists of exactly n characters A and n characters B, and every prex does not contain more B-s than A-s. For example, there are ve words with 6 letters in the Dyck language:

AAABBB AABABB AABBAB ABAABB ABABAB

Corollary

Cn is the number of words of length 2n in the Dyck language. Applications of Catalan numbers

Number of complete binary trees with n + 1 leaves is Cn

The Dyck language consists of exactly n characters A and n characters B, and every prex does not contain more B-s than A-s. For example, there are ve words with 6 letters in the Dyck language:

AAABBB AABABB AABBAB ABAABB ABABAB

Corollary

Cn is the number of words of length 2n in the Dyck language. Applications of Catalan numbers (2)

Monotonic paths

Cn is the number of monotonic paths along the edges of a grid with n × n square cells, which do not pass above the diagonal. A monotonic path is one which starts in the lower left corner, nishes in the upper right corner, and consists entirely of edges pointing rightwards or upwards. Applications of Catalan numbers (3)

Polygon triangulation

Cn is the number of dierent ways a convex polygon with n + 2 sides can be cut into triangles by connecting vertices with straight lines.

See more applications, for example, on http://www.absoluteastronomy.com/topics/Catalan_number Next section

1 Convolutions Fibonacci convolution m-fold convolution Catalan numbers

2 Exponential generating functions Exponential generating function

Denition

The exponential generating function (briey, egf) of the sequence hgni is the function

gn n Gb (z) = z , ∑ n! n>0

that is, the generating function of the sequence hgn/n!i. For example, ez zn is the egf of the constant sequence 1. = ∑n>0 n! Exponential generating function

Denition

The exponential generating function (briey, egf) of the sequence hgni is the function

gn n Gb (z) = z , ∑ n! n>0

that is, the generating function of the sequence hgn/n!i. For example, ez zn is the egf of the constant sequence 1. = ∑n>0 n! Why exponential generating functions?

Because hgn/n!i might have a simpler generating function than hgni has. Exponential generating functions: Basic maneuvers

Let Fb(z) and Gb (z) be the exponential generating functions of hfni and hgni. As usual, we put fn = gn = 0 for every n < 0, and undefined · 0 = 0.   αfn + βgn n αFb(z) + βGb (z) = ∑ z n n! n c gn n Gb (cz) = ∑ z n n! ngn−1 n zGb (z) = ∑ z n n! gn+1 n Gb 0(z) = ∑ z n n! z Z gn−1 n Gb (w)dw = ∑ z 0 n n! 1 n ! F z G z f g zn b( ) · b ( ) = ∑ n ∑ k k n−k n ! k Exponential generating functions: Basic maneuvers

Let Fb(z) and Gb (z) be the exponential generating functions of hfni and hgni. As usual, we put fn = gn = 0 for every n < 0, and undefined · 0 = 0.   αfn + βgn n αFb(z) + βGb (z) = ∑ z n n! n c gn n Gb (cz) = ∑ z n n! ngn−1 n zGb (z) = ∑ z n n! gn+1 n Gb 0(z) = ∑ z n n! z Z gn−1 n Gb (w)dw = ∑ z 0 n n! 1 n ! F z G z f g zn b( ) · b ( ) = ∑ n ∑ k k n−k n ! k Exponential generating functions: Basic maneuvers

Let Fb(z) and Gb (z) be the exponential generating functions of hfni and hgni. As usual, we put fn = gn = 0 for every n < 0, and undefined · 0 = 0.   αfn + βgn n αFb(z) + βGb (z) = ∑ z n n! n c gn n Gb (cz) = ∑ z n n! ngn−1 n zGb (z) = ∑ z n n! gn+1 n Gb 0(z) = ∑ z n n! z Z gn−1 n Gb (w)dw = ∑ z 0 n n! 1 n ! F z G z f g zn b( ) · b ( ) = ∑ n ∑ k k n−k n ! k Exponential generating functions: Basic maneuvers

Let Fb(z) and Gb (z) be the exponential generating functions of hfni and hgni. As usual, we put fn = gn = 0 for every n < 0, and undefined · 0 = 0.   αfn + βgn n αFb(z) + βGb (z) = ∑ z n n! n c gn n Gb (cz) = ∑ z n n! ngn−1 n zGb (z) = ∑ z n n! gn+1 n Gb 0(z) = ∑ z n n! z Z gn−1 n Gb (w)dw = ∑ z 0 n n! 1 n ! F z G z f g zn b( ) · b ( ) = ∑ n ∑ k k n−k n ! k Exponential generating functions: Basic maneuvers

Let Fb(z) and Gb (z) be the exponential generating functions of hfni and hgni. As usual, we put fn = gn = 0 for every n < 0, and undefined · 0 = 0.   αfn + βgn n αFb(z) + βGb (z) = ∑ z n n! n c gn n Gb (cz) = ∑ z n n! ngn−1 n zGb (z) = ∑ z n n! gn+1 n Gb 0(z) = ∑ z n n! z Z gn−1 n Gb (w)dw = ∑ z 0 n n! 1 n ! F z G z f g zn b( ) · b ( ) = ∑ n ∑ k k n−k n ! k Exponential generating functions: Basic maneuvers

Let Fb(z) and Gb (z) be the exponential generating functions of hfni and hgni. As usual, we put fn = gn = 0 for every n < 0, and undefined · 0 = 0.   αfn + βgn n αFb(z) + βGb (z) = ∑ z n n! n c gn n Gb (cz) = ∑ z n n! ngn−1 n zGb (z) = ∑ z n n! gn+1 n Gb 0(z) = ∑ z n n! z Z gn−1 n Gb (w)dw = ∑ z 0 n n! 1 n ! F z G z f g zn b( ) · b ( ) = ∑ n ∑ k k n−k n ! k Binomial convolution

Denition

The binomial convolution of the sequences hfni and hgni is the sequence hhni dened by: n h f g n = ∑ k k n−k k Binomial convolution

Denition

The binomial convolution of the sequences hfni and hgni is the sequence hhni dened by: n h f g n = ∑ k k n−k k

Examples

h(a + b)ni is the binomial convolution of hani and hbni.

If Fb(z) is the egf of hfni and Gb (z) is the egf of hgni, then Hb (z) = Fb(z) · Gb (z) is the egf of hhni, because then:

hn fk gn−k n = ∑ k n k ! k ! ( − )! Bernoulli numbers and exponential generating functions

Recall that the Bernoulli numbers are dened by the recurrence:

m m 1 + B m 0 m 0 ∑ k k = [ = ] ∀ > , k=0

which is equivalent to:

n ∑ Bk = Bn + [n = 1] ∀n > 0. n k

The left-hand side is a binomial convolution with the constant sequence 1. Then the egf Bb(z) of the Bernoulli numbers satises

z Bb(z) · e = Bb(z) + z :

which yields z Bb(z) = . ez − 1 Bernoulli numbers and exponential generating functions

Recall that the Bernoulli numbers are dened by the recurrence:

m m 1 + B m 0 m 0 ∑ k k = [ = ] ∀ > , k=0

which is equivalent to:

n ∑ Bk = Bn + [n = 1] ∀n > 0. n k

To make a comparison:

B z 1 d2 Z ∞ n zn B+zn ln tz−1e−t dt = z but n = 2 ∑ n! e − 1 ∑ z dz 0 n>0 n>0

+ where Bn = Bn · [Bn > 0].