how do I write the function obtained from these two graphs? 

I would like to design a function that has the maximums of the first image as maximums and the minimums of the second.
in the first image f(x) is $$ \cos ^ {- 1} (\cos (x)) + x / 3 $$ while the second is $$ \cos ^ {- 1} (\cos (x)) + x / 6 $$ the lines are $$ x / 3 + \pi $$ (the blue one) and $$ x / 6 $$ the other.
 A: 
Let call $f(x)=\arccos(\cos(x))$.
Since the minimum of $f(x)$ is always $0$ then we have to go $f(x)+\dfrac x6$ to keep the minima at the right height.
Now the maxima are occuring at $x_M=(2n+1)\pi\iff n=\dfrac 12\left(\dfrac {x_M}\pi-1\right)$
And their value is $\quad\overbrace{f(x_M)}^{\pi}+\dfrac{x_M}3=\dfrac{(2n+4)\pi}3$
So we are going to multiply $f(x)$ by a coefficient such that the maxima coincide.
$C\times f(x_M)=\dfrac{(2n+4)\pi}3-\dfrac{(2n+1)\pi}6=\dfrac{(2n+7)\pi}6$
We can now rewrite $Cf(x)+\frac x6$ in term of $x$ by eliminating $n$
$$g(x)=\left(\frac x{6\pi}+1\right)\arccos(\cos(x))+\frac x6$$

Edit:
This is maybe a bit hidden, but the technique is very similar to what we do for scaling interval $[0,1]$ to interval $[min,max]$ with the formula below:
$$g(t)=min+(max-min)\,t\quad\text{for }0\le t\le 1$$
Here we have $\begin{cases} min=\frac x6\\ max=\frac x3+\pi\\ t=\frac 1\pi f(x)\end{cases}$
Giving $g(t)=\frac x6+(\frac x3+\pi-\frac x6)\frac 1\pi f(x)=(\frac x{6\pi}+1)f(x)+\frac x6$
