# What is known about primes of the form $x^2-2y^2$?

David Cox's book Primes of The Form: $x^2+ny^2$ does a great job proving and motivating a lot of results for $n>0$. I was unable to find anything for negative numbers, let alone the case I am interested in, $n=-2$.

What is the reason for this? Maybe I am missing something. Any references to results involving primes of this form will be greatly appreciated.

• Since $\mathbb{Z}[\sqrt2]$ is a UFD (hence a PID) you only need to understand for which odd primes the congruence $x^2-2y^2\equiv 0 \pmod p$ has a nontrivial solution, i.e. when $\left(\frac2p\right)=1$, that is when $p\equiv\pm1\pmod 8$. This leaves out 2, but then $2 = 2^2 - 2\cdot 1^2$.. Feb 19, 2015 at 7:40

Take any square free $1 \neq n \in \mathbb{N}$ and recall that $R_n = \mathbb{Z}[\sqrt{n}]$ has a multiplicative norm function $N \colon R \to \mathbb{Z}$ given by $N(x + y\sqrt{n}) = x^2 -ny^2$ so a prime $p$ is of the required form iff $p$ is a norm in $R_n$ (i.e $p$ is in the image of $N$).

Now take $n$ which is not $1$ mod $4$ (this assures that $R_n$ is the ring of integers of $\mathbb{Q}(\sqrt{n})$) and for which the class number of $\mathbb{Q}(\sqrt{n})$ is $1$ (equivalently, $R_n$ is a principal ideal domain).

Clearly, $p = 2$ is of the required form for $n = 2$ ($x=2, y=1$), so assume $p$ is an odd prime number. Recall that $R_2$ is Euclidean with respect to $N$, so it is a principal ideal domain and $n = 2$ satisfies our assumptions.

Claim: The ideal $(p)$ splits completely (is a product two distinct prime ideals) in $R_n$ iff $p$ is of the required form.

Proof: We use the equivalent condition with the norm.

If $p = IJ$ is a splitting, taking norms of ideals we see that $N(IJ) = p^2$ so since the ideals are proper, $N(I) = p$. Since $R_n$ is principal, there exists some $a \in R_n$ such that $(a) = I$. Therefore, $N(a) = N(I) = p$, and $p$ is a norm as required.

If $p = N(x + y\sqrt{n})$, then $(p) = (x + y\sqrt{n})(x - y\sqrt{n})$ is the required splitting since the equality is obvious, and the primality of the factors follows from the fact that their norm is prime (equal to $p$). Furthermore the ideals are distinct as dividing a generator of one of them by a generator of the other does not belong to $R_n$.

Now, according to Neukirch’s Algebraic Number Theory proposition (8.5) $(p)$ splits completely iff $n$ is a quadratic residue mod $p$. For $n = 2$ this amounts to $p = \pm 1 \pmod 8$, by a lemma of Gauss.

• Thanks!! I like this solution better, but I appreciate the variety of perspectives to solve this. Feb 20, 2015 at 16:14
• It is possible that I will write also a completely elementary solution soon. Hope it will be of interest. Feb 20, 2015 at 16:19
• How do you know that the norm of a is positive? You either need to prove it, or to show that there is a unit with negative norm (i.e., solution to $X^2-nY^2=-1$, for $n=2$ one may take $(1,1)$, of course...). Nov 15, 2017 at 16:04
• @LiorBary-Soroker you are right, I have completely missed this point. For instance, if $n=3$ and $p=11$ there seems to be a problem. As you correctly suggest, one needs the extra assumption that the negative Pell equation has a solution. Nov 15, 2017 at 18:04

As $2 = x^2 -2y^2$ for $x = 2$ and $y=1$ we fix an odd prime number $p$, and

Claim: There exist integers $x,y$ such that $p = x^2 -2y^2$ if and only if $p \equiv \pm1 \mod 8$.

First if $p = x^2 -2y^2$ for some $x,y \in \mathbb{Z}$ then observing that the squares mod $8$ are $0,1,4$, we conclude that $p$ can only be $0,1,2,4,6,7$ mod $8$ but it is odd so $p \equiv \pm1 \mod 8$.

For the other direction, suppose that $p \equiv \pm1 \mod 8$. By a lemma of Gauss, there exists some $t \in (\mathbb{Z}/p\mathbb{Z})^*$ such that $t^2 \equiv 2 \mod p$. Define: $$S = \{a \in \mathbb{Z} \mid 0 \leq a \leq \sqrt{p}\}$$ and observe that $|S| > \sqrt{p}$. Consequently, $|S^2| > p$ so by the pigeonhole principle, there are different $(x_1,y_1),(x_2,y_2) \in S^2$ for which $x_1 - ty_1 \equiv x_2-ty_2 \mod p$, or equivalently, $x_1 - x_2 \equiv t(y_1 - y_2) \mod p$.

Set $x = |x_1 - x_2|, y = |y_1 - y_2|$ and note that $(x,y) \in S^2$ and that $x \equiv \pm t y \mod p$, so after squaring we get that $x^2 \equiv 2y^2 \mod p$, that is $p | x^2 - 2y^2$. On the other hand, $$|x^2 -2y^2| \leq |x|^2 +2|y|^2 < p + 2p = 3p.$$ Therefore, $x^2 -2y^2 \in \{-2p,-p,0,p,2p\}$.

Case 1: $x^2-2y^2 = 0$ which means that $x^2 = 2y^2$. Taking into account the number of times $2$ divides both sides (alternatively, set $x = 2x_0$ and apply infinite descent), we see that equality is possible if and only if $x = y = 0$, but this contradicts our assumption that $(x_1,y_1) \neq (x_2,y_2)$.

Case 2: $x^2 -2y^2 = 2p$. Clearly, $x$ is even. Set $a = x + y, b = x/2+y$ and observe that $a^2 -2b^2 = p$.

Case 3: $x^2 -2y^2 = -p$. Set $a = x + 2y, b = x + y$ and observe that $a^2 -2b^2 = p$.

Case 4: $x^2 -2y^2 = -2p$. Clearly, $x$ is even. Set $a = 2x + 3y, b =3x/2 + 2y$ and observe that $a^2 -2b^2 = p$.

Case 5: $x^2 -2y^2 = p$, which is what we want.

• The part before the cases can be improved: first, you can actually get that $-2p<x^2-2y^2<p$ by doing cases on whether $x^2\geq 2y^2$ or $x^2<2y^2$. So you get $x^2-2y^2\in\{-p,0\}$. This means that you only need to check cases 1 and 3. Mar 8, 2021 at 12:54

Ummm. Just so you know, the same type of conclusion holds for $$x^2 - p y^2$$ for prime $p,$ $$5 \leq p \leq 197, \; \; \; \; p \equiv 1 \pmod 4.$$ For that matter, one may switch to the forms $$x^2 + xy - \left( \frac{p-1}{4} \right) y^2$$

For these forms, a number $n$ is represented if and only if $-n$ is represented. There is a solution to $x^2 - p y^2 = -1,$ a result in Mordell's book. Since every odd prime $q$ that satisfies $(p|q) = 1$ is represented by some form of the discriminant, and there is only one class of this discriminant, then all odd primes $q$ with $(q|p) = 1$ are integrally represented. Representation of the prime $2$ is a different matter, as we need $(2|p) = 1,$ so this works only when we further demand $p \equiv 1 \pmod 8.$