Finding all integer solutions of a quadratic equation I am trying to find all integer solutions for the equation $x^2+xy+5=y^2$. 
I believe it is possible to apply some sort of substitution and completing the square to rewrite the equation into the form $x^2-5y^2= \pm 4$ which is a solvable Pell's equation. I can rewrite the equation as $x^2+xy-y^2=-5$. However I do not see the correct way to proceed.
 A: Multiplying your equation by $4$ makes completing the square easier:
$$(2x+y)^2-5y^2=-20.$$
So you need to solve
$$z^2-5y^2=-20$$
with $z$ and $y$ of the same parity (but this is automatic).
This means that $z=5u$ and
$$y^2-5u^2=4.$$
I hope this is Pell enough for you...
A: There is a pictorial method by Conway that I like, especially for indefinite $Ax^2 + B xy + C y^2 = D$ when $B \neq 0.$
Starting with the solution
$$
\left(
\begin{array}{c}
1 \\
3
\end{array}
\right)
$$
we find all representations of $-5$ as
$$
\left(
\begin{array}{cc}
1 & 1\\
1 & 2
\end{array}
\right)
\left(
\begin{array}{c}
1 \\
3
\end{array}
\right)
$$
where $n$ is an integer that may be positive, negative, or $0$ (the identity matrix)
Put another way, we have $x_0 = -1, \; x_1 = 1, \; $ then $y_0 = 2, y_1 = 3,$ then
$$  x_{n+2} = 3 x_{n+1} - x_n,   $$
$$  y_{n+2} = 3 y_{n+1} - y_n \; .   $$
We can go backwards to negative $n$ because
$$  x_{n} = 3 x_{n+1} - x_{n+2},   $$
$$  y_{n} = 3 y_{n+1} - y_{n+2} \; .   $$
The results are Lucas numbers. The first few Lucas numbers are
$$  2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, \ldots $$

