I'm reviewing mathematical analysis from the book Mathematical Analysis: A Concise Introduction by Bernd S. W. Schröder.
In section 3.4 the author gives the following definition for continuous functions:
Let $D \subseteq \mathbb{R} $ be an interval of nonzero length from which at most finitely many points have been removed and let $f : D \to \mathbb{R} $ be a function. Then $f$ is called continuous at $x$ iff
- $f(x)$ is defined, that is, $x \in D$, and
- $\lim_{z \to x}f(z)$ exists, and
- $\lim_{z \to x}f(z)=f(x)$, and
- If $x$ is an endpoint of $D$, use left or right limits in 2 and 3, as appropriate.
$f$ is called continuous (on $D$) iff $f$ is continuous at every $x \in D$.
He remarks:
We could also define continuity for functions defined on sets for which every point of the domain is contained in an interval of nonzero length. Exercise 3-32 shows that with the present definition this idea is a bit too simple to produce a sensible result.
Now, exercise 3-32 is the following:
Let $U = \bigcup\limits_{n=1}^{\infty}[\frac{1}{n} - \frac{1}{10n}, \frac{1}{n}]=\{ x \in \mathbb{R}:(\exists n\in \mathbb{N}: x \in [\frac{1}{n} - \frac{1}{10n}, \frac{1}{n}])\}$ and let the function $f : [-1,0] \cup U \to \mathbb{R}$ be defined by $f(x) = 0$ for $x \in [-1,0]$ and $f(x) = 1$ for $x \in U$.
- Prove that $f$ is continuous on every interval $I$ that is contained in its domain $D = [-1,0] \cup U$.
- Prove that every point in $D$ is contained in an interval of nonzero length.
- Explain why the function still should not be considered to be continuous on $D$.
- Suggest a generalization of the definition of continuity that would allow domains such as $D$ and that would make $f$ discontinuous at $0$.
Since $(-0.01, 0.01) \subseteq D$ and $\lim_{x \to 0^+}f(x) = 1 \neq 0 = \lim_{x \to 0-}f(x)$, I don't understand why the function $f$ is continuous at $0$ according to the above definition.
Much later in the book the author gives a more general definition of continuity on metric spaces which supposedly "resolves the problem" with the above definition and can be used to prove that the defined function indeed doesn't have a limit at $x = 0$ (exercise 16-29).
EDIT:
Following the comments, I'll prove that $(0,0.01) \subset U$ (and therefore $(-0.01, 0.01) \subseteq D$). Let $ x \in (0, 0.01)$. Choose $ n \in \mathbb{ N}$ such that $\frac{1}{n+1} \leq x \leq \frac{1}{n}$. Since $ x< 0.01$, it follows that $n \geq 100 > 9$. Therefore, $$9 < n \iff 9n+9 < 10n \iff 10(n+1) -(n+1) <10n \iff \frac{1}{n} - \frac{1}{10n} < \frac{1}{n+1}$$ so $$ \frac{1}{n} - \frac{1}{10n} < \frac{1}{n+1} \leq x \leq \frac{1}{n} $$ and thus $x \in U$. $\square$