Find the non-negative integer solutions of the diophantine equation I want to find the non-negative integer solutions of the diophantine equation 
$$x^2+2y^2=z^2 \ \ \ \ , \ \ \ \ \gcd(x,y,z)=1$$
It holds that $(x,y)=(y,z)=(x,z)=1$.
That's what I have tried:
$$2y^2=z^2-x^2=(z-x)(z+x)$$
$$2 \mid (z-x)(z+x) \Rightarrow (z-x)(z+x)=2k, k \in \mathbb{Z}$$
Let $(z-x,z+x)=d>1$
Then $d$ has a prime divisor, let $p$.
$p \mid d, d \mid z-x, d \mid z+x \Rightarrow p \mid z-x \text{ and } p \mid z+x \Rightarrow p \mid 2z \text{ and } p \mid 2x \Rightarrow p \mid 2(x,y)=2 \Rightarrow p=2$
So:
$$2 \mid z-x \Rightarrow z-x=2x_1, x_1 \in \mathbb{Z}$$
$$2 \mid z+x \Rightarrow z+x=2z_1, z_1 \in \mathbb{Z}$$
So $2y^2=2x_1 \cdot 2z_1 \Rightarrow y^2=2x_1 z_1$.
So it has to hold $x_1=2l, z_1=l, l \in \mathbb{Z}$.
So $z=x+2x_1=x+4l \text{ and } z=2x_1-x=4l-x  \Rightarrow x+4l=4l-x \Rightarrow x=0$.
$$z=4l$$
$$y=2l$$
Could you tell me if it is right?
 A: Here's how I would approach this problem:
Like in finding Pythogorean triplets, we can turn the problem into finding rational points, in this case, on an ellipse. That is, we can modify the equation to:
$$\left(\frac{x}{z}\right)^2 + 2\left(\frac{y}{z}\right)^2 = 1$$
We have a rational parametrization for the ellipse (use $\sin(t) = \frac{1-t^2}{1+t^2}$ and $\cos(t) = \frac{2t}{1+t^2}$).
A: The start is good, rewrite as $2y^2=z^2-x^2=(z-x)(z+x)$. Now we imitate the standard approach to generating primitive Pythagorean triples.  Note that $z$ and $x$ must have the same parity.  If they are both even then $\gcd(x,y,z)\ne 1$. So $z$ and $x$ must be both odd.
Any common divisor $\gt 2$ of $z-x$ and $z+x$ must divide $y$. It follows that $\gcd(z-x,z+x)=2$. Thus (i) $z-x=u^2$, $z+x=2v^2$ where $u$ and $v$ are non-negative and relatively prime, or (ii) the same thing with $z-x$ and $z+x$ switched. 
We look at (i). Both $z-x$ and $z+x$ are even. That forces $u$ even, so $v$ odd. Let $u=2w$. We get $z-x=4w^2$, $z+x=2v^2$, giving $z=v^2+2w^2$, $x=v^2-2w^2$. It follows that $y=2vw$.  
The side conditions are $v$ and $w$ relatively prime, $v$ odd, and $v^2\ge 2w^2$.  We can verify that any such choice of $v$ and $w$ yields a primitive solution of $x^2+2y^2=z^2$. 
A very similar analysis can be made for Case (ii). We can put the two conclusions together by setting $x=|v^2-2w^2|$.
