# Find all solutions in positive integers of the Diophantine equation $x^2+2y^2 =z^2$

I can't solve the following exercise. It's already on this site, but the solution method is not the same as in my solutions manual.

Find all solutions in positive integers of the Diophantine equation $x^2+2y^2 =z^2$.

The solution is given, but I do not understand the italicised parts.

13.1.8 $2y^2=z^2-x^2=(z-x)(z+x)$. $x$ and $y$ have the same parity, so $(z-x)/2$ and $(z+x)/2$ are integers. It suffices to assume $(x,z)=1$. Then either $((z-x)/2,z+x)=1$, and then $y^2=((z-x)/2)(z+x)=m^2n^2$, and solving $(z-x)/2=m^2$ and $z+x=n^2$ for $x$ and $y$ gives $x=(m^2-2n^2)/2,y=mn,z=(m^2+2n^2)/2$. Or $((z+x)/2,z-x)=1$ which gives $x=(2m^2-n^2)/2,y=mn,z=(2m^2+n^2)/2$.

• Why have x and y the same parity?

• Why are $(z-x)/2$ and $(z+x)/2$ integers?

• Why do they assume $\gcd((z-x)/2,z+x)=1$ and next $\gcd((z+x)/2,z-x)=1$?

• How to solve $(z-x^2)/2 = m^2$ and $z-x=n^2$ for x and y to become the values for x, y and z? • If $x$ is even, what can you say about $x^2$? Can $2y^2$ be odd? If not, what can you now say about $z^2$? and about $z$? – Mastrem Jan 28 '18 at 12:58
• @Mastrem How do we know if x is even or odd? $2y^2 is always even! If$z^2$is even, then z is even, if$z^2$is odd, then z is odd – WinstonCherf Jan 28 '18 at 13:12 • You don't. However, what you CAN deduce is, that IF$x$is even, THEN$z$is even and in a similair way, IF$x$is odd, THEN$z$is odd as well. Therefore$x$and$z$are always of the same parity. – Mastrem Jan 28 '18 at 13:30 ## 1 Answer •$2y^2=z^2-x^2$, the left-hand side is an even number so$z,x$must either both be even (even minus even is even) or they must both be odd (odd minus odd is even). They did, however, mistype. They typed$x,y$have the same parity (false for some solutions) but meant$x,z$gave the same parity (proven true here). •$z-x$must be even (by the argument above), so$\frac{z-x}{2}$is an integer. •$z+x$must also be even by the exact same argument, so$\frac{z+x}{2}$is also an integer. • First they assume that$\gcd(x,z)=1$, because if they have a common factor, say$d$, then you have the expression: $$2y^2=(z'd-x'd)(z'd+x'd)=d^2(z'-x')(z'+x')$$ and you can divide both sides by$d^2$and get exactly the same expression ($x=x'd$,$y=y'd$,$z=z'd$). At some point this has to stop so you can assume that$x,z$have no common factor. • This is perhaps the hardest part: Why is $$\gcd\left (\frac{(z-x)}{2},z+x\right )=1$$ or $$\gcd\left (z-x,\frac{(z+x)}{2}\right )=1$$ This follows from another result: If$\gcd(z,x)=1$then$\gcd(z-x,z+x)$is$1$or$2$The result is proven here. Now, we know that both$z-x,z+x$are divisible by$2$, and this is the largest factor they can have in common. Atleast one of$z-x,z+x$is divisible by$2$and not$4$. This means that we must have either$\gcd\left (\frac{(z-x)}{2},z+x\right )=1$or$\gcd\left (z-x,\frac{(z+x)}{2}\right )=1$. Now, which one is it? We don't know! 1. If$\gcd\left (\frac{(z-x)}{2},z+x\right )=1$then we know that $$y^2=\frac{(z-x)}{2}(z+x)$$ but$y^2$is a square, and$\frac{(z-x)}{2},z+x$have no factor in common! This must mean that$\frac{(z-x)}{2}=m^2$is a square, and$z+x=n^2$is a square. You can use this information to solve for$x,y,z$. 2. If$\gcd\left (z-x,\frac{(z+x)}{2}\right )=1$then again we know that $$y^2=(z-x)\frac{(z+x)}{2}$$ but$y^2$is a square, and$z-x,\frac{(z+x)}{2}$have again no factor in common! This must mean that$z-x=n^2$is a square, and$\frac{z+x}{2}=m^2$is a square. • Thnx! Clear! But how can you solve$(z−x^2)/2=m^2$and$z−x=n^2$for x and y to become the values for x, y and z? – WinstonCherf Jan 28 '18 at 14:34 • Ok, so rewriting we have$z-x=2m^2$and$z+x=n^2$. If you add these to equations together you get$2z+0=2m^2+n^2$, dividing by$2$yields$z=\frac{2m^2+n^2}{2}$. Now that you know what$z$is, can you find out what$x$is? – cansomeonehelpmeout Jan 28 '18 at 14:40 • Thnx! I found it! There's just one thing not clear to me: First we say$y^2=((z-x)/2)((z+x)/2)$and next we say$y^2=((z-x)/2)(z+x)$and later on$y^2=((z+x)/2)(z-x)$. Why is this true? – WinstonCherf Jan 29 '18 at 10:10 • @Elce I have updated my answer, please tell me if it is more helpful now! We don't say that$y^2=\left ( (\frac{z-x}{2})(\frac{z+x}{2})\right )$, we start with:$2y^2=(z-x)(z+x)$, then we divide by the$2$. Now we can choose which factor to divide by$2$, and the result is still the same. For instance$\frac{4}{2}\times 6=2\times 6$is still the same as$4\times\frac{6}{2}=4\times 3$. But notice that$\gcd(2,6)=2$and$\gcd(4,3)=1$. So we are choosing to divide by the factor that gives a$\gcd$of$1\$. – cansomeonehelpmeout Jan 29 '18 at 15:53
• @Elce everything you have done seems perfect. I'm sure the book have made some typos. – cansomeonehelpmeout Jan 29 '18 at 19:27