Find all the functions satisfying this criterion Find all functions $f:\mathbb{R}\rightarrow\mathbb{R}$ such that $$\left|f(x)-f(y)\right|=2\left|x-y\right|$$
 A: We have $f(x+h)-f(x)=2h$ or $f(x+h)-f(x)=-2h$ so $\lim_{h\rightarrow0} {f(x+h)-f(x)\over h}=\pm2$ so $f'(x)=\pm2$ so $f(x)=\pm2x+c$.
We need to first show the function is differentiable everywhere. 
First we show one sided limit exist for every point. Suppose the opposite then there exist $0<h_1,0<h_2$ that
$$f(x+h_2)-f(x)=2h_2$$ and $$f(x+h_1)-f(x)=-2h_1$$
which would imply $f(x+h_2)-f(x+h_1)=2(h_1+h_2)=2|h_1-h_2|$ which would imply $h_1=0$ or $h_2=0$ contradiction. So one-sided limit exist everywhere.
Now we assume there exist a point where the limits on both side are not equal, that is, there exist an $x_0$ that $\lim_{h\rightarrow0-} {f(x_0+h)-f(x_0)\over h}\neq\lim_{h\rightarrow0+} {f(x_0+h)-f(x_0)\over h}$.
WLOG we assume $\lim_{h\rightarrow0-} {f(x_0+h)-f(x_0)\over h}=-2$ and $\lim_{h\rightarrow0+} {f(x_0+h)-f(x_0)\over h}=2$ then for any $\epsilon<2$ we can find $h_0$ such that $|{f(x_0+h_0)-f(x_0)\over h_0}+2|<\epsilon$ and $|{f(x_0-h_0)-f(x_0)\over -h_0}-2|<\epsilon$ which implies
$$-\epsilon-2<{f(x_0+h_0)-f(x_0)\over h_0}<\epsilon-2$$
$$-\epsilon+2<{f(x_0-h_0)-f(x_0)\over -h_0}<\epsilon+2$$
Add them together we have 
$$-2\epsilon<{f(x_0+h_0)-f(x_0-h_0)\over h_0}<2\epsilon$$
hence
$$|{f(x_0+h_0)-f(x_0-h_0)}|<\epsilon|(x_0+h_0)-(x_0-h_0)|<2|(x_0+h_0)-(x_0-h_0)|$$
contradiction. So we have the function differentiable everywhere.
Now assume there exist two points $f'(a)=2$ and $f'(b)=-2$ then there must exist some $c$ between $a$ and $b$ where $-2<f'(c)<2$ contradiction. So $f'(x)$ must be either $2$ or $-2$ consistently.
A: Let $C=f(0)$. Then
Lemma. Either $f(x)=C+2x$ for all reals $x$, or $f(x)=C-2x$ for all reals $x$.
Proof: Suppose the contrary. Then there is an $x$ such that $f(x)\not=C+2x$ (in which case we must have $f(x)=C-2x$), and a $y$ such that $f(y)\not=C-2y$ (in which case we must have $f(y)=C+2y$). Note that, in particular, $x,y\not=0$.
Now, $\left| f(x)-f(y) \right| = 2 \cdot \left| x - y \right|$ implies that
$\left| C-2x - C - 2y \right| = 2 \cdot \left| x - y \right|$, which further implies that $\left| x + y \right| = \left| x - y \right|$.
Now this implies that $x+y=x-y$ (and hence $y=0$), or $-(x+y)=x-y$ (and hence $x=0$). However, neither possibility holds. This proves the lemma (without any assumption about the differentiability of $f$, to boot).
