TITLE: sums of rational squares
QUESTION [20 upvotes]: It is a well-known fact that if an integer is a sum of two rational squares then it is a sum of two integer squares.  For example, Cohen vol. 1 page 314 prop. 5.4.9.   Cohen gives a short proof that relies on Hasse-Minkowski, but he attributes the theorem (without reference) to Fermat, who didn't have Hasse-Minkowski available.   So my question is,  how did Fermat prove this theorem?  and part 2 of the question is,  what is the simplest direct proof?   I googled for this result and found a manuscript with a proof that doesn't use Hasse-Minkowski, but it's not very short.

REPLY [2 votes]: This is an answer to the second question, "what is the simplest direct proof?"
Let m be an integer satisfyng $\frac{a^{2}}{b^{2}}+\frac{c^{2}}{d^{2}}=m$. $a,b,c,d \in \mathbb{Z}$, gcd(a,b)=1, gcd(c,d)=1.
$\frac{a^{2}d^{2}+b^{2}c^{2}}{b^{2}d^{2}}=m$
$a^{2}d^{2}+b^{2}c^{2}=mb^{2}d^{2}$
$b^{2}(md^{2}-c^{2})=a^{2}d^{2}$.
As our assumtion $b^{2} \not | a^{2}$ so $b^{2} | d^{2}$, $d^{2}=kb^{2}$. Then $\frac{1}{b^{2}}(a^{2}+\frac{c^{2}}{k})=m$.
$\frac{c^{2}}{k}=mb^{2}-a^{2}$ which is an integer. Thus we have $k=1$ as gcd(c,d)=1.
We have $\frac{a^{2}}{b^{2}}+\frac{c^{2}}{b^{2}}=m$, $a^{2}+c^{2}=mb^{2}={p_{1}}^{\alpha_{1}}...{p_{k}^{\alpha_{k}}}$ [Unique prime factorization].
If $a^{2}+c^{2}=wp$, p is prime and gcd(w,p)=1, then we can find integers x, y such that $x^{2}+y^{2}=p$.
Thus for every $p_{1}$, $p_{2}$,...,$p_{k}$, we can find $a_{1}, a_{2},...,a_{k}$ and $c_{1}, c_{2},...,c_{k}$ such that 
${a_{1}}^{2}+{c_{1}}^{2}=p_{1}$
${a_{2}}^{2}+{c_{2}}^{2}=p_{2}$
$\vdots$ 
${a_{k}}^{2}+{c_{k}}^{2}=p_{k}$
Now if $m=p_{1}p_{2}$, ${a_{1}}^{2}+{c_{1}}^{2}=p_{1}$, ${a_{2}}^{2}+{c_{2}}^{2}=p_{2}$.
$({a_{1}}^{2}+{c_{1}}^{2})({a_{2}}^{2}+{c_{2}}^{2})$ = ${(a_{1}a_{2}+c_{1}c_{2})}^{2}+ {(a_{1}c_{2}-c_{1}a_{2})}^{2}=m$.
We can continue in this way to show the claim if $m=p_{1}p_{2}...p_{k}$.