Can a function be differentiable at only isolated points?

It is possible for a derivative to fail to exist at isolated points, but I would like to know if a function could be constructed that is not differentiable almost everywhere and differentiable at isolated points only.


Consider $$f(x) = \begin{cases} x^2 & \textrm{if $x \in \mathbb{Q}$} \\ 0 & \textrm{if $x \notin \mathbb{Q}$}. \end{cases}$$ Observe that $f$ is continuous only at $x = 0$, hence $f$ is not differentiable except possibly at $x = 0$. We claim that $$\lim_{x \to 0}\frac{f(x)}{x} = 0,$$ i.e. $f'(0) = 0$. To see this, note that $\tfrac{f(x)}{x} = 0$ for all $x \not\in \mathbb{Q}$. If $x \in \mathbb{Q} \setminus \{0\}$, then $\tfrac{f(x)}{x} = x,$ hence if $\vert x \vert < \epsilon$, then $\left\vert \tfrac{f(x)}{x} \right\vert < \epsilon$.

If you want continuity, you might be interested in the Weierstrass function $$f(x) = \sum_{n=0}^{\infty}a^n\cos(b^\pi x)$$ where $0 < a < 1$, $b$ is a positive odd integer, and $ab > 1 + \tfrac{3}{2}\pi$. It can be shown that $f$ is continuous everywhere but differentiable nowhere.

Now if you want an example of a function continuous everywhere but differentiable at only a point, take $f$ to be a continuous everywhere but differentiable nowhere function (i.e. the Weierstrass function), then define $g(x) = x^2f(x)$. Since $f(x) = \tfrac{g(x)}{x^2}$ is differentiable nowhere, $g$ cannot be differentiable except possibly at $x = 0$. You can easily show that $g'(0) = 0$.