Is there a function that is differentiable in a point $x_0$ (and so continuous of course in $x_0$) but not continuous in a neighborhood of $x_0$ (as said, besides the point $x_0$ itself)?

Can anyone suggest me an example of that ?

Thanks a lot in advice


1 Answer 1


To begin with we take $x_0 = 0$ : we want $f(0) = 0$ and $f'$ defined at $0$, with $f'(0)=1$.

Then you take :

  • $f(x) = x$ if $x \in \mathbb{Q}$

  • $f(x) = x + x^2$ if $x \notin \mathbb{Q}$

$f$ is continuous only at $0$. Moreover, you can check that $f'(0) = 1$ : indeed we have $f(0) = 0$, so $\mid \frac{f(x) - f(0)}{x} - 1\mid = \mid \frac{f(x)}{x} - 1\mid$. This quantity equals either to $0$ if $x \in \mathbb{Q}$ or to $\mid x \mid$ if $x \notin \mathbb{Q}$. Either way, when $x$ approaches $0$, $\mid \frac{f(x) - f(0)}{x} -1 \mid $ approaches $0$. Although $f$ is almost nowhere continuous, the derivative at $0$ exists and $f'(0) = 1$.

More generally, if you want $g(x_0) = y_0$, $g'(x_0) = a$ and $g$ continuous only at $x_0$, you can take :

$g(x) = y_0 + a\times f(x-x_0)$

A quite equivalent (but slightly different) explicit version would be :

  • $g(x) = y_0 + a(x-x_0)$ if $x\in \mathbb{Q}$

  • $g(x) = y_0 + a(x-x_0) +(x-x_0)^2$ if $x\notin \mathbb{Q}$

  • 1
    $\begingroup$ If a function $f$ is analytic at a point $a$, then $f$ is analytic in a neighborhood of $a$. But it is possible that a function $f$ which is differentiable at $a$ is not differentiable in a neighborhood of $a$. Thank you very much for your answer. $\endgroup$
    – tchappy ha
    Nov 8, 2022 at 4:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .