Let $f:X\to X $ be continuous. Does $f $ have a fixed point when $X=[0,1)$ or $X=(0,1) $?
Solution 1:
The IVT is not the only ingredient here. The way the theorem works is by setting up this square:
where the line in the middle is $y = x$. A function from $[0, 1]$ to $[0, 1]$ that intersects this line will have a fixed point at the point of intersection.
The IVT kicks in when we have a function whose graph enters the top triangle and the bottom triangle at various points, e.g.
The fact is, by the IVT, the function has to cut the line somewhere, i.e. it must have a fixed point.
But, this makes an assumption! The function may only exist in one triangle or the other, but not in both. That is, why can we not have $f(x) > x$ for all $x$ or $f(x) < x$ for all $x$?
The picture above illustrates it. Due to the function having a full domain of $[0, 1]$, there's a squeeze happening. The green function is about as close as we can have to a function satisfying $f(x) > x$. Similarly, the red function attempts to have $f(x) < x$. But, both are pinched towards the diagonal line. The green function must have $f(1) = 1$, and the red function must have $f(0) = 0$.
This illustrates the necessity of defining all the way to $0$ and $1$. Removing either of these points means that the functions are not squeezed to a fixed point (we'd only ensure that $f(x)$ and $x$ become arbitrarily close).
Solution 2:
The compactness is not really used in proving the FPP for $[0,1]$. We do use both endpoints (we use $f(0) >0$ and $f(1) <1$ when $f$ has no fixpoint in $\{0,1\}$ which then triggers the IVT). You could say that compactness forces these endpoints to be in your set.. (compact and connected in $\mathbb{R}$ means homeomorphic to $[0,1]$).
So to find a counterexample, look for functions on $[0,1]$ with a unique fixed point that is either $0$ or $1$. Then removing that point makes a counterexample. $f(x) = \frac{1}{2}x$ is an easy one for $X=(0,1]$ e.g.
Solution 3:
$$f:[0,1) \to [0,1), x \mapsto \frac x2 + \frac12$$
$$f:(0,1) \to (0,1), x \mapsto \frac x2 + \frac12$$
If $x = f(x)$, then $x = 1$ which is not in the domain of $f$.
$$f:(0,1] \to (0,1], x \mapsto \frac x2$$ also has no fixed points.