Consider the equation $$x^2+5=y^2.\tag{1}$$
If $x,y\in\mathbb{Z}$, what are solutions to (1)?
If $x,y\in\mathbb{Q}$, what are solutions to (1)?
Note: $\mathbb{Z}$ is the set of all integers and $\mathbb{Q}$ is the set of all rational numbers.
My attempt: For problem 1, I run the following Mathematica program:
Solve[x^2 + 5 == y^2, {x, y}, Integers]
The output is
{{x -> -2, y -> -3}, {x -> -2, y -> 3}, {x -> 2, y -> -3}, {x -> 2,
y -> 3}}
I do not know if there is any other solutions. If the above result is correct, I would like to know why there is no other solutions.
For problem 2, I run the following Mathematica program:
Solve[(x/a)^2 + 5 == (y/b)^2 && a != 0 && b != 0 && GCD[x, a] == 1 &&
GCD[y, b] == 1, {a, b, x, y}, Integers]
The output is the same as the input, it means that Mathematica cannot solve this equation.
Any comments and answers are welcome. Thank you very much.
For solutions over $\Bbb Z$ see comments by others.
Finding solutions over $\Bbb Q$ is equivalent to solving $$x^2+5z^2=y^2$$ over $\Bbb Z$, with $x,y,z$ coprime. Without loss of (much) generality assume that $x,y,z$ are positive. Two points first:
Thus one of $x,z$ is even , the other odd, so $y$ is odd. We have $$5z^2=(y-x)(y+x)\ .$$ First consider the case $x$ odd, $z$ even. Then $y-x$ and $y+x$ are both even and $$5\Bigl(\frac{z}{2}\Bigr)^2=\frac{y-x}{2}\frac{y+x}{2}\ .$$ The two factors on the RHS are coprime, so one of them is a square and the other is $5$ times a square. So there are two possibilities:
In both of these $a,b$ must be coprime; and one is even, one odd (since $x$ is odd). This gives positive rational solutions of the original equation as $$\left|\frac{5a^2-b^2}{2ab}\right|\ ,\quad \frac{5a^2+b^2}{2ab}\ .$$
Similarly in the case $x$ even, $z$ odd, $y-x$ and $y+x$ are coprime; similar working leads in fact to the same formulae but with with $a,b$ both odd. So the complete solution is as above, with $a,b$ having no common factor. (And of course if you do allow them to have a common factor you get repetitions of the same solutions.)