Continuous functions between metric spaces are equal if they are equal on a dense subset If two functions defined on metric spaces $X$ and $Y$ are equal on a dense subset of $X$  and are continuous also, then are they equal on all of the metric space $X$?
 A: This is correct. Suppose $f$ and $g$ are continuous functions on a metric space $X$ and agree on a dense subset $Y$. For any $x\in X$, we have some sequence $(y_n)$ in $Y$ such that $y_n\to x$, so $f(y_n)\to f(x)$ and $g(y_n)\to g(x)$. Since $f(y_n)=g(y_n)$ for all $n$, this implies $f(x)=g(x)$.
A: Yes. The set of points where the functions $f,g\colon X\to Y$ agree is closed and contains a dense subset. The closure of a dense subset is $X$. (This does not require metric spaces, it is sufficient that $X$ is any topological space and $Y$ is Hausdorff)
A: Another proof:
Let $h = f-g$, $h:X\to Y$. Since $f$ and $g$ are continuous, so is $h$. Hence, $h^{-1}(\{0\})$ is a closed subset of $X$, and since it contains a dense subset of $X$, then it is equal to $X$. Therefore, $h=0$ on $X$, and so $f=g$ on $X$.
A: Here is another proof. Let's denote by $D$ the dense subset of $X$, i.e., $\overline{D}=X$. Also, by hypothesis, we have two continuous functions $f,g\colon X\rightarrow Y$ such that the restriction $f|_{D}=g|_{D}$. Note also that we have the following inclusion:
\begin{equation}
D\subseteq \{x\in X\colon f(x)=g(x)\}\subseteq X.
\end{equation}
If we take closures, as these preserve the inclusion, we just need to show that $\{x\in X\colon f(x)=g(x)\}$ is closed and it will follow that $\{x\in X\colon f(x)=g(x)\} = X$. Now, consider the diagonal:
\begin{align}
\Delta = \{(y,y)\colon y\in Y\}\subseteq Y\times Y.
\end{align}
Since $Y$ is a metric space, it is Hausdorff and therefore $\Delta$ is closed (easy to prove). Now consider the function $h\colon X\rightarrow Y\times Y$ given by $h(x)=(f(x),g(x))$. This function is continuous because both $f$ and $g$ are continuous. Since $\Delta \subseteq Y\times Y$ and $\Delta$ is closed, then the inverse image $h^{-1}(\Delta)$ is closed, and note that
\begin{align}
h^{-1}(\Delta) = \{x\in X\colon f(x)=g(x)\},
\end{align}
which completes the proof.
