<s>[INST] Primes of the form $x^2 + 9 y^2$ and $x^2 + 12 y^2$ I've been studying primes of the form $x^2 + n y^2$ (where of course $x$, $y \in \mathbb{Z}$) and I noticed the following:
$$p = x^2 + 9 y^2 \iff p \equiv 1 \,\, (\textrm{mod} \,\, 12) \iff p = u^2 + 12 v^2$$
For example, $10^2 + 9 \cdot 7^2 = 541 = 23^2 + 12 \cdot 1^2$.

The "difficult halves" of these biconditionals can be gotten immediately from the fact that

an integer $m$ is represented by a quadratic form of discriminant $\Delta$ $\iff$ $\Delta$ is a square mod $4m$

The reduced quadratic forms of discriminant $-36$ are $x^2 + 9 y^2$ and $3 x^2 + 3 y^2$ and $2 x^2 + 2 x y + 5 y^2$. If $p \equiv 1 \,\, (\textrm{mod} \,\, 12)$, then $-36$ is a square mod $4p$, and among these three forms, the only one with any $1 \,\, (\textrm{mod} \,\, 3)$ outputs is $x^2 + 9 y^2$.
Likewise, the reduced quadratic forms of discriminant $-48$ are $u^2 + 12 v^2$ and $2 u^2 + 6 v^2$ and $3 u^2 + 4 v^2$. If $p \equiv 1 \,\, (\textrm{mod} \,\, 12)$, then $-48$ is a square mod $4p$; and among these three forms, the only one with any $1 \,\, (\textrm{mod} \,\, 4)$ outputs is $u^2 + 12 v^2$.
So $p \equiv 1 \,\, (\textrm{mod} \,\, 12)$ implies both $p = x^2 + 9 y^2$ and $p = u^2 + 12 v^2$.

My question: is it just a coincidence that $x^2 + 9 y^2$ and $u^2 + 12 v^2$ represent exactly the same primes?
I've computed $(x,\,y)$ and $(u,\,v)$ for the relevant primes under $1000$, and there doesn't seem to be a pattern relating them.
Thanks!
 [/INST] Not a concidence.
I will prove that if a prime p is of the form $x^2+9y^2$ then it must be of the form $a^2+12b^2$ and viceversa.
Case 1: $p=a^2+12b^2$ Prove $p=x^2+ 9y^2$ for some $x$ and $y$
$p=a^2+12b^2$  Note that $p$ is $\equiv 1\pmod{4}$ so -1 is also a quadratic residue, so $-1\times9=9$ also is one.
From Thue's lemma we have, by taking $a$ such that $a^2\equiv-9\pmod{p}$ (obviously, $p\neq 3$) some $x$, $y$ such that $x\equiv ay\pmod{p}$ so $x^2\equiv -9y^2\pmod{p}$ so $x^2+9y^2$ is divisible by p. Also from Thue's lemma we have that $x^2+9y^2<10p$ Now a simole analysis will lead to the fact that $p$ is indded of the form $x^2+9y^2$
Case 2: $p=x^2+ 9y^2$ Prove $p=a^2+12b^2$ for some $a$ and $b$
$x\equiv 1\pmod{3}$ so $\big(\frac{-3}{p}\big)=\big(\frac{3}{p}\big)\times\big(\frac{-1}{p}\big)=\frac{1}{\big(\frac{p}{3}\big)}\times (-1)^{\frac{p-1}{2}\frac{3-1}{2}}\times(-1)^{\frac{p-1}{2}}=1$ From the quadratic reciprocity law so $-3$ is a qudratic residue. Again use Thue to prove that there exist $a$ and $b$ such that $a^2+12b^2$ is divisible by $p$ and $<13p$ and from a simple analysis we get that $p$ is indeed of the form we wanted
So we win!
</s>