Is every integer a mixed sum of three squares?

Lagrange's four-square theorem states that every natural number can be represented as the sum of four integer squares $n = a^2 + b^2 + c^2 + d^2$.

Question: Is every integer a mixed sum of three integer squares $n = \pm a^2\pm b^2 \pm c^2$ ?

Note that the signs are independently positive or negative, for example $28 = 36-9+1$.

• n=28 is a counter example – Jack Frost Nov 10 '15 at 13:59
• @JackFrost, $28=25+4-1=36+1-9=49-25+4=\ldots$. – Barry Cipra Nov 10 '15 at 14:05
• But that alternates signs. The OP said $n=\pm{}a^2\pm{}b^2\pm{}c^2.$ So they all must have the same sign – Jack Frost Nov 10 '15 at 14:08
• @JackFrost, I don't think that's what the OP means. I'm pretty sure he means the signs are independently positive or negative. – Barry Cipra Nov 10 '15 at 14:10
• @BarryCipra: yes, is there a better notation for that? – Sebastien Palcoux Nov 10 '15 at 14:11

You can write every number $n$ in the form $a^2+b^2-c^2$. Just pick $a$ so that $n-a^2$ is odd and then solve

\begin{align} b+c&=n-a^2\\ b-c&=1 \end{align}

for $b$ and $c$:

\begin{align} b&={n-a^2+1\over2}\\ c&={n-a^2-1\over2} \end{align}

• There is a standard list of these universal indefinite ternary forms, in Dickson (1939). I see, in earlier pages he shows that any such form must nontrivially represent $0;$ he also allows square factors of some things. – Will Jagy Nov 10 '15 at 18:05
• @WillJagy, I was just giving a quick construction to answer the OP's question. – Barry Cipra Nov 10 '15 at 18:19
• I know, I was letting you know in case you might be interested. – Will Jagy Nov 10 '15 at 18:21
• @WillJagy, I appreciate it. Changing notation slightly, I wonder if there might be three coefficients $a$, $b$, and $c$ such that no single fixed choice of signs gives a ternary form $\pm ax^2\pm by^2\pm cz^2$ that represents all integers $n$, but every $n$ is represented by at least one choice of signs. – Barry Cipra Nov 10 '15 at 20:39
• Oh, sure, together $x^2 + y^2 - 3 z^2$ and $-x^2 - y^2 + 3 z^2$ ought to cover everything, but each has congruence obstructions: the first is never $9^k (9 n + 6)$ (including negative $n$)because, if divisible by $3,$ both $x$ and $y$ must be divisible by $3.$ The other form, its negative, misses $9^k (9 n + 3).$ I will need to check some things to confirm, but that should work. – Will Jagy Nov 10 '15 at 20:49

around 1930, L. E. Dickson and his students, A. Oppenheim and A. E. Ross, found all indefinite ternary quadratic forms (up to $SL_3 \mathbb Z$ equivalence) with squarefree "discriminant" that do represent all integers. Three out of four infinite families are indicated on page 161 of Modern Elementary Theory of Numbers by Dickson. With odd and squarefree $N,$ also squarefree $M,$ both allowed positive or negative, the four are $$xy - M z^2,$$ $$2xy - N z^2,$$ $$2xy + y^2 - N z^2,$$ $$2xy + y^2 - 2N z^2.$$

In particular $$g(u,v,w) = 2 uv - w^2$$ is evidently universal, if the target number $n$ is even take $w=0$ and $v=1$ and $u=n/2.$ If $n$ is odd take $w=1.$

Take your $$f(x,y,z) = x^2 - y^2 - z^2$$ along with $g(u,v,w) = n.$ Then $$f(u+v+w, u + w, v+w) = (u+v+w)^2 - (u+w)^2 - (v+w)^2 = g(u,v,w) = n.$$ Note that I have indicated a linear change of variables with determinant $1,$ so that its inverse will also have integer coefficients. This is the $SL_3 \mathbb Z$ equivalence I indicated, and the reason for taking a roundabout path to a simple fact.