chapter 6 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 6 PowerPoint Presentation
Download Presentation
Chapter 6

Loading in 2 Seconds...

play fullscreen
1 / 48

Chapter 6 - PowerPoint PPT Presentation


  • 136 Views
  • Uploaded on

Chapter 6. Advanced Counting Techniques. Contents. Recurrence Relations Solving Recurrence Relations Divide-and-conquer Relations The Inclusion-Exclusion principle Applications of the Inclusion-Exclusion principle Generating Functions. 6.1 Recurrence relations.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

Chapter 6


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 6

Chapter 6

Advanced Counting Techniques

contents
Contents
  • Recurrence Relations
  • Solving Recurrence Relations
  • Divide-and-conquer Relations
  • The Inclusion-Exclusion principle
  • Applications of the Inclusion-Exclusion principle
  • Generating Functions
6 1 recurrence relations
6.1 Recurrence relations
  • #bacteria doubles every hour.

Initially (t=0), there are 5 bacteria

==> #bacteria after n hours = ?

sol: Let an = #bacteria after n hours.

=> a0 = 5 --- (1) initial condition

an = 2 an-1 for n > 0. --- (2) recurrence relation

(1) and (2) uniquely determine an for all n  N.

-- called a recurrence definition of the sequence a0,a1,..={an}nÎN

Goal: find explicit formula for an satisfying the recurrence relation (and initial conditions)

