Diophantine equation $x^2+n y^2 = b$ : when does it have solutions?

96 Views Asked by At

recently I had to solve some diophantine equations in the form $x^2 + n y^2 = b $ in the variables $x$ and $y$, for various fixed values of $n$, and $b$.

Other than "bruteforcing" it, are there some ways to know if, given $n$ and $b$, this equation has at least a solution?

Edit: $n$ and $b$ are both positive integers

1

There are 1 best solutions below

4
On

Because of the Brahmagupta–Fibonacci identity, it is enough to answer the question for $b$ prime. But then the answer depends on the arithmetic of quadratic fields. The answer is not simple but it is fascinating. See the book Primes of the Form $x^2+ny^2$, by David Cox.

A good introduction is the case $n=1$, which is solved by Fermat's theorem on sums of two squares .