# generalisations of Lagrange's four-square theorem

1. For which positive integers $a, b, c, d$, any natural number $n$ can be represented as $$n=ax^2+by^2+cz^2+dw^2$$ where $x, y,z,w$ are integers?

Lagrange's four-square theorem states that $(a,b,c,d)=(1,1,1,1)$ works. Ramanujan proved that there are exactly $54$ possible choices for $a, b, c, d$.

2 . For which positive integers $a, b, c, d$, $$n=ax^2+by^2+cz^2+dw^2$$ is solvable in integers $x, y,z,w$ for all positive integers $n$ except one number? For example, $n=x^2+y^2+2z^2+29w^2$ is solvable for all natural number $n$ except $14$, $n=x^2+2y^2+7z^2+11w^2$ and $n=x^2+2y^2+7z^2+13w^2$ except $5$

P.R.Halmos proved that there are exactly $88$ possible choices for $a, b, c, d$.

How to get that? Can recommend some references? Thanks

As I recall, Ramanujan mistakenly included $(1,2,5,5)$ which does not represent 15.
The main thing you need is the list of regular ternary forms $$a x^2 + b y^2 + c z^2$$ with $$1 \leq a \leq b \leq c,$$ which I put at KAPLANSKY as a pdf under the name Dickson_Diagonal_1939. The list also requires $$\gcd(a,b,c) = 1,$$ so one needs to check for when that might make a difference. I also put the proof of the 15 theorem as Bhargava_2000. Manjul's main observation was that any positive universal form has a regular ternary section, which greatly shortened the search.
For the Halmos result, I do not remember that a regular section is necessary. Indeed, Halmos found $(1,2,7,11)$ which lacks a regular ternary section, so there you go.
If I were to do this, I would simply do a quadruple loop in some computer language, once $(a,b,c)$ represents all numbers up to $c,$ or misses at most one value, then try possible $d \geq c$ so that no more values are missed (up to 100, say). For the Halmos problem it is acceptable to consider $a=1,2.$ As it happens, we now know for sure that the single number missed is 15 or smaller, but Halmos did not need to assume that.
In case of actually computing this: Given $a=1,2,$ there are infinitely many numbers not represented. Call the smallest number missed $A_1,$ call the second $A_2.$ So, then we are considering $a x^2 + b y^2$ with $a \leq b \leq A_2,$ otherwise we miss two values. Call the smallest number missed $B_1,$ the next $B_2.$ We move on to consider $a x^2 + b y^2 + c z^2$ with $b \leq c \leq B_2.$ Now, it is not entirely trivial that any positive ternary still misses infinitely many values. A short discussion, not quite a full proof, is at the very end of The Sensual Quadratic Form by J. H. Conway. Anyway, call the smallest number missed $C_1,$ the next $C_2.$ We move on to consider $a x^2 + b y^2 + c z^2 + d w^2$ with $c \leq d \leq C_2.$
Positivity is used in an essential way in all of this. As to indefinite forms that are otherwise the same, given any integer $N,$ the forms $$x^2 - y^2 + (2N+1)z^2$$ and $$x^2 - y^2 + (4N+2)z^2$$ are universal.