Condition on function $f:\mathbb{R}\rightarrow \mathbb{R}$ so that $(a,b)\mapsto | f(a) - f(b)|$ generates a metric on $\mathbb{R}$ Can we impose such condition on function $f:\mathbb{R}\rightarrow \mathbb{R}$ so that 
$(a,b)\mapsto | f(a) - f(b)|$ generates a metric on $\mathbb{R}$?
This question came into my mind when I was working on problem $(a,b)\mapsto | e^{a} - e^{b}|$ is a metric on $\mathbb{R}$. I guess this can be done by taking injective function $f$. But I am not sure whether this will work or not. Certainly, this will help everyone in dealing with such kind of problems. I need help with this.
Thank you very much.
 A: It is necessary and sufficient that $f$ be injective. If $f$ is injective, then $|f(a)-f(b)|=0$ iff $a=b$, and otherwise we have some $a\neq b$ such that $|f(a)-f(b)|=0$. Clearly $|f(a)-f(b)|=|f(b)-f(a)|$, so it remains to check the triangle inequality. But this follows from just applying the triangle inequality for $|\cdot |$, so $f$ gives you a metric.
A: Let $f:\Bbb R\to\Bbb R$, and for $x,y\in\Bbb R$ define $d(x,y)=|f(x)-f(y)|$.
First note that for any function $f:\Bbb R\to\Bbb R$ and $x,y,z\in\Bbb R$ we have $$\begin{align*}
|f(x)-f(y)|&=\left|\big(f(x)-f(z)\big)+\big(f(z)-f(y)\big)\right|\\
&\le|f(x)-f(z)|+|f(z)-f(y)|\;,
\end{align*}$$
so $d$ always satisfies the triangle inequality. It’s also clear that $d(x,x)=0$ for all $x\in\Bbb R$ and that $d$ is symmetric no matter what $f$ we use. Thus, $d$ is always a pseudometric on $\Bbb R$. Finally, in order for $d$ to separate points, so that it’s necessary and sufficient that $f$ be injective: that ensures that if $x\ne y$, then $f(x)\ne f(y)$ and hence $d(x,y)\ne 0$. The function $f$ need not be nice in any other way.
For example, you could use the following function:
$$f(x)=\begin{cases}
\tan^{-1}x,&\text{if }x\in\Bbb Q\\
\tan^{-1}(x+1),&\text{if }x\in\Bbb R\setminus\Bbb Q\;.
\end{cases}$$
It’s discontinuous at every point, and it’s not surjective, but it is injective, and that’s all that matters.
