$\{x\in X: f(x)=g(x)\}$ is closed in $X$ if $f$ and $g$ are continuous on $X$. could you help me demonstrate the following please
Let $f,g:(X,d_X)\rightarrow\mathbb{R}$ be continuous functions. Prove that $\{x\in X: f(x)=g(x)\}$ is closed in $X$.
It is a result that is very interesting to me, but I really do not know how to start the demonstration, it is like relative closed, but I do not know how to use the continuity hypotheses to arrive at the result. I have no attempts, because I have no idea how to attack the problem
 A: The inverse image of closed sets through continuous functions are closed sets. Take the function $f-g$, it is continuous as a difference of continuous functions. Take the closed subset $\{0\}$ of $\mathbb{R}$. Do you see why your set is equal to $(f-g)^{-1}(\{0\})$?
A: Consider the continuous function $f-g$. Then your set is the inverse image $(f-g)^{-1}(\{0\})$ and thus closed.
Alternatively, take a sequence $(x_n)_n$ in $\{x \in X: f(x) = g(x)\}$ with $x_n \to x$. Then by continuity $f(x_n) \to f(x)$ and $g(x_n) \to g(x)$. But since $f(x_n) = g(x_n)$ for all $n$ it follows that $f(x) = g(x)$. Thus your set must be closed.
A: Since it is a metric space a set is closed if and only if it is sequentially closed. So suppose $x_n$ is a sequence from your set which converges to $x$. Then by continuity $f(x_n)\to f(x)$ and $g(x_n)\to g(x)$. But for each $n\in\mathbb{N}$ we have $f(x_n)=g(x_n)$, hence by passing to the limit $f(x)=g(x)$.
A: The key property is that ${\Bbb R}$ is Hausdorff. More generally, consider two continuous functions $f, g$ from a topological space $X$ to a Hausdorff topological space $E$. Then the map $f \times g: X \to E \times E$ is continuous. Moreover,
according to this result, the diagonal of $E \times E$, that is the set $D = \{(x, x) \mid x \in E\}$, is closed. It follows that $(f \times g)^{-1}(D)$ is also closed. But
$$
(f \times g)^{-1}(D) = \{x \in X \mid (f(x), g(x)) \in D\} = \{x \in X \mid f(x) = g(x)
$$
A: consider a sequence in the set that converges to an $x\in X$. Then prove the statement by using sequential continuity
