Sums of squares are closed under division

Addition: Trivial. Any sum of two finite sums of squares is a finite sum of squares.

Multiplication: Trivial. Any product of two squares is a square and the distributive property shows that a product of two finite sums has finitely many terms.

Division: Suppose that $a=\sum_{i=1}^n x_i^2$ is not zero. We would like to show that $a^{-1}\in S$ (using s.harp's comment). If $n=1$, then the inverse of $a$ is trivial. The first interesting case is when $n=2$ Suppose that $a=x_1^2+x_2^2$.

Now, $$ \frac{1}{x_1^2+x_2^2}=\frac{x_1^2+x_2^2}{(x_1^2+x_2^2)^2}=\left(\frac{x_1}{x_1^2+x_2^2}\right)^2+\left(\frac{x_2}{x_1^2+x_2^2}\right)^2 $$ The denominators are OK because this is a field. All higher $n$'s are generalizations of this case.


$$\frac{1}{x_1^2+x_2^2+x_3^2}=\frac{x_1^2}{(x_1^2+x_2^2+x_3^2)^2}+\frac{x_2^2}{(x_1^2+x_2^2+x_3^2)^2}+\frac{x_3^2}{(x_1^2+x_2^2+x_3^2)^2}$$


$\begin{align}{\bf Hint} \ \ a\neq 0\ \Rightarrow&\ \ \color{#c00}{a^{\large -2}} =\, (a^{\large -1})^{\large 2} \in S\ \ \text{by $\,S\,$ contains all squares}\\ {\rm so}\ \ \ a\in S\ \Rightarrow&\ \ a^{\large -1} =\, a\cdot \color{#c00}{a^{\large-2}}\in S\ \ \text{by $\,S\,$ is closed under multipication} \end{align}$

Remark $ $ You asked how it generalizes. The above idea works not only for squares, but for any positive power, i.e. we can obtain $\,a^{-1}\,$ from any of its positive powers via $\,a^{\large -1} = a^{\large n-1}(a^{\large -1})^{\large n}.$ Also the only property of squares (or powers) employed in proving multiplicative closure is that they are closed under multiplication. These observations lead to the following generalization.

Theorem $ $ Suppose $K$ is a field, $M$ is a subset of $K$ and $S$ is the set of all sums of elements of $M.$

$(1)\ \ S$ is closed under multiplication if $M$ is closed under multiplication.

$(2)\ \ S$ is closed under division (by all nonzero elements) if $S$ is both closed under multiplication, and every $\,a\in K$ has some positive power $\,a^{\large n}\in S.$

Proof $\ (1)\,$ is an immediate consequence of the distributive law. $\ (2)\ $ follows as above, namely if $\,0\neq s\in S\,$ then by hypothesis $\,(s^{\large -1})^{\large n}\in S\,$ for some $\,n\geq 1\,$ thus $\,s^{\large n-1}(s^{\large -1})^{\large n} = s^{\large -1}\in S\,$ because $S$ is closed under multiplication. Hence $\,a\in S\,\Rightarrow\,as^{-1} = a/s\in S,\,$ so $S$ is closed under division.