When does pell equation not have infinite solution? I am working on a problem and while trying to make some progress, I stumbled across a sub-question.
When does $x^2-2y^2 = n$ NOT have infinite solutions for some positive integer $n$.
Now I tried to make some progress with help of a professor. I stumbled across the idea that if I take mod n I get $x^2 \equiv 2 y^2 \pmod N.$ Then if $y$ is relatively prime to $N$ I can multiply by the inverse of $y^2$ and that gives me $(xy^{-1})^2 \equiv 2 \pmod{n}.$ So, $2$ has to be a quadratic residue mod n. I don't know whether this helps though because, for example $2$ is not a qudratic residue mod $9$ but $x^2-2y^2 = 9$ does have infinite solutions.
I hope you guys can come up with some helpful ideas. Thanks!
 A: ummmm.  $2$  is a quadratic residue $\mod p$  when prime $ p \equiv \pm 1  \pmod 8$
On the other hand, $2$  is a quadratic nonresidue $\mod q$  when prime $ q \equiv \pm 3  \pmod 8$
From the Lemma below, if prime $ q \equiv \pm 3  \pmod 8$ and
$ x^2 - 2 y^2 \equiv 0 \pmod q,$
then both $x,y$ are divisible by $q$  and $x^2 - 2 y^2$ is diviaible by $q^2.$  Indeed, if we find the complete prime factorization of $x^2 - 2 y^2,$  the exponent of any prime $ q \equiv \pm 3  \pmod 8$ is EVEN
LEMMA
Given a binary quadratic form
$$ f(x,y) = a x^2 + b xy+ c y^2   $$
with $a,b,c$ integers.
Given
$$  \Delta = b^2 - 4 a c,  $$
where we require that $\Delta,$ if non-negative, is not a square (so also $\Delta \neq 0,1$).
Proposition: given an odd prime $q$ such that $q$ does not divide $\Delta$ and, in fact, $$ (\Delta| q) = -1, $$
whenever $$ f(x,y) \equiv 0 \pmod q,   $$ then BOTH
$$ x \equiv 0 \pmod q, \; \; \; \; \; y \equiv 0 \pmod q.   $$
Proof: the integers taken $\pmod q$ form a field; every nonzero element has a multiplicative inverse. If either $a,c$ were divisible by $q,$ we would have $\Delta $ equivalent to $b^2$ mod $q,$ which would cause $(\Delta|q)$ to be $1$ rather than $-1.$ As a result, neither $a$ nor $c$ is divisible by $q.$
Next, $q$ is odd, so that $2$ and $4$ have multiplicative inverses mod $q,$ they are non zero in the field. Put togethaer, $$4a \neq 0 \pmod q$$
Now, complete the square:
$$ a x^2 + b xy+ c y^2 \equiv 0 \pmod q  $$
if and only if
$$ 4a(a x^2 + b xy+ c y^2) \equiv 0 \pmod q,  $$
$$ 4a^2 x^2 + 4abxy + 4ac y^2   \equiv 0 \pmod q,       $$
$$ 4a^2 x^2 + 4abxy + (b^2 y^2 - b^2 y^2) + 4ac y^2   \equiv 0 \pmod q,       $$
$$ 4a^2 x^2 + 4abxy + b^2 y^2 - (b^2 y^2 - 4ac y^2)   \equiv 0 \pmod q,       $$
$$ (4a^2 x^2 + 4abxy + b^2 y^2) - (b^2  - 4ac) y^2   \equiv 0 \pmod q,       $$
$$ (2ax + by)^2 - (b^2  - 4ac) y^2   \equiv 0 \pmod q,       $$
$$ (2ax + by)^2 - \Delta y^2   \equiv 0 \pmod q,       $$
$$ (2ax + by)^2 \equiv \Delta y^2   \pmod q.       $$
Now, ASSUME that $y \neq 0 \pmod q.$ Then $y$ has a multiplicative inverse which we are allowed to call $1/y,$ and we have
$$ \frac{(2ax + by)^2}{y^2} \equiv \Delta   \pmod q,       $$
$$ \left( \frac{2ax + by}{y} \right)^2 \equiv \Delta   \pmod q.       $$
However, the HYPOTHESIS that $ (\Delta| q) = -1 $ says that this is impossible, thus contradicting the assumption that $y \neq 0 \pmod q.$
So, in fact, $y \equiv 0 \pmod q.$ The original equation now reads
$$ a x^2  \equiv 0 \pmod q  $$ with the knowledge that $a \neq 0 \pmod q,$ so we also get
$$ x \equiv 0 \pmod q, \; \; \; \; \; y \equiv 0 \pmod q.   $$
$$ \bigcirc   \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc $$
