So I have been going through Munker's Topology on my own and one exercise asks us to construct a function $f:\mathbb{R} \rightarrow \mathbb{R}$ that is continuous only at a single point. From my limited understanding of analysis I believe that the function $$f(x) = \begin{cases} x^2 , x \in \mathbb{Q} \\ -x^2 , x \in \mathbb{R} - \mathbb{Q} \end{cases}$$ Is continuous only at $0$ since both onesided limits as $x \rightarrow 0$ equal $f(0)$. However from a topological standpoint, $(-1,2)$ is a neighborhood of $0$ in the target space, but the preimage is $$f^{-1}\left((-1,2)\right)= \left( (-\sqrt{2}, -1]-\mathbb{Q} \right) \cup (-1,1) \cup \left([1,\sqrt{2})-\mathbb{Q} \right)$$ Which is definitely not open in $\mathbb{R}$. Can someone please help me make sense of this seeming contradiction?
Real valued function continuous at one point
1 Answers
Continuity of a function $f$ on its entire domain is equivalent to $f^{-1}(U)$ is open for all open $U$. Continuity of a function at a single point $x$ is not equivalent to $f^{-1}(U)$ is open for all open $U$ containing $f(x)$.
Continuity at $x$ just means $\lim_{y\to x} f(y) = f(x)$, i.e. for every neighborhood $V$ of $f(x)$ there is a neighborhood $U$ of $x$ such that $f(y) \in V$ for all $y \in U$.
Edit: I should note that by "neighborhood" here I mean open neighborhood. Some authors use "neighborhood" to mean "contains a nontrivial open set".
If you use neighborhood to mean "contains a nontrivial open set" then continuity at $x$ is in fact equivalent to $f^{-1}(U)$ is a neighborhood of $x$ for all neighborhoods $U$ containing $f(x)$. In your example, $(-1,1)$ is an open set contained in $f^{-1}((-1,2))$, so this set is a neighborhood.