For a function $f: U \to \mathbb{R}$ where $U$ is a subset of $\mathbb{R}$, it seems like that it being continuous at a point doesn't imply that there is a neighbourhood of the point where it can be continuous. Similarly, it seems like that it being differentiable at a point doesn't imply that there is a neighbourhood of the point where it can be differentiable. I was wondering if there are some counterexamples to confirm the above?
Added:
What are some necessary and/or sufficient conditions for continuity/differentiability at a point and in some neighbourhood of the point to be equivalent?
Can the case of continuity be generalized to mappings between topological spaces?
Thanks and regards!
Best Answer
Define $f$ by putting $f(x) = 1$ if $x$ is rational and $f(x) = 0$ if $x$ is irrational. Let $g(x) = x \cdot f(x)$ and let $h(x) = x^2 \cdot f(x).$
$g$ is continuous at $x=0$ and $g$ is not continuous at each $x \neq 0.$
$h$ is differentiable at $x=0$ and $h$ is not differentiable at each $x \neq 0.$
(In fact, $g$ is also not differentiable at $x=0$ and $h$ is not continuous at each $x \neq 0$.)