Question about continuous function. 
Question. Which of the following statements are true:
  
  
*
  
*If $f \in C[0,2]$ is such that $f(0)=f(2)$, then there exist $x_1$ and $x_2$ in $[0,2]$ such that $x_1-x_2=1$ and $f(x_1)=f(x_2)$.
  
*Let $f$ and $g$ be continuous real valued functions on $\mathbb{R}$ such that for all $x\in \mathbb{R}$, we have $f(g(x))=g(f(x))$. If there exists $x_0 \in \mathbb{R}$ such that $f(f(x_0))=g(g(x_0))$, then there exists $x_1\in \mathbb{R}$ such that $f(x_1)=g(x_1)$.

My Attempts.


*

*Here $f(0)=f(2)$. If $f(1) \ne f(0)$, say, $f(1)>f(0)$ then for any $k$ such that $f(0)<k<f(1)$ there exists a $x_1,x_2$ with $0<x_1<1$ and $1<x_2<2$ such that $f(x_1)=f(x_2)=k$ (by Intermediate Value Property of $f$). But how can I prove $x_2-x_1=1$? Please help.

*I don't have any guess here to start... 
 A: For 1) you can consider :
$$ g(x) = f(x+1) - f(x)$$ 
$g$ is continuous and verify :
$$ g(1) = f(2) - f(1) = f(0) - f(1) = -(f(1) - f(0)) =-g(0)$$
Then $g$ sign is changing and by the intermediate value theorem you can such $x_1$ and $x_2$. Using the same idea for 2) you'll have the result.
For 2), pose $h(x) = f(x) - g(x)$. Using the hypothesis : 
\begin{align*}
h(f(x_0)) &= f(f(x_0)) - g(f(x_0)) \\
&=g(g(x_0)) - f(g(x_0)) \\
&= -h(g(x_0))
\end{align*}
So it means that $h$ sign is changing and since $h$ is continuous, the intermediate value theorem gives you that you can find $x_1$ such as $h(x_1) = f(x_1) - g(x_1) =0$.
A: As always in this kind of problems, to use intermediate values theorem, you have to convert your "equation" in the form $g(x)=0$. Here you have $f(x+1)=f(x)$, so let $g:x\mapsto f(x+1)-f(x)$ be defined on interval $[0,1]$.
You have $g(0)=f(1)-f(0)$, $g(1)=f(2)-f(1)$, so $g(0)+g(1)=f(2)-f(0)=0$.
Either $g(0)$ and $g(1)$ are both $0$ (in which case you have found TWO solutions to your problem), or they are non null opposite. As $g$ is continuous, you can apply IVT to $g$ to prove existence of a solution.
A note : with a little bit of work, you can generalize the result : for every fraction $\frac2n$ of the complete interval, you can find two points distant of this fraction where $f$ takes the same value.
For example, if you run $10$ miles in an hour, there is a quarter of an hour where you actually ran $2.5$ miles.
