TITLE: $f,g$ continuous from $X$ to $Y$. if they are agree on a dense set $A$ of $X$ then they agree on $X$
QUESTION [8 upvotes]: Problem:
Suppose $f$ and $g$ are two continuous functions such that $f: X \to Y
 $ and $g : X \to Y $. $Y$ is a a Hausdorff space. Suppose $f(x) = g(x)
 $ for all $x \in A \subseteq X $ where $A$ is dense in $X$, then $f(x)
 = g(x) $ for all $x \in  X $.

Attempt at a solution:
Put $h(x) = f - g $. Therefore, $h: X \to Y $ is continuous and $Y$ is Hausdorff by hypothesis. Also we know $h(x) = 0 $ for all $x \in A $ such that $A$ is dense in $X$. I want to show that $h(x)$ vanishes everywhere in $X$. We can show $h(x) = 0 $ for all $x \in X \setminus A $. Suppose $h(x) > 0 $ on $X \setminus A$. Pick points $y_1,y_2 \in Y $. Since $Y$ is Hausdorff, can find open set $O_1, O_2 \subseteq Y $ which are disjoint such that $y_1 \in O_1$ and $y_2 \in O_2$. By continuity, $f^{-1}(O_1), f^{-1}(O_2)$ are open in $X$. 
I know that if I can show that one of the $f^{-1}(O_i)$ lies in $X \setminus A $, then we would have a contradiction since we have non-empty open set in $X \setminus A$ and this implies $A$ cannot be dense in $X$. But this is the part I am stuck. Any help would greatly be appreciated.
Also, Would be be possible to prove this without using the Hausdorff condition on $Y$?

REPLY [3 votes]: I'm just going to add a short proof to this question, since this proof wasn't listed, and this question seems to be the version all duplicates are directed towards.
Setting up notation:
Let $f,g : X\to Y$ be continuous functions, with $Y$ Hausdorff. Let $f,g$ agree on a dense subset $A$ of $X$. Let 
$\Delta_X : X\to X\times X$ denote the diagonal map and let $D_Y\subset Y\times Y$ denote the diagonal as a subset of $Y\times Y$, finally let $(f,g)$ denote the product map from $X\times X\to Y\times Y$.
Proof:
It is a standard fact that $Y$ is Hausdorff if and only if $D_Y$ is closed, so $D_Y$ is closed. Therefore the set of points at which $f$ and $g$ agree,
$((f,g)\circ \Delta_X)^{-1}(D_Y),$ is a closed subset of $X$. However,
we know this set also contains a dense subset, so it must be all of $X$.
Thus $f=g$.