Continuity of $f$ at $x=0$ Could you please help me the following question from Adam's Calculus?

Let
$$
f(x) = \begin{cases}
x,   & \text{if } x=1, 1/2, 1/3, \ldots \\
x^2, & \text{otherwise.}
\end{cases}
$$
Is it continuous at $x=0$?

According to the definition of continuity, it's not continuous at $x=1/2, 1/3, 1/4, \ldots$ At $x=0$ it is continuous, but I cannot understand how it is continuous at $x=0$ when the values of $f$ are approaching $0$ at two different rates. I mean, in any interval containing $x=0$ there are points at which the function is discontinuous. Is it enough to rely on the definition of continuity?
 A: It is sufficient to note  that for $|x|<1$, you have
$$
|f(x)-0| \leq x \to 0, \quad x\to 0
$$
This implies that $\lim_{x\to 0} f(x)=0=f(0)$, and therefore $f$ is continuous at $x=0$.
A: Let $\epsilon>0$ be arbitrary. By the Archimedean property there exists a $n\in\mathbb N$ such that $\epsilon>1/n$. Let $\delta=1/n$.
Now, let $|x|<\delta$ be arbitrary. If $x=1/m$ for some $m\in\mathbb N$, then $|f(x)-f(0)|=1/m<1/n<\epsilon$.
Otherwise, $|f(x)-f(0)|=x^2\le |x|<\delta=1/n<\epsilon$.
Thus, $f$ is continuous at $x=0$.
A: There is no “rate” of approaching. Nothing approaches anywhere.
The function is continuous at $a$ if, for every $\varepsilon>0$, there exists $\delta>0$ such that, for $|x-a|<\delta$, it holds $|f(x)-f(a)|<\varepsilon$.
In your case, $|f(x)|<\varepsilon$ is the inequality to prove.
We need that $1/n<\delta$ implies $1/n<\varepsilon$, so a first attempt is to choose $\delta=\varepsilon$. However, we also need that $|x|<\delta$ implies $|x^2|<\varepsilon$ for points not of the form $1/n$. OK, let's choose
$$
\delta=\min(\varepsilon,1)
$$
Now, if $1/n<\delta$, then $1/n=|f(1/n)|<\varepsilon$. For the other points,
$$
|f(x)|=|x^2|<|x|<\delta\le\varepsilon
$$
and we're done.
