If $[c,d]\subset f([a,b])$, $[a,b]\subset f([c,d])$, and $[a,b]\cap[c,d]=\emptyset$, show that $f$ has a periodic point with period $2$ Given a continuous function $f:\mathbb{R}\rightarrow\mathbb{R}$, let $[a,b]$ and $[c,d]$ be intervals in $\mathbb{R}$ such that
$[c,d]\subset f([a,b])$,   $[a,b]\subset f([c,d])$,   and $[a,b]\cap[c,d]=\emptyset$.
Show that $f$ has a periodic point with period $2$, i.e. $f^2(x)=x$ but $f(x)\neq x$.
My attempt: I think I'm most of the way done with the proof, I'm just having trouble showing that while $f^2(x)=x$ for some point, $f(x)\neq x$. Here it is:
By the Intermediate Value Theorem, we know $\forall v\in[a,b]\subset f([c,d])$, $\exists h \in [c,d]$ such that $f(h)=v$. Choose $v=a$, i.e. let $h$ be the element of $[c,d]$ such that $f(h)=a$.
We also have, by the Intermediate Value Theorem, that $\forall h \in [c,d]\subset f([a,b])$, $\exists g\in[a,b]$ such that $f(g) = h$. Thus, we have $f^2(g) = f(f(g))=f(h)=a$.
Suppose by way of contradiction that $f$ has no periodic point with period 2. Then, since $f(f(x))\neq x$, either $f(f(x))>x$ or $f(f(x))<x$ for all $x$. Suppose $f(f(x))>x$. Thus, if $x\in[a,b]$, $f(f(x))>a$. However, $g\in[a,b]$, but $f(f(g))=a$, a contradiction. Hence, there must exist a point $x$ such that $f(f(x))=x$.
How do I show there is a point such that $f^2(x)=x$ holds, but $f(x)=x$ does not?
 A: Hint: prove that you can find a closed interval $I\subseteq [a,b]$ such that $f(I)=[c,d]$ and then do the same thing you did with $I$.
Full solution:

 Let $C=f^{-1}(c)\cap[a,b]$ and $D=f^{-1}(d)\cap[a,b]$, pick a point $\gamma\in C$ and pick and used the closure of $D$ to take $\delta\in D$ such that there is no point in $D$ between $\gamma$ and $\delta$. Now use the closure of $C$ to find a point $\gamma'\in C$ inside the closed interval with enpoints $\delta$ and $\gamma$, such that there is no point in $C$ between $\delta$ and $\gamma'$. Let $I$ be the closed interval with endpoints $\gamma'$ and $\delta$. It is easy to prove by contradiction and the intermediate value theorem that $f(I)=[c,d]$. Since $f(f(I))\supseteq[a,b]$ we can take $x_1<x_2$ such that $f(f(x_1))$ and $f(f(x_2))$ are $a$ and $b$ in some order. Using the intermediate value theorem on the function $f(f(x))-x$ shows there is a value $x\in [x_1,x_2]$ such that $f(f(x))-x=0$. Since $f(x)\in [c,d]$ we have $f(x)\neq x$.

