TITLE: How to find the absolute value of the difference of two variables?
QUESTION [5 upvotes]: The problem is as follows:

Let $x$ and $y$ integers which satisfy the following equations:
  $$x+y-\sqrt{xy}=7$$
  $$x^2+y^2+xy=133$$
  Find the value of  $\;|x-y|.$

I'm stuck on this problem due the fact that there appears a square root of $xy$ and the squares of both $x$ and $y$, hence the system cannot be solved using the regular methods. Moreover I don't know how to approach the absolute value.
The answer which would help me the most is one which addresses some theoretical basis about absolute value and steps which would led me to find $x$ and $y$.

REPLY [11 votes]: Notice that
$$\color{blue}{x^2+y^2+xy}=(x+y)^2-xy=(\color{red}{x+y-\sqrt{xy}})(\color{green}{x+y+\sqrt{xy}})$$ so that $$\color{green}{x+y+\sqrt{xy}}=\frac{\color{blue}{133}}{\color{red}{7}}=\color{magenta}{19}.$$
Then by half sum and half difference,
$$x+y=\frac{\color{magenta}{19}+\color{red}7}2=13,\\\sqrt{xy}=\frac{\color{magenta}{19}-\color{red}7}2=6.$$
Finally,
$$|x-y|=\sqrt{(x-y)^2}=\sqrt{(x+y)^2-4xy}=\sqrt{13^2-6^2}=5.$$
This is the only solution.

REPLY [3 votes]: Let $a=x+y,b=\sqrt{xy}$.  The two given equations can be rewritten as $a-b=7$ and $a^2-b^2=133$.  As $a^2-b^2=(a+b)(a-b)$, $a+b=133/7=19$, so $a=(19+7)/2=13$ and $b=(19-7)/2=6$.  Thus, $x+y=13$ and $xy=36$.
$$|x-y|^2=(x+y)^2-4xy=13^2-4(36)=13^2-12^2=13+12=25=5^2,$$
so $|x-y|=5$.