I want to verify that the solution to the difference equation
$m_x - 2pqm_{x-2} = p^2 + q^2$
with boundary conditions
$m_0 = 0$
$m_1 = 0$
is
$$m_x = -\frac{1}{2}(\frac{1}{\sqrt{2pq}} +1)(\sqrt{2pq})^x + \frac{1}{2}(\frac{1}{\sqrt{2pq}} - 1)(-\sqrt{2pq})^x + 1$$
General solution to inhomogeneous equation
I know that that general solution for $m_x$ will be equal to the general solution to the homogeneous equation plus a particular solution to the inhomogeneous equation. So the general solution to the homogeneous equation
$m_x - 2pqm_{x-2} = 0$
ends up being
$m_x = A(\sqrt{2pq})^x + B(-\sqrt{2pq})^x$
Using $m_0 = 0$ we have that $A = -B$ giving us
$m_x = A(\sqrt{2pq})^x - A(-\sqrt{2pq})^x$
Using $m_1 = 0$ we have that
$0 = -B(\sqrt{2pq}) + B(-\sqrt{2pq})$
$0 = -B(\sqrt{2pq}) - B(\sqrt{2pq})$
$0 = -2B(\sqrt{2pq})$
$=> B = -A = 0$
So I must have done something wrong? And where is the "$1$" at the end of the correct general solution above coming from? Can someone show how to verify the solution correctly?
If, as I suspect, $p+q=1$, one might prefer the general formula, valid for every integer $x\geqslant0$, $$m_{2x}=m_{2x+1}=1-(2pq)^x.$$ In the general case, if $2pq\ne1$, try $$m_{2x}=m_{2x+1}=\left(1-(2pq)^x\right)\,\frac{p^2+q^2}{1-2pq}.$$ Finally, if $2pq=1$, $$m_{2x}=m_{2x+1}=x\,(p^2+q^2).$$ In each case, checking that the recursion holds should be direct.
Morality: To transform the formula for $m_{2x}=m_{2x+1}$ into a single formula valid for every $m_x$, based on the oscillatory nature of $(-1)^x$, while always posssible, might not be a good idea.