Characterization of continuity with open subsets.

Recently I learned about the following characterization for continuity:

A function $f: X \to Y$ with $X,Y \subseteq \mathbb{R}$ is continuous if for every open subset $U \subseteq Y$ the inverse image $f^{-1}(U)$ is an open subset of $X$.

I understand why this is useful and generally true, but I think I'm missing a detail. Consider the function $$f: x \in \mathbb{R}_{\geq0} \mapsto \sqrt{x} \in \mathbb{R}$$ and the open subset $U = (-1,1) \subseteq \mathbb{R}$. Then the inverse image $f^{-1}(U) = [0, 1)$ is by my understanding not an open set, right? But obviously $f$ should be continuous. Or is $f$ only considered continuous if we change it to $f: x \in \mathbb{R}_{\geq0} \mapsto \sqrt{x} \in \mathbb{R}_{\geq0}?$ I'm confused.


That half-closed interval is open, if for example you are considering the domain with the subspace topology. You can read this: Square root function Topology.

By thinking about these things, you are venturing into a subject called point-set or general topology. Topology is (usually) concerned with open sets, but it's very important to realize that in order for a set to be open it only has to satisfy a few abstract rules (look up the definition of a topological space). There are topologies out there containing open sets that you wouldn't normally think are open.