sums of rational squares

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.

This result is pretty shy of needing the full Hasse-Minkowski Theorem. Indeed, since Fermat already knew which integers were a sum of two integer squares, it would suffice for him to show that those that weren't (i.e., those with an odd power of some prime congruent to 3 mod 4 showing up in its prime factorization) could also not be written as a sum of two rational squares. But this is the easy direction of Hasse-Minkowski: To show that (let's say) a prime $p\equiv 3\pmod{4}$ can't be written as a sum of two rational squares, it suffices to check that it can't be a sum of two $\ell$-adic rational squares for some $\ell$. Of course, Fermat did not have the language of the $\ell$-adics, so this would have had been replaced with mod-$q^k$ conditions for various $k$.

Specifically, the modern Hasse-Minkowski proof boils down to the statement that a prime which is 3 mod 4 can't be written as a sum of two rational squares because it can't be done so 2-adically. Indeed, one can just compute the single Hilbert symbol $$p\equiv 3\pmod{4}\Rightarrow (p,-1)_2=(-1)^{(p-1)/2}=-1,$$ showing that $x^2=pz^2-y^2$ has no $2$-adic, and hence no rational, solutions, which afte the substitutions $a=x/z$ and $b=y/z$, implies one cannot write $p=a^2+b^2$ with $a,b\in\mathbb{Q}$. Of course (again), Fermat did not have Hilbert symbols, but this is just a change of language away from Fermat's approach (I imagine). It would not be hard to unwind the above calculation into a single (probably lengthy) mod-8 calculation, since that's all that goes into deciding which elements of $\mathbb{Q}_2$ are squares, which in turn is essentially all that lives behind the Hilbert symbols.

• Can't one just say that if a=(b/c)^2+(d/e)^2, then ac^2e^2=(be)^2+(cd)^2? So this reduces to the statement that if a number can't be written as the sum of two integer squares, then that number times a square can't be written as the sum of two integer squares. But this is obvious given the theorem on which numbers are the sum of two integer squares. – Will Sawin Feb 15 '12 at 20:19
• Ah, the ol' "clearing the denominator trick." Great! – Cam McLeman Feb 15 '12 at 20:23
• The fact that $p \equiv 3 \pmod{4}$ can't be written as a sum of two rational squares can also be proved $p$-adically : if $p d^2 = a^2+b^2$ then $-1$ would be a square mod $p$, which is impossible. In modern language the equation $p=x^2+y^2$ has obstruction precisely at $2$ and at $p$. – François Brunault Feb 16 '12 at 7:36

In his early days, Fermat realized that a natural number that can be written as a sum of two rational squares actually is a sum of two integral squares, but he did not come back to this claim when eventually he discovered the proof of the Two-Squares Theorem. The result in question can be proved with the methods available to Fermat, as I will show here.

Theorem 1 If $n$ is a sum of two rational squares, then every prime $q = 4n+3$ divides $n$ an even number of times.

Theorem 2 Every prime number $p = 4n+1$ is the sum of two integral squares.

Now we invoke the product formula for sums of two squares $$(a^2 + b^2)(c^2 + d^2) = (ac-bd)^2 + (ad+bc)^2.$$ It implies that every product of prime numbers $4n+1$ and some power of $2$ can be written as a sum of two integral squares, and multiplying through by squares of primes $q = 4n+3$, the claim follows.

Proof of Theorem 1 We will show that primes $p = 4n+3$ do not divide a sum of two coprime squares.

Assume that $p \mid x^2 + y^2$ with $\gcd(x,y) = 1$. Reducing $x$ and $y$ modulo $p$ we may assume that $-p/2 < x, y < p/2$; cancelling possible common divisors we then have $p \mid x^2 + y^2$ with $\gcd(x,y) = 1$ and $x^2 + y^2 < \frac12 p^2$.

If $x$ and $y$ are both odd, then the identity $$\Big(\frac{x+y}2\Big)^2 + \Big(\frac{x-y}2\Big)^2 = \frac{x^2+y^2}2$$ allows us to remove any remaining factor of $2$ from the sum, and we may therefore assume that $a^2 + b^2 = pr$ for some odd number $r < p$. Since $a$ and $b$ then have different parity, $a^2 + b^2$ must have the form $4n+1$, and therefore the number $r$ must have the form $4n+2$. But then $r$ must have at least one prime factor $q \equiv 3 \bmod 4$, and since $a^2 + b^2 < p^2$, we must have $q \le r < p$.

