(Write $[]$ for the Iverson bracket.)
I recently learned about the function $$\mathbb{R} \rightarrow \mathbb{R}$$
$$x \mapsto [x \in \mathbb{Q}]x^2 +[x \notin \mathbb{Q}](-x^2)$$
which is differentiable at $0$ but nowhere else.
Question.
Let $P$ denote one of the conditions:
- $r$-times differentiable
- $r$-times continuously differentiable
- smooth
- analytic
Consider a function $f : \mathbb{R} \rightarrow \mathbb{R},$ and fix
$x_0$ in $\mathbb{R}$. Do all possible implications of the form "If
$f$ satisfies $P$ at $x_0$, then $f$ satisfies $P$ in some
neighbourhood of $x_0$" fail?
I'd especially appreciate explicit counterexamples, or references to where such counterexamples can be found.
Best Answer
Take an everywhere continuous but nowhere differentiable function $g$ such as the Weierstrass function. Then $f(x) = x^2g(x)$ is once differentiable at $0$, but not anywhere else. Integrate this $r-1$ times to find a function that is $r$ times differentiable at $0$ but nowhere else.
Let $g$ have a derivative that is bounded globally but not continuous at $0$ -- for example, $$ g(x)=x^2\sin(1/x) $$ Then, $$f(x)=\sum_{n=1}^\infty \frac{g(x-1/n)}{2^n} $$ is differentiable and its derivative is continuous at $0$, but has discontinuities arbitrarily close to $0$. Integrate this $r-1$ times to find a counterexample for $r>0$.
The function $$ f(x) = \sum_{n=1}^\infty \max(0,x-1/n)^n $$ converges for $x<1$. It is differentiable arbitrarily often at $0$, but the $n$th derivative fails to exist at $x=1/n$, so it is not smooth in any neighborhood of $0$.
As noted in comments, being analytic at a point implies being analytic in a neighborhood of it.