Solving $x^2 - ay^2 = b$
$a, b$ are given integers with a squarefree and $b$ prime, and I need to find pairs of integers $(x,y)$ that is a solution.
I try writing $a$ as $(\sqrt{a})^2$ , so the equation becomes $(x^2 - (\sqrt{a}\cdot y)^2)$. This is a difference of squares so I can write as $(x+y \sqrt{a}) (x - y \sqrt{a})$.
This means that I am factoring b in the ring $Z[\sqrt{a}]$. I can factor the ideal generated by $b$:
$Z[\sqrt{a}]/(b) = Z[x]/(x^2 -a, b) = Z/(b) [x] / (x^2 -a)$, and factoring $(x^2 -a)$ in the field (since $b$ is prime) $Z/(b)$ gives me a factorization of the ideal $(b)$. If $x^2 -a$ is irreducible, then $(b)$ cannot be factored, so there are no solutions.
The thing that I am stuck on is how to turn a factorization of the ideal $(b)$ into a factorization of $b$, and thus a solution to the diophantine equation?
Your quadratic form $\langle 1, 0, -a \rangle$ has discriminant $4a.$ If there is a solution, with prime $p,$ to $$ \beta^2 \equiv 4 a \pmod {4p}, $$ then we have an integer $t$ with $$ \beta^2 = 4a + 4pt, $$ whence form $$ \langle p, \beta, t \rangle. $$
Lagrange's methods reduce this to some form. The full cycle of this form is then calculated. If this form represents $1,$ it is, indeed, the principal form, and inverting some two by two matrix tells us how to solve $x^2 - a y^2 = p.$ There is, however, no guarantee that it is the principal form we find, when the class number is larger than one. Further, it is usually impossible to tell ahead of time which reduced form is found. For example, $x^2 - 229 y^2$ does not represent either prime $3$ or $11,$ but there is no way to predict this merely by congruences.
Same for these primes, which are not represented by $x^2 - 229 y^2,$ rather by $3 x^2 + 28 xy - 11 y^2$ and $11 x^2 + 28 xy - 3 y^2.$ These are equivalent to $3 x^2 + 2 xy - 76 y^2$ and $76 x^2 + 2 xy - 3 y^2$
The odd primes $p,$ with $(229|p)=1,$ that can actually be written as $x^2 - 229 y^2$ are those for which there are three roots to $$ z^3 - 4z + 1 \equiv 0 \pmod p. $$ Also $229$ itself. For the primes above, the cubic is irreducible
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
These primes can be written as $x^2 - 229 y^2:$
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Not sure about the prime $2,$ for odd primes $q$ when $(229|q) = -1,$ we get one root, factors as a linear times a quadratic:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=