Primes Represented By Quadratic Forms With Discriminant $-35$ I have been working through an exam question about which primes are represented by quadratic forms of discriminant $-35$.
So far I have been able to show that the only two reduced forms with discriminant $-35$ are $x^2 + xy + 9y^2$ and $3x^2 + xy + 3y^2$.
Next I showed that only primes $p$ with $\left(\frac{p}{5}\right)\left(\frac{p}{7}\right) = 1$ are represented by a form with discriminant $-35$.
However now the question asks me to show that if $\left(\frac{p}{5}\right) = \left(\frac{p}{7}\right) = 1$, $p$ is represented by $x^2 + xy + 9y^2$ and if $\left(\frac{p}{5}\right) = \left(\frac{p}{7}\right) = -1$, $p$ is represented by $3x^2 + xy + 3y^2$ and I can't see how to do it.
Please can someone show me how to do this? 
 A: ADDED: it is worth your time to calculate exactly how the possible steps in Gauss reduction of a positive binary form match perfectly with matrix updates, given $Z$ take an "elementary" matrix $E$ and calculate $E^T ZE$
In the two by two case, we usually demand positive determinant, so the legal elementary matrices are
$$
E = 
\left(
\begin{array}{cc}
1 & s \\
0 & 1
\end{array}
\right)
$$
$$
E = 
\left(
\begin{array}{cc}
1 & 0 \\
s & 1
\end{array}
\right)
$$
$$
E = 
\left(
\begin{array}{cc}
0 & -1 \\
1 & 0
\end{array}
\right)
$$
the way you wrote it, you need quadratic reciprocity. We begin with a (positive) prime  $p \neq 2,5,7$ such that
$$  (-35|p) = 1.$$ That means we can find some 
$$  w^2 \equiv -35 \pmod p,  $$
$$  w^2 + 35 \equiv 0 \pmod p .  $$
Now if $w$ is even, we replace it by $p - w \equiv -w \pmod p.$ Now $w^2 + 35 \equiv 0 \pmod 4,$ together
$$ w^2 + 35 \equiv 0 \pmod {4p}. $$ This means there is an integer $t$ with
$$  w^2 + 35 = 4pt.  $$ Finally,
$$  w^2 - 4pt = -35. $$ We have constructed the binary form with discriminant $-35$ andcoefficients
$$  \langle p , \; w , \; t \rangle \; .  $$ Let
$H$ be the two by two matrix
$$
H = 
\left(
\begin{array}{cc}
2p & w \\
w & 2t
\end{array}
\right)
$$
Reduce this, meaning construct the matrix $P$ with integer elements and determinant $1,$ such that $G =P^T HP$ is reduced; either
$$
G = 
\left(
\begin{array}{cc}
2 & 1 \\
1 & 18
\end{array}
\right)
$$
OR
$$
G = 
\left(
\begin{array}{cc}
6 & 1 \\
1 & 6
\end{array}
\right)
$$
Whichever one happens, take
$$  Q = P^{-1}, $$
and $Q^T G Q = H$
shows how to represent $p$ with integers. 
