TITLE: hausdorff space and continuous function
QUESTION [6 upvotes]: 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.

REPLY [5 votes]: 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.