I am completely at a loss as how to proceed. I can't use differentiability here.The question is
Let $K$ be a compact subset of $\mathbb{R}$ and $f:K\rightarrow K$ be a function satisfying the condition $|f(x)-f(y)|=|x-y|\ \ \ \ \ \forall \ x,y\in K$ . Show that $f$ is surjective.
Please help..
Because $K$ is a compact subset of $\mathbb{R}$ it has a minimum, $a$, that every element of $K$ is not less than $a$, and a maximum too $b$. These are the only points in $k$ that their distance is the diameter of $K$, so $f$ maps the set $\{a,b\}$ into $\{a,b\}$. You can show (or you can use the fact, that there are only two kind of isometries of $\mathbb{R}$: translation and reflection on a point), if $f(a)=a$ then $f$ is the identity, and if $f(a)=b$ then $f(x)=a+b-x$.