Continuous function whose range is its domain must intersect $f(x) = x$ Here is the question more formally
Suppose that $f:[a, b] \longrightarrow[a, b]$ is continuous. Prove that there is an $x \in[a, b]$ such that $f(x)=x$.
Seems like a very easy question, but I'm struggling with the formal proof. I think it suffices to show that there are points above y=x and points below y=x provided $f(a) \neq a$ and $f(b) \neq b$ (if either of these things are true we are of course done). Then since $f$ is continuous we know it has to intersect the line $y=x$ at some point giving $f(x)=x$.
If anyone could help me write this as a formal proof that would be greatly appreciated. Thanks in advance.
 A: Suppose $f(a) \neq a$ and $f(b) \neq b$ (if they are equal you are done). Then we have that $f(a) > a$ and $f(b) < b$. Consider the function $g(x) = f(x) - x$. $g$ is continuous and due to our assumptions we have $g(a) > 0$ and $g(b) < 0$. Then using the intermediate value theorem there is a point $x$ such that $0=g(x) = f(x) - x$.
A: This is essentially a special case of Brouwer's fixed-point theorem.
Hint: Since you've already reduced to the case $f(a)\neq a$ and $f(b)\neq b$, note that in particular $f(a)>a$ and $f(b)<b$. Now consider the auxiliary function $g:[a,b]\to[a,b]$ with $g(x)=f(x)-x$. What can you say about the sign of $g$ on $[a,b]$? Now apply the intermediate value theorem.
A: If $f : [a,b] \to [a,b]$ is a function then $x \mapsto f(x) - x$ is a function $[a, b] \to [a - b, b - a]$
At $x = a$, $f(x) - x \geq 0$, and at $x = b$, $f(x) - x \leq 0$.  So there must be a point in $[a,b]$ at which $f(x) - x = 0$ [This is the intermediate value theorem].
To prove the intermediate value theorem, we can repeatedly halve the length of the interval in consideration.  Let $m = (a + b)/2$.  On at least one of the intervals $[a,m]$, $[m,b]$, $f(x) - x$ has opposite signs at each endpoint; if we repeatedly have the interval in this way we get a sequence that converges to an actual solution to $f(x) - x$.
We can also prove it using topology.
A: you informal reasoning is the right one.
Consider the map
$$ g:\left [ a, b \right ] \to \left [a, b \right ], g(x) :=f(x) - x$$
$g(a) =f(a) - a \geq 0 ;
g(b)\leq 0$
Since $f$ is continuous the intermediate value theorem applies, to ensure the existence of $c\in \left [ a, b \right ]$ such that $g(c) =f(c) - c=0$
So $f(c) =c$.
