How can I prove that this function is continuous at $0$?

Solution 1:

$f$ is continuous at $x$ if the preimage of every open neighborhood of $f(x)$ contains an open neighborhood of $x$. The preimage need not be open itself.

For a simpler example, let $g(x)=1$ if $x\geq 0$, and let $g(x)=0$ when $x<0$. Then $g$ is continuous at $x=1$, but the preimage of $(0,2)$ is $[0,\infty)$, which is not open in $\mathbb R$. Nonetheless, the preimage contains the open neigborhood $(0,2)$ of $x=1$.

Translating this to $\varepsilon$s and $\delta$s, recall that $f$ is continuous at $x$ if for all $\varepsilon>0$ there exists $\delta>0$ such that $\{y:|x-y|<\delta\}\subseteq f^{-1}(\{y:|f(x)-y|<\varepsilon\})$. Here $\{y:|x-y|<\delta\}$ is the neighborhood of $x$, and it is only required to be contained in the preimage of the neighborhood $\{y:|f(x)-y|<\varepsilon\}$ of $f(x)$.

Solution 2:

Hint: What is the definition of continuity at a point in terms of open sets? How does it differ from the global definition of continuity in terms of open sets?