While going through the proof of Banach's fixed point theorem, this question came to my mind. I have no clue if it is true or not. I was unable to prove or disprove myself and didn't get any reference after googling too. So here it goes. Any proof or disproof is much appreciated.
Let $f : [a,b] \to \mathbb{R}$ is a contraction mapping such that both $f(a)$ and $f(b)$ belong to $[a,b]$. Prove or disprove that $f$ maps $[a,b]$ into itself, i.e. $f([a,b]) \subseteq [a,b]$.
$f([a,b])\subseteq [a,b]$ does not need to hold.
For example, let $0<a<b,$ and define $$f(x)=\left\{\begin{array}{c}b+\frac 12(x-a),{\rm if~}a\leq x\leq \frac{a+b}2\\ b+\frac 12(\frac{a+b}2-a)-\frac 12(x-\frac{a+b}2),{\rm if ~}\frac {a+b}2\leq x\leq b.\end{array}\right.$$ Then $f(x)$ is a contraction and $f(a)=f(b)=b,$ but $f(\frac{a+b}2)>b.$