Are there any functions that are differentiable but not continuously-differentiable?

An example for $n = 1$ from the theory of random walks. Let $f$ be a (-n everywhere) discontinuous Lebesgue measurable function on $\mathbb{R}$. Here's an example with $f$ bounded by $1$, just showing the part $x \in [-3,3]$. (Note that I have only barely subsampled the graph in this interval. If I were to fully sample it, this finite resolution representation would almost surely appear to be a solid rectangle of points of the graph. Actually produced by generating $10^6$ uniformly distributed reals in $[-1,1]$ assigned to evenly spaced abscissae, then plotting a subsample of size $10^4$.)

An almost surely nowhere continuous function

This function is almost surely nowhere continuous (as any open interval almost surely contains points of heights arbitrarily close to $-1$ and $1$). The integral of this function, $$ \int_{0}^x \; f(t) \,\mathrm{d}t $$ is differentiable, but there's no hope of continuous differentiability. Graph of the integral (actually, Riemann sum approximations using $10^6$ intervals in $[-3,3]$):

integral

Picking a different instance of a bounded by $1$ discontinuous Lebesgue measurable function on $\mathbb{R}$ and integrating it the same way, we can graph the integral.

integral 2

These are almost everywhere differentiable by construction (by Lebesgue's differentiation theorem); we know the derivative is $f$. (The theorem generalizes to $n > 1$ and the integral to $\int_{[0,x_1]\times [0,x_2] \times \cdots \times [0,x_n]} \; f(t) \,\mathrm{d}t$ where we understand the intervals to be $[0,a]$ when $0 \leq a$ and $[a,0]$ when $a < 0$.) In some way, "most" functions are everywhere discontinuous messes, so "most" functions can be integrated to a differentiable, but not continuously differentiable, function.

(This construction can be iterated to get a function that is several times continuously differentiable, but whose "last" derivative is not continuous.)


Consider $f:\mathbb R^2\to \mathbb R $ defined by $$f(x,y)=\begin{cases}(x^2+y^2)\sin\left(\frac1 {\sqrt{x^2+y^2}}\right),&(x,y)\neq 0\\0,&(x,y)=0\end{cases}.$$ Then $f $ is differentiable everywhere but $\dfrac{\partial f}{\partial x}(x,y)$ and $\dfrac{\partial f}{\partial y}(x,y)$ are not continuous at $(0,0)$.


A detailed calculation for the above example can be found in the book Functions of Several Real Variables.