# $Dm^2 - n^2D^2$ is a perfect square then $D$ is the sum of two squares

How do I show that if $$Dm^2 - n^2D^2$$ is a perfect square for some integers $m$ and $n$ ($n \neq 0$), $D$ is the sum of two (non-zero) perfect squares? I tried solving for $D$ but that only gives me $$D = \frac{m^2}{2n^2} \pm \frac{\sqrt{m^4 - 4n^2 k^2}}{2n^2}$$ for integers $m$, $n$, and $k$, which doesn't seem easier.

EDIT: $D$ itself should not be a perfect square.

• But, he didn't say if and only if. It might be a sufficient condition but not necessary. @GyuminRoh – MathIsNice1729 Dec 3 '15 at 7:04
• If $Dm^2 - n^2D^2$ is a perfect square for any integers $m,n$, then in particular, letting $m = 1, n = 0$, we have that $D$ is a perfect square. But then $D = D + 0^2$ is a sum of two perfect squares. – Ethan Alwaise Dec 3 '15 at 7:05
• Oops misread the question sorry. I think the above solution works. – Gyumin Roh Dec 3 '15 at 7:07
• But, is the question really saying this? I mean, can we just let $m$ and $n$ be some fixed numbers? I think we should go for a general approach. I believe it'd be easier to prove contrapositively. @EthanAlwaise – MathIsNice1729 Dec 3 '15 at 7:09
• @EthanAlwaise I edited the question to make it more precise. n should not be 0. – arbitrary username Dec 3 '15 at 7:09

If $Dm^2-D^2n^2= a^2$, then $Dm^2$ is a sum of two squares. Now an integer is a sum of two squares if and only if all primes $\equiv 3 \mod 4$ in its factorization occur with even multiplicities. The presence of the extra square $m^2$ doesn't affect this condition, so $D$ is a sum of two squares, also.

• Also the hypothesis $n \neq 0$ is unnecessary. If the statement is true for some $m$ when $n = 0$ then $Dm^2$ is a perfect square. But then $D$ must be a perfect square and so $D = D + 0^2$ is a sum of two squares. – Ethan Alwaise Dec 3 '15 at 7:32
• How do you prove that an integer is the sum of two squares if and only if all primes $\equiv 3$ mod $4$ in its factorization occur with even multiplicities? – arbitrary username Dec 3 '15 at 7:35
• It's not obvious, you can get it as a by-product of the analysis of Gaussian primes: en.wikipedia.org/wiki/Gaussian_integer – user138530 Dec 3 '15 at 7:38
• And see here: en.wikipedia.org/wiki/… – user138530 Dec 3 '15 at 7:41
• @GerryMyerson: I'm not claiming I need it, I'm just saying it's a quick way to finish it off. – user138530 Dec 3 '15 at 9:10

The proposition is false. Suppose every prime divisor (if any) of $D$ is congruent to $3$ modulo $4$ and that $D$ is a square. Then $D$ is not the sum of two non-zero squares. Suppose $(p,q,r)$ is any Pythagorean triplet with $p^2=q^2+r^2$. Let $D=E^2$. We have $D(Ep)^2-q^2D^2=(rD)^2.$ Examples:(I)D=1,m=5,n=4. (II).D=9,m=15,n=4.

• But the problem says $D$ is not to be a square. – Gerry Myerson Dec 3 '15 at 9:27
• The edit demanding that D is a non-square wasn't there before. – DanielWainfleet Dec 3 '15 at 9:31
• The last edit on the question was 2 hours ago. Your answer went up 52 minutes ago. – Gerry Myerson Dec 3 '15 at 9:38
• SO WHAT .I thought about the question for along while and put up an answer – DanielWainfleet Dec 3 '15 at 14:07

Let's take the equation.

$$dx^2-d^2y^2=z^2$$

If we represent the coefficient as a sum of squares. $d=a^2+b^2$

The solution can be written as.

$$x=d(p^2+s^2)$$

$$y=ap^2+2bps-as^2$$

$$z=d(bs^2+2aps-bp^2)$$