Let $f:X\to X $ be continuous. Show that if $X=[0,1] $, $f $ has a fixed point(i.e. there exists $x$ such that $f (x)=x$). What happens if $X $ equals $[0,1) $ or $(0,1) $?
First part of the question is an immediate consequence of intermediate value theorem(for a proof, see here). I think $f (x)=x^2$ is a counterexample when $X=(0,1) $, since $x^2\lt x $ for all $x\in (0,1) $. But to be honest, I don't understand what causes breakdown of the fixed point theorem on $(0,1)$, since IVT only requires connectedness of domain. Is this related to the non-compactness of $(0,1)$?
Also I can't think of any counterexample for the case $X=[0,1)$(assuming fixed point is somehow related to compactness).
Any help is appreciated.
Thank you.


