I'm working on a problem for which I need to efficiently compute the number of integer solutions to equations of the form $x_1 + \cdots + x_k = n$ with some subset of $\{x_1, \dots, x_n\}$ equivalent.
For example, the problem stated in the title: $x_1 + x_2 + x_3 + x_4 = n$ with $x_1 = x_2$
I know how to find the number of integer solutions to such an equation without the added restraint of equivalent variables. I'm also familiar with adding restraints of the form $x_i \geq m$. But I don't see how to adapt that method here.
In my combinatorics book, similar problems are tackled using generating functions. I believe that the generating function for my equation would be:
$$(1+x^2 + x^4 + \cdots)(1+x + x^2 + \cdots)^2 = \dfrac{1}{1-x^2} \dfrac{1}{(1-x)^2}$$
But unless there is a way to put this into the form $\sum_{n=0}^{\infty} a_n x^n$ and thus recover $a_n$ I don't see how to make use of it.
Ideally, I would like to find a method that works for $2x_1 + x_2 + x_3 = n$ and which can also be extended to cases with more variables and different subsets of equivalent variables.
Use partial fractions: $$\eqalign{ \frac1{1-x^2}\frac{1}{(1-x)^2} &=\frac1{(1+x)(1-x)^3}\cr &=\frac18\Bigl(\frac{1}{1+x}+\frac{7-4x+x^2}{(1-x)^3}\Bigr)\cr &=\frac18\Bigl(\frac{1}{1+x}+\frac1{(1-x)}+\frac2{(1-x)^2} +\frac{4}{(1-x)^3}\Bigr)\cr &=\frac18\sum_{n=0}^\infty\bigl((-1)^n+1+2(n+1)+2(n+1)(n+2)\bigr)x^n\cr &=\frac18\sum_{n=0}^\infty\bigl((-1)^n+7+8n+2n^2\bigr)x^n\ ,\cr}$$ where we have differentiated $$\frac1{1-x}=\sum_{n=0}^\infty x^n$$ to get $$\frac1{(1-x)^2}=\sum_{n=0}^\infty nx^{n-1}=\sum_{n=0}^\infty (n+1)x^n$$ and then $$\frac2{(1-x)^3}=\sum_{n=0}^\infty n(n+1)x^{n-1}=\sum_{n=0}^\infty (n+1)(n+2)x^n\ .$$