Q:

Solve for all possible functions f: $|f(x)-f(y)|=2|x-y|$.

I'm getting $f(x)=2x+f(0)$ and $f(x)=f(0)-2x$ by setting $y=0$, but I'd like to verify. Am I right?

A:

The function $f$ is clearly continuous and one-to-one, since it satisfies the Lipschitz condition and $f(x) = f(y)$ implies $x=y$. Thus $f$ is monotone, and consequently either increasing or decreasing. 
If $f$ is increasing, the condition $|f(x) - f(0)| = 2|x|$ leads to $$x > 0 \implies f(x) > f(0) \implies f(x) - f(0) = 2x$$ and $$x < 0 \implies f(x) < f(0) \implies f(0) - f(x) = -2x$$
so that $f(x) = 2x + f(0)$ for all $x \in \mathbb R$.
Likewise, if $f$ is decreasing then $f(x) = -2x + f(0)$ for all $x \in \mathbb R$.
This means these are  the only two functions satisfying the stated condition.

A:

Another way to look at it is perhaps that the condition is equivalent to
$$\left|\dfrac{f(x)-f(y)}{x-y}\right| = 2 \quad \quad \text{for } x \neq y$$
which says that absolute values of the slopes of the secant lines at any pair of points $x$ and $y$ are always 2. That is, the possible slopes of the secant lines at any pair of points $x$ and $y$ are $\pm 2$

