1

Is squared Euclidean distance a metric? In particular does it obey triangle inequality? I think no, but cannot find a counterexample.

Edit: Does this (not obeying the triangle rule) happen only when one of the points resides on the line segment made by the two other points?

user25004
  • 3,586
  • 2
  • 33
  • 61

2 Answers2

6

Take $x = 0$, $y = 1/2$ and $z = 1$. Then $|x-z|^2 = 1$ but $|x-y|^2 + |y-z|^2 = 1/2$.

  • Does this (not obeying the triangle rule) happen only when one of the points resides on the line segment made by the two others? – user25004 Dec 25 '15 at 06:06
  • 1
    @user25004 No. Take $x=(-1,\epsilon)$, $z=(1,\epsilon)$ and $y=(0,0)$ and define $d((a,b),(c,d))=(a-c)^2+(b-d)^2$. So $d(x,z)=4$ and $d(x,y)=d(y,z)=1+\epsilon^2$. Thus if $0<\left|\epsilon\right|<\sqrt2$ then the triangle inequality fails and the points are not on a single line. – Mohsen Shahriari Dec 25 '15 at 06:20
  • If $x,y,z$ are any three distinct points, where $|x-z| \geq |x-y|, |y-z|$, then we can think of these three points as the vertices of a triangle. If this is a right triangle then by Pythagoras we have $|x-z|^2 = |x-y|^2 + |y-z|^2$. But if this triangle is obtuse, i.e. if me move $x$ and $z$ further apart while leaving $|x-y|$ and $|y-z|$ constant, then we get $|x-z|^2 > |x-y|^2 + |y-z|^2$. – Jendrik Stelzner Dec 25 '15 at 06:29
4

Let's define $d:\mathbb R\to\mathbb R^{0+}$ such that $d(x,y)=(x-y)^2$. We have: $$d(-1,0)=1\quad d(0,1)=1\quad d(-1,1)=4$$ $$\therefore d(-1,1)\nleq d(-1,0)+d(0,1)$$ Hence $d$ is not a metric.