TITLE: Positive primes represented by indefinite binary quadratic form
QUESTION [11 upvotes]: Neil Sloane asked me about commands in computer languages to find the (positive) primes represented by indefinite binary quadratic forms. So I wrote something in C++ that works. This is for the OEIS, these primes go into sequences... Note that, within a few hours, another guy had run the tables much higher with a one-line Maple command. Some days it does not pay to get up. 
I thought of one I really do not understand. Discriminant $205$ has four classes of forms, $$ \langle 1, 13, -9 \rangle, \; \langle -1, 13, 9 \rangle, \;  \langle 3, 13, -3 \rangle, \; \langle -3, 13, 3 \rangle.   $$
The third and fourth are opposites so in the same genus, although distinct. The first two are in the principal genus, but they are not opposites, one is $-1$ times the other; in particular, they get diffeent positive primes, although both do residues $\pmod 5$ and $\pmod {41}.$ For $\langle 1, 13, -9 \rangle$ we get
$$ 1,5,59,131,139,241,269,271,359,409, \ldots,  $$ while for $\langle -1, 13, 9 \rangle$ we get
$$ 31,41,61,251,349,379,389,401,419,431, \ldots.  $$
For positive forms, low class number, there are polynomials, such as in Cox's book, such that primes represented by the principal form are those for which the polynomial factors a certain way. For a prime $p \equiv 1 \pmod 3,$ Gauss showed that $2$ is a cubic residue if an only if $p = u^2 + 27 v^2.$ Jacobi showed that $3$ is a cubic residue if an only if $p = u^2 + uv + 61 v^2.$ All I found in Henri Cohen's tables was the fact that $\mathbb Q(\sqrt {205})$ has class number $2$ and $L_K = \mathbb Q(\sqrt 5),$ appendix 12C on pages 533 and 534. See related information at IT'S A LINK.
Let's see, $34$ is the smallest number where it is a surprise that there is no solution to $x^2 - 34 y^2 = -1.$ The smallest such odd number is $205,$ as there is no solution to $x^2 - 205 y^2 = -1.$ For prime $p \equiv 1 \pmod 4,$ there is always a solution to $x^2 - p y^2 = -1.$ Proof in Mordell's book. Anyway, this is why $\langle 1, 13, -9 \rangle, \; \langle -1, 13, 9 \rangle$ are distinct classes.
So, that is the question, can I distinguish the represented (positive) primes by factoring some polynomial mod these primes?

REPLY [2 votes]: Consider the quadratic number field $K$  with discriminant $D = pq$,
where $p$ and $q$ are primes $\equiv 1 \bmod 4$ (all results below
hold after a suitable modification also for $p = 2$). By results due 
to Dirichlet and Scholz, The fundamental unit of this field has norm

$-1$ if $(p/q) = -1$
$+1$ if $(p/q) = +1$ and $(p/q)_4 (q/p)_4 = -1$
$-1$ if $(p/q) = +1$ and $(p/q)_4 = (q/p)_4 = -1$

Here $(q/2)_4$ is $+1$ or $-1$ according as $p$ is congruent to $1$
or $9$ modulo $16$.
In the case $(p/q) = -1$, the Hilbert $2$-class field coincides with
the genus field $K^* = Q(\sqrt{p},\sqrt{q}\,)$. This is also the Hilbert
$2$-class field in the usual sense if  $(p/q) = +1$ and $(p/q)_4 (q/p)_4 = -1$;
in this case, however, there is a quadratic extension of the genus field
unramified at finite primes, which can be constructed explicitly by
solving the diophantine equation $x^2 - 4py^2 = q$ and setting
$K = K^*(\sqrt{\mu})$ for $\mu = x + 2y\sqrt{p}$, where the sign of
$x$ is chosen in such a way that $\mu$ is congruent to a square mod $4$,
i.e., such that $x + 2y \equiv 1 \bmod 4$. In this case this means
that $x$ is negative.
For the smallest discriminants, the corresponding elements are

$D = 2 \cdot 17$: $\mu = -5 + 2 \sqrt{2}$;
$D = 5 \cdot 41$: $\mu = -11 + 4 \sqrt{5}$;
$D = 13 \cdot 17$: $\mu = -9 + 2 \sqrt{17}$;
$D = 5 \cdot 61$: $\mu = -9 + 2 \sqrt{5}$.   

Noam's generator in the case $D = 205$, by the way, is 
$\sqrt{\varepsilon_{205}} \cdot \omega$, where 
$\sqrt{\varepsilon_{205}} = \frac12(3\sqrt{5} + \sqrt{41})$
and $\omega = \frac12(1+\sqrt{5})$.
It is possible to construct the corresponding polynomials, but for your purpose it is
better to work with the generators, as already Noam has pointed out.