definition of recurrence relations
Definition of recurrence relations
  • A recurrence relation for the sequence {an} is a formula that express an in terms of one or more of the previous terms of the sequence (i.e., some aj's with j < n).
    • i.e., an = f(n, an-1,an-2,…,a0) is a function of n and an-1,…,a0.
  • A sequence is called a solution of a recurrence relation if its terms satisfy the recurrence relation.

Ex1: If {an} satisfies

(1) an = an-1 - an-2 for n = 2,3,...

(2) a0=3, a1 = 5.

=> a2 = ? and a3 = ?

  • Many problems can be modeled(or expressed) more naturally by recurrence relations.
recurrence relation example
recurrence relation example

Ex3: deposit $10,000 in an account with

11% compound interest annually.

==> How much will be in the account after 30 years ?

Sol: let Pn = amount of the account after n years

==> 1. p0 = 10,000

2. pn = pn-1 + pn-1 x 0.11.

==> Pn = 1.11 Pn-1 = 1.112 Pn-2=...= 1.11n P0 = 1.11n x 10000.

==> P30 = 1.1130 x 10000 = 22,892,297.

Ex4: Rabbits and Fibonacci number.

A pair of rabbits produce one pair per month after 2 month old.

Initially there is only one pair.

=> How many pairs of rabbits are there after n months?

sol: fn = #pairs after n months.

=>1. f0 = f1 = 1 --initial case 2. fn = fn-1 + fn-2 for n > 1 , where fn-1: #old-rabbits and f n-2 is #new born rabbits.

more recurrence examples
More recurrence examples
  • (The tower of Hanoi) 3 pegs: A,B,C. Initially n disks placed on peg A. Disks can be moved from peg to peg only if the disk is on top of the original disk and smaller than that on top of the target peg.The goal is to have all disks moved to the 2nd pegs.
  • Let Hn = #moves required to solve the problems with n disks

=> Hn = ?

Sol: 1. H1 = 1.

2. Hn = H n-1 + 1 + H n-1 = 2Hn-1 + 1.

A--n-->B A--n-1-->C A--1-->B C--n-1-->B.

Hence Hn = 2 Hn-1 + 1 = 22 Hn-2 + 2 + 1 = ...

= 2n-1 H1 + 2n-2 + ... + 1 = 2 n -1.

  • How big is H64 ?

: assume one move takes 1 sec => 264 - 1 = 1.8 x 10 19 = 500 billion years!!

more recurrence examples1
more recurrence examples

Ex6: #bit strings of length n not containing two consecutive 0s.

sol: an = #bit strings of such kind of length n.

==> 1. a0 = 1, a1 = 2.

2. an = #bits string ending with 1 + #bit-strings-ending with 10

= an-1 + an-2.

Ex7: an = # n-digit-strings containing an even number of 0.

Sol: valid strings must be in one of the forms:

1. x1 x2 ... xn-1 xn with xn = 1..9 or

2. x1 x2 ... xn-1 0 with x1 x2 ... xn-1 containing odd number of 0.

==> 1. a0 = 1, a1 = 9.

2. an = an-1 x 9 + (10n-1 - an-1) for n > 1.

6 2 solving recurrence relations
6.2 Solving recurrence relations
  • Linear homogeneous recurrence relation of degree k with constant coefficients: any recurrence of the form:

an = c1 an-1 + c2an-2+...+ckan-k,

where k > 0 and every cj is a constant.

Theorem: The recurrence relation: an = c1 an-1 + c2an-2+...+ckan-k,

and initial conditions: a0 = t0, ..., ak-1 = tk-1 uniquely determine a sequence (satisfying both conditions)

Pf: 1. Existence: trivial. (by Math Ind)

2. Uniqueness: If {an} and {bn} satisfy the relation =>

{an} = {bn} (i.e., an =bn for all n.)

simple math. ind. Left as an exercise.

solving linear homogeneous recurrence relations with constant coefficients
Solving linear homogeneous recurrence relations with constant coefficients
  • an = c1 an-1 + c2an-2+...+ckan-k -- (1) : a recurrence relation
    • => an = rn is a solution of (1) iff

rk = c1 rk-1 + c2 rk-2+...+ck rk-k -------(2)

    • (2) is called the characteristic equation of (1)
slide10
an = c1 an-1 + c2an-2 ------ (3) a recurrence relation

Theorem 1: If r2 = c1 r + c2has two distinct roots r1, r2 then sequence {an} is a solu of (3) iff

an = d1 r1n + d2 r2n for n = 0,1,2,.. (*) where d1 and d2 are constants.

pf: <= : simple substitution.

=>: Let b0,b1,... be any solution of (3).

==> For {bn} to satisfy (*) ==> b0 = d1 + d2; b1 = d1r1 + d2 r2

==> (by ind.) for any k > 1:

bk = c1bk-1 + c2bk-2 = (by ind.hyp.) c1(d1r1k-1+d2r2k-1) + c2 (d1r1k-2 +d2r2k-2) = d1(c1r1k-1+c2r1k-2) +d2(c1r2k-1+c2r2k-2)

= (by *) d1 r1k + d2 r2 k. QED

examples
Examples:

Ex3: Find solu of an = an-1 + 2 an-2 for n > 1 and a0 = 2 and a1 = 7.

sol: char equ: r2 = r +2 has roots 2, -1.

Hence an = d1 2n + d2 (-1)n for all n for some d1, d2.

==> a0 = d1 + d2

a1 = 2 d1 - d2 => d1 = 3; d2 = -1

==> an = 3 x 2n - (-1)n for n ³ 0.

slide12
Ex4: find solu of the Fibonacci sequence: f1=f0=1 and fn = fn-1 + fn-2 for n > 1.

Sol: The char equ: r2 = r + 1 has roots:

a=(1+rt(5)) /2,

b=(1-rt(5))/2. note: 1<a<2 and -1 < b <0.

Hence fn = d1an + d2bn with

f0 = 1 = d1 + d2 and

f1 = 1 = d1a + d2b

  • => d1 = rt(5)/5 and d2 = -rt(5)/5.

=> fn = d1an + d2bn = O(an) grows exponentially.

solving recurrence relation
Solving recurrence relation

Theorem 2: If r2 = c1 r + c2has only one r0 then any sequence {an} is a solu of (3) iff an = d1 r0n + d2 n r0n for n = 0,1,2,.. (*) where d1 and d2 are any constants.

Pf: => : Similar to Theorem 1.

<= : a n-1 = d1 r0n-1 + d2 (n-1) r0n-1

a n-2 = d1 r0n-2 + d2 (n-2) r0n-2

==> c1 an-1 + c2 an-2= d1 (c1 r0n-1 + c2 r0n-2) +

d2 (c1(n-1) r0n-1 + c2(n-2) r0n-2)

= d1 r0n-2(c1 ro + c2) + d2 r0n-2((n-1)(c1ro+c2) -c2)

= d1 r0n + d2 r0n-2((n-1) r02 + r02) -- since r2- c1r -c2 = (r-r0)2.

= d1 r0n + d2 n r0n

slide14
Ex5: find solu. of an = 6an-1 - 9 an-2

with a0 = 1 and

a1 = 6.

sol: the char equ has one root 3.

=> an = d1 3n + d2 n 3 n.

=> d1 = 1 and 3d1 + 3 d2 = 6

=> an = 3n + n 3n. for n ≥ 0.

generalization
Generalization

Theorem 3': If the equ. rk = c1 rk-1 + c2rk-2+...+ ck has solutions r1m1, r2m2,..,rsms (with m1+...+ms = k) where mi is the multiplicity of the root ri.

(i.e. rk - c1 rk-1 +...-ck = Pi=1..s (x-ri)mi ) then

{an} is a solution of the recurrence relation:

an = c1 an-1 +...+ck an-k iff

an = Si=1,s (Sj=0,mi-1 dij nj rin ), where dij's are constants.

Ex: The recurrence relation an = 5 an-1 + 9 an-2 -7 an-3 + 2 an-4

has char. equ. r4 = 5r3 -9r2 -7r + 2, which is equ. to

(r-2)(r-1)3 = 0. Hence r has roots: 2, 13.

Then the relation has general solu: an = d02n + e01n + e1 n1n + e2 n21n. where d0, e0,e1 and e2 are constants determined by initial conditions.

simultaneous recurrence relations
simultaneous recurrence relations

Ex24: Solving the simultaneous recurrence relations:

1. an = 3 an-1 + 2 bn-1

2. bn = an-1 + 2 bn-1, with a0 = 1 and b0 = 2.

sol: (1,2) can be represented in matrix form:

Let Y be the eigenvector of A: (I.e., AY = lY for some l.)

=> (A-lI)Y = 0 => det(A-lI) = 0 => (3-l)(2-l) - 2 = 0 => l =1,4.

=> Y1 = (1,-1)T and Y2 = (2,1)T. Now assume X0 = d1Y1 + d2 Y2

=> Xn = A Xn-1 = ... = An Xo = An-1 (AX0) = An-1 (d1AY1 + d2AY2) = An-1 (d1l1Y1 + d2l2Y2) = ... = d1l1n Y1 + d2l2n Y2.

6 3 divide and conquer relations
6.3 Divide-and-conquer relations
  • f(n): resources (time or space) needed to solve a problem of size n. Then

f(n) = a f(n/b) + g(n) : where

    • a : the number of subproblems
    • n/b : size of each subproblem
    • g(n) : cost for splitting problem and combining solutions
  • Problem: How to estimate the size of f(n) ?
  • f(n) = a f(n/b) +g(n) = a2f(n/b2) + a g(n/b) + g(n)

= .... = akf(n/bk) + Sj=0,k-1 ajg(n/bj).

Hence if n = bk ==> f(n) = akf(1) + Sj=0,k-1 ajg(n/bj) ----- (1)

Theorem 1: If f(n) = a f(n/b) + c, where a ³ 1, b > 1 and c > 0, is an increasing function, then

f(n) = O(n(logba)) if a > 1 and

= O(log n) if a = 1.

proof
proof:

Pf: If n = bk, by (1), f(n) = akf(1) + Sj=0,k-1 aj c.

If a = 1 ==> f(n) = f(1) + Sj=0,k-1 c = f(1) + ck = O(log n).

If a > 1 ==> f(n) = akf(1) + Sj=0,k-1 aj c

= akf(1) + c(ak-1) /(a-1) = ak[f(1) + c/(a-1)] - c/(a-1)

= c1 algbn + c2 = c1 nlogba + c2 = O(nlogba).

If bk < n < bk+1 is not a power of b.

==> f(n) < f(bk+1) = c1 ak+1 + c2 < c1a alogbn + c2 = O(nlogba ) .

Ex: If f(n) = 5 f(n/2) + 3.

=> a = 5 > 1; c = 3; b = 2. ==> f(n) = O(nlogba ) = O(nlg 5 )

If f(n) = 2 f(n/2) + 2

==> f(n) = O(nlg 2) = O(n) is linear.

divede and conquer relations cont d
divede-and-conquer relations(cont'd)

Theorem 2: If f(n) = a f(n/b) + cnd, where a ³ 1, b > 1 and c,d > 0, is increasing, then

f(n) = O(nd) if a < bd// nd dominates if #subproblems is small

= O(nd lg n) if a = bd// every level of problems requires nd.

= O(nlogba ) if a > bd.// nd (conquer effort) has no effect.

Pf: f(bk) = a f(bk-1) + cbkd = a2f(bk-2) + c a bd(k-1) + c bdk.

= .... = akf(1) + Sj=0,k-1 cbkd (a/bd)j

= f(1) ak + cbkd (1-(a/bd)k)/(1 - (a/bd)).

case 1: n = bk. (k = logb n)

Hnece if a < bd ==> f(n) = f(1) ak + cbkd (1-(a/bd)k)/(1 - (a/bd))

£ O(bkd) = O(bd logbn) = O(nd).

If a = bd =>f(n) = f(1) ak + ckbkd = O(kbkd) = O(nd lg n) .

If a > bd => f(n) = f(1) ak + cbkd (1-(a/bd)k)/(1 - (a/bd)).

£ f(1) ak + cbkd (a/bd)k = O(ak) = (nlogba).

the master theorem
The master theorem:

case 2: bk < n < b k+1:

=> f(bk) £ f(n) £ f(bk+1).

But O(f(bk)) = O(f(bk+1)), hence O(f(n)) =O(f(bk)). QED

Ex8:Fast integer multiplication:

A = (a2n-1 a2n-2 ... a1 a0)

B = (b2n-1 b2n-2 ... b1 b0)

AH = (a2n-1...an); AL = (an-1,...,a0); BH = ..., BL = ...

=> A x B = (2n AH + AL) x (2nBH + BL) = 22n AHBH + 2n(AHBL + ALBH) + (ALBL)

=> f(n) = 4f(n/2) + O(n) => f(n) = O(n lg 4) = O(n2) - no improving !!

But AXB = 22n AHBH + 2n(AHBL + ALBH) + (ALBL)

= 22n AHBH + 2n((AH+AL)(BH+BL)) - AHBH - ALBL) + (ALBL)

==> f(n) = 3f(n/2) + O(n) => f(n) = O(nlg 3) < O(n2).

more examples
More examples:
  • Fast matrix multiplication:(Ex4 & 9)

one nxn matrix multiplication can be divided into

7 (n/2)x(n/2) multiplications + 15 (n/2)x(n/2) additions.

=> f(n) = 7 f(n/2) + 15n2/4

=> a = 7, b = 2, d = 2. => a > bd = 4.

=> f(n) = O(n lg 7) = O(n2.81).

Better than direct multiplication(=O(n3)) !!

Although even better result (O(n2.376 )) is possible.

6 5 inclusion exclusion principle

2

1

1

3

2

2

1

1

1

1

0

1

1

1

6.5 Inclusion-Exclusion principle

The principle: A, B : two finite sets

=> |AUB| = |A| + |B| - |A Ç B|.

Ex2: #positive integers < 1000 and dividable by 7 or 11 = ?

sol: let A ={x | x < 1000 and 7 | x}

B = {x | x < 1000 and 11 |x}.

=> |AÇB| ={x | x < 1000 and 77 | x}

=> |AUB| = |A| + |B| - |AÇB|

=⌊ 1000/7⌋ + ⌊1000/11 ⌋- ⌊1000/77 ⌋

= 220.

Problem: |AUBUC| = ?

|A| +|B|+|C| -|AÇB|-|AÇC||BÇC|+|AÇBÇC|

|A|+|B|+|C|

|A|+|B|+|C| -|AÇB|-|AÇC|-|BÇC|

the general inclusion exclusion principle
The general inclusion-exclusion principle

Theorem 1: |A1 U A2 ...UAn | = S1£i£n |Ai| - S1£i<j£n|AiÇAj| + S1£i<j<k£n|AiÇAjÇAk| - ... +(-1)n+1 |A1ÇA2Ç...ÇAn| ---(*)

pf: Let a be any element belonging to exactly Ad1, Ad2,...,Adr. (i.e., ∉ Ad for d ∈ {1,…,n} - {d1,…,dr}.)

==> It is counted C(r,s) times by the sum:

S1≤j1<j2<...<js ≤n |Aj1ÇAj2Ç...ÇAjs|.

(note: C(r,s) = 0 if r < s).

==> # a counted by (*) = C(r,1) - C(r,2) + ... +(-1)n+1 C(r,n)

= C(r,1) - C(r,2) + ... +(-1)r+1 C(r,r)

= (-1) [ C(r,0) - C(r,1) + C(r,2) + ... +(-1)r C(r,r) ] + C(r,0)

= - (1-1)r + C(r,0) = 1

6 6 applications of the ie principle
6.6 Applications of the IE principle
  • Alternative form:

|~A1Ç~A2... Ç~An)| = |~(A1UA2...UAn)|

