Is an integer a sum of two rational squares iff it is a sum of two integer squares?

Let $a\in \mathbb Z$. Is it true that $a$ is a sum of two squares of rational numbers if and only if it is a sum of two squares of integers?

I came to face this problem while dealing with quaternion algebras.


Solution 1:

Yes, if an integer is the sum of two rational squares then it is a sum of two integer squares. For suppose that $n\ge 1$ is the sum of two rational squares. Without loss of generality we may assume that $n=\left(\frac{a}{c}\right)^2+\left(\frac{b}{c}\right)^2$, where $a,b,c$ are integers with $c\ge 1$.

Then $nc^2=a^2+b^2$.

Any prime of the form $4k+3$ in the prime power factorization of $a^2+b^2$ occurs to an even power.

It follows that the same is true of $n$, and therefore $n$ is a sum of the squares of two integers.

Remark: We have used without proof the fact that if $m$ is a positive integer, then $m$ is a sum of two squares if and only if every prime of the form $4k+3$ in the prime power factorization of $m$ occurs to an even power. This is an elementary but non-trivial result that goes back to Fermat. It is most easily proved by using Gaussian integers.

The idea of the proof can be used to show directly that a sum of two rational squares is the sum of two integer squares. But there is little saving.

Solution 2:

Given your choice of language, I think you had best also look at some articles about when an (integral) quadratic form has Pete L. Clark's ADC property, which is exactly what you quote: it represents a number integrally if and only if it represents the number rationally.

These would be the items in his publications page numbered 15, 15D, and 28.

Meanwhile, from article [28], there are 764 known positive binary quadratic forms with your property. There are exactly 103 ternary forms that do this. In those dimensions, there are just a handful of forms that satisfy the "Euclidean" condition, given (positive) form $f(\vec{x}),$ for any point $\vec{x}$ in $\mathbb R^n,$ there is at least one point $\vec{p} \in \mathbb Z^n$ such that $f(\vec{x} - \vec{p}) < 1.$ Theorem 8 in item [15] is the proof that the Euclidean property implies the ADC property. The technique goes back to Aubry, but is usually attributed to Davenport-Cassels. Very simple trick.

Out of the 764 ADC binary forms, the primitive ones that also are Euclidean (so that the Aubry trick proves your property) are $$ x^2 + xy+ y^2, x^2 + y^2,x^2 + xy+ 2y^2, x^2 + 2y^2, $$ $$ 2x^2 + xy+ 2y^2, x^2 + xy+ 3y^2, 2x^2 +2xy + 3y^2. $$

Pete would want me to mention indefinite forms. The revised Euclidean condition is $0 < |f(\vec{x} - \vec{p})| < 1.$ There are a bit over a dozen indefinite binary forms that satisfy this; most are principal, but about three are non-principal; Lenstra's idea, he called these "Euclidean Ideal Classes." Meanwhile, I imagine there are infinitely many indefinite ADC binary forms. I know there are infinitely many indefinite ternary, such as $xy-Tz^2$ for fixed nonzero integer $T.$