For $x,y,z \in \Bbb R$, define $d(x,y):= (x-y)^2$

Is this a metric on $\Bbb R$?

It's clear that $d(x,x)=0$ and $d(x,y)=d(y,x)$ for all $x,y \in \Bbb R$.

The triangle inequality seems to have a contradiction [$d(x,z) \leq d(x,y) +d(y,z)$] If I let $x=1$, $y=0$ and $z=-1$, then I will have $(1+1)^2 = 4 > (1-0)^2 + (0+1)^2 = 2$.

So is this $d$ a metric? If it's, how can I prove it?

  • $\begingroup$ This is a practice question for my class. Show that d(x,y) = (x-y)^2 defines a metric on R. $\endgroup$
    – Liam Nousa
    Sep 13, 2014 at 1:15
  • 1
    $\begingroup$ Nice counterexample. $\endgroup$
    – hardmath
    Sep 13, 2014 at 1:18
  • $\begingroup$ I really doubt that it's not a metric. I have seen this in many book's exercise. $\endgroup$
    – Liam Nousa
    Sep 13, 2014 at 1:34
  • $\begingroup$ That's why Euclidean distance has an extra square root, which makes the triangle inequality work out (think of the reals as a one dimensional vector space) $\endgroup$
    – Alex R.
    Sep 13, 2014 at 2:29

1 Answer 1


The function $d$ defined is not a metric. The triangle inequality fails, and you showed a counter-example yourself. Good job.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.