# How do I find the example of a continuous surjective function $f: X \rightarrow Y$ such that inverse image of dense set is not dense?

How do I find the example of a continuous surjective function $$f: X \rightarrow Y$$ such that inverse image of dense set is not dense?

Can anyone suggest some hints for this question?

• Try to find a proof that the inverse image of a dense subset under a continuous function is dense. See why such a proof might fail. This should help you find a counterexample. – Stephen Montgomery-Smith Sep 5 '20 at 16:25

Hint: what if $$X$$ has the discrete topology?
$$\begin{array}{l|rcl} f : & X= \mathbb R & \longrightarrow & Y = [0,\infty) \\ & x & \longmapsto & \begin{cases}0 & x <0\\ x & x \ge 0\end{cases}\end{array}$$
$$(0,\infty)$$ is dense in $$Y$$ but $$f^{-1}[(0,\infty)] = (0,\infty)$$ is not dense in $$\mathbb R$$.