Prime representation when h of minus eight q equals two (source code)

= Prime representation when h of minus eight q equals two
{title2=$h(-8q)=2$}

Suppose $q$ is a <prime number> with $q\equiv3\pmod8$ and $h(-8q)=2$. For each <prime number> $p>q$, there is an <integer> representation
$$
p=x^2+2qy^2
$$
exactly when $p\equiv\pm1\pmod8$ and $(p/q)=1$ as a <Legendre symbol>.

Necessity follows directly. <Modulo> $q$, $p$ is a nonzero square. Since $p$ is odd, $x$ is odd, so <modulo> eight the value is one when $y$ is even and seven when $y$ is odd, using $2q\equiv6\pmod8$.

Conversely, the two conditions give
$$
\left(\frac{-8q}{p}\right)=\left(\frac2p\right)\left(\frac pq\right)=1
$$
by <quadratic reciprocity> and the <second supplementary law for quadratic reciprocity>. The <discriminant criterion for prime representation by a binary quadratic form> therefore gives a primitive positive definite form of discriminant $-8q$ representing $p$.

By <two distinguished classes of discriminant minus eight q> and the hypothesis $h(-8q)=2$, it reduces to $[1,0,2q]$ or $[2,0,q]$. Any odd value of the second form has odd $y$, and is three or five <modulo> eight. It cannot represent this $p$, so the first form must. For $q=3$, the two reduced forms of discriminant $-24$ are $[1,0,6]$ and $[2,0,3]$; the permitted prime seven is $1^2+6\cdot1^2$.