All continuous $f$ such that $\sin(f(x)) = \sin(x)$ 
Question Find all continuous $f: \mathbb{R} \rightarrow \mathbb{R}$ such that $\sin(f(x)) = \sin(x)$ $\forall x \in \mathbb{R}$.

Here is my thinking for this problem:

Since $\sin(k\pi) = 0, \forall k \in \mathbb{Z}$ we require an $f$ which is an integer multiple of $\pi$ at integer multiples of $\pi$ and since $\sin$ is $2\pi$ periodic we require the 'translation' associated with periodicity to be an even multiple of $\pi$.
Because of continuity we require a linear solution and due to the fact that $\sin$ is odd, we require the coefficient of the $x$ term to be $1$.
Thus the only solutions take the form: $f(x) = x + 2m\pi, m \in \mathbb{Z}$.

My question is, have I missed any solutions? How might I know that these are the only ones?
 A: For each $x \in \Bbb R$ you have
$$
 \sin(f(x)) = \sin(x) \Longleftrightarrow
\begin{cases}
 f(x) = g_k(x) :=  x + 2k \pi \text{ for some } k \in \Bbb Z \\
 \text{or} \\
 f(x) = h_k(x) := -x + (2k+1) \pi \text{ for some } k \in \Bbb Z \\
\end{cases}
$$
Those two families of curves intersect exactly at 
the points $x_i = (i + \frac 12)\pi$, $i \in \Bbb Z$.
Now suppose that $x_0 \in I = (x_{i-1}, x_{i})$, and
$f(x_0) = g_k(x_0)$ for some $k$.  Then there is some $\varepsilon > 0$
such that $|g_l(x_0) - f(x_0)| > \varepsilon $ for all $l \ne k$
and $|h_l(x_0) - f(x_0)| > \varepsilon$ for all $l$.
$f$ is continuous, so there is a $\delta > 0$ such that
$|f(x) - f(x_0)| < \varepsilon$ for $x \in (x_0 - \delta, x_0 + \delta)$
and therefore $f(x) = g_k(x)$ in that interval.
This shows that the set $\{ x \in I \mid f(x) = g_k(x) \}$ is open.
Since it is closed as well and intervals are connected, we must
have $f(x) = g_k(x)$ for all $x \in I$.
We have therefore shown: On each interval $(x_{i-1}, x_{i})$,
$f$ is equal to some $g_k$ or some $h_k$.
In other words, $f$ is piecewise linear with
 $f(0) = k \pi$, $f'(0) = (-1)^k$ for some $k \in \Bbb Z$ and slope $+1$ or $-1$ on each
interval $[(i - \frac 12)\pi, (i + \frac 12)\pi]$.
A: I used product and sum formulas for $\sin(x)$:
$$ \sin p + \sin q = 2\sin \left(\frac{p+q}{2}\right)\cos \left(\frac{p-q}{2}\right) $$
Which using in the problem: 
$$ \sin f(x) = \sin x  \Leftrightarrow \sin f(x) + \sin (-x) =0 \Leftrightarrow $$
$$ 2\sin\left(\frac{f(x)-x}{2}\right)\cos\left(\frac{f(x)+x}{2}\right) = 0$$
Thus, let $k$ be an integer:
$$ \sin\left(\frac{f(x)-x}{2}\right) =0 \Leftrightarrow \frac{f(x)-x}{2} = k\pi \Leftrightarrow f(x) = x + 2k\pi   $$
Or
$$ \cos\left(\frac{f(x)+x}{2}\right) =0 \Leftrightarrow \frac{f(x)+x}{2} = \frac{\pi}{2} + k\pi \Leftrightarrow f(x) = -x + \pi + 2k\pi  $$
However, $f$ can assume any of the two forms above depending on the interval. To satisfy the continuity, we require that (for $k$ and $q$ integers):
$$ x + 2k\pi = -x +\pi + 2q\pi \implies x = \left(q-k+ \frac{1}{2} \right)\pi = \left(j + \frac{1}{2} \right)\pi $$
Which will be the points in which $f$ can "changes" its form. Then, 
$$f(x) = \begin{cases} x + 2k\pi, x \in \left[(j + \frac{1}{2} )\pi, (j +1 + \frac{1}{2} )\pi\right]  \\
-x + \pi + 2k\pi,  x \in [(i + \frac{1}{2} )\pi, (i +1 + \frac{1}{2} )\pi] \end{cases} $$
For some $k$ integer. Besides, $i \in A$ and $j \in B$, such that $A\bigcap B = \emptyset$ and $A \bigcup B = \mathbb{Z}$.
A: The equation implies
$$f(x)=x+2k\pi\lor f(x)=\pi-x+2k\pi.$$
The locus of these expressions is a square grid slanted by $45°$.
You can follow any left-to-right trajectory in this lattice, taking one of two directions at each intersection.
