Construct a continuous monotone function $f$ on $\mathbb{R}$ that is not constant on any segment but $f'(x)=0$ a.e.
This is one exercise from Rudin's book,
Construct a continuous monotone function $f$ on $\mathbb{R}^1$ that is not constant on any segment but $f'(x)=0$ a.e.
I came across an example of such a function some time ago. It is called Minkowski's Question Mark Function, and it is denoted simply by $ ? $. Minkowski defined it so that it would map the quadratic irrationals (i.e. numbers of the form $ \dfrac{a + b \sqrt{c}}{d} $, where $ a,b \in \mathbb{Z} $, $ d \in \mathbb{Z}^{\times} $ and $ c \in \mathbb{N} $ is square-free) contained in the open interval $ (0,1) $ to the rationals in $ (0,1) $ in a continuous and order-preserving manner. More precisely, $ ? $ takes the number $ x $ with the continued fraction expression $ [0;a_{1},a_{2},a_{3},\ldots] $ to the number $$ ?(x) \stackrel{\text{def}}{=} \sum_{k=1}^{\infty} \frac{(-1)^{k - 1}}{2^{(a_{1} + \cdots + a_{k}) - 1}}. $$
According to [Salem 1943], the function $ ? $ satisfies the following properties:
- $ ? $ is continuous on $ [0,1] $.
- $ ? $ is strictly increasing.
- $ ? $ is purely singular.
As such, $ ? $ is sometimes called the Slippery Devil's Staircase, as opposed to the Devil's Staircase, which is actually constant on some intervals.
As the exercise is from one of Rudin's three books (is it Real and Complex Analysis?), I believe that a solution should not be so complicated. Anyway, if $ f $ is NOT required to be continuous, then the following basic example works. Firstly, enumerate $ \mathbb{Q} $ as a sequence $ (q_{n})_{n \in \mathbb{N}} $. Next, for each $ n \in \mathbb{N} $, define a step function $ f_{n}: \mathbb{R} \rightarrow [0,1) $ by $$ f_{n} \stackrel{\text{def}}{=} \frac{1}{2^{n}} \cdot \chi_{[a_{n},\infty)}. $$ Finally, define $$ f \stackrel{\text{def}}{=} \sum_{n=1}^{\infty} f_{n}. $$ This function is well-defined because pointwise, its value is defined by a positive infinite series that is termwise dominated by a convergent positive geometric series (this automatically makes $ f $ positive). It is increasing because it is a sum of increasing functions. It is strictly increasing because the rationals are dense in $ \mathbb{R} $. Finally, we can apply Fubini's theorem on the termwise-differentiability of a series with monotone terms to conclude that $ f' = 0 $ almost everywhere (to understand this last claim, please refer to my solution to another problem posted on the MSE: Prove $\sum_{n=1}^{\infty}f_n'(x)<\infty$ on $(0,1)$, when non-negative and increasing function $\lim_{x\to \infty}\sum_{n=1}^{\infty}f_n(x)<\infty$). However, $ f $ is not continuous at the rationals.
Perhaps if one works along these lines, then one might be able to produce an easier example than Minkowski's Question Mark Function.
References
Minkowski, H. "Zur Geometrie der Zahlen." In Gesammelte Abhandlungen, Vol. 2. New York: Chelsea, pp. 44-52, 1991.
Salem, R. "On Some Singular Monotone Functions which Are Strictly Increasing." Trans. Amer. Math. Soc. 53, 427-439, 1943.
Image Source: Armoux R., Starosta S. "The Rauzy Gasket" https://www.researchgate.net/publication/267068315_The_Rauzy_Gasket