[Math] The sum of two integers is a square. The sum of their squares is also a square.

diophantine equationselementary-number-theorynumber theoryrecreational-mathematicssums-of-squares

The sum of two integers is a square. The sum of their squares is also a square. E.g.
$$
-3 + 4 = 1^2, \ (-3)^2 + 4^2 = 5^2
$$

$$
9 + 40 = 7^2, \ 9^2 + 40^2 = 41^2
$$

Question: General solution/form of all such pairs.

Clarification: By general form we mean a parametric form like Euclid's solution for Pythagorean triplets $a = r^2 – s^2, \ b = 2rs$ and $c = r^2 + s^2$ which covers all Pythagorean triplets.

Best Answer

WLOG for $d^2=a^2+b^2, a=2mn, b=m^2-n^2$

$a+b=m^2-n^2+2mn$

Let $m^2-n^2+2mn=(m+pn)^2\iff n(p^2+1)=2m(1-p)$

$\dfrac n{2(1-p)}=\dfrac m{1+p^2}=r$(say)

Now $(1+p^2,1-p)|(1+p^2,1-p^2)$ which must divide $1+p^2+1-p^2=2$

Case $\#1:$ $(1+p^2,2(1-p))=1$ if $p$ is even

$n=2r(1-p^2),m=r(1+p^2)$

Case $\#2:$ For odd $p, p^2\equiv1\pmod8, 1+p^2\equiv2$

In that case, $(1+p^2,2(1-p))=2$

$n=r(1-p)$ and $m=\dfrac{r(1+p^2)}2$

Related Question