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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

314 GENERATING FUNCTIONS<br />

The first term stands <strong>for</strong> the way to leave no pennies, the second term stands<br />

<strong>for</strong> one penny, then two pennies, three pennies, and so on. Now if we’re<br />

allowed to use both pennies and nickels, the sum of all possible ways is<br />

since each payment has a certain number of nickels chosen from the first<br />

factor and a certain number of pennies chosen from P. (Notice that N is<br />

not the sum { + 0 + 0 $- (0 + O)2 + (0 + @)3 + . . . , because such a<br />

sum includes many types of payment more than once. For example, the term<br />

(0 + @)2 = 00 + 00 + 00 + 00 treats 00 and 00 as if they were<br />

different, but we want to list each set of coins only once without respect to<br />

order.)<br />

Similarly, if dimes are permitted as well, we get the infinite sum<br />

D = (++@+@2+@3+@4+..)N,<br />

which includes terms like @3@3@5 = @@@@@@@@O@@ when it is<br />

expanded in full. Each of these terms is a different way to make change.<br />

Adding quarters and then half-dollars to the realm of possibilities gives Coins of the realm.<br />

Q = (++@+@2+@3+@4+...)D;<br />

C = (++@+@2+@3+@4+-.)Q.<br />

Our problem is to find the number of terms in C worth exactly 509!.<br />

A simple trick solves this problem nicely: We can replace 0 by z, @<br />

by z5, @ by z”, @ by z25, and @ by z50. Then each term is replaced by zn,<br />

where n is the monetary value of the original term. For example, the term<br />

@@@@@ becomes z50+10f5+5+’ = 2”. The four ways of paying 13 cents,<br />

namely @,03, @OS, 0203, and 013, each reduce to z13; hence the coefficient<br />

of z13 will be 4 after the z-substitutions are made.<br />

Let P,, N,, D,, Qn, and C, be the numbers of ways to pay n cents<br />

when we’re allowed to use coins that are worth at most 1, 5, 10, 25, and 50<br />

cents, respectively. Our analysis tells us that these are the coefficients of 2”<br />

in the respective power series<br />

P = 1 + z + z2 + z3 + z4 + . . )<br />

N = (1 +~~+z’~+z’~‘+z~~+...)P,<br />

D = (1+z’0+z20+z”0+z40+...)N,<br />

Q = (1 +z25+z50+z;‘5+~‘oo+~~~)D,<br />

C = (1 +,50+z’00+z’50+Z200+...)Q~

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

Saved successfully!

Ooh no, something went wrong!