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:


*

*(Non-negativity) $d(x,y) \ge 0$ for all $x,y \in X$ 

*(Definiteness) $d(x,y) =0 \iff x=y$

*(Symmetry) $d(x,y)=d(y,x)$ for all $x,y \in X$ 

*(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$


*

*function to the square power is positive

*function $f(x) = x$ is injective => for every input there is only one output => $d(x,x) = (x - x)^2 = 0^2 = 0$

*$d(x,y) = d(y,x)$ is easy to show by simple algebraic manipulations  
For my second example:$d(x,y) = \sqrt{(|x-y|}$


*

*output of absolute value function is positive

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

*$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. 
 A: 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. 
A: 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$$
