Generating Functions

This week, we have a guest post written by Alexander B. on generating functions, which are useful tools for solving advanced counting problems.

How would you use generating functions to solve the following?

>

  1. How many non-negative integer solutions are there to a+b+2c=n a + b + 2c = n for any positive integer nn?

  2. Share a question which can be approached using Generating Functions.


If you are interested in contributing a post, please contact me at Calvin@Brilliant.org.

#KeyTechniques #Math

Note by Calvin Lin
7 years, 7 months ago

No vote yet
21 votes

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

After you finish number 1, try this:

How many non-negative integer solutions are there to a+b+2c=na+b+2c=n for any positive integer nn for distinct a,b,ca, b, c?

Logan Dymond - 7 years, 7 months ago

Log in to reply

If dnd_n is the number of solutions with a=ba=b, then dn  =  {12n+1n even0n odd d_n \; = \; \left\{ \begin{array}{lcl} \tfrac12n+1 & \quad & n \mbox{ even} \\ 0 & \quad & n \mbox{ odd} \end{array}\right. If ene_n is the number of solutions with a=ca=c or b=cb=c then en  =  1+13n e_n \; = \; 1 + \big\lfloor \tfrac13n\big\rfloor If fnf_n is the number of solutions with a=b=ca=b=c then fn  =  {14n04∤n f_n \; = \; \left\{ \begin{array}{lcl} 1 & \quad & 4\,|\,n \\ 0 & \quad & 4 \not| n \end{array} \right. and the number of solutions with a,b,ca,b,c distinct is cndn2en+2fn c_n - d_n - 2e_n + 2f_n where cn=14(n+2)2c_n = \big\lfloor \tfrac14(n+2)^2\big\rfloor is as in my other post.

Mark Hennings - 7 years, 7 months ago

The number of solutions, cnc_n, is the coefficient of xnx^n in the expansion of 1(1x)2(1x2)  =  1(1x)3(1+x)  =  (j=0(j+22)xj)(k=0(1)kxk) \frac{1}{(1-x)^2(1-x^2)} \; = \; \frac{1}{(1-x)^3(1+x)} \; = \; \left(\sum_{j=0}^\infty {j+2 \choose 2}x^j\right)\left(\sum_{k=0}^\infty (-1)^kx^k\right) and so cn=m=0n(1)nm(m+22)  =  12(1)nm=0n(1)m(m+1)(m+2)=14(1)nm=0n(1)m[(m+1)2+(m+2)21]=14(1)n[m=0n(1)m(m+1)2m=1n+1(1)m(m+1)2m=0n(1)m]=14(1)n[1+(1)n(n+2)2m=0n(1)m]  =  14[(n+2)2εn] \begin{array}{rcl} c_n & = & \sum_{m=0}^n (-1)^{n-m}{m+2 \choose 2} \; = \; \tfrac12(-1)^n\sum_{m=0}^n(-1)^m(m+1)(m+2) \\ & = & \tfrac14(-1)^n\sum_{m=0}^n (-1)^m\big[(m+1)^2+(m+2)^2-1\big] \\ & = & \tfrac14(-1)^n\left[\sum_{m=0}^n (-1)^m(m+1)^2 - \sum_{m=1}^{n+1}(-1)^m(m+1)^2 - \sum_{m=0}^n(-1)^m\right] \\ & = &\tfrac14(-1)^n\left[1 + (-1)^n(n+2)^2 - \sum_{m=0}^n(-1)^m\right] \; = \; \tfrac14\big[(n+2)^2 - \varepsilon_n\big] \end{array} where εn  =  {0n even1n odd \varepsilon_n \; = \; \left\{ \begin{array}{lcl} 0 & \qquad & n \mbox{ even} \\ 1 & \qquad & n \mbox{ odd} \end{array} \right. and hence cn  =  14(n+2)2 c_n \; = \; \left \lfloor \tfrac14(n+2)^2 \right\rfloor

Mark Hennings - 7 years, 7 months ago

Awesome..Till now, I was completely unknown to this concept,(I had seen it in problems but never understood )but now I am very interested in it...I am very happy now..thnx Alexander and Calvin.

Kishan k - 7 years, 7 months ago

Can you use generating functions when you are picking 2 or more distinct elements from one set?

Michael Tong - 7 years, 7 months ago

Log in to reply

Consider f(x)2f(x2) f(x)^2 - f(x^2) .

What would it look like for picking 3 distinct objects?

Calvin Lin Staff - 7 years, 7 months ago

Log in to reply

Ah, brilliant. Though as you start picking 3, 4, 5, etc. elements this doesn't become very practical anymore.

To your edit-- It would be f(x)3f(x3)f(x)^3 - f(x^3) - some other things to get rid of the products in which only a pair are the same. I'll think about it.

Michael Tong - 7 years, 7 months ago

Log in to reply

@Michael Tong There is a 'nice' generalized formula. Think about how I created the function, and why it works.

I don't think your example works.

Hint: Just because you learnt an advanced technique, doesn't mean that you should forget your basics.

Calvin Lin Staff - 7 years, 7 months ago

Log in to reply

@Calvin Lin I know mine doesn't work, my sentence comes out weird in latex but what I meant was "this minus some other things." Your first one works because you take the product and then subtract the case when two of the same element is being multiplied by each other, but when you scale up to three you have to worry about all three of them being the same as well as them being not pairwise distinct (e.g. x4×x4×x7x^4 \times x^4 \times x^7). However, while a term being multiplied three times occurs only once, the situation where two terms plus another distinct term occurs thrice. This makes me come to the formula of f(x)33f(x)f(x2)+2f(x3)f(x)^3 - 3f(x)f(x^2) + 2f(x^3). It's multiplying by three, then taking out three times the pairwise non-distinct as well as the triple non-distinct, and then adding two of the triple non-distincts back in since that only occurs once in the original expansion of f(x)3f(x)^3. Though I'm a bit doubtful that this one works either..

Michael Tong - 7 years, 7 months ago

Log in to reply

@Michael Tong To elaborate on my hint, use the Principle of Inclusion and Exclusion.

This tells you why the formula looks the way it does (and also why it gets ugly quickly). Interestingly, it only involves terms of the form f(xn) f(x^n) , so if you have a simple description of f(x) f(x) , then you might be able to get a simple description for the generating function of distinct elements.

Calvin Lin Staff - 7 years, 7 months ago

If f(x)=x4+x5+x6+x7f(x) = x^4 + x^5 + x^6 + x^7 then it would be (f(x))3x4f(x2)x5f(x2)x6f(x2)x7f(x2)(f(x))^3 - x^4 f(x^2) - x^5 f(x^2) - x^6f(x^2) - x^7f(x^2)?

Mike Kong - 7 years, 7 months ago

Log in to reply

@Mike Kong Write it out and check :)

Your formula looks like f(x)3f(x)f(x2) f(x)^3 - f(x) f(x^2) .
If it works, why does it work?
If it doesn't work, why doesn't it work?

Calvin Lin Staff - 7 years, 7 months ago
×

Problem Loading...

Note Loading...

Set Loading...