# The set of points where two continuous functions agree is closed.

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.

-

If $Y$ is a metric space, the set $\Delta =\{(y,y):y\in Y\}$ is closed in $Y\times Y$ -- this holds more generally iff $Y$ is Hausdorff (can you prove this?). Observe now that $$A=\{x\in X:f(x)=g(x)\}$$ equals the set $$B=\{x\in X:h(x)\in \Delta\}=h^{-1}(\Delta)$$ where $h:X\to Y\times Y$ is defined by $h(x)=(f(x),g(x))$. But $\Delta$ is closed, and $h$ is continuous. This proves the more general case where $Y$ is Hausdorff.

-

Consider the map $F:X\rightarrow \Bbb R$ given by $F(x)=d(f(x),g(x))$. $F$ is continuous (you can check this), and $F^{-1}(\{0\})=A$ so $A$ is closed since $\{0\}$ is closed in $\Bbb R$.

-
What is $0$ in metric space? – Hamou Jul 26 '14 at 22:38
@Hamou $0\in\Bbb R$! – Pedro Tamaroff Jul 26 '14 at 22:38

It's equal to

$$\bigcap \{x\in X: d(f(x),g(x))\le \epsilon\}$$

which is the intersection of closed sets since $Y$ is metric (hence Hausdorff) and $f,g$ are continuous.

We know it's closed because $Y$ is Hausdorff, so that the diagonal, $\Delta Y\subseteq Y\times Y$ is closed. This is so because the complement is open:

Proof: If $(x,y)\ne (y,y)$ then $B(x,{1\over 2}d(x,y))\times B(y,\delta)$ is an open set around $(x,y)$ not containing $(y,y)$, so the complement is open.

-
It doesn't matter if the intersection is finite when you're dealing with closed sets, that's only for open sets. – Adam Hughes Jul 26 '14 at 22:42
@AymanHourieh I've updated my answer to address your question of "why is it closed." Really it holds more generally in all Hausdorff spaces, there you substitute the balls I used in the answer by an open set containing $x$ by not $y$ crossed with any open set around $y$. – Adam Hughes Jul 26 '14 at 22:50
I think it was fine. I just got confused for a second and thought we were talking about a union. – Ayman Hourieh Jul 26 '14 at 22:53

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.

-