1 / 17

Generating Functions

Generating Functions. A robust tool to solve a wide variety of problems that deal with sequences, series, permutations, combinations, and more. A generating function gives us a way to mathematically represent or encode such problems. Definition Purpose Examples. Generating function.

heath
Download Presentation

Generating Functions

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generating Functions A robust tool to solve a wide variety of problems that deal with sequences, series, permutations, combinations, and more. A generating function gives us a way to mathematically represent or encode such problems. • Definition • Purpose • Examples

  2. Generating function • A polynomial with either • Interesting choices for its coefficients (useful for recurrence relations) • Interesting choices for its exponents (useful for permutations/combinations) • Customary to write in ascending powers of x • Coefficients can correspond to terms of a sequence Sequences have no mathematical operators. Writing as a polynomial provides a way to manipulate sequences. • Convenient if number of terms is infinite • We almost never substitute a value for x

  3. Purpose • Our textbook shows how to solve simple: • Permutation & combinations • Recurrence relations Using techniques that are narrowly defined. • Generating functions allow you to solve a much wider variety of problems in a systematic, less ad-hoc way. • Disadvantage: not very easy to use • Can be tedious • Requires techniques such as binomial expansion or partial fractions along the way

  4. Preliminary remarks • How many terms do you get if you multiply…? (a + b)(c + d) (a + b)(c + d)(e + f) (a + b + c)(d + e + f + g) • Notice that each term of the product tells you which number you selected inside each ( ). • If you replace each letter with “1”, you get # of terms! • Analogous concept: how many factors does a number have, e.g. 1200?

  5. Combinations • Consider the multiplication of (1+ax)(1+bx)(1+cx) • We need to create terms, where we select something from each factor: • Select the 1 or ax from (1+ax) • Select the 1 or bx from (1+bx) • Select the 1 or cx from (1+cx) • And you sum all 8 possibilities to get: 1 + (a+b+c)x + (ab + bc + ac)x2 + (abc)x3 • What are the coefficients saying?  • If you take away the letters a,b,c, you get the answer to a different question: (1+x)3 = 1 + 3x + 3x2 + x3

  6. continued • A simple generating function for combinations is (1+x)(1+x)(1+x)…(1+x) = (1+x)n • The coefficient of xr is the number of ways to choose r objects from a set of n distinct objects. • You are basically deciding which x’s to multiply to produce the xr. • What if the collection from which we are selecting has duplicates? Notice the contrast: • Select 2 objects from { A, B, C, D } • Select 2 objects from ( A, A, B, B ).

  7. Duplicates • To select from ( A, A, B, B ) is like selecting from a set { A, B} with the ability to choose up to two of each! • Try this generating function: (1 + ax + a2x2) (1 + bx + b2x2) = 1 + (a+b)x + (a2 + ab + b2)x2 + (ab2 + a2b)x3 + a2b2x4. • If we just want the number of ways, we don’t need to specify “a” and “b”: (1+x+x2) (1+x+x2) = 1 + 2x + 3x2 + 2x3 + x4. • What do the coefficients 1, 2, 3, 2, 1 tell us? • Try another problem like this.

  8. Duplicates (2) • I have 10 A’s and 3 B’s. How many ways are there to select r objects, given that the number of A’s I can select must be a multiple of 5? (1 + x5 + x10)(1 + x + x2 + x3) = 1 + x + x2 + x3 + x5 + x6 + x7 + x8 + x10 + x11 + x12 + x13 • What answers do you see in this polynomial? • Restriction on A’s: this problem can be stated as a coin problem with pennies and nickels! Exponent on x = total number of cents • We can easily generalize to different numbers plus more categories such as C’s, D’s, etc.

  9. Applications • How to select r objects from a set • Allowing for repetition of the same element • Restrictions • Answer = coefficient of xr in some ( ) ( ) generating function. • Similar problems that are only superficially different • Coin problems • Dice problems

  10. Review • What combination question would this generating function help solve? (1 + ax + a2x2) (1 + bx) (cx + c2x2) • We can elegantly encode restrictions: maximum, minimum, even number, etc. • What if we just wanted the # of possibilities? • What if the a’s were unlimited? • The number of ways to choose coins to obtain c cents from pennies and nickels. • Think of the set { P, N } but the number of N’s you choose must be a multiple of 5.

  11. Dice application • How many ways can we roll a sum of 7 with 2 dice? • Formulation: (x + x2 + x3 + x4 + x5 + x6) (x + x2 + x3 + x4 + x5 + x6) = (x + x2 + x3 + x4 + x5 + x6)2 And we want the coefficient of x7. • We can match x with x6; x2 with x5; etc. • Thought process is parallel to how you might do with without generating functions. • The answer is 6. • Note that this question is equivalent to asking for coefficient of x5 in (1 + x + x2 + x3 + x4 + x5)2.

  12. 3 dice • But, what if we had more than 2 dice? Generating functions “scale” very well. • Sum of 7 for 3 dice? No problem: • We want coefficient of x7 in (x + x2 + x3 + x4 + x5 + x6)3 • Equivalent to asking for coefficient of x4 in (1 + x + x2 + x3 + x4 + x5)3. • Inside ( ) we have a geometric series = (1 – x6)/(1 – x) • So (1 + x + x2 + x3 + x4 + x5)3 = (1 – x6)3(1 – x)–3 • Let’s work out (1 – x6)3 and (1 – x)–3….

  13. continued We need to use the fact that the coefficients of (a+b)n are 1, n, n(n – 1)/2!, n(n – 1)(n – 2)/3!, n(n – 1)(n – 2)(n – 3)/4!, etc. (1 – x6)3 = 1 – 3x6 + 3x12 – x18 (1 – x)–3 = 1 + 3x + (3)(4)/2! x2 + (3)(4)(5)/3! x3 + … • If we multiply these polynomials, how do we find a term containing x4? • x18, x12 and x6 can’t help us, because 2nd polynomial has only positive powers of x. • The only possibility is to multiply “1” from first polynomial by the x4 term from the 2nd polynomial. • Its coefficient is (3)(4)(5)(6)/4! = (5)(6) / 2 = 15. 

  14. Alternate calculation • Determining the coefficient of a single term can be phrased as a combination question. • The coefficient of x4 in (1 + x + x2 + x3 + x4 + x5)3 means we want 3 exponents to sum to 4, where each exponent ranges from 0 to 5. • In other words, e1 + e2 + e3 = 4 where each ei = 0,1,…,5. • How can 3 numbers sum to 4? • 0+0+4, 0+1+3, 0+2+2, 1+1+2 • In each case, decide which ei represents each number. • Total number of ways = 3 + 6 + 3 + 3 = 15.

  15. Ball in urn • Many combination questions are of the ball-in-urn type. We have n identical balls to place in r urns. The balls are identical, so we simply need to know how many wind up in each urn. • Basic approach: the generating function is of the form (1 + x + x2 + x3 + …)r and we want the coefficient of xn. Highest term in each factor can simply be xn. • Distribute 12 bottles of wine among 4 tables… • What if each table must get 1+ bottle? • What if no table may get more than 4? • The first table must have at most 1 bottle, the 2nd must receive at least 1, the third must receive 0, 2 or 4; and the last must receive 2 or 3?

  16. Practice formulating • A combination problem can be encoded as a generating function. Try these… • How many ways are there to select 4 objects from [ 5 A’s, 5 B’s, 5 C’s ]? • Also: Impose your own restrictions. • How many ways can you make $1 change using pennies, nickels, dimes and/or quarters? • How many integers from 0 to 999 have a sum of digits of 12?

  17. Two variables • Yes, it’s possible for a generating function to have 2 variables. • Why? Maybe you want to keep track of two quantities at the same time. • Example: (1, 1, 2, 3, 3, 4, 4, 5, 5, 6). How many ways to… • select r different numbers • select numbers that have a sum of r • select r numbers that have a sum of s. • Example: (0, 1, 2, 2, 3, 4) (1 + x)(1 + xy)(1 + xy2 + x2y4)(1 + xy3)(1 + xy4) Some of the terms include 3x3y5, 2x3y4, 3x2y4, x2y7

More Related