The number of integral solutions for the equation $x-y = x^2 + y^2 - xy$ Find the number of integral solutions for the equation $x-y = x^2 + y^2 - xy$ and the equation of type $x+y = x^2 + y^2 - xy$
 A: These are the equations of (fairly small) ellipses in the $x-y$ plane.  Plot and count.
A: $$x-y = x^2 + y^2 - xy \Leftrightarrow \\
2x-2y = 2x^2 + 2y^2 - 2xy \Leftrightarrow \\
0= 2x^2 + 2y^2 - 2xy-2x+ 2y \Leftrightarrow \\
(x-y)^2+(x-1)^2+(y+1)^2=2$$
As $x,y$ are integers, there are only 2 possibilities for each bracket: $0$ or $1$. So two of the squares have to be $1$ and the third one must be $0$.
Second one leads to 
$$(x-y)^2+(x-1)^2+(y-1)^2=2$$
A: Rearranging  we get $$x^2-x(y+1)+y^2+y=0$$ which is a Quadratic Equation in $x$
As $x$ must be real, the discriminant must be $\ge0$ i.e., 
$(y+1)^2-4(y^2+y)=-3y^2-2y+1\ge0$
$\iff 3y^2+2y-1\le0$
$\iff \{y-(-1)\}(y-\frac13)\le0$
$\iff -1\le y\le \frac13$
Now, use the fact that $y$ is integer
A: Added: The approach below is ugly: It would be most comfortable to delete. 
We look at your second equation. Look first at the case $x\ge 0$, $y\ge 0$. We have $x^2+y^2-xy=(x-y)^2+xy$. Thus $x^2+y^2-xy\ge xy$. So if the equation is to hold, we need $xy\le x+y$. 
Note that $xy-x-y=(x-1)(y-1)-1$. The only way we can have $xy-x-y\le 0$ is if $(x-1)(y-1)=0$ or $(x-1)(y-1)=1$. 
In the first case, we have $x=1$ or $y=1$. Suppose that $x=1$. Then we are looking at the equation $1+y=1+y^2-y$, giving $y=0$ or $y=2$. By symmetry we also have the solution $y=1$, $x=0$ or $x=2$.
If $(x-1)(y-1)=1$, we have $x=0$, $y=0$ or $x=2$, $y=2$.
Now you can do an analysis of the remaining $3$ cases $x\lt 0$, $y\ge 0$; $y\lt 0$, $x\ge 0$; $x\lt 0$, $y\lt 0$. There is less to these than meets the eye. The first two cases are essentially the same. And since $x^2+y^2-xy=\frac{1}{2}((x-y)^2+x^2+y^2)$, we have $x^2+y^2-xy\ge 0$ for all $x,y$, so $x\lt 0$, $y\lt 0$ is impossible. 
A: For second equation:
$$x + y = x^2 + y^2 − xy$$
By dividing $xy$ on both sides
$$\frac{1}{x} + \frac{1}{y} = \frac{x}{y} + \frac{y}{x} -1 = y \text{ (say)}$$
Here for any real no. $a$
$$a + \frac{1}{a}\ge 2$$
So RHS will be $\ge1$.
But because only integer solutions are required:
LHS will be $\le 2$. (Assuming neither $x$ nor $y$ is zero).
So for this equality to be true $1\le y\le2$. Hence we need to consider cases only for $x =0,1$ and $y=0,1$
By substituting values 3 possible solutions are:
$x=0,y=0$;
$x=1,y=0$;
$x=0,y=1$;
A: This equation can be rewritten just in another form:   $\frac{m+1}{n}+\frac{n+1}{m}=a$
Can be solved using the equation Pell:
$p^2-(a^2-4)s^2=1$
Solutions have the form:
$n=2(p-(a+2)s)s$
$m=-2(p+(a+2)s)s$
And more:
$n=\frac{2p(p+(a-2)s)}{a-2}$
$m=\frac{2p(p-(a-2)s)}{a-2}$
If this equation has a solution:   $p^2-(a^2-4)s^2=4$  Formulas are: :
$n=\frac{p-(a-2)s+2}{2(a-2)}$
$m=\frac{p+(a-2)s+2}{2(a-2)}$
Anyway I'll write more general equation: $\frac{X^2+aX+Y^2+bY+c}{XY}=j$
If this square a:
$t=\sqrt{(b+a)^2+4c(j-2)}$
Then using the equation Pell:
$p^2-(j^2-4)s^2=1$
Solutions can be written:.
$X=\frac{(b+a\pm{t})}{2(j-2)}p^2+(t\mp{(b-a)})ps-\frac{(b(3j-2)+a(6-j)\mp{(j+2)t})}{2}s^2$
$Y=\frac{(b+a\pm{t})}{2(j-2)}p^2+(-t\mp{(b-a)})ps-\frac{(b(6-j)+a(3j-2)\mp{(j+2)t})}{2}s^2$
We must also take into account that the number $p,s$ may still be different signs.