Thus if $p \equiv 3 \bmod 4$ divides a sum of two coprime squares, then there must be some prime $q \equiv 3 \bmod 4$ less than $p$ with the same property. Applying descent we get a contradiction.

Proof of Theorem 2

1. The prime $p$ divides a sum of two squares.

For every prime $p = 4n+1$ there is an integer $x$ such that $p$ divides $x^2+1$.

By Fermat's Theorem, the prime $p$ divides $$a^{p-1}-1 = a^{4n}-1 = (a^{2n}-1)(a^{2n}+1).$$ If we can show that there is an integer $a$ for which $p$ does not divide the first factor we are done, because then $p \mid (a^n)^2+1$. By Euler's criterion it is sufficient to choose $a$ as a quadratic nonresidue modulo $p$. Equivalently we may observe that the polynomial $x^{2n}-1$ has at most $2n$ roots modulo $p$.

2. The descent. The basic idea is the following: Assume that the prime number $p = 4n+1$ is not a sum of two squares. Let $x$ be an integer such that $p \mid x^2 + 1$. Reducing $x$ modulo $p$ shows that we may assume that $p \mid x^2+1$ for some even integer $x$ with $0 < x < p$. This implies that $x^2+1 = pm$ for some integer $m < p$. Fermat then shows that there must be som prime divisor $q$ of $m$ such that $q$ is not a sum of two squares; since prime divisors of sums of two coprime squares have the form $4n+1$, Fermat now has found a prime number $q = 4n+1$ strictly less than $p$ that is not a sum of two squares. Repeating this step eventually shows that $p = 5$ is not a sum of two squares, which is nonsense since $5 = 1^2 + 5^2$.

Assume that $p = 4n+1$ is not a sum of two squares. We know that $pm = x^2 + 1$ is a sum of two squares for some odd integer $m < p$. By Theorem 1, $m$ is only divisible by primes of the form $4k+1$. We now use the following

Lemma Assume that $pm = x^2 + y^2$ for coprime integers $x, y$, and let $q$ be a prime dividing $m$, say $m = qm_1$. If $q = a^2 + b^2$ is a sum of two squares, then $pm_1 = x_1^2 + y_1^2$ is also a sum of two squares.

Applying this lemma repeatedly we find that if every $q \mid m$ is a sum of two squares, then so is $p$ in contradiction to our assumption. Thus there is a prime $q = 4k+1$, strictly smaller than $p$, which is not a sum of two squares, and now descent takes over.

It remains to prove the Lemma. To this end, we have to perform the division $\frac{x^2+y^2}{a^2+b^2}$. By the product formula $$(a^2+b^2)(c^2+d^2) = (ac-bd)^2 + (bc+ad)^2$$ we have to find integers $c, d$ such that $x = ac-bd$ and $y = bc+ad$.

Since $q \mid (a^2 + b^2)$ and $q \mid (x^2 + y^2)$ we also have $$q \mid (a^2+b^2)x^2 - (x^2+y^2)b^2 = a^2x^2 - b^2y^2 = (ax-by)(ax+by).$$ Since $q$ is prime, it must divide one of the factors. Replacing $b$ by $-b$ if necessary we may assume that $q$ divides $ax-by$. We know that $q$ divides $a^2 + b^2$ as well as $pm = x^2 + y^2$, hence $q^2$ divides $(ax - by)^2 + (ay+bx)^2$ by the product formula. Since $q$ divides the first summand, it must divide the second as well, and we have $pm_1 = (\frac{ax-by}q)^2 + (\frac{ay+bx}q)^2$.

Dear Michael,

