Assume, $p$ is a prime of the form $8k\pm 1$
How can I prove that the equation $$a^2-2b^2=p$$ has an integer solution with $1\le b<\sqrt{p}$ ?
I am not even sure that the claim is true, but I checked the primes upto $p=10^7$ and a solution always exists upto this limit. I tried to use that $2$ is a quadratic residue mod $p$ , but without success. Any ideas ?
First of all, $2$ is a quadratic residue modulo $p$, since by (the supplement of) Quadratic Reciprocity $$ \left(\frac 2p\right) = \begin{cases} +1&\text{ if $p\equiv \pm1$ modulo $8$ ,}\\ -1&\text{ if $p\equiv \pm3$ modulo $8$ .} \end{cases} $$ Let $R=\Bbb Z[\sqrt 2]$ be the ring of integers in the quadratic field $\Bbb Q(\sqrt 2)$, generated by $$\sqrt 2\ ,$$ then the splitting of the ideal $(p)$ in $R$ corresponds to the structure of $R/(p)$, Prime Factorization of ideals in a Quadratic Field (wiki), and in our case $$ \Bbb Z[\sqrt 2]/p=(\Bbb Z[X]/X^2-2)/p=\Bbb Z[X]/(X^2-2,p)=(\Bbb Z[X]/p)/(X^2-2)=\Bbb F_p[X]/(X^2-2)\ , $$ which is a product of two rings, since $X^2-2$ has two different roots in $\Bbb F_p$, since $2$ is a quadratic residue modulo $p$.
The ring $R$ is factorial, unique decomposition, $p\in R$ splits as a product of two Galois conjugated factors $a\pm b\sqrt 2$, $a,b\in \Bbb Z$, so there exists a solution $$ p = (a+b\sqrt 2)(a-b\sqrt 2)=a^2 -2b^2\ .$$ Let $a,b$ be such that $a,b\ge 1$, (replace possibly $a,b$ by $\pm a$, $\pm b$ for suitable changes of signs,) and have a minimal $b$.
The units in $R$ are generated by $\pm1$, and (integer powers of) $1+\sqrt 2$. So from a solution we can get an other one by multiplying with $(\pm 1\pm \sqrt 2)$. Let us compute first: $$ (a+b\sqrt 2)(1-\sqrt 2)=(a-2b)+(b-a)\sqrt 2 \ . $$ So we can assume first $1\le b<a$. (Else, we can pass from $b$ to $b-a$.) We can even assume $b<\frac a2$. (Possibly passing from $b$ to $|b-a|=|a-b|$. This gives $$p=a^2-2b^2 >(2b)^2-2b^2=2b^2\ .$$ We found a better bound. $\blacksquare$
Note: The above "dance" is related to the (genus) theory of quadratic forms and to the question if a prime is "represented" by a given form.
Computer check, sage:
This gives: