Let $k$ be a positive integer. Let
$$Q=
\begin{pmatrix}
 1 &1/2& & & & \\
1/2& 1 & & & & \\
 & & 1 &1/2& & \\
 & &1/2& 1 & & \\
 & & & & 1 &1/2\\
 & & & &1/2& 1 
\end{pmatrix}.
$$



> 
> How many solution $x\in\mathbb Z^6$ are there to $\quad x^tQx=k$?
> 
> 
> 


This is equivalent to: 



> 
> How many solution $x\in\mathbb Z^6$ are there to 
>  $$x\_1^2+x\_1x\_2+x\_2^2+ x\_3^2+x\_3x\_4+x\_4^2+ x\_5^2+x\_5x\_6+x\_6^2=k?$$
> 
> 
> 


or to



> 
> How many solution $x\in \mathbb Z\left[\omega \right]^3$ are there to $\quad x^\* I\_3 x=k$?
> 
> 
> 


where $I\_3$ is the $3\times3$-identity matrix and $\omega=\frac{1+\sqrt{-3}}{2}$.


I know that there is a formula for this number (there is only one class in its genus), but I don't know it.


This question is related to


* [which integers take the form x^2 + xy + y^2 ?](https://mathoverflow.net/questions/78361/which-integers-take-the-form-x2-xy-y2)
* <https://math.stackexchange.com/questions/44139/how-many-solutions-are-there-to-fn-m-n2nmm2-q/>


but they don't answer my question. 



How many solutions are there to $\sum_{i=1}^3 x_i^2+x_iy_i+y_i^2=k$?
The formula that emiliocba seeks seems to be as follows.
Let $\chi$ be the Dirichlet character mod $3$. For $k>0$
write $k = 3^e n$ with $n \equiv \pm 1 \bmod 3$. Then
the number of representations of $k$ by this quadratic form $A\_2^3$ is
$$
s(k) :=
9 (3^{2e+1}-\chi(n)) \phantom. \sum\_{d|n} \phantom. \chi(n/d)\phantom. d^2.
$$
I append **gp** code that verifies that this holds for $k \leq 432$.


To prove it in general it will be enough to check that
$$
\varphi := 1 + \sum\_{k=1}^\infty \phantom. s(k) q^k
$$
is a modular form of weight $3$ and character $\chi$ for $\Gamma\_0(3)$,
and to match a few coefficients with the theta function $\theta\_{A\_2^3}$.
In principle, it is enough to match only the $q^0$ coefficient:
the dual of $A\_2^3$ is isomorphic with the scaling of $A\_2^3$ by $1/3$,
so by Poisson summation $\theta\_{A\_2^3}$ is modular also for
the normalizer $\Gamma\_0^+(3)$ of $\Gamma\_0(3)$ (generated by $\Gamma\_0(3)$ and
the involution $w\_3 : \tau \longleftrightarrow -1/3\tau\phantom.$);
and $\Gamma\_0^+(3)$ has only one cusp,
and no cusp forms of weight less than $6$ (the weight of
$\eta(\tau)^6 \eta(3\tau)^6$), so the normalized Eisenstein series $\varphi$
is the only candidate for $\theta\_{A\_2^3}$.



```
H = 24
A2 = sum(m=-H,H,sum(n=-H,H,q^(m^2+m*n+n^2))) + O(q^(3*H^2/4+1));
L = A2^3;

chi3(m) = kronecker(m,3)
{
s(k, e,n) =
  e = valuation(k,3);
  n = k / 3^e;
  9 * (3^(2*e+1)-chi3(n)) * sumdiv(n, d, chi3(n/d)*d^2)
}

L == 1 + sum(k=1,3*H^2/4,s(k)*q^k)

```