concerning your first question, I think that Franz's proof is really in the spirit of Fermat's techniques. Concerning the second question, here is a short, elementary proof, inspired by a theorem of Thue (cf. exercice 1.2 in Franz's book Reciprocity laws). I tried to write it using only notions known to Fermat.

We want to prove that if there exist positive integers $m,n,a$ and $b$ such that $$m^2n=a^2+b^2,$$ then $n$ is itself the sum of two integer squares. It is easily seen that it is sufficient to prove this assertion under the hypothesis that $a$ and $b$ (and therefore $a$ and $n$) are coprime and that $n$ is not a square. Let $t$ be the unique positive integer such that $t^2< n<(t+1)^2$. Since there are $(t+1)^2>n$ integers of the form $au+bv$ with $0\leq u,v\leq t$, it follows that $n$ divides the difference $a(u-u')+b(v-v')$ of two of them. Setting $x=u-u'$ and $y=v-v'$, we have the inequalities $|x|,|y|\leq t$. The integer $n$ then divides $a^2x^2-b^2y^2$; since it also divides $a^2y^2+b^2y^2$, it divides their sum, which is equal to $a^2(x^2+y^2)$. Now, the integers $a$ and $n$ being coprime, it follows that $n$ divides $x^2+y^2$. The inequalities $0< x^2+y^2<2n$ finally imply that $n=x^2+y^2$.

EDIT: there is an elementary trick to do this due to Aubry, it is Theorem 4 on page 5 of PETE.

The positive primitive binary forms which give the easy Aubry trick showing rational implies integral are: $$x^2 + y^2, x^2 + 2 y^2, x^2 + 3 y^2, x^2 + 5 y^2,$$ $$x^2 + x y + y^2, x^2 + x y + 2 y^2, x^2 + x y + 3 y^2,$$ $$2 x^2 + 3 y^2, 2 x^2 + x y +2 y^2, 2 x^2 + 2 x y + 3 y^2.$$ Note that these are all "ambiguous," that is, equivalent to their "opposites." This is not an accident.

Probably needs mention, for the property mentioned by the OP there is no difference between the sum of two squares and the sum of three squares...

Right, I don't know about Fermat, but this phenomenon happens often enough. The first mention on MO is Intuition for the last step in Serre's proof of the three-squares theorem
and the technique, due to Aubry, Cassels, and Davenport, is mentioned in Serre A Course in Arithmetic, pages 45-47, and Weil Number Theory: An approach through history from Hammurapi to Legendre, pages 59 and 292ff in which Fermat's possible thinking is discussed.

About my use of the word "phenomenon," it is necessary for the Aubry-Cassels-Davenport trick to work that we have Pete's "Euclidean" condition, Must a ring which admits a Euclidean quadratic form be Euclidean? which is usually, for positive quadratic forms, referred to as a bound on the "covering radius" of the integral lattice under consideration. It took me a year or so to prove that Pete's condition implied that there could only be one class in that genus, A Priori proof that Covering Radius strictly less than $\sqrt 2$ implies class number one

A complete list of positive forms that satisfy Pete's condition is at NEBE. A mild generalization of the condition, due to Richard Borcherds and his student, Daniel Allcock, applies to such forms as the sum of five squares.

This is an easy consequence of the fact that if $p \equiv 3$ (mod 4) is a rational prime, then $p$ remains prime in the ring of Gaussian integers $\mathbb{Z}[i].$ Then it follows that if $a$ and $b$ are rational integers, the powers of $p$ dividing $a+bi$ and $a-bi$ (in $\mathbb{Z}[i]$ ) are equal. Hence if $n$ is an integer with $a^2 + b^2 = c^2 n$ for integers $a,b$ and $c,$ then the power of $p$ dividing $n$ is even. The fact that $p$ remains prime in $\mathbb{Z}[i]$ was (at least implicitly) known to Fermat. For if $p = (r +si)(t+ui)$ for integers $r,s,t$ and $u,$ then $p^2 = (r^2 +s^2)(t^2 + u^2).$ We can't have $p = r^2 + s^2$ since a sum of two integer squares is congruent to $0,1$ or $2$ (mod 4). Hence we must conclude that one of $r + si$ or $t +ui$ is a unit in $\mathbb{Z}[i]$, so $p$ does remain prime in $\mathbb{Z}[i].$

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}$$.

• Welcome to MathOverflow. I've edited your post to make clear the question you are answering. You may want to make clear that $gcd(w, p) = 1$ (as otherwise, $3^2 + 0 = 3*3$ is a counterexample to your statement). I'm not sure I understand your proof that $k = 1$; isn't it enough to show that $b^2 | d^2$ and $d^2 | b^2$? Further, you need that $gcd(a^2, b^2) = 1$ to show $b^2 | d^2$. – user44191 Dec 7 '18 at 19:51
• Thank you very much for pointing out gcd(w,p)=1. From gcd(c,d)=1, gcd(c^{2},d^{2)=1. Thus, we can say k does not divide $c^{2}$ as $d^{2}=kb^{2}$. Then k=1 as it must give integer in the right-hand side. But your method is much better. – supriya saha Dec 8 '18 at 6:49