TITLE: An equivalent condition for differentiability almost everywhere?
QUESTION [7 upvotes]: Given a function $f \in L^1 (\mathbb R)$, define the roughness $R_f$ of $f$ at $x \in \mathbb R$ by
$$\DeclareMathOperator{\esssup}{\operatorname{esssup}}
R_f (x) := \limsup_{r \to 0+}\dfrac{r \esssup_{y \in B_r (x)} |f(y) - f(x)|}{\displaystyle\int\limits_{B_r (x)} |f(s) - f(x)| ds} 
$$
where $\esssup$ denotes the essential supremum, and by convention we take $\frac{0}{0} = 1$.
Question: Let $f$ be continuous. Is it true that $f$ is differentiable almost everywhere if and only if $R_f = 1$ almost everywhere?
Remark: The “only if” direction is relatively straightforward, the “if” direction is the issue.

REPLY [2 votes]: The answer is negative: If $f'(x) = 0$ "too often", then $R_f$ may fail to be equal to one almost everywhere.

Let $C$ be a fat Cantor set, let $I_n = (a_n, b_n)$ ($n \geqslant 2$) be the sequence of all finite components of the complement of $C$, and let $f$ be a differentiable function with the following properties:

$f(x) = 0$ for $x \in C$;

on $I_n$, $f$ is a smooth bump of a fixed shape, supported in $\tfrac1n I_n$ (the middle $n$th part of $I_n$), and with maximum equal to $|I_n|^2$ (and hence the integral of $f$ over $I$ is equal to $\tfrac1n |I_n|^3$).


Then $f'(x) = 0$ for $x \in C$ by the first property, so $f$ is everywhere differentiable. On the other hand, it is rather straigthforward to see that there is a constant $C$ such that for each $n$ and $t \in I_n = (a_n, b_n)$ we have
$$ \int_{a_n}^t f(y) dy \leqslant \frac{C}{n} (t - a_n) \sup_{y \in [a_n, t]} f(y) $$
and
$$ \int_t^{b_n} f(y) dy \leqslant \frac{C}{n} (b_n - t) \sup_{y \in [t, b_n]} f(y) . $$
It follows that if $x \in C$ and $r$ is small enough, so that $B_r(x)$ is disjoint with $\tfrac12 I_2 \cup \tfrac13 I_3 \cup \ldots \cup \tfrac1{n-1} I_{n-1}$, then
$$ \int_{B_r(x)} f(y) dy \leqslant \frac{C}{n} |B_r(x)| \sup_{y \in B_r(x)} f(y) . $$
This, in turn, implies that $R_f(x) = \infty$ for every $x \in C$.
Thus, $R_f(x) \ne 1$ on a set of positive Lebesgue measure.