= |U| - | A1UA2...UAn |

= |U| - S|Ai| + S|AiÇAj| -... + (-1)n |A1Ç...ÇAn|.

Ai : set of elements having property Pi.

N(Pj1,...,Pjk) = #elements with properties Pj1,...,Pjk.

(i.e. N(Pj1,...,Pjk) = |Aj1Ç ...ÇAjk|. )

~Pj : the negation of property Pj.

N(~Pj1,...,~Pjk)) = #elements without any property of Pj1,..,pjk.

= N(~(Pj1\/...\/Pjk)) = |U| - |Aj1.. Ajk|.

  • N(~P1,...~Pn))

= |U| – SN(Pi) + SN(PiPj) - S N(PiPjPk) +... +(-1)n N(P1P2...Pn).

examples1
Examples:

Ex1: x1+x2+x3 = 11, 0 £ x1 £3, 0£ x2 £ 4, 0 £ x3 £ 6.

==> #integer solutions = ?

Sol: let P1 = "x1 > 3"; P2 = "x2 > 4"; P3 = "x3 > 6".

=>#sol = N(~p1/\~p2/\~p3) = N(~(P1\/P2\/P3))

= N - N(p1) - N(P2) - N(P3) +N(p1/\P2) +N(P1/\P3) + N(P2/\P3)

