TITLE: Differentiable function with bounded derivative, yet not uniformly continuous
QUESTION [8 upvotes]: It is well-known that if a differentiable function $f:I \to \mathbb{R}$ ($I$ an interval) has bounded derivative, then it is uniformly continuous.  On the other hand, there are differentiable functions, which are uniformly continuous, but whose derivative is unbounded.  My related question is as follows.  Does there exist a differentiable function $f:\mathbb{R} \to \mathbb{R}$, and a subset $X \subseteq \mathbb{R}$, such that $f'$ is bounded on $X$, and yet $f$ is not uniformly continuous on $X$?  Note that $X$ cannot be an interval, a finite disjoint union of intervals, nor can it be a discrete set.

REPLY [2 votes]: Let $$f(x)=cos(x^2),\quad \text{and}$$ $$X=\{x:|f'(x)|\le1\}.$$
The function is differentiable everywhere, and oscillates faster and faster to $\pm\infty$, yet keeps attaining $\pm1$ with $f'(x)=0$ at those points.  Thus there is a tiny, but nonzero length neighborhood around each peak where the derivative is $-1\le f'(x)\le1$.  $X$ is the set of exactly those points.
The peaks are at $x=\pm\sqrt{2k\pi}$ $(k\in\mathbb{Z})$ and the valleys are at $y=\pm\sqrt{(2k+1)\pi}$.  Creating sequences out of the peaks and troughs going off to the right from the origin $(n\in \left\{0,1,... \right\})$, we have $$|y_n-x_n|=\left|\sqrt{(2n+1)\pi}-\sqrt{2n\pi}\right|\rightarrow0$$ but $$\left|f(y_n)-f(x_n)\right|=|-1-1|=2$$so by the sequential characterization of uniform continuity, the function is not uniformly continuous on this set.