Fourier series for function $f(x) = \arccos (\cos x), \ \ x\in ]-\pi, \pi[$ $f(x) = \arccos (\cos x), \ \ x\in [-\pi; \pi]$
Here is what I did:
$$a_0 = \frac{1}{2\pi} \int^{\pi}_{-\pi} \arccos (\cos x)dx = \frac{\pi}{2} \\ a_n = \frac{1}{\pi} \int^{\pi}_{-\pi} \arccos (\cos x) \cos \left(\frac{\pi n x}{\pi} \right)dx = \frac{1}{\pi}\left(\left(  x\cos(n x)\right|^{\pi}_{-\pi} - \frac{1}{n}\int^{\pi}_{-\pi} \sin nx \ dx\right) = -2\pi \\ b_n = \frac{1}{\pi} \int^{\pi}_{-\pi} \arccos (\cos x) \sin \left(\frac{\pi n x}{\pi} \right)dx = \frac{1}{\pi} \left(x \sin nx |^{\pi}_{-\pi} + \frac{1}{n} \int^{\pi}_{-\pi}  \cos nx dx \right)= 0 \\ f(x) = \frac{\pi}{4}-2\pi \sum^{\infty}_{n=1} \cos\left(\frac{2\pi kx }{2\pi}\right)$$
Is it correct?
 A: I am a bit puzzled as to why you write $f(x) = \arccos(\cos x))$.  This is identical to $f(x) = \lvert x \rvert$ which seems to me a simpler form, and I think is the form you used to evaluate the integrals.
Then the calculation for $a_0 = \pi / 2$ is fine.   $b_n = 0$ because $f(x) \sin nx$ is an odd function.  For $a_n$ you can say,
\begin{align}
 a_n &= \frac{1}{\pi} \int_{-\pi}^\pi \lvert x\rvert \cos nx ~ dx \\
&=\frac{2}{\pi}\int_0^\pi x \cos nx ~ dx \\
&\hspace{1cm} \small \text{(because the integrand is an even function)}\\
&= \frac{2}{\pi} \Bigg\{\Big[ \frac{1}{n}x\sin nx \Big]_0^\pi - \int_0^\pi \frac{1}{n}\sin nx ~ dx\Bigg\} \\
&= \frac{2}{\pi}\Big[ \frac{1}{n^2} \cos nx \Big]_0^\pi \\
&= -\frac{2}{\pi n^2}\Big( 1 -(-1)^n \Big)
\end{align} 
That means by my reckoning your calculation of $a_n$ is incorrect.  It should be $a_n = 0$ for even $n$ and $-\dfrac{4}{\pi n^2}$ for odd $n$.  Thus 
$$ f(x) = \frac{\pi}{2} - \frac{4}{\pi} \Bigg( \cos x+ \frac{1}{3^2}\cos 3x + \frac{1}{5^2}\cos 5x + \cdots \Bigg)$$

Incidentally, you can use this Fourier series to solve the Basel Problem, evaluate $\displaystyle \zeta (2) = S = \sum_{n\geqslant 1} \frac{1}{n^2}$. 
To do so use pointwise convergence for $f(x)$ when $x=0$ (it is continuous and piecewise smooth).  That gives a formula for the sum of odd terms in $S$.  The even terms in $S$ sum simply to $\frac{1}{4} S$ and the result, $\frac{\pi^2}{6}, $ follows with a little manipulation.
