The range of the derivative of a differentiable function I read somewhere that, given a function $f$ differentiable on $[a,b]$, the range of $f'$ can be
(1) a closed interval or
(2) an open interval or
(3) a half-open interval or
(4) an unbounded interval
Can someone give an example for each one ?
 A: Let's see: For (1), any $f$ with continuous derivative works. The typical example for (4) is the continuous extension of $x^2\sin(1/x^2)$ to $[0,1]$.
An example for (2) is a bit harder. This comes from

Bernard R. Gelbaum, John M. H. Olmsted. Counterexamples in Analysis, Dover Books on Mathematics, 2003. 

Differentiation is discussed in chapter 3. Consider the function
 $$ f(x)=\left\{\begin{array}{cc}x^4e^{-x^2/4}\sin(8/x^3)&x\ne0,\\ 0&x=0,\end{array}\right. $$
for $-1\le x\le 1$. Its derivative is
 $$ f'(x)=\left\{\begin{array}{cc}e^{-x^2/4}\left[\bigl(4x^3-\frac12x^5\bigr)\sin(8/x^3)-24\cos(8/x^3)\right]&x\ne0,\\ 0&x=0,\end{array}\right. $$
which has range $(-24,24)$ (in any neighborhood of zero). A proof is in their book (pp. 37-38). The reference they provide is 

John M. H. Olmsted. Advanced calculus, Appleton Century Crofts, Inc., 
  New York, 1961.

I include the graph of $f'$ produced by WolframAlpha:

Once we have an example for (2), an example for (3) is easy: Simply pick some $t\ne0$ where $f'(t)=0$, say $0<t<1$, and replace $f$ to the right of $t$ with a continuous function $g$ such that $g(t)=f(t)$, $g'(t)=0$, and $g'$ has range $[-24,0]$.
A: Example for 2: On $[0,1],$ define $f(x)=\int_0^x (1-t)\sin(1/t)\, dt.$ Then for $x\in (0,1], f'(x) = (1-x)\sin(1/x).$ From this you do a little work to see $f'((0,1]) = (-1,1).$
What about $f'(0)?$ Claim: $f'(0)=0.$ Note first that the FTC shows that the derivative of $\int_0^x t\sin(1/t)\, dt$ at $0$ equals $0.$ So we have to prove
$$\frac{1}{x}\int_0^x \sin(1/t)\, dt \to 0$$
as $x\to 0^+.$ Let $t=1/y$ to see the above equals
$$\tag 1 \frac{1}{x}\int_{1/x}^\infty \sin(y)y^{-2}\, dy.$$
If we integrate by parts (integrating $\sin y$ and differentiating $y^{-2}$), we see that not only does $(1) \to 0,$ it is $O(x).$
A: for (3), $\exists \beta>0$, define
\begin{equation*}
        f(x)=\left\{
            \begin{aligned}
                x^2+x+x^2\sin\frac{1}{x}, \quad x &\neq 0, x\in [0,\beta]\\
                0,  \quad & x=0.
            \end{aligned}
        \right.
\end{equation*}
\begin{equation*}
        f'(x)=\left\{
            \begin{aligned}
                1-\cos\frac{1}{x}+2x(1+\sin\frac{1}{x}), \quad  &x\neq 0, x\in [0,\beta]\\
                1,  \quad & x=0.
            \end{aligned}
        \right.
\end{equation*}
s.t., $Rf'(x)\in (0,3]$. 
 The trick part is to prove the range is open at 0. For $\forall x_k=\frac{1}{2k\pi}, k=1,2,...,$ $f'(x_k)=\frac{1}{k\pi}>0, {\rm for}~x\neq x_k, f'(x)=1-\cos\frac{1}{x}+2x(1+\sin\frac{1}{x})\geq 1-\cos\frac{1}{x}>0$. So $0\notin Rf'(x)$. Moreover, $\lim_{k\to\infty} f'(x_k)=0$, which proves 0 is a limit point. So, it's open at 0. 
