# Quadratic sum of Gauss integers

Let $A$ be a set, define $nA=\{x\mid x=a_1+a_2+\cdots a_k,a_i\in A,1\leq k\leq n\}$.

Denote $G=\{z\mid z=(a+bI)^2,a,b\in \mathbb Z,I=\sqrt{-1}\},K=\{z\mid z=a+2bI,a,b\in \mathbb Z,I=\sqrt{-1}\}$

What's the smallest integer $n$ such that $K=nG$ (if there exist)?

Lagrange's four-square theorem states that any natural number can be represented as the sum of four integer squares: $a=x_1^2+x_2^2+x_3^2+x_4^2,$ hence $a+2bI=x_1^2+x_2^2+x_3^2+x_4^2+b\cdot(1+I)^2$.

$a+bI~(2\not\mid b)$ cannot be represented as the sum of several integer squares, because $2\mid \Im(x+yI)^2=2xy$.

• At most 4. Since $a + 2bi = (a+b^2-1) + (1+ib)^2$ and one need at most 3 to represent $a + b^2 - 1$. If $a + b^2 - 1 = 2k+1$ is odd, it can be represent as $(k+1)^2 + (ik)^2$. – achille hui Aug 7 '13 at 12:40

If $a$ is odd we need at most two, because $$a+2bi=1\cdot(a+2bi)=u_1u_2$$ is a factorization into parts $u_1=1$ and $u_2=a+2bi$ such that $u_1\pm u_2$ have even real and imaginary parts. This means that we can solve for $z_1$ and $z_2$ from $$u_1u_2=z=z_1^2+z_2^2=(z_1+iz_2)(z_1-iz_2)$$ (using the ansatz $u_1=z_1+iz_2$, $u_2=z_1-iz_2$) as $$z_1=\frac{u_1+u_2}2=\frac{a+1}2+bi,\qquad z_2=\frac{u_1-u_2}{2i}=-b+i\frac{a-1}2.$$

And if $a$ is even we need at most one more, because $a-1$ is then odd.

So at this point we have $n\le3$.

It seems to me $z=2+2i$ cannot be written as a sum of two squares (study real and imaginary parts modulo four and check all the cases), meaning that $n=3$ is the answer.

Edit: Alternatively we can verify that no factorization of $2+2i=-i(1+i)^3$ leads to a factorization with both factors having the same parity in their real and imaginary parts. Working the above trick backwards then shows that it cannot be written as a sum of two squares. My testing suggests that $z=a+2bi$ is a sum of two Gaussian squares unless its real and imaginary parts are both congruent to $2$ modulo $4$.

• Thanks, @achille. Surely this is known. It is simpler than the four square theorem. – Jyrki Lahtonen Aug 7 '13 at 12:51

(This is not a full answer, but too long for a comment)

Claim: $n\leq 8$.

Given $a+2bi\in\mathbb Z[i]$ for some $a,b\in\mathbb Z$. By Langrange's theorem, we have: $$|a|=x_1^2+x_2^2+x_3^2+x_4^2$$ $$|b|=y_1^2+y_2^2+y_3^2+y_4^2$$ for some $x_i,y_i\in\mathbb Z$. Now, define $$c_a=\begin{cases}1&a\geq 0\\i&a<0\end{cases}\qquad c_b=\begin{cases}1+i&b\geq 0\\1-i&b<0\end{cases}$$ Then \begin{align} &\quad (c_ax_1)^2+(c_ax_2)^2+(c_ax_3)^2+(c_ax_4)^2+(c_by_1)^2+(c_by_2)^2+(c_by_3)^2+(c_by_4)^2 \\ &=c_a^2\left(x_1^2+x_2^2+x_3^2+x_4^2\right) + c_b^2\cdot\left(y_1^2+y_2^2+y_3^2+y_4^2\right) \\ &=c_a^2\cdot |a| + c_b^2\cdot |b| \\ &=a+2bi \end{align} (Check, that the last equation holds for all four cases of $(c_a,c_b)$.)