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.