showing distance function is a metric

The distance function is defined as

$d\left ( x,y \right )=\left | x-y \right |= \begin{cases} x-y, &\text{if }x\geq y \\ y-x,&\text{otherwise} \end{cases}$

For $d\left ( x,y \right )$ to be a metric, it must be non-negative, symmetric and satisfy the triangle inequality.

I'm unable to show that it satisfies the triangle inequality on R.

Help is appreciated.

We will show the missing property i. e. the triangular inequality : $d(x,z)+d(z,y)\geq d(x,y)$.

By symmetry assume that $y\leq x$ and consider three separate cases $z<y$, $y\leq z\leq x$, and $x<z$.

i) if $z<y$ then $$d(x,z)+d(z,y)=x-z+y-z\geq d(x,y)=x-y \Leftrightarrow 2y\geq 2z \quad\mbox{which holds};$$

ii) if $y\leq z\leq x$ then $$d(x,z)+d(z,y)=x-z+z-y\geq d(x,y)=x-y \quad\mbox{which holds};$$

iii) if $x<z$ then $$d(x,z)+d(z,y)=z-x+z-y\geq d(x,y)=x-y \Leftrightarrow 2z\geq 2x \quad\mbox{which holds}.$$

• How does one identify the three separate cases? – Mathematicing Aug 11 '16 at 11:47
• @Mathematicing You are on the real line, so once you choose the points $x$ and $y$ with $x\geq y$, then the third point $z$ has three possible positions with respect to the interval $[y,x]$: to the left, inside and to the right. – Robert Z Aug 11 '16 at 11:54
• I cannot understand why in i) you took |x-z|+|z-y|. What motivates you to make that choice? I've been doing Abstract Algebra for a large part and analysis comes across as very very different. – Mathematicing Aug 11 '16 at 11:55
• @Mathematicing Is it better now? Of course by symmetry $d(z,y)=d(y,z)$. – Robert Z Aug 11 '16 at 11:58
• Why is z not allowed to be less than or equal to y? – Mathematicing Aug 11 '16 at 12:08

Use $|a|+|b|\ge|a+b|$

Then $$|x-z|+|z-y|\ge |x-z+z-y|=|x-y|$$