Awesome Some Generating Functions: Great Theoretical Ideas in Computer Science
Awesome Some Generating Functions: Great Theoretical Ideas in Computer Science
Some AWESOME
Great Theoretical Ideas
in Computer Science
about Generating Functions
Generating Functions
Lecture 9 (September 21, 2010)
What is a generating function
and why would I use one?
Representation
What IS a Generating
Function?
We’ll just looking at a particular
representation of sequences…
Choice 1
Choice 2
Counting 1,2,3…
Danny owns 3 beanies and 2 ties. How many
ways can he dress up in a beanie and a tie?
Choice 1
Choice 2
( + + )( + ) =
+ + + + +
Counting 1,2,3…
Danny owns 3 beanies and 2 ties. How many
ways can he dress up in a beanie and a tie?
( + + )( + ) =
+ + + + + =
That is, 6 is the number of ways to choose 2 things
Counting …4,5,6,…
Danny owns 3 beanies and 2 ties. How many
ways can he dress up if he doesn’t always wear
a beanie or a tie (and wears at most one of each)?
How many ways for a beanie?
1) 1 way for no beanie
2) 3 ways for one beanie
They're fun!
Proving identities
Counting Coins
Suppose we have pennies, nickels, dimes, and
quarters, and we want to know how many ways
we can make change for n cents.
1) 6 pennies
2) 1 penny and 1 nickel
So,
Counting Coins
Suppose we have pennies, nickels, dimes, and
quarters, and we want to know how many ways
we can make change for n cents.
Pennies:
Nickels:
Dimes:
Quarters:
Counting Coins
Suppose we have pennies, nickels, dimes, and
quarters, and we want to know how many ways
we can make change for n cents.
Pennies:
Nickels:
Dimes:
Quarters:
Putting the pieces together…
Counting Coins
Suppose we have pennies, nickels, dimes, and
quarters, and we want to know how many ways
we can make change for n cents.
is the coefficient of in
Domino Domination
We have a board, and we would
like to fill it with dominos. We have two colors
of dominos: green and blue. The green ones
are , and the blue ones are .
How many ways can we tile our board using
non-staggered dominos?
Domino Domination
Write a recurrence!
Domino Domination
So we have a
recurrence…but now
what?
Domino Domination
Now we derive a closed form
using generating functions!
Let
Let
Domino Domination
Now we derive a closed form
using generating functions!
Let
Domino Domination
Why is the closed form of the
GF helpful or useful?
Let
Let
Domino Domination
Why is the closed form of the
GF helpful or useful?
Let
Rogue Recurrence
for n>2
, ,
Solve this recurrence…or else!
Let
Rogue Recurrence
for n>2
, ,
Solve this recurrence…or else!
Let
Rogue Recurrence
for n>2
, ,
Solve this recurrence…or else!
Let
Rogue Recurrence
for n>2
, ,
Solve this recurrence…or else!
Let
Let
Some Common GFs
Sequence Generating
Function
Double Sums OMGWTFBBQ!
So…
Generating Functions
• Counting with GFs
• Solving recurrences with GFs
• How to derive base cases of
recurrences
• Basic partial fractions
Here’s What
You Need to
Know…