User:Mr. Maths/sandbox

We use our previous proof: D=2: Proof 1 (proof of prime QR sufficiency).

Let $$R(n)=\left\vert \{(x,y)\mid x,y\in\mathbb{Z},1\le x+y\sqrt{2}<3+2\sqrt{2},x^2-2y^2=n\} \right\vert$$. This notation will be needed in future. We deduce several properties of $$R(n)$$ that will assist us in determining when will the equation $$x^2-2y^2=n$$ have a solution.


 * 1) $$R(n)\ge 1$$ if and only if the equation $$x^2-2y^2=n$$ has a solution.
 * Proof: If $$R(n)\ge 1$$, clearly the equation $$x^2-2y^2=n$$ has a solution. Now suppose that a solution to $$x^2-2y^2=n$$ exists given as $$(x,y)$$. Consider $$(x',y')$$ with $$x'+y'\sqrt{2}=(x+y\sqrt{2})(x_0-y_0\sqrt{2})^m$$, where $$(x_0+y_0\sqrt{2})^m\le x'+y'\sqrt{2}<(x_0+y_0\sqrt{2})^{m+1}$$. Then by multiplicativity of the norm, $$x'^2-2y'^2=n\times 1^{-m}=n$$, and $$1\le x'+y'\sqrt{2}<3+2\sqrt{2}$$ while also satisfying $$x,y\in\mathbb{Z}$$. Therefore $$R(n)\ge 1$$.
 * 1) If $$p\equiv 3,5\pmod{8}$$ and $$n\in\mathbb{Z}$$, then $$R(p^2 n)=R(n)$$.
 * Proof: Consider $$x^2-2y^2=p^2 n \bmod p$$. Note that either $$\left(\frac{x}{y}\right)^2\equiv 2\pmod{p}$$ (where division denotes multiplying by one's inverse $$\bmod p$$), which is impossible as $$p\equiv 3,5\pmod{8}$$, or $$p\mid x,y$$, giving rise to a solution to $$x^2-2y^2=n$$. Hence $$R(p^2 n)=R(n)$$.
 * 1) If $$p\mid\mid n$$ where $$p\equiv 3,5\pmod{8}$$ then $$R(n)=0$$.
 * Proof: We employ a similar argument as above. Consider $$x^2-2y^2=n \bmod p$$. Note that either $$\left(\frac{x}{y}\right)^2\equiv 2\pmod{p}$$ (where division denotes multiplying by one's inverse $$\bmod p$$), which is impossible as $$p\equiv 3,5\pmod{8}$$, or $$p\mid x,y$$, so $$p^2\mid x^2-2y^2=n$$, contradicting the fact that $$p\mid\mid n$$.
 * 1) If $$p^{k}\mid\mid n$$ where $$k$$ is odd then $$R(n)=0$$.
 * Proof: This follows directly from the above 2 parts.
 * 1) If $$p\equiv 1,7\pmod{8}$$, or $$p=2$$, then $$R(p)\ge 1$$.
 * Proof: The former case is covered in D=2: Proof 1 (proof of prime QR sufficiency), while the latter case is solved by setting $$x=2,y=1$$.
 * 1) If $$R(n_1)\ge 1$$ and $$R(n_2)\ge 1$$, then $$R(n_1 n_2)\ge 1$$. (Can be extended to multiple terms.)
 * Proof: $$R(n_1)\ge 1$$ implies $$\exists x,y\in\mathbb{Z},x_1^2-2y_1^2=n_1$$, so $$N(x_1+y_1\sqrt{2})=n_1$$ (where $$N(a+b\sqrt{2})$$ denotes the usual multiplicative norm function on $$\mathbb{Z}[\sqrt{2}]$$, $$N(a+b\sqrt{2})=a^2-2b^2$$). Similarly, $$R(n_2)\ge 1$$ implies $$\exists x,y\in\mathbb{Z},x_2^2-2y_2^2=n_2$$, so $$N(x_2+y_2\sqrt{2})=n_2$$. By multiplicativity of the norm function, we have $$N\left((x_1+y_1\sqrt{2})(x_2+y_2\sqrt{2})\right)=n_1 n_2$$, so $$R(n_1 n_2)\ge 1$$.

We are now ready for our main theorem.

Claim. The numbers n for which the equation $$x^2-2y^2=n$$ has a solution are precisely those which admits a prime power factorisation with no primes $$p\equiv 3,5\pmod{8}$$ raised to an odd power.

Proof. By Part 2 of the above it can be seen that if $$n=\prod_{i=1}^k {p_i}^{a_i} \prod_{j=1}^m {q_i}^{b_j}$$ where $$\forall i, p_i\equiv 1,7\pmod{8}, \forall j, q_j\equiv 3,5\pmod{8}$$, then

If n admits a prime power factorisation with a prime $$p\equiv 3,5\pmod{8}$$ raised to an odd power, then by part 4 of the above it can be seen that $$x^2-2y^2=n$$ does not have a solution. Conversely, if $$n=\prod_{i=1}^k {p_i}^{a_i} \prod_{j=1}^m {q_j}^{2b_j}$$ where $$\forall i, p_i\equiv 1,7\pmod{8}, \forall j, q_j\equiv 3,5\pmod{8}$$, then n admits a prime power factorisation with no primes $$p\equiv 3,5\pmod{8}$$ raised to an odd power. We use the extended form of part 6 of the above on $$(n_1,n_2,...n_s)=\left(\overbrace{p_1,p_1,...p_1}^{a_1},\overbrace{p_2,p_2,...p_2}^{a_2},...\overbrace{p_k,p_k,...p_k}^{a_k},{q_1}^{2b_1},{q_2}^{2b_2},...{q_m}^{2b_m}\right)$$ to find a solution to $$x^2-2y^2=n$$, noting that $$R(p_i)\ge 1$$ and $$\forall c,R(c^2)\ge 1$$, showing that $$R(n)\ge 1$$, and hence the equation $$x^2-2y^2=n$$ has a solution.