TITLE: The set of points where two continuous functions agree is closed.
QUESTION [6 upvotes]: I want to prove that if $f,g$ are continuous functions from a topological space $(X,\tau)$ to a metric space $(Y,d)$ then the set
$$ A = \{ x \in X : f(x) = g(x) \} $$
is closed. I found a very similar question asked on this site but it referred to Hausdorff spaces, which I haven't quite met. I know I can prove this by proving that the complement of $A$ is open. If I consider $b \in X$ such that $f(b) \neq g(b)$, then I can find two open sets $U,V \subseteq Y$ such that $f(b) \in U $, $\ g(b) \in V$ and $U \cap V = \varnothing$. Then since the functions are continuous we must have that $f^{-1}(U)$ and $g^{-1}(V)$, which both contain $b$, are open. Hence so is their intersection.
Now I'm not sure how to proceed...
EDIT: Whilst there are neater methods in the answers, I've just realised how I can finish the proof above. The intersection 
$$ W_b = f^{-1}(U) \cap g^{-1}(V)$$
lies entirely outside $A$ --- one can show this by supposing that there exists some $a \in A$ that is a member of $W_b$ and showing that $f(a) \in U$ and $g(a) \in V$. But $f(a) = g(a)$ by the assumption that $a \in A$, which is impossible since $U \cap V = \varnothing$.
Then the union
$$ \bigcup_{b \in X \setminus A} W_b$$
is a union of open sets and hence open, contains all $b \in X \setminus A$, and does not intersect with $A$ since $W_b \cap A = \varnothing$. Hence the union above is precisely $X \setminus A$, and hence $A$ is closed.

REPLY [2 votes]: Let $X$ be topological space and Y be a metric space. We show that X\A is open. Let $x \in$ X\A be arbitrary. 
Then $f(x)\neq g(x)$ (Otherwise x would be in A). We define $\epsilon:=d(f(x),g(x))$, so the open neighborhoods $U_{\frac{\epsilon}{2}}(f(x))$ and $V_{\frac{\epsilon}{2}}(g(x))$ are disjoint. 
Hence $W:=f^{-1}(U_{\frac{\epsilon}{2}}(f(x)))\cap f^{-1}((V_{\frac{\epsilon}{2}}(g(x))) \neq \emptyset $ is an open neighborhood of x with $W \subseteq$ X\A. If this were not true then there were a $y \in W$ such that $f(y)=g(y)$ which can't be happen.