# If function is differentiable at a point, is it continuous in a neighborhood?

I was reading a proof for the multi-variable chain rule and in the proof the mean-value theorem was used. The use of the theorem requires that a function is continuous between two points.

Hence the motivation for the question, if a function is differentiable at a point, is it continuous in some neighborhood? If not, then the multi-variable chain rule proof is fake?

• Actually the mean-value theorem requires also that the function is differentiable, which is shown to not always be true in a different question. So is the proof of the multi-variable chain-rule wrong? – Tony Jul 10 at 20:17
• in the chain rule all the functions are differentiable at any point, and thus, they are also continuous at every point – Exodd Jul 10 at 20:25
• @Exodd Not according to this (answer by Ben) math.stackexchange.com/questions/1566376/… – Tony Jul 10 at 20:28
• yeah Stefan appears to be assuming differentiability in a neighbourhood of the point, so it's not a fake proof, but it makes stronger assumptions than necessary – shibai Jul 10 at 20:37
• @Tony Ben's result is the "stronger" version of the classic chain rule, meaning that it is more difficult to prove. Stefan proof is not sufficient and needs to be changed a lot – Exodd Jul 10 at 20:45

To answer the question in the title: a function that is differentiable at a point need not be continuous in a neighbourhood. For example, consider the function $$f(x) = \begin{cases} x^2, & x\in\mathbb Q \\ 0, & x\notin\mathbb Q\end{cases}$$ then $$\frac{\mathrm{d}f}{\mathrm{d}x}(0)=0$$, but $$\lim_{x\to a}f(x)$$ cannot exist for $$a\neq0$$ because $$\lim_{\substack{x\to a\\x\in\mathbb Q}}f(x)=\lim_{x\to a}x^2=a^2$$ whereas $$\lim_{\substack{x\to a \\ x\notin\mathbb Q}}f(x)=0$$.

This doesn't mean the multivariable chain rule is fake, however, though perhaps the proof you were reading made stronger assumptions than just being differentiable at the point of interest?

It usually isn't. Consider the function $$f : [0,1[ \rightarrow \mathbb R$$ defined by

$$f(x) = \frac{1}{n} \quad \text{if} \quad x \in \left[\frac{1}{n+1},\frac{1}{n} \right[,n \in \mathbb N^*$$ $$f(0) = 0$$

It is surely continuous at $$x = 0$$ and you can easily check that it is differentiable at $$0$$ with derivative $$1$$. And yet there is a discontinuity in any neighborhood of $$0$$.

No, differentiability in a point only implies continuity in that specific point. A counterexample can already be found in one dimension:

$$f:\mathbb R\to\mathbb R,\quad f(x)=\begin{cases}x^2&x\in\mathbb Q\\0&\textrm{otherwise}\end{cases}$$

This function is differentiable in $$0$$, but not continuous anywhere other than $$0$$.

There is also a proof of the multi-variable chain rule which does not depend on the mean value theorem. A function $$f:U\to\mathbb R^m$$ with $$U\subseteq \mathbb R^n$$ open is differentiable in $$x_0\in U$$ iff there exists a linear map $$\mathrm Df(x_0):\mathbb R^n\to\mathbb R^m$$ and a function $$R_f:U\to\mathbb R^m$$ with $$\lim_{x\to x_0}\frac{R_f(x)}{\Vert x-x_0\Vert}=0$$ such that

$$f(x)=f(x_0)+\mathrm Df(x_0)(x-x_0)+R_f(x).$$

The same goes for a function $$g:V\to\mathbb R^k$$ with $$U\subseteq\mathbb R^m$$ open and $$y_0\in V$$. So if $$g$$ is differentiable in $$y_0:=f(x_0)$$, then

$$g(y)=g(y_0)+\mathrm Dg(y_0)(y-y_0)+R_g(y).$$

Insert $$y_0=f(x_0)$$ and $$y=f(x)=f(x_0)+\mathrm Df(x_0)(x-x_0)+R_f(x)$$ to get

\begin{align*}g\circ f(x)&=g(f(x_0))+\mathrm Dg(f(x_0))[f(x_0)+\mathrm Df(x_0)(x-x_0)+R_f(x)-f(x_0)]+R_g(y)\\ &=g(f(x_0))+\mathrm Dg(f(x_0))[\mathrm Df(x_0)(x-x_0)+R_f(x_0)]+R_g(x_0)\\ &=g(f(x_0))+\underbrace{\mathrm Dg(f(x_0))\mathrm Df(x_0)}_{=\mathrm D(g\circ f)(x_0)}(x-x_0)~+~\underbrace{\mathrm Dg(f(x_0))R_f(x_0)+R_g(y_0)}_{=:R_{g\circ f}} \end{align*}

It is now straightforward to show that $$R_{g\circ f}$$ has the required property of

$$\lim_{x\to x_0}\frac{R_{g\circ f}(x)}{\Vert x-x_0\Vert}=0,$$

which makes

$$\mathrm D(g\circ f)(x_0)=\mathrm Dg(f(x_0))\mathrm Df(x_0).$$

And that's exactly the multi-variable chain rule.

Define $$f(1/n) =0, n=1,2,\dots$$ and define $$f(x)=x^2$$ everywhere else. Then $$f'(0)=0.$$ But in any neighborhood of $$0,$$ $$f$$ has infinitely many points of discontinuity–namely at the points $$1/n$$ that fit into that neighborhood.