# Give examples of functions that satisfy all but one property of metrics

A function $d: \mathbb{R}\times\mathbb{R}\to\mathbb{R}$ is a metric on $\mathbb{R}$ iff all of the following holds:

1. $d(x,y)\geq0 \;\forall x,y$

2. $d(x,y)=0 \iff x=y$

3. $d(x,y)=d(y,x)$

4. Triangle inequaliy

The exercise asks us to give one example of function that satisfies all of the conditions above but one (for each condition).

I was successfull on 2.: $d(x,y)=\vert x-y\vert +1$ do satisfies 1,3,4 but not 2., right?

On the others I got stuck, I tried floor and ceil things, sums, multiplications... nothing did work.

Could you help me? (I'm sorry if it is duplicated, I couldn't find something like this)

Edit: I could do 4. too, but it isn't a "beautiful" example I think: $d(x,y)=\begin{cases}\vert x-y\vert-5, \mbox{ if }\vert x-y\vert >5 \\\vert x-y\vert, \mbox{ otherwise}\end{cases}$, then we have $d(1,15)>d(1,7)+d(7,15)$ for example.

For a nicer solution to (4), try $$d(x,y)=|x-y|^2$$ $d(0,1)=1>0.5=0.25+0.25=d(0,0.5)+d(0.5,1)$

The relevant jargon for these four functions is found on wikipedia, where functions omitting (2) are called pseudometrics or metametrics, functions omitting (3) are called quasimetrics, functions omitting (4) are called semimetrics. No mention of omitting (1), because that seems to be impossible.

• +1, Can I know the motivation ? – tarit goswami Aug 28 '18 at 21:52
• It's a nonlinear function. – vadim123 Aug 28 '18 at 21:54

After all the comments here, which I thank all you for, I can summarize an answer for my question.

First case: After all, properties 2,3,4 implies 1. In fact,: $0 = d(x,x)\leq d(x,y)+d(y,x)=2d(x,y)$ hence $d(x,y)\geq 0 \; \forall x,y$. Thus it is impossible to give na example of function that satisfy 2-4 but not 1.

Second case: $d(x,y)=1 \; \forall x,y$ will do.

Third case: $d(x,y)=\begin{cases}x-y, \mbox{ if x}\geq y\\1, \mbox{ otherwise } \end{cases}$ is enough.

Fourth case: $d(x,y)=\vert x-y\vert ^2$