<s>[INST] A curious infinite product Let $R$  be the ring  $\mathbb{Z[q]}/(q^2)$ whose elements $a+bq$ satisfy $q^2=0.$ 
Define $g_n\in R$ by $g_1=1$, $g_{2^n}=1-2^{n-1}q$ for $n>0$ and $g_{2n}=0,$ $g_{2n+1}=-q$ else.
It seems that in $R$ the following identity holds in the sense of formal power series with coefficients in $R$:
$$1+x+(1-q)x^2+(1-2q)x^3+(1-3q)x^4+\dots =(1+g_{1}x)(1+g_{2}x^2)(1+g_{3}x^3)\dots.$$
For $q=0$ this reduces to the well-known identity 
$$1+x+x^2+x^3+x^4+\dots =(1+x)(1+x^2)(1+x^4)(1+x^8)\dots.$$
Any idea how to prove this?
 [/INST] Write $\epsilon = -q$, which will save us some minus signs. Start by substituting $x \mapsto \left( 1 + \frac{\epsilon}{2} \right) x$ into the well-known identity, which gives
$$\prod_{k \ge 0} (1 + (1 + 2^{k-1} \epsilon)) x^{2^k} = \frac{1}{1 - \left( 1 + \frac{\epsilon}{2} \right) x} = \sum_{n \ge 0} \left( 1 + \frac{n\epsilon}{2} \right) x^n.$$
This incorporates all the power-of-$2$ factors except that the factor for $k = 0$ is slightly off; above it's $(1 + \left( 1 + \frac{\epsilon}{2} \right) x)$ when you ask for it to be $1 + x$. We can correct this by multiplying by $\frac{1 + x}{1 + \left( 1 + \frac{\epsilon}{2} \right) x}$, which gives
$$\prod_{k \ge 0} (1 + g_{2^k} x^{2^k}) = \frac{1 + x}{1 - (1 + \epsilon) x^2} = \sum_{n \ge 0} \left( 1 + \left\lfloor \frac{n}{2} \right\rfloor \epsilon \right) x^{n}.$$
Now we need to incorporate the odd factors. The product of the odd factors only is, by direct expansion,
$$\prod_{k \ge 1} (1 + \epsilon x^{2k+1}) = 1 + \epsilon \sum_{k \ge 1} x^{2k+1} = 1 + \epsilon \frac{x^3}{1 - x^2} = \frac{1 - x^2 + \epsilon x^3}{1 - x^2}$$
and taking the product with the power-of-$2$ factors above gives
$$\prod_{n \ge 0} (1 + g_n x^n) = \frac{1 - x^2 + \epsilon x^3}{(1 - x^2 - \epsilon x^2)(1 - x^2)}.$$
This is not yet in the form we want it; we need to move the $\epsilon$ in the denominator to the numerator by multiplying by the "conjugate" $1 - x^2 + \epsilon x^2$, which gives
$$\begin{eqnarray*} \frac{(1 + x)(1 - x^2 + \epsilon x^3)(1 - x^2 + \epsilon x^2)}{(1 - x^2)^3} &=& \frac{(1 - x^2)^2 + \epsilon (x^2 + x^3 - x^4 - x^5)}{(1 - x)(1 - x^2)^2} \\
 &=& \frac{1}{1 - x} + \epsilon \frac{x^2}{1 - x} \end{eqnarray*}$$
which is the desired result. I don't have a good explanation for why there is so much cancellation at the end.
</s>