Continuity at exactly one point

Solution 1:

The open set definition you quoted shows that a function is continuous everywhere on its domain. Your function is most definitely not continuous everywhere; as you noted in the comments, it's continuous only at $0$.

That said, there is a topological notion of continuity at a single point, using open sets. The definition says,

A function $f : X \to Y$ is continuous at a point $x_0 \in X$ if and only if, for all open $V \subseteq Y$ containing $f(x_0)$, there exists an open $U \subseteq X$ containing $x_0$ such that $f(U) \subseteq V$.

To show this, suppose $V \subseteq \Bbb{R}$ is open and contains $f(0) = 0$. Then we take $U = V$, which again contains $0$. For all $x \in U$, we have $f(x) = x \in U$, or $f(x) = 0 \in U$. Either way, $f(x) \in U = V$. That is, $f$ is continuous at the specific point $0$.

We can also use this to show discontinuity at other points. For example, if $x_0$ is irrational, we can take $V = (-|x_0|/2, |x_0|/2)$, which contains $f(x_0) = 0$. Suppose there is some open $U$, containing $x_0$, such that $f(U) \subseteq V$. As $U$ is an open set containing $x_0$, it must contain an interval $(x_0 - \delta, x_0 + \delta)$. We can shrink $\delta$ as much as we like, until we have $\delta < |x_0|/2$. Since the rationals are dense in $\Bbb{R}$, we can choose $x \in (x_0 - \delta, x_0 + \delta) \cap \Bbb{Q}$. Then, $$|f(x) - x_0| = |x - x_0| < \delta < \frac{|x_0|}{2}.$$ Therefore, $$|x| \ge |x_0| - |x - x_0| > |x_0| - \frac{|x_0|}{2} = \frac{|x_0|}{2}.$$ This implies $f(x) \notin V$. That is, we have $x \in U$ such that $f(x) \notin V$, which contradicts $f(U) \subseteq V$, and hence $f$ is not continuous at $x_0$.

You can also come up with an analogous argument for $x_0 \in \Bbb{Q} \setminus \{0\}$. I'll leave it to you to come up with the details.