Continuous functions on closed set 
Possible Duplicate:
Show that the set $\{ x \in [ a,b ] : f(x) = g(x)\}$ is closed in $\Bbb R$. 

I was wondering if some one can answer my following question:   
Suppose $f$ and $g$ are continuous real valued functions. Then  show the set $A=\{x|f(x)=g(x)\}$ is closed.
Thanks
 A: Certainly the easiest way to do this was alluded to by enzotib in the comments: if $f(x)=g(x)$, then $(f-g)(x)=0$. Hence, $A$ is $(f-g)^{-1}(\{0\})$, which is the pre-image of a closed set in a continuous function.
Here's an interesting way of proving a more general result:


*

*Prove that for any Hausdorff space $Y$, the "diagonal" $\{(y,y) : y\in Y\}$ is a closed subset of $Y\times Y$. (I think that in fact this condition is equivalent to Hausdorff-ness).

*Prove that for continuous functions $f:X\to Y$, $g:X\to Z$, the function defined by $h(x)=(f(x),g(x))$ is continuous as a map $X\to Y\times Z$.

*$A=(f\times g)^{-1}(D)$ where $D$ is a suitable diagonal.


(Note that the second point, coupled with the fact that addition and negation are both continuous, is probably the easiest way of proving that $f-g$ is continuous, which you needed for the first method).
A: Hints:


*

*$(-\infty, 0)\cup(0, +\infty)$ is an open set.

*$\{x \in \mathbb{R} : f(x) \neq g(x)\} = (f - g)^{-1}((-\infty, 0)\cup(0, +\infty))$.

A: Let us consider $h(x):=f(x)-g(x)+x$. Then $h(x)=x\iff f(x)=g(x)$. Thus $A=\{x|h(x)=x\}=\text{Fix}(h)$. $h$ is of course continuous. 
Now we show that the complement of $\text{Fix}(h)$ is open.  
Let $x\in\text{Fix}(h)^c$. Then $x$ is not a fixed point of $h$, i.e. $h(x)\neq x$. We have two points $x$ and $h(x)$ of $\mathbb{R}$, and since $\mathbb{R}$ is Hausdorff, we can find open sets $U,V$ with $x\in U$ and $h(x)\in V$ and $U\cap V =\emptyset$. Since $h$ is continuous $h^{-1}(V)$ is open, and $U\cap h^{-1}(V)$ is an open set containing $x$. Observe also that $U\cap h^{-1}(V)$ is disjoint of $\text{Fix}(h)$. 
(Suppose $x\in U\cap h^{-1}(V)$ and $h(x)=x$. Since $x\in U\cap h^{-1}(V)$, $x\in h^{-1}(V)$ an $f(x)\in V$. Also $x\in U$ and if $h(x)=x$, then $h(x)\in U$. So $f(x)\in U\cap V$, however $U\cap V=\emptyset$. Contradiction!)
Hence we have found around every point $x$ in $\text{Fix}(h)^c$. This complement is thus open.
