Find minimum $n$ for $x^2+3x+6=f_1(x)^2+f_2(x)^2+ \cdots +f_n(x)^2$

Solution 1:

Let $\mathbf{v} = (v_1,\ldots,v_n)$ be a vector with $\|\mathbf{v}\| = 1$ and entries in $\mathbf{Q}$. It is a fact, not completely obvious, that $\mathbf{v}$ extends (as either a row or a column) to an orthogonal matrix with rational entries. (For example, see Is every unit vector in $\mathbb{Q}^n$ the first column of a rational orthogonal matrix?). In particular, there exists an orthogonal matrix $M \in \mathrm{O}(n)$ with $M \mathbf{e}_1 = \mathbf{v}$, or replacing $M$ by its inverse, with $M \mathbf{v} = \mathbf{e}_1$.

The polynomial $x^2 + 3 x + 6$ can clearly be written as the sum of $n$ squares if and only if the same is true for $4(x^2 + 3 x + 6) = (2x + 3)^2 + 15$, and this can clearly be written as the sum of $n$ squares if and only if the same is true for $x^2 + 15$. Now write

$$x^2 + 15 = (v_1 x + u_1)^2 + (v_2 x + u_2)^2 + (v_3 x + u_3)^2 + (v_4 x + u_4)^2.$$

Equating coefficients, we deduce, with $\mathbf{v} = (v_1,v_2,v_3,v_4)$ and $\mathbf{u} = (u_1,u_2,u_3,u_4)$, that

$$1 = v^2_1 + v^2_2 + v^2_3 + v^2_4 = \|\mathbf{v}\|,$$ $$0 = 2 v_1 u_1 + 2 v_2 u_2 + 2 v_3 u_3 + 2 v_4 u_4 = 2 \mathbf{v}.\mathbf{u},$$ $$15 = u^2_1 + u^2_2 + u^2_3 + u^2_4 = \|\mathbf{u}\|.$$

Now take a rational orthogonal matrix $M$ above, so $M \mathbf{v} = \mathbf{e}_1$, and $M \mathbf{u} = \mathbf{x}$ for some rational vector $\mathbf{x}$. Since orthogonal matrices preserve angles and lengths, we get

$$\mathbf{e}_1.\mathbf{x} = 0, \ \|\mathbf{x}\| = 15.$$

The first equality implies that $\mathbf{x} = (0,a,b,c)$ for rational $a$, $b$, and $c$, and the second implies that

$$a^2+b^2+c^2 = 15.$$

This, however, has no solutions in rational numbers because $15 \equiv 7 \bmod 8$ and no such numbers are sums of three rational squares by a standard $2$-adic argument. (When is a rational number a sum of three squares?)

Thus the minimal possible number of squares is $5$, but clearly

$$x^2 + 15 = (x)^2 + 3^2 + 2^2 + 1^2 + 1^2.$$