Is $1-\sin(x)$ a contraction mapping? And is there a sufficient/necessary condition for a real-valued function to be a contraction? This came up as I was thinking about how to solve an assignment problem I've been given. I'm not posting the assignment problem here as I want to think about it myself, but one approach I am currently working on is to try to show that
$$f:\mathbb{R}\to\mathbb{R},\quad f(x) = 1-\sin(x)$$
is a contraction mapping.
At the moment I have a feeling it isn't. For example take $x_1 < 0 < x_2$, then
$$ \left|\frac{(1-\sin x_1)-(1-\sin x_2)}{x_1-x_2}\right| = \left|\frac{\sin(x_1) - \sin(x_2)}{x_1-x_2}\right| \to 1$$
as $x_1 \to 0^-, x_2 \to 0^+$.
Hence there does not exist a non-negative $k<1 \in \mathbb{R}$ such that $|\sin(x_1)-\sin(x_2)| \leq k|x_1-x_2|$ for all $x_1,x_2 \in \mathbb{R}$. (Just take $x_1,x_2$ arbitrarily close to $0$.) So $f$ is not a contraction mapping.
That was the idea. Thinking just a little bit further, we see that this occurs because $|f'(x)| = 1$ at $x=0$. So perhaps we have a necessary and sufficient condition for a function on the reals to be a contraction mapping, namely that $\forall x\in\mathbb{R},|f'(x)|\leq k<1$ for some non-negative real $k$. Is this the case? Or have I missed some subtle (or not-so-subtle) point?

That's the case if $f$ is differentiable on all of $\mathbb{R}$, then by Lagrange's theorem (mean value theorem)
$$|f(x)-f(y)|=|f'(c_{x,y})||x-y|$$
for some $c_{x,y}$ between $x$ and $y$, for all $x,y\in\mathbb{R}$. From here, sufficiency is clear since if $|f'(x)|\leq K$ then
$$|f(x)-f(y)|=|f'(c_{x,y})||x-y|\leq K|x-y|$$
Now, for necessity we only need to use the definition of the derivative: if $f$ is contracting with constant $K<1$, given $x\in \mathbb{R}$ then
$$|f'(x)|=\lim_{h\to 0} \left|\frac{f(x+h)-f(x)}{h}\right|\leq\lim_{h\to 0} \frac{K\cdot|x+h-x|}{|h|}=K$$
using that the absolute value is continuous and that limits preserve inequalities.
q.e.d.