- N(N(p1/\P2/\P3)

=> N = C(11+2, 2);

N(p1) = #sol with x1 > 3 = #sol of "x1' + x2 + x3 = 7" = C(9,2)

N(p2) = C(8,2); N(P3) = C(6,2).

N(p1/\P2) = #slo with X1> 3 and X2 > 4 = #sol of "x1'+x2'+X3 = 2" = C(4,2) = 6.

N(P1/\P3) = C(0+2,2) = 0; N(P2/\P3) = 0.

N(P1/\P2/\P3) = 0.

=> #sol = 78 - 36 - 28 - 15 + 6+ 1 + 0 - 0 = 6.

more example
More example

Ex2: #positive integers < 101 and dividable by 4, 5 or 6.

A = {x : 4|x}; B = {x: 5|x }; C= {x: 6|x}.

=> |A| +|B|+|C| = [100/4] + [100/5] + [100/6] = 25 + 20 + 16 =61.

|AÇB|+|AÇC|+|BÇC| = [100/20] +[100/12] + [100/30] =16

|AÇBÇC| = [100/60] = 1. => #sol = 61-16+1 =46.

Ex3': |A|= m, |B| = n, m  n. #onto function f:A -> B = ?

Let B = {b1,...,bn} and Pi = "bi is not in the range of the fun"

=> N(Pi) = |Ci|= |{f | f:A->B and bi ∉ f(A)}|.

#ontos = N(~P1/\~P2.../\~Pn) = N(~(P1\/...\/Pn))

= |U| - |C1 U C2 U... U Cn|

= nm - S|Ci| + S|Ci Ç Cj| - ... +(-1)n |C1ÇC2Ç...ÇCn|

= nm - C(n,1)(n-1)m + C(n,2)(n-2)m -... +(-1)n-1 C(n,n-1) 1 m.

more examples cont d
more examples (cont'd)

Ex3: #ways to assign 5 jobs to 4 people s.t. each one is assigned at least one job.

sol: m =5, n = 4.

#ways = 45 -C(4,1)35 + C(4,2)25+C(4,3)15

= 1024 - 972 + 192 - 4 = 240.

Ex4: [The hatcheck problem:] n hats randomly returned to the customers. => What is the probability that no one receives his own hat?

derangements
Derangements
  • x1,x2,...,xn: a list

Any permutation a1,...,an of {x1,...,xn} s.t. aj¹ xj for all j = 1..n is called a derangement of the list.

Ex: 1,2,3,4,5 has derangement

21453 but not 21543

Let Dn = # derangements of n objects.

=> D1 = 0, D2 = 1, D3 = 2. (123 has derangements: 231, 312)

Theorem: Dn = n! (1- 1/1! + 1/2! +... + (-1)n /n! )

Pf: let Pi =def "a=a1...an is a perm of x1...xn s.t. ai = xi."

=> Dn = N(~P1/\~P2/\../\~Pn) = N(~(P1\/P2\/..\/Pn))

= N -SN(Pi) + SN(Pi/\Pj) -... + (-1)nN(p1/\../\Pn)

= n! -C(n,1)(n-1)! +C(n,2)(n-2)! + ... +(-1)nC(n,n)(n-n)!

= n![1 - 1/1! + 1/2! .. ].

=> solu of the hatcheck problem = Dn / P(n,n) = Dn /n! ∈[0.3,0.5]

= (1 -1/1! + 1/2!-...) e-1 = 0.368 as n ¥ .

6 4 generating functions
6.4 Generating Functions
  • Goal: transform combinatorial problems into algebraic problems.
  • Definition 1: The generating function for the sequence a0,a1,…,an,… of real numbers is the infinite series:

G(x) = a0 + a1 x + … + ak xk + … = Sk = 0.. akxk.

    • also called the ordinary generating function to distinguish it from other kind of generating functions.
  • EX:
    • {an} = 3,3,…,3,… => G(x) = Sk = 0.. 3xk.
    • {bn} =1,2,3,… => G(x) = 1 + 2x + 3x2+… = Sk = 0.. (k+1)xk.
    • {Cn} = 1,2,4,8,… => G(x) = 1 + 2x + 2x2+… = Sk = 0.. 2kxk.
more examples1
More Examples

Ex2: {ak }k = 0..5 = 1,1,1,1,1,1. Then

G(x) = 1 + x + x2 + x3 + x4 + x5.

= (x6 -1) / (x -1)

Ex3: m: a positive integer, ak = C(m,k) for k = 0..m. Then

G(x) = C(m,0) + C(m,1)x + C(m,2) x2 +…+ C(m,m) xm

= (1+x)m.

some facts about formal power series
Some facts about formal power series
  • When generating functions are used to solve counting problems, they are usually represented as formal power series.
    • convergence problem ignorable here.

Ex4: f(x) = 1/(1-x) is the generating function of the series:

1,1,1,… since

1/(1-x) = 1 + x + x2+… for |x| < 1.

Ex5: f(x) = 1/(1-ax) is the generatign function of the series:

1,a,a2,a3,… since

1/(1-ax) = 1 + ax + a2x2+ … for |x| < 1 / |a| .

sum and product of generating functions
sum and product of generating functions
  • Theorem 1 : Let f(x) = Sk = 0.. akxk, g(x) = Sk = 0.. bkxk. Then
    • f(x) + g(x) = Sk = 0.. (ak+bk ) xk.
    • f(x) g(x) = (a0 + a1x + a2x2+…) * (b0 + b1x1+ b2x2+…)
    • = Sk = 0..(Sj= 0..k akbk-j) xk.
    • I.e., f(x) + g(x) is the generating function of the sum of both sequences:
    • { ak+bk },
    • while
    • f(x)g(x) is the generating function of the sequence:
    • {ck} where ck = Sj= 0..k akbk-j ,
    • { ck} is called the convolution of {ak} and {bk}.
slide33
Ex 6

Since 1/(1-x) = 1 + x + x2 + x3+ … (*)

we have 1/(1-x)2

= (1 + x + x2 + x3+ …)(1 + x + x2 + x3+ … )

= 1 + (1x + x 1) + (1 x2 + x x + x2 1) + …

= Sk = 0.. (Sj= 0..k 1)xk = Sk = 0.. (k+1)xk.

Hence 1/(1-x)2 is the generating function of the seq:

1,2,3,4,… = { k+1 }k = 0..

Another approach: take derivatives on both sides of (*), we get

(1-x)-2 = 1 + 2x + 3x2 + … = Sk = 0.. (k+1)xk.

extended binominal coefficients
Extended Binominal Coefficients

Definition 2: u: real number, k : nonnegative integer. Then the extended binominal coefficient C(u,k) is defined by

C(u,k) = u (u-1) … (u-k+1) / k! if k > 0, and

1 if k = 0.

EX 7: 1. C(-2, 3) = -2 -3 -4 / 3! = - 4.

2. C(1/2, 3 ) = (1/2)(1/2-1) (1/2 – 2) /3!

= 1 (-1) (-3) / (2 * 2 * 2 * 6) = 1/16.

EX 8: n, r: nonnegative integers . Then

C(-n, r) = (-n) (-n-1) … (-n –r+1) /r!

= (-1) r P(n+r-1, r) /r!

= (-1)r C(n+r-1, r).

the extended binominal theorem
The Extended Binominal Theorem

Theorem 2: Let x be a real number with |x| < 1 and let u be a real number. Then

(1+x)u = Sk = 0.. C(u, k) xk, and hence

(x+y)u = yu(1+ (x/y))u = Sk = 0.. C(u, k) xkyu-k.

pf: Let f(x) = (1+x)u. By Tayler ‘s theorem

f(x) = f(a) + (x-a)f'(a) + (x-a)2f(2)(a)/2! +...+ (x-a)nf(n)(a)/n! + …

Now select a = 0, we have

f(x) = f(0) + f'(0) x + f(2)(0)/2! x2+...+ f(n)(0)/n! xn+ …

where f(k)(0) = u (u-1) … (u-k+1) (1+x)u-k |x = 0 = P(u,k) .

hence f(x) = Sk = 0.. C(u, k) xk.

Note: when u is a positive integer, Theorem 2 reduces to the normal Binominal theorem since ,when k > u,

C(u,k) = 0 and Sk = 0.. C(u, k) xk = Sk = 0..u C(u, k) xk.

slide36
Ex 9

Ex9 : Find the formal power series for (1+x) –n and (1-x)-n,where n > 0.

Sol:

  • (1+x) –n = Sk = 0.. C(-n, k) xk.
  • = Sk = 0.. (-1)k C(n+k-1, k) xk.
  • Replacing x by –x, we have
  • (1-x) -n = Sk = 0.. (-1)k C(n+k-1, k) (-x) k
  • = Sk = 0.. C(n+k-1, k) xk.
more facts
More facts
  • If G(X) =«a0,a1,…» is the generating function (gf) of the seq {an}. Then
    • xG(x) =«0, a0,a1,a2,…» is the gf of {an} >>1. [shift right]
    • xk G(x) =«0,0,…,0, a0,a1,…» is the gf of {an} >> k.
    • (G(x)-a0)/x = «a1,a2,…» is the gf of {an} << 1 [shift left]
    • d G(x) / dx = «a1, 2a2, 3a3,…» is the gf of { (n+1) an+1 }n=0…
    •  G(x) dx = a0 x + a1x2/2 + a2 x3/3 + …

= «0, a0, a1/2, a2/3,…»

    • is the gf of { an /(n+1) } >> 1.
counting problems and generating functions
Counting problems and generating functions
  • Ex10: Find the number of solutions of e1 + e2 + e3 = 17, where e1,e2 and e3 are nonnegative integers with

2  e1  5, 3 e2 6 and 4e37.

  • Sol: The #solutions is equal to the coefficient of x17 in the expansion of the product:

(x12+x13+x14+x15)(x23+x24+x25+x26)(x34+x35+x36+x37)

The #Solutions is 3 (x5x5x7, x4x6x7 , x5x6x6)

e1=5 e2=6 e3=6

slide42
Ex11: 8 identical cookies distributed among 3 different children with each child receiving at lest 2 cookies and no more than 4 cookies. #possible distributions = ?

Sol: the number is the coefficient of x8 in the product:

(x2+x3+x4)3,

which is equal to 6

( 4+2+2, 2+4+2, 2+2+4, 2+3+3, 3+3+2, 2+3+3).

Ex12: Determine the number of ways to insert coins worth $1,$2 and $5 into a vending machine to pay for an item costing $r, in case (1) the insertion order matters and (2) does not matter.

Sol: (1) order matters: => The possible ways of inserting n coins can be represented by (x + x2 + x5)n.

slide43
So the possible ways of inserting coins is

1 + (x+x2+x3) + (x + x2 + x5)2+ (x + x2 + x5)3+ …

= 1/(1 –x – x2 –x3)

=> possible ways of inserting coins with total value r is

the coeff. of the term xr in the above generating function.

    • for example, if r = 7, then the answer is 26.
    • can be computed by computer algebra system.
  • Order does not matter: possible ways of inserting coins
    • (1+x+x2+x3+…) (1+ x2+ x4 + …) (1+ x5 + x10+ x15+…)
    • = 1/(1-x ) 1/(1-x2) 1/(1-x5)
    • if r = 7, then xr has coefficient 6.
slide44
Ex13 : Find #k-combinations of a set of size n.
  • solu: = coefficient of xk in the product:
    • (x0+x1) (x0+x1) … (x0+x1) = (1+x)n = f(x).
    • By Binominal theorem :
    • f(x) = Sk = 0..n C(n, k) xk where C(n,k) = n! / (k!(n-k)!)
    • hence #k-combinations = C(n,k).
  • Ex14: Find #r-comb from a set with n objects when repetition is allowed.
  • Sol: Let {ar} be the seq where ar = #r-comb with repetition allowed. Then {ar} has generating function:

(1+x+x2+…)… (1+x+x2+…) = (1+x+x2+…)n = (1+(-x))-n.

= Sk = 0..  C(-n,k)(-1)k xk , Thus #r-comb with repetition

= C(n+r-1, r) = H(n,r).

slide45
Ex15: Find the number of ways to select r objects of n different kinds if each kind must be selected at least 1 object.

Sol: G(x) = (x + x2+ x3+ …)n.

= Xn (1+x+x2+…)n = Xn / (1-x)n

= xn(1-x)-n.

= xnSk = 0..  C(-n,k)(-1)k xk

= Sk = 0..  C(n+k-1,k) xk+n

= St = n..  C(t-1,t-n) xt

=> there are C(r-1, r-n) = H(n, r-n) ways to select r objects.

using generating functions to solve recurrence relations
Using generating functions to solve recurrence relations
  • Ex16: Solve the recurrence relation :
    • ak = 3 a k-1 for k >0 , and
    • a0 = 2.
  • Sol: Let G(x) be the generating function of the seq {ak}.

I.e., G(x) = Sk = 0.. akxk. =<a0, a1,a2,… >

=> xG(x) = Sk = 0.. akxk+1 = St = 1.. at-1xt. =<0, a0,a1,… >

=> G(x) – 3xG(x) = Sk = 0.. akxk - St = 1.. 3 at-1 xt.

=<a0, a1-3a0, a2-3a1,…>

= a0 + Sk = 1.. (ak - 3 ak-1 )xk = <2, 0,0,0…> = 2.

=> G(x) = 2/ (1-3x)

= 2(1+ 3x + (3x)2 + … )

Hence ak = 2 3k.

slide47
Ex17: Solve the recurrence relation:
    • a0 = 1,
    • an = 8an-1 + 10n-1 for n > 0. (*)

Sol: Let G(x) be the generating function of the seq {an}.

By (*) we have an xn = 8an-1 xn + 10n-1 xn if n > 0

Since G(X) = «a0=1, a1,…»

G(x) – 1 = « 0,a1,a2,…» = « 0, 8a0 + 100, 8 a1+ 101,…»

= 8 « 0, a0,a1,…» + « 0, 100,101,102,…»

= 8x G(x) + (x + 10x2 + 102x3 + … )

= 8x G(x) + x/(1-10x).

  • G(X) (1-8x) = 1+ x/(1-10x) => G(x) = (1-9x) /(1-8x)(1-10x)

= (½) (1/(1-8x) + 1/(1-10x)) = (½) « 1,8,82,…»+ (½) « 1,10,102,..»

Hence an = ½ (8n + 10n).

slide48
Ex18: Show that Sk = 1..n C(n,k)2 = C(2n,n) using generating functions.

pf: (1+x) 2n = [ (1+x)n ]2.

= «C(n,0), C(n,1),…,C(n,n)»«C(n,0), C(n,1),…,C(n,n)»

= «C(n,0)C(n,0), C(n,0)C(n,1)+C(n,1)C(n,0), …,

C(n,0)C(n,k)+C(n,1)C(n,k-1)+…+C(n,k)C(n,0),… »

Hence C(2n,n) =

C(n,0)C(n,n)+C(n,1)C(n,n-1)+…+C(n,n)C(n,0)

= C(n,0)C(n,0)+C(n,1)C(n,1)+…+C(n,n)C(n,n) -- C(n,k) = C(n,n-k).

= Sk = 1..n C(n,k)2

Ex19: Show the Pascal’s identity C(n+1, k) = C(n,k) + C(n,k-1).

Hint: (1+x)n + 1 = (1+x)(1+x)n = (1+x)n + x(1+x)n.

Similarly, (1+x)m+n = (1+x)m (1+x)n =>

C(m+n,r) = Sk=0..r C(m,k)C(n,r-k)