Waste less time on Facebook — follow Brilliant.
×

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 \) for any positive integer \(n\)?

  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.

Note by Calvin Lin
3 years, 9 months ago

No vote yet
21 votes

Comments

Sort by:

Top Newest

After you finish number 1, try this:

How many non-negative integer solutions are there to \(a+b+2c=n\) for any positive integer \(n\) for distinct \(a, b, c\)? Logan Dymond · 3 years, 9 months ago

Log in to reply

@Logan Dymond If \(d_n\) is the number of solutions with \(a=b\), then \[ d_n \; = \; \left\{ \begin{array}{lcl} \tfrac12n+1 & \quad & n \mbox{ even} \\ 0 & \quad & n \mbox{ odd} \end{array}\right. \] If \(e_n\) is the number of solutions with \(a=c\) or \(b=c\) then \[ e_n \; = \; 1 + \big\lfloor \tfrac13n\big\rfloor \] If \(f_n\) is the number of solutions with \(a=b=c\) then \[ 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,c\) distinct is \[ c_n - d_n - 2e_n + 2f_n \] where \(c_n = \big\lfloor \tfrac14(n+2)^2\big\rfloor\) is as in my other post. Mark Hennings · 3 years, 9 months ago

Log in to reply

The number of solutions, \(c_n\), is the coefficient of \(x^n\) in the expansion of \[ \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 \[ \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 \[ \varepsilon_n \; = \; \left\{ \begin{array}{lcl} 0 & \qquad & n \mbox{ even} \\ 1 & \qquad & n \mbox{ odd} \end{array} \right. \] and hence \[ c_n \; = \; \left \lfloor \tfrac14(n+2)^2 \right\rfloor \] Mark Hennings · 3 years, 9 months ago

Log in to reply

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 · 3 years, 9 months ago

Log in to reply

Can you use generating functions when you are picking 2 or more distinct elements from one set? Michael Tong · 3 years, 9 months ago

Log in to reply

@Michael Tong Consider \( f(x)^2 - f(x^2) \).

What would it look like for picking 3 distinct objects? Calvin Lin Staff · 3 years, 9 months ago

Log in to reply

@Calvin Lin If \(f(x) = x^4 + x^5 + x^6 + x^7\) then it would be \((f(x))^3 - x^4 f(x^2) - x^5 f(x^2) - x^6f(x^2) - x^7f(x^2)\)? Mike Kong · 3 years, 9 months ago

Log in to reply

@Mike Kong Write it out and check :)

Your formula looks like \( 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 · 3 years, 9 months ago

Log in to reply

@Calvin Lin 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)^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 · 3 years, 9 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 · 3 years, 9 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. \(x^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)^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)^3\). Though I'm a bit doubtful that this one works either.. Michael Tong · 3 years, 9 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(x^n) \), so if you have a simple description of \( f(x) \), then you might be able to get a simple description for the generating function of distinct elements. Calvin Lin Staff · 3 years, 9 months ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...