# Solve diophantine equation $x^2 - 2y^2 = x - 2y$

Thanks to internet, I found and understand how to solve diophantine $x^2 - Dy^2 = 1$. Now I would like to solve the following diophantine equation : $$x^2 - 2y^2 = x - 2y$$ but I don't know how to do it, even if I could read articles explaining how to solve the diophantine $x^2 - Dy^2 = c$.

• You can find solutions at the alpertron. It even explains its work, I highly recommend it. – vadim123 Oct 30 '13 at 21:24

The equation is

$$x^2-x-2(y^2-y)=0\iff \left(x-\frac12\right)^2-2\left(y-\frac12\right)^2-\frac14+\frac12=0\iff$$

$$\iff\left(x-\frac12\right)^2-2\left(y-\frac12\right)^2=-\frac14$$

Now substitute

$$x':=x-\frac12\;\;,\;\;y':=y-\frac12$$

So that the equation becomes

$$x'^2-2y'^2=-\frac14$$

and it now has the form you're used to.

Note that we can rearrange the given equation into the form $$(2x-1)^2-2(2y-1)^2=-1$$ which is a Pell-like equation. This is similar to the Pell equation $x^2-2y^2=1$, and solutions to $x^2-2y^2=\pm 1$ can be found from the Pell Numbers and Pell-Lucas numbers. All integer solutions $(2x-1,2y-1)$ are in the form $$\left(\frac{(1+\sqrt{2})^{2n+1}+(1-\sqrt{2})^{2n+1}}{2},\frac{(1+\sqrt{2})^{2n+1}-(1-\sqrt{2})^{2n+1}}{2\sqrt{2}}\right)$$ for some nonnegative integer $n$, and $x,y$ can be solved for with this formula for $(2x-1,2y-1)$.