# Solving a system of equations with an absolute value term

$x$ and $y$ are two integer numbers and $x \geq y$. The values of $x$ and $y$ are positive or negative integers. When the sum of these two numbers are multiplied by $y$ we obtain $P$ and when the absolute value of the subtraction of these two numbers is multiplied by $x$ we obtain $Q$. Given $P$ and $Q$ we need to find the value of $x$ and $y$. An input example: $(160, 48)$ output: $(12, 8)$

I'm trying to solve this by systems, but I don't know how to solve it when there's this absolute value of $x-y$.

• I don't see the need for the absolute value, since $X \geq Y$. – Gary. Jul 11 '15 at 18:45
• @Gary, Perhaps the problem setter wanted to remove ambiguity in case the student interpreted the "subtraction of these two numbers" as $y-x$. Which would make it negative, but the problem setter wanted it to be positive? I dunno. – Zain Patel Jul 11 '15 at 18:47

We have the equation $$y(x+y) = p$$ and $$x|x-y| = x|y-x| = q.$$
But since $x \geq y$ then $x-y$ will always be positive so $$|x-y| = x-y.$$
Hence our system becomes $$x(x-y) = q \quad \text{and} \quad y(x+y) = p$$