# $|x-y| + |y-z| = |x-z|$ then $x \le y \le z$

I'm doing this exercise from Robert Bartle's Introduction to Analysis, it's a if only if excersise and I've done the half part, but I can't figure this part of the proof: $x,y,z \in \Re$ and $|x-y| + |y-z| = |x-z|$ then $x \le y \le z$

Thanks for any hint.

-
Draw a picture. If the distance from x to z is just the sum of the distance from x to y, plus the distance from y to z, there must be no overlap. – Ragib Zaman Sep 23 '11 at 14:27
@RagibZaman: Why don't you leave that hint as an answer? That way, nobody comes along (without seeing your hint), and solves the exercise outright. – JavaMan Sep 23 '11 at 14:30
Sure about the text of the exercise? Try x=3, y=2, z=1. – Did Sep 23 '11 at 14:39
Perhaps it was given to take $x\leq z$. But you are right Didier, as stated the only implication is that $y$ is somewhere between $x$ and $z$. @DJC, converting the intuition from the diagram into a real rigorous proof would take some time and I'm quite tired at the moment. Hopefully someone else will answer Rho's question in full, or Rho will do it himself. – Ragib Zaman Sep 23 '11 at 14:46
@DidierPiau yes, seems that it's true with $z \le y \le x$. I tried something like: if $x - z \gt 0$ then $|x - z| = x - z$ and $x \gt z$. if $x - z \lt 0$ then $|x - z| = -(x - z)$ and $x \lt z$. But couldn't come up with the logical steps to have a consistent proof. I will give a try to Ragib Zaman's hint. – Rolando Sep 23 '11 at 14:53

I think the best way is just to work it out with brute force. Then, having $|x-y| + |y-z| = |x-z|$,assume $y$ is not between $z$ and $x$; without loss of generality (because the other cases will be proved analogously), we suppose $y < x$ and $y \leq z$. Also, without loss of generality, we assume $x \leq z$ (as already pointed out in the comments above, we can just prove that $y$ is between $x$ and $z$, without assumption on who's greater between them). Then, by the implication you've already proved, since $y < x \leq z$ we have $|y-z|=|y-x|+|x-z|$; substituting in the original identity $$|x-y| + |y-z| = |x-z| \iff |x-y| + |y-x|+|x-z| = |x-z| \iff 2|x-y|=0$$ contradiction.

-
WLOG you may assume that $y=0$ since distances are preserved by translation. It makes the reasoning easier. – lhf Sep 23 '11 at 16:36
@lhf yep, thanks. – Immanuel Weihnacht Sep 24 '11 at 1:22