TITLE: A continuous mapping is determined by its values on a dense set
QUESTION [8 upvotes]: Let f and g be continuous mappings of a metric space $X$ into a metric space $Y$ and let $E$ be a dense subset of $X$. Prove that $f(E)$ is dense in $f(X)$. If $g(p)=f(p)$ for all $p \in E$, prove that $g(p)=f(p)$ for all $p \in X$.

REPLY [4 votes]: For the first part it is not restrictive to assume $f$ is surjective.
Suppose $U$ is an open set in $Y=f(X)$ such that $U\cap f(E)=\emptyset$. Then $f^{-1}(U)\cap E=\emptyset$ and therefore, by density, $f^{-1}(U)=\emptyset$, so also $U=\emptyset$. Thus every nonempty open set of $f(X)$ has nonempty intersection with $f(E)$, which is density.
For the second part, note that $W=\{x\in X:f(x)\ne g(x)\}$ is open in $X$. Indeed, if $x\in W$, take disjoint neighborhoods $U_1$ and $U_2$ of $f(x)$ and $g(x)$, respectively. Then $V=f^{-1}(U_1)\cap g^{-1}(U_2)$ is a neighborhood of $x$ and $V\subseteq W$. Hence $W$ is open.
As a consequence $E\subseteq X\setminus W$; since $X\setminus W$ is closed and $X$ is the only closed subset of $X$ containing $E$ (by density), we are done.

Notes. The first part is true for any continuous map between topological spaces. The second part is true for any continuous map between topological spaces, provided the codomain is Hausdorff.