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?

>

How many non-negative integer solutions are there to \( a + b + 2c = n \) for any positive integer \(n\)?

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.

No vote yet

21 votes

×

Problem Loading...

Note Loading...

Set Loading...

Easy Math Editor

`*italics*`

or`_italics_`

italics`**bold**`

or`__bold__`

boldNote: you must add a full line of space before and after lists for them to show up correctlyparagraph 1

paragraph 2

`[example link](https://brilliant.org)`

`> This is a quote`

Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.`2 \times 3`

`2^{34}`

`a_{i-1}`

`\frac{2}{3}`

`\sqrt{2}`

`\sum_{i=1}^3`

`\sin \theta`

`\boxed{123}`

## Comments

Sort by:

TopNewestThe 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 \]

Log in to reply

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\)?Log in to reply

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.

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.

Log in to reply

Can you use generating functions when you are picking 2 or more

distinctelements from one set?Log in to reply

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

What would it look like for picking 3 distinct objects?

Log in to reply

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)\)?

Log in to reply

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?

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)^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.

Log in to reply

I don't think your example works.

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

Log in to reply

Principle of Inclusion and Exclusion.

To elaborate on my hint, use theThis 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.

Log in to reply