Differentiable functions satisfying a certain property Whilst thinking about this question, I came across a problem. The original question was for what  differentiable functions $f:\mathbb{R} \to \mathbb{R}$, with $y=f(x)$, does $\frac{dy}{dx} = F(y)$ for some function $F$; note the domain of $F$ is the image of $f$. Injectivity is sufficient, letting $F = f' \circ f^{-1}$. If $f$ is constant, then, even though $f^{-1}$ is not well defined, we can still define the derivative as a function of $y$ in a natural manner, namely $F(y) = 0$.  How to characterize this leads me to the question.  

Consider $f:\mathbb{R} \to \mathbb{R}$ differentiable with the following property.  For the fiber $S_a$ of some $a$ in the image of $f$, $f'(x) = c$ for constant $c$ for all $x \in S_a$. If this holds for every $a$ in the image, then either $f$ is injective or $f$ is constant. 

Roughly speaking, $f$ has the property that $a=f(x_1)=f(x_2)=\cdots f(x_n)$ implies $c=f'(x_1)=f'(x_2)=\cdots f'(x_n)$ (roughly because the set which maps to $a$ needn't be countable). 
Perhaps this is trivial. I can't seem to find a counterexample. 
 A: Consider
$$
  f(x)=\begin{cases}
    x^3&\text{for }x<0,\\
    0&\text{for }0\leq x\leq 1,\\
    (x-1)^3&\text{for }x>1.
  \end{cases}
$$
For $a\in\mathbb R$ nonzero, $f^{-1}(a)$ is a singleton so your condition holds. On the other hand $f^{-1}(0)=[0,1]$ and $f'(x)=0$ on $[0,1]$. It's possible to find examples that are infinitely differentiable if desired.

However $f(x)$ is quite constrained by the conditions. Firstly if $|f^{-1}(y)|>1$ then $f'=0$ on $f^{-1}(y)$. Suppose otherwise, and pick $b>a$ with $f(a)=f(b)=y$. wlog suppose $f'(a)>0$. Then $f(x)>y$ for $x\in(a,a_1)$ for some $a_1>a$. Let
$$
  c=\inf\{x\in(a,b]\mid f(x)=y\}.
$$
Then $c\in[a_1,b]$ and $f(c)=y$ by continuity. Thus $f'(c)=f'(a)>0$, so $f(x)<y$ for $x\in(c_1,c)$ for some $c_1<c$. Pick $a_2\in(a,a_1)$, $c_2\in(c_1,c)$ with $a_2<c_2$. Then $f(a_2)>y$, $f(c_2)<y$ and $f(x)\neq y$ for $x\in[a_2,c_2]$. This contradicts the IVT.
Secondly $f$ is monotonic (either nonincreasing or nondecreasing). Suppose otherwise, and wlog suppose $a<b<c$ with $f(a)\leq f(c)<f(b)$. By the MVT, $f'(d)<0$ for some $d\in(b,c)$. However the IVT implies $f(d_1)=f(d)$ for some $d_1\in(a,b)$. This contradicts the first property.
Therefore $f$ is either nondecreasing or nonincreasing, and if there are any $y$-values whose preimage is a nontrivial interval (a "plateau"), then $f'$ is zero at the ends of the plateau.
