Given the two equations $|x - z_1| = d_1 + y$ and $|x - z_2| = d_2 + y$ , and suppose that $z_1, z_2 \in \mathbb{R}$, $z_1 \neq z_2$ and $d_1, d_2, \in \mathbb{R}_{> 0}$ are all known reals, solve this system of equations simultaneously for $x \in \mathbb{R}$ and $y \in \mathbb{R}_{\geq 0}$.

First of all, I know that there aren't always solutions. If you take $z_1 = 8$, $z_2 = 11$, $d_1 = 6$ and $d_2 = 1$, it's impossible to find $x$ and $y$ that satify these equations. If you look at the possible value of $x$, by the first equation you get $x = 14 + y$ or $x = 2 - y$. Because we know that $y > 0$, the larger possible solution is $x = 14 + y$. With the same reasoning, we get that the larger solution of the second equation is $x = 12 + y$. There is no $x, y$ that satisfy both equations at once. The same reason applies if you look at the smaller of the two, so $x = 2- y$ and $x = 10 - y$.

Now suppose that there is a solution, how do we find it? Breaking $\mathbb{R}$ up into regions and checking each case where the absolute value changes the sign of the inside expression, is not the way I want to solve this. I want to get general expressions for $x$ and $y$, if that's possible.

I can solve this if $y = 0$ (which I don't know initially, but that's not the point). I square both equations and subract them, so I get a linear equation for $x$, which is easily solved. But I can't use the same trick if $y > 0$. I get the equations $$ x^2 - 2\cdot x\cdot z_1 + z_1^2 = d_1^2 + 2\cdot y\cdot d_1 + y^2 $$ and $$ x^2 - 2\cdot x\cdot z_2 + z_2^2 = d_2^2 + 2\cdot y\cdot d_2 + y^2. $$ I can subtract these, so I get rid of $x^2$ and $y^2$. But then there remains an equation wich has both $x$ and $y$: $$ x\cdot 2(z_2 - z_1) + z_1^2 -z_2^2 = d_1^2 - d_2^2 + y\cdot 2(d_1 -d_2). $$

At this point, I thought about getting rid of $y$ by subtracting the equations, resulting in $$ |x - z_1| - |x-z_2| = d_1 - d_2. $$ If I bring the $|x-z_2|$ to the RHS and squaring this, I get $$ x^2 - 2\cdot x\cdot z_1 + z_1^2 = (d_1-d_2)^2 + 2\cdot (d_1 - d_2)\cdot |x-z_2| + (x^2 - 2\cdot x\cdot z_2 + z_2^2). $$ Now I write this as an equations for $|x-z_2|$: $$ |x-z_2| = \frac{- 2\cdot x\cdot z_1 + z_1^2 - (d_1-d_2)^2 +2\cdot x\cdot z_2 - z_2^2}{2(d_1-d_2)}. $$ It's technically possible to square this equations, resulting in an quadratic expression for $x$. This however, looks very, very unappealing. Another problem is that if I solve this expression, I still don't know an exact value of $x$, because of the $\pm$ in the quadratic formula (I've checked using a problem with known numbers that the root isn't (always) $0$, unfortunately).

So, I'm stuck. I've used all the tricks I known regarding the absolute value, but it doesn't seem to help. I'm now wondering if it is at all possible to get an expression for $x$ and $y$, even if there is a solution.


There are no solutions when $|z_1-z_2|<|d_1-d_2|$, one solution when $|z_1-z_2|>|d_1-d_2|$, and a whole region of solutions when $|z_1-z_2|=|d_1-d_2|$. For the one-solution case, taking $z_2>z_1$, the solution is at $x=(z_1+z_2+d_2-d_1)/2, y=(d_2+d_1+z_2-z_1)/2$.

The argument is pretty much from the geometry of the graphs of these functions.

enter image description here

  • $\begingroup$ If I take $z_1 = 4, z_2 = 20, d_1 = 3, d_2 = 11$, the solution is $x = 8$ and $y = 1$. However, if I use your equations, I get $x = 16$ and $y = 15$. Where is my mistake? Edit: ah, I switched some variables. $\endgroup$ – Pierre Feb 25 '15 at 13:58
  • $\begingroup$ Could you explain to me how you got this solution if $z_2 > z_1$? $\endgroup$ – Pierre Mar 2 '15 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.