<s>[INST] Primes of the form $x^2+31y^2$ and $x^2+xy+8y^2$ and quadratic forms While working on an exercise in algebraic number theory, I encountered the following problem:

A prime number $p$ can be represented as $x^2+31y^2$ if and only if it can be represented  as $x^2+xy+8y^2$.

In this answer by Will Jagy, he claims that those quadratic forms represent the same odd numbers (where odd is in bold).
A while ago, I encountered a similar problem, with $x^2+3y^2$ and $x^2-xy+y^2$, which I managed to solve using some ad-hoc reasoning:
Claim. There exist $a,b\in \Bbb Z$ such that $p=a^2-ab+b^2$ if and only if there exist $x,y\in \Bbb Z$ such that $p=x^2+3y^2$. Proof. $\boxed{\Leftarrow}$ Let $a=x-y$ and $b=x+y$.  $\boxed{\Rightarrow}$ If $a$ and $b$ have the same parity, let $x=\frac{a+b}{2}$ and $y=\frac{a-b}{2}$. In the case where $a$ and $b$ have different parity, wlog $a$ is odd and $b$ is even. Write $a=2n+1$ and $b=2m$ with $n,m\in \Bbb Z$. Let $x=m-2n-1$ and $y=m$. $\blacksquare$
This is not very satisfying, I would like to know if there is some general method for tackling this. Here I found some explanation, pointing me into the direction of equivalent quadratic forms. It suggests to find a matrix $T\in GL_2(\mathbf{Z})$ with determinant $\pm 1$ such that $T^\top \begin{bmatrix}1 & \frac12 \\ \frac12 & 8 \end{bmatrix}T=\begin{bmatrix}1 & 0 \\ 0 & 31 \end{bmatrix}$. Letting $T=\begin{bmatrix} a & b \\ c& d \end{bmatrix}$, we get $1=\begin{bmatrix} a & b\end{bmatrix}\begin{bmatrix}1 & \frac12 \\ \frac12 & 8 \end{bmatrix}\begin{bmatrix}a \\ b\end{bmatrix}=a^2+ab+8b^2$, which has unique integer solutions $(a,b)=(\pm 1,0)$. Similarly,  $31=c^2+cd+8d^2$ has unique integer solutions $(c , d)=(\pm 1,\mp 2)$. Hence, such $T$ does not exist. I suspect this has to do  with what Will Jagy is underlining.
Clearly, my knowledge of quadratic forms is too weak. Could someone shed a light on this problem?
 [/INST] It turns out I was thinking too difficult. "Completing the square" gives $$x^2+xy+8y^2=(x+\tfrac12 y)^2+31(\tfrac12 y)^2.$$
Let $n$ be an odd integer such that $n=x^2+xy+8y^2$ for some integers $x,y$. Reducing modulo 2 gives $1\equiv x(x+y)\bmod{2}$, hence $x$ and $x+y$ are odd, so in particular $y=(x+y)-x$ is even.
Conversely, if $n=z^2+31w^2$ for some integers $z,w$, then we can $y=2w$ and $x=z-2w$ to see that $n=x^2+xy+8y^2$.
Hence, we see that an odd number can be represented by the quadratic form $x^2+xy+8y^2$ if and only if it can be represented by the quadratic form $x^2+31y^2$.
</s>