<s>[INST] Solving Diophantine equations involving $x, y, x^2, y^2$ My father-in-law, who is 90 years old and emigrated from Russia, likes to
challenge me with logic and math puzzles. He gave me this one:
Find integers $x$ and $y$ that satisfy both $(1)$ and $(2)$
$$x + y^2 = 8 \tag{1} $$
 $$x^2 + y = 18 \tag{2}$$
I found one solution by deriving this equation:
$$ x(x+1) + y(y+1) = 26$$
which means, I need to find two numbers that add up to $26$, where each number is the product of two consecutive numbers. Through trial and error I found a solution. From college days I seem to remember that there is a more elegant way using the theory of Diophantine equations.
Can someone remind me or point to me to an easy to follow explanation of the method for solving problems like these?
 [/INST] Here is an alternative way to solve for the original problem.
$$\left\{\begin{array}{ll}x+y^2&=&8\\x^2+y&=&18\end{array}\right. \tag{1}$$
Instead of adding, subtract the two equations and get
$$x^2-y^2+y-x=10\Rightarrow\\(x-y)(x+y-1)=10$$
For two integers $a$ and $b$ to have product $10$, list all possibilities. $$1\times 10,2\times 5,2\times 5, 10\times 1,-1\times -10,-2\times -5,-2\times -5, -10\times -1, $$
Now for each $a$ and $b$, obtain the system $$\left\{\begin{array}{lll}x-y&=&a\\x+y-1&=&b\end{array}\right. \tag{2}$$
This is a linear equation and has solution $x=\dfrac{a+b+1}{2}$ and $y=\dfrac{b-a+1}{2}$ (if instead of $10$, say, we have $16$; use the constraint that $x$ and $y$ are integers to eliminate certain choices. In particular, we can eliminate cases where $a$ and $b$ have same parity because $a+b+1$ and $a-b+1$ have to be even).
Plug in values of $a$ and $b$ obtained from $(2)$ to get possible values for $x$ and $y$ (that are integers). And recheck the values for $x$ and $y$ so obtain matches with the original system (because we are essentially solving $(2)$ and not $(1)$, and we haven't shown that $(2)$ is necessary and sufficient condition for $(1)$ to hold).
$$\begin{array}{rr|rr}
a&b&x&y\\ \hline
1&10&6&5\\
2&5&4&2\\
5&2&2&4\\
-1&-10&-5&-4\\
-2&-5&-3&-1\\
-5&-2&-1&-3\\
-10&-1&-4&-5
\end{array}$$
See that $(4,2)$ is the only possible answer for $(x,y)$.
</s>