# How to find the absolute value of the difference of two variables?

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$.

• – Namaste Dec 18 '17 at 20:57
• @amWhy Personally I don't mind my post to be "improved" to fit stack standards. It helps me to address betters questions in the future and also to learn about how to make them more valuable but these constant edits make me to believe that there is some kind of war going on. Moreover by looking at the history of edits there is no clear explanation on the reason why is changed each time. – Chris Steinbeck Bell Dec 18 '17 at 20:58
• @ChrisSteinbeckBell some theoretical basis One clue (which I used in my answer) is that both the equations and the required value are symmetric in $x,y$. When that's the case, often times it helps to work in terms of the elementary symmetric polynomials, instead, in this case $x+y$ and $xy$. – dxiv Dec 18 '17 at 21:01
• @dxiv I appreciate your effort to explain about symmetric polynomial but the article in Wikipedia is rather wordy and its length and explanations are intimidating to me. Do you happen to know other source which could use more layman terms?. – Chris Steinbeck Bell Dec 18 '17 at 21:07
• @ChrisSteinbeckBell You could look here or there as well. Also, you can recognize that the elementary symmetric polynomials are related to Vieta's formulas, which you are likely familiar with. – dxiv Dec 18 '17 at 22:03

## 3 Answers

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.

• Can you add more steps in the final lines. I'm lost at where does the value of five comes from. – Chris Steinbeck Bell Dec 18 '17 at 21:31
• The half sum and half difference thing you mentioned would you add an step there as I dont get the picture of what were you trying to explain. – Chris Steinbeck Bell Dec 18 '17 at 21:51
• @ChrisSteinbeckBell: hint: when you know the values of $a+b$ and $a-b$. – Yves Daoust Dec 19 '17 at 11:16
• Probably what you meant is that we know the values of $x+y$ and $\sqrt{xy}$ and all that was left to do is just build up a system of equations of $2\times2$ and by solving this system we get to those answers. The final step is not very obvious but what you did was to "factorize" the sum of squares therefore $(x+y)^2-4xy$. I think you should have added a step between those two and more importantly be more wordy in explanations as to decipher from the equations is not very clear. – Chris Steinbeck Bell Dec 19 '17 at 13:39
• @ChrisSteinbeckBell: I added a little colors. – Yves Daoust Dec 19 '17 at 14:05

Hint: let $s=x+y, p=xy$ then the system writes as:

$$s-\sqrt{p} = 7 \\ s^2-p = 133$$

Solving gives $s=13, p=36$ so $x, y$ are the roots of $z^2-13z+36=0$, and the absolute value of the difference between the roots of a quadratic is $\sqrt{\Delta}/|a|$.

• By solving the quadratic equation luckily the discriminant has an exact answer and therefore the solutions are $9$ or $4$, which would be the values of $z$ in your equation but since the difference is taken by absolute value that would be $5$ right?. – Chris Steinbeck Bell Dec 18 '17 at 21:21
• That's correct. You don't actually need to calculate the roots, the difference is $\sqrt{\Delta}/|a|=\sqrt{25}/1=5\,$. – dxiv Dec 18 '17 at 21:24
• The last part where you mention the difference between the roots of a quadratic is the square root of the discriminant divided by the absolute value of a, this part is where I'm stuck at. Mind if you could prove that?. – Chris Steinbeck Bell Dec 18 '17 at 21:28
• @ChrisSteinbeckBell By the quadratic formula the roots of $az^2+bz+c=0$ are $\frac{-a \pm \sqrt{\Delta}}{2a}\,$, so their difference is $\,\require{cancel} \frac{\bcancel{-a}+\sqrt{\Delta}}{2a} - \frac{\bcancel{-a}-\sqrt{\Delta}}{2a} = \frac{\cancel{2} \sqrt{\Delta}}{\cancel{2}a} = \frac{\sqrt{\Delta}}{a}\,$. – dxiv Dec 18 '17 at 21:52
• But where does the absolute value in the denominator come from?.Moreover the question asks about the difference between $x$ and $y$ not the difference of the roots. That's why I am confused on why to finding the values of each one is not necessary?. If you could prove that the difference between $x$ and $y$ is equal to the difference of the roots you mentioned that would be helpful. – Chris Steinbeck Bell Dec 18 '17 at 21:56

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$.