A friend of mine presented a problem I found interesting:
Compute the following: $$\sum_{n=0}^\infty\left(\prod_{k=1}^j(1+x^k)\right)[x^{mn}]$$ where $P(x)[x^n]$ denotes the $x^n$ coefficient of $P$.
This problem is meant to be solved with the assistance of a program for large $j$ (larger than 1000) and $m\ll j$. I'm interested in general, but if the case of $m~|~j$ is special, then that suffices for me.
My first thought was to brute force compute all of the coefficients, but this takes $\mathcal O(j^3)$ time, which is too slow.
My second thought was that this is essentially searching for distinct partitions. The issue is the finite upper bound, meaning that this becomes inaccurate after than $x^{j+1}$ coefficient. I'm not super familiar with partitions to know how to adjust for this without brute force like above.
My third thought was to tackle this more generally with:
$$\sum_{n=0}^\infty P(x)[x^{mn}]=\frac1m\sum_{n=0}^{m-1}P(e^{2\pi in/m})$$
But this almost completely ignores the form of $P$, so I don't feel like this is how the problem should be tackled.
How can I tackle this problem?
Update:
I just realized that when $m~|~j$ we have
$$\sum_{n=0}^\infty\left(\prod_{k=1}^j(1+x^k)\right)[x^{mn}]=\frac1m\sum_{n=0}^{m-1}\left[\prod_{k=0}^{m-1}(1+e^{2\pi ink/m})\right]^{j/m}$$
which is far fewer computations. Ruby code.
Still interested in alternative solutions.