Existence of differentiable functions on $\mathbb R$ whose derivative is constant on the complement of uncountable set but not everywhere Let $ A $ be a countable subset of the set of real numbers and $f:\mathbb R \to \mathbb R$ be a differentiable function such that $f'$ is constant on $\mathbb R \setminus A$ , then I know that $f'$ is constant on $\mathbb R$ . My question is ; is it true that for every $c \in \mathbb R$ and uncountable set $B \subseteq \mathbb R$ , there exists a differentiable function $f:\mathbb R \to \mathbb R$ such that $f'(x)=c , \forall x \in \mathbb R \setminus B$ but $f'$ is not constant on $\mathbb R$ ?
 A: Let $K$ be the Cantor set. Then $K$ is uncountable. Suppose $f:\mathbb {R}\to \mathbb {R}$ is differentiable on $\mathbb {R}$ and $f'(x) = 0$ for all $x\in\mathbb {R}\setminus K.$ Then $f$ is constant on $\mathbb {R}.$
Proof: Clearly $f' = 0$ outide of $[0,1].$ Recall how the Cantor set is constructed: At the $n$th stage, $2^n$ open intervals of length $1/3^n$ are removed. Suppose $(a,b)$ is such an interval. Then $f'=0$ on $(a,b),$ hence $f$ is constant on $(a,b).$ By continuity, $f$ is constant on $[a,b].$ It follows that $f'(a)=f'(b)=0$ as well.
Below all expansions will be ternary. Recall that an open interval of the form
$$\tag 1(.x_1 \dots x_{n-2}2\, 0 \overline 2 , .x_1 \dots x_{n-2} 2 2 \overline 0)$$
is an interval removed at the $n$th stage.
Let $K= A \cup B,$ where $A$ is the set of endpoints of open intervals removed to form $K,$ and $B = K \setminus A.$ Then $B$ is the set of points in $K$ whose expansions have infinitely $0$'s and infinitely many $2$'s.
Suppose now $x = .x_1 x_2\dots \in B.$ Then there will be infinitely many $n$ such that $x_{n-1} = 2, x_n=0.$ For such $n$ define the interval $(a_n,b_n)$ as in $(1).$ Since this is one of the removed intervals, $f(a_n)= f(b_n).$ We get
$$ \frac{f(b_n)-f(x)}{b_n-x}= \frac{f(a_n)-f(x)}{b_n-x}$$
But $a_n-x = 1/3^n,b_n-x = 2/3^n.$ As $n\to \infty$ through the appropriate sequence of $n$'s, we conclude $f'(x) = 2f'(x).$ It follows that $f'(x)=0.$ This shows $f'\equiv 0$ on $\mathbb {R}.$
