TITLE: Is $d(x,y)=(x-y)^2$ a valid metric in $\mathbb R$?
QUESTION [8 upvotes]: Is $d(x,y)=(x-y)^2$ a valid metric in  $\mathbb R$?

So obviously $d(x,y)=(x-y)^2\ge0$ for all $x,y \in \mathbb R$ and equality iff $x=y$, and is also symmetric $d(x,y)=d(y,x)$. But how do I check if $d(x,z)\le d(x,y)+d(y,z)$ ?
I tried $d(x,z)=(x-z)^2=\lvert x-z\rvert ^2\le (\lvert x-y\rvert + \lvert y-z \rvert)^2$ but there is a leftover $2\lvert x-y \rvert \lvert y-z \rvert$ term

REPLY [12 votes]: $$(3-1)^2\stackrel{\color{red}?}\le (3-2)^2+(2-1)^2$$

REPLY [6 votes]: $$d(x,z)\le d(x,y)+d(y,z) \iff (y-x)(y-z) \ge 0$$
not always true! Triangle inequality fails.

REPLY [5 votes]: It's not a metric:
$(1-0)^2+(2-1)^2 \leq(2-0)^2$