09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

324 GENERATING FUNCTIONS<br />

Fortunately the problem is easy to fix, since we can add [n = 11 to the right;<br />

this adds 1 when n = 1, and it makes no change when n # 1. So, we have<br />

gn = s-1 +a-2+[n=ll;<br />

this is the equation called fo:r in Step 1.<br />

Step 2 now asks us to t:rans<strong>for</strong>m the equation <strong>for</strong> (g,,) into an equation<br />

<strong>for</strong> G(z) = t, gnzn. The task is not difficult:<br />

G(z) = x gnzn = ~gnlzn+tg,~rzn+~[n=l]zn<br />

n<br />

= ;gnzn+l+;gnzn+2 fnz<br />

n n<br />

= G(z) + z’G(z) + z.<br />

Step 3 is also simple in this case; we have<br />

G(z) = '<br />

l-z-z2'<br />

which of course comes as no surprise.<br />

Step 4 is the clincher. We carried it out in Chapter 6 by having a sudden<br />

flash of inspiration; let’s go more slowly now, so that we can get through<br />

Step 4 safely later, when we meet problems that are more difficult. What is<br />

b”l z<br />

l-z-22'<br />

the coefficient of zn when z/( 1 - z - z2) is expanded in a power series? More<br />

generally, if we are given any rational function<br />

P(z)<br />

R(z) = Qo,<br />

where P and Q are polynomials, what is the coefficient [z”] R(z)?<br />

There’s one kind of rational function whose coefficients are particularly<br />

nice, namely<br />

(1 - puz)m+1<br />

= x (m;n)ap"z"<br />

n30<br />

(7.25)<br />

(The case p = 1 appears in Table 321, and we can get the general <strong>for</strong>mula<br />

shown here by substituting pz <strong>for</strong> z.) A finite sum of functions like (7.25),<br />

s(z) = (1 - pyl,-,+, '-<br />

a2<br />

(1 -p2Z)m2+' +'.'+ (1 -pLZ)mL+l '<br />

al<br />

(7.4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!