# To show, that $d(x,y) = (x-y)^2$ and $d(x,y) = \sqrt{|x-y|}$ is/is not metric.

In order to show, if the function is metric, this function need to satisfy 4 properties:

1. (Non-negativity) $d(x,y) \ge 0$ for all $x,y \in X$
2. (Definiteness) $d(x,y) =0 \iff x=y$
3. (Symmetry) $d(x,y)=d(y,x)$ for all $x,y \in X$
4. (Triangle Inequality) $d(x,y) \le d(x,z)+d(z,y)$ for all points $x, y, z \in X$

For my first example:$d(x,y) = (x-y)^2$

1. function to the square power is positive
2. function $f(x) = x$ is injective => for every input there is only one output => $d(x,x) = (x - x)^2 = 0^2 = 0$

3. $d(x,y) = d(y,x)$ is easy to show by simple algebraic manipulations

For my second example:$d(x,y) = \sqrt{(|x-y|}$

1. output of absolute value function is positive

2. function $f(x) = x$ is injective => for every input there is only one output => $d(x,y) = \sqrt{(|x-x|} = 0$

3. $d(x,y) = d(y,x)$ is true, beacause the difference between two number under the absolute value function is always the same

But the question is: how can I prove 4th property(triangle inequality)? $$|f(x)-f(y)|\le|f(x)-f(z)|+|f(z)-f(y)|\,$$ is a formula of triangle inequality. But can you provide some examples of using this ineaquality? It would be much easier for me to understand the technique of usage this inequality.

• Your rendering of the triangle inequality at the bottom of the question is quite strange. What is the $f$ that appears all over? And $|a-b|$ is not the metric want to prove satisfies the inequality. Oct 11 '16 at 9:06
• There may be a deeper misunderstanding somewhere, because both of your steps (2) also feature an $f$ that comes out of nowhere -- and they don't seem to make much sense as proof of the property you're proving. The talk about the identify function being injective function has nothing obvious to do with your task; computing $d(x,x)=0$ does prove the $\Leftarrow$ part of the definiteness property, but what about $\Rightarrow$? Oct 11 '16 at 9:08

Hint:

As noted in the comment, it is not clear from where comes the function $f(x)$ , and this function has no matter in the given problem.

You wrote correctly the triangle inequality as $d(xy)\le d(x,z)+d(y,z)$ for all $x,y,z$ in the set $X$ (what is this set in your case? Is it $\mathbb{R}$?) and this becomes: $$(x-y)^2\le(x-z)^2+(y-z)^2$$

for the first example. And $$\sqrt{|x-y|}\le\sqrt{|x-z|}+\sqrt{|y-z|}$$

If you can prove that these are true for all $x,y,z$ you have proved the triangle inequality.

It remains the triangle inequality.

$(1)$ $d(x,y) = \sqrt{|x-y|}$ is a metric because$$\sqrt{|x-y|}\le\sqrt{|x-z|}+\sqrt{|y-z|}\iff|x-y|\le|x-z|+|y-z|+2\sqrt{|x-z||y-z|}$$ and is is quite known the triangle inequality for absolute value (a fortiori one has a triangle inequality here).

$(2)$ $d(x,y) = (x-y)^2$ is not a metric because, for instance, take $x=1$, $z=2$ and $y=3$ so we have $(3-1)^2=4$, $(3-2)^2=1=(2-1)^2$ hence $$(3-1)^2\gt(3-2)^2+(1-2)^2$$ If $d(x,y) = (x-y)^2$ were a metric we should have $$(3-1)^2\le(3-2)^2+(1-2)^2$$