A continuous function is 'mostly' nowhere differentiable
About this post
It is taught in elementary calculus course that, if a function is differentiable at some point $x_0$, then it’s continuous at $x_0$, but not vice versa. It’s easy to construct an counterexample which is continuous but not differentiable. An example is $y=|x|$ at $x=0$. In fact, we can even find a nowhere differentiable function by series:
where $g(x)=|x|$ for $x \in [-1,1]$ and $g(x+2)=g(x)$ for all $x \in \mathbb{R}$.
Though the existence has been proved already, we are looking for some feasible estimation on “quantity”. Also, this post is a good chance to review some elementary analysis techniques such as continuity and differentiability.
Some basic facts
I’m assuming that you have finished this post or some equivalences (basic facts about Baire Category Theorem).
Let $K=[0,1]$ and let $C(K)$ be the set of all real-valued continuous functions defined on $K$. For $f \in C(K)$, we define the norm of $f$ by $\lVert f \rVert = \sup_{x \in K}|f(x)|$, and a metric $d$ on $C(K)$ by $d(f,g)=\lVert f-g \rVert$, then $C(K)$ becomes a complete metric space, where BCT applies, showing that $C(K)$ is of the second category.
A function $f \in C(K)$ will be called somewhere differentiable if there exists some point $x \in K$ such that $f$ is differentiable at $x$ (A somewhere differentiable function need not to be everywhere continuous on $K$, but that’s out of our consideration.). If there are several collections of functions defined by
then trivially $E \subset A \subset S \subset C(K)$. We’ll show that, however, $S$ is of the first category (needless to talk about $E$ and $A$), which indicates that there are “very few” somewhere differentiable functions.
Proof in detail
(Theorem) $S$ is of the first category.
By somewhere differentiable, we mean that there exists some $x \in K$ such that the limit
exists and is bounded. If we omit the restriction of existence, we got a super set of $S$ defined by
We will show that $B_{n,m}$ is of the first category which forces $S$ to be the first category.
Step 1 - Each $B_{n,m}$ is closed
Proof
It suffice to show that every Cauchy sequence in $B_{n,m}$, namely $(f_k)_{k=1}^{\infty}$, converges in $B_{n,m}$. Since $S$ is complete, we have $f_k \to f$ (uniformly) for some $f \in S$ when $n \to \infty$. For each $k$, we can find $x_k \in [0,1]$ such that
for all $0 < h < \frac{1}{m}$. Since $[0,1]$ is compact, by Bolzano-Weierstrass theorem, $(x_k)_{k=1}^{\infty}$ has a convergent subsequence, namely $(x_{k_i})_{i=1}^{\infty}$. Therefore, for each $i$, we have some $g_{i}=f_{k_i}$ and $y_i=x_{k_i}$ such that
for all $0<h<\frac{1}{m}$. Suppose then $y_i \to x$ as $i \to\infty$, we therefore have
for all $0<h<\frac{1}{m}$. Therefore $f \in B_{n,m}$, which implies that $B_{n,m}$ is closed.
Remarks
There are two basic analysis facts used in this step.
First, subspace of complete metric space is closed iff it’s complete. This can be easily shown by proving that subspace of complete metric space is not complete iff it’s not closed (a word of warning: not closed $\neq$ open!). For detailed proof, click here.
Second, the Bolzano-Weierstrass theorem. A subset $M$ of $\mathbb{R}$ is compact iff every sequence of elements of $M$ has a subsequence which converges to an element of $M$. We already know that $[0,1]$ is compact.
Step 2 - Each $B_{n,m}$ is nowhere dense
Proof
To show that $B_{n,m}$ is nowhere dense, we have to show that $B_{n,m}$ contains no open ball. The open ball for $f \in B_{n,m}$ is defined by
We will show that $B(f,\varepsilon)-B_{n,m} \neq \varnothing$ for any $\varepsilon >0$. This is done by constructing a function $g$ such that $g \in B(f,\varepsilon)$ but $g \notin B_{n,m}$.
Since $PL(K)$ (the family of piecewise linear functions defined on $K$) is dense in $C(K)$, we may find a function $p \in PL(K)$ such that $\left\Vert f-p \right\Vert<\frac{\varepsilon}{2}$.
Since $p$ is piecewise differentiable as well, we may find some $M \in \mathbb{N}$ such that $|p’(x)| \leq M$ for all $x$ where $p$ is differentiable. Pick an integer $k$ where $k>\frac{2(M+n)}{\varepsilon}$.
Define another periodic piecewise linear function $\varphi$ on $K$ as follows. For $x \in [0, \frac{2}{k}]$, $\varphi(x)=-k|x-\frac{1}{k}|+1$, for $\frac{k}{2} < x \leq 1$, $\varphi(x+\frac{k}{2})=\varphi(x)$. For this function, we have $|\varphi(x)| \leq 1$ and $|\varphi’(x)|=k$ for all $x$ where $\varphi$ is differentiable. With $g(x)$ defined by
we have
Thus $g \in B(f,\varepsilon)$. However, as we’ll show, $g \notin B_{n,m}$.
Pick $x \in K$ such that both $p$ and $\varphi$ are differentiable at $x$, then
Still, $g \in PL(K)$. For $x$ where $g$ is differentiable, we have $|g’(x)|>n$. For the turning points of $g$, we have $|g’_{-}(x)|>n$ and $g’_{+}(x)>n$, that is, the left and right derivatives of $g$. Therefore, for any $n,m \in \mathbb{N}$ and $\varepsilon \in \mathbb{R}^{+}$, we have $B(f,\varepsilon) - B_{n,m} \neq \varnothing$. That is, $B_{n,m}$ is nowhere dense.
Remarks
There are some confusing parts worth talking about.
Why do we have to prove that $B_{n,m}$ contains no open balls?
Since $B_{n,m}$ is closed, the closure of $B_{n,m}$ is itself. Therefore it suffices to show that $B_{n,m}$ has empty interior, or equivalently, contains no open balls.
The detail of $g \notin A_{n,m}$?
Notice that $g$ is a piecewise linear function. Suppose the turning points of $g$ are $x_1,x_2,\cdots,x_N$. Then $g(x)$ is differentiable (also linear) on $(x_i,x_{i+1})$ for $i=1,2,\cdots,N-1$, and $g’(x)$ is the slope of the segment, which is equal to $\frac{g(x+h)-g(x)}{h}$ for $x+h \in (x_i,x_{i+1})$. If $x=x_i$ for some $i$, then $\frac{g(x+h)-g(x)}{h}$ is equal to the slope of the segments on the left and right hand. Therefore, for all $x \in K$, we can find some $0<|h|<\frac{1}{m}$ such that $|g(x+h)-g(x)|/|h|>n$.
Piecewise linear functions?
A function $p$ is called piecewise linear on $[0,1]$ if there is a partition $0=a_0<a_1<\cdots<a_n=1$ such that $p$ is “linear” (can be expressed in the form $y=ax+b$ ) on $[a_n,a_{n+1}]$. Also we assume that $p$ is continuous, whose collection is denoted by $PL(K)$. The fact that $PL(K)$ is dense in $C(K)$ can be shown as follows (For an advanced proof, you may want to check here).
$PL(K)$ is dense in $C(K)$. Alternatively, for every $f \in C(K)$ and $\varepsilon >0$, there exists some $p(x)$ such that $\left\Vert p-f \right\Vert < \varepsilon$.
(Proof) Since $K$ is compact, $f$ is uniformly continuous on $K$. Therefore, there exists some $\delta>0$ such that $|f(x)-f(y)|<\frac{\varepsilon}{2}$ for all $|x-y|<\delta$ where $x,y\in{K}$.
Refine the partition associated with $p$ by forcing $|a_{i+1}-a_i|< \delta$. Define $p \in PL(K)$ by $p(a_i)=f(a_i)$. If $x \in K$, there is an $i$ such that $a_i \leq x \leq a_{i+1}$. Then $|f(x)-f(a_i)|<\frac{\varepsilon}{2}$. Also,
Therefore
This holds for all $x \in K$. Therefore holds for $\sup|f(x)-p(x)|$.
Step 3 - $S = \bigcup_{m}\bigcup_{n} B_{n,m}$, therefore of the first category
Proof
Since $f$ is differentiable at $x$, there exists a real number $A$ such that for any $\varepsilon>0$, there exists some $\delta>0$ such that
for $|h| \in (0,\delta)$. In fact, $A=f’(x)$, all we have to do is pick $n,m$ such that $n > A$ and $\frac{1}{m}<\delta$. Alternatively speaking, all we need to show is that, if $f \in S$, then $f \in B_{n,m}$ for some $m$ and $n$. Therefore
Remarks
If we think of meagre sets as being “small”, this tells us that “mostly” $f \in C(K)$ is nowhere differentiable. At the very least, nowhere differentiable functions topologically exists, since a space cannot be of the first and second category at the same time.
A continuous function is 'mostly' nowhere differentiable
https://desvl.xyz/2020/07/04/nowhere-differentiable-functions/