# How to show that a continuous function has a fixed point

Suppose that $a < b$ and $f: [a,b] \to\mathbb{R}$ is a continuous function such that the range of $f$ contains $[a,b]$. Prove that $f$ has a fixed point.

Since $f$ is continuous on a closed and bounded interval it attains its maximum and minimum. So there exist $m$ and $M$ such that $f(m)<a$ and $f(M)>b$. Now take the function $g(x)=f(x)-x$; $g(m)<0$ and $g(M)>0$. By intermediate value property of continuous functions the result follows.
Let $[c,d]=\text{Range of} f\subset [a,b]$ and consider the function $g(x)=f(x)-x.$
Note that $$a\le c\le f(a),f(b)\le d \le b$$ and therefore $$f(a)-a=\color{Green}{g(a) \ge0}$$ and $$f(b)-b\color{Green}{=g(b)\le0}.$$ Since $g$ is continuous, by the intermediate value theorem...........
Firstly note that $f(x)-x \neq 0$. Now if $f(b)=b$ then $b$ is a fixed point. So assume that $f(y_1)=b$ then $f(y_1)-y_1 >0$. Simlarly say $f(y_2)=a$ then $f(y_2)-y_2 >0$ this implies that the image of $[a,b]$ is a disconnected set.