hausdorff space and continuous function Here is the question I could not solve even though I have been thinking it since couple days.

Let $f$ be a continuous function from $(X, \mathcal{T})$ to $(X, \mathcal{T})$. Show that if $X$ is a Hausdorff space, then
  $$\{x \in X : f(x)=x\}$$
  is closed.
If $X$ is a $T_1$ space can we still have the same conclusion? If not, provide a counterexample.

 A: Since there are several answers addressing the first question, let me just give an example for the second one. A good example for a T1-space that is not T2 is $\mathbb{N}$ with the cofinite topology, i.e. the closed sets are the finite ones. Then take the map $f:\mathbb{N}\to \mathbb{N}$, given as $f(x)=\begin{cases}x&\text{$x$ odd}\\\frac{x}{2}&\text{$x$ even.}\end{cases}$
I'll leave it as an exercise for you to show that this map is continous (you have to show that preimages of finite sets are finite). But $\{f(x)=x\}$ is the set of odd numbers, which is certainly not finite.
A: Let $G=\{x \in X : f(x)=x\}$.
We want to prove that $G$ is closed, hence that $G^c$ is open.
So take $y\in G^c$.
Since X is Hausdorff we can find a two open sets U and V so that:
$y\in U$, $f(y)\in V$ and $U\cap V= \emptyset$.
Since f is continuous we can find a Set $V'$ s.t. $f(V')\subset V$.
The set $W=V' \cap U$ is open and non empty, since $y\in W$.
Furthermore, we see: $$f(W)\cap W=\emptyset$$
Hence $G^c$ is open. 
A: Basic facts about nets: A function $f: X\to Y$ is continuous at $x \in X$ if and only if for every net $(x_\alpha)$ in $X$ converging to $x$ we have that $f(x_\alpha) \to f(x)$; and a set $A \subseteq X$ is closed if and only if for every convergent net $(x_\alpha)$ taking values in $A$ the limit lies in $A$.
Lemma 1. The graph of a continuous function $f: X\to Y$ is homeomorphic to $X$ as a subspace of $X\times Y$ via the projection map $\pi_1((x,y)) = x$.
Proof. We only need to verify that the inverse $x \mapsto (x,(f(x))$ is continuous. Let $(x_\alpha)$ be a net converging to $x$. Then $f(x_\alpha) \to f(x)$ by continuity of $f$ and by the properties of the product topology $(x_\alpha,f(x_\alpha)) \to (x,f(x))$ as desired.
Lemma 2. The graph of a continuous function into a Hausdorff space is closed.
Proof. Let $f: X\to Y$ be as in Lemma 1 with $Y$ Hausdorff.  Suppose we have a net $(x_\alpha,f(x_\alpha))$ converging to $(x,y) \in X \times Y$.  We are to show that $(x,y)$ is in the graph of $f$, i.e. $y = f(x)$.  Certainly we have $x_\alpha \to x$, so $f(x_\alpha) \to f(x)$ and since limits of nets in Hausdorff spaces are unique, we have $y=f(x)$ as desired.
Now we're ready for the proof that your set is closed. 
Proposition 3. Let $X$ be Hausdorff and $f,g: X \to X$ continuous. Then $E = \{x \in X\mathrel| f(x)=g(x)\}$ is closed in $X$.
Proof. By the lemmas above $F$ and $G$, the graphs of $f$ and $g$ respectively, are closed in $X\times X$ and $E = \pi_1(F \cap G)$ is the image of a closed set under a homeomorphism, so $E$ is closed in $X$.
That your set is closed follows from using the above with the identity map as $g$.
A: If $f(x) \neq x$, then since $X$ is Hausdorff, there exist open sets $V$ and $W$ such that $x \in V$, $f(x) \in W$ and $V \cap W = \emptyset$. Moreover, since $f$ is continuous, there exists a neighborhood $V'$ of $x$ such that $f(V') \subset W$. Let $V_x = V \cap V'$. This means that $f(y) \neq y$ for all $y \in V_x$. Proceed similarly to construct such neighborhoods $V_x$ for all $x \in X$ with $f(x) \neq x$ and let
$$V = \bigcup_{x \in X, x \neq f(x)}V_x$$
Then $V$ is open since each $V_x$ is, $f(x) \neq x$ for all $x \in V$ and if $f(x) \neq x$ then $x \in V_x \subset V$. This shows that
$$X \setminus \{x \in X: f(x) = x\} = V$$ is open, so that the set itself is closed.
If you have encountered the concept of a net, then since nets have unique limits in Hausdorff spaces, we can also argue as follows:
Let $v(\alpha)$ be a net in $F = \{x \in X: f(x) = x\}$. Then we have
$$\lim v(\alpha)  = \lim f(v(\alpha)) = f(\lim v(\alpha))$$
which shows that the limit of every net in $F$ lies in $F$. Hence $F$ is closed.
