According to p. 36 of Stein and Shakarchi's Fourier Analysis, the Fourier series is $\frac{\pi^2}{12} + \sum_{n=1}^{\infty} \frac {\cos{n\theta}}{n^2}$.
But to calculate the Fourier coefficients, I computed $\int_{-\pi}^{\pi}\frac{(\pi-\theta)^2}{4}e^{-in\theta}d\theta = \frac {1} {4} \Bigg[\frac{4\pi^2e^{in\pi}}{in}-\frac{2}{in}\int_{-\pi}^{\pi}e^{-in\theta}(\pi-\theta)d\theta\Bigg]=\frac {1} {4}\Bigg[\frac{4\pi^2e^{in\pi}}{in}-\frac{4\pi{e^{in\pi}}+2e^{-in\pi}-2e^{in\pi}}{n^2}\Bigg]=\frac{\pi^2ne^{in\pi}+\sin{n\pi}}{in^2}$
This means the Fourier series is $\sum_{n=-\infty}^{\infty}\frac{\pi^2ne^{in\pi}+\sin{n\pi}}{in^2}e^{in\theta}=\sum_{n=-\infty}^{\infty}\frac{\pi^2e^{in(\pi+\theta)}}{in}+\frac{e^{in(\theta-\pi)}}{2n^2}$, but I can't seem to get this to equal that simple thing from the book.
Can anyone help?
The Fourier coefficients can be calculated as follows.
If $n=0$ then \begin{align} \hat{f}(0) &= \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi-\theta)^2}{4}d\theta\\ &=\frac{1}{8\pi}\int_{-\pi}^{\pi}u^2du\\ &=\frac{1}{8\pi}\cdot\frac{2\pi^3}{3}\\ &=\frac{\pi^2}{12} \end{align}
If $n\neq0$ then \begin{align} \hat{f}(n) &= \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi-\theta)^2}{4}e^{-in\theta}d\theta\\ &=\frac{e^{-in\pi}}{8\pi}\int_{-\pi}^{\pi}u^2e^{-inu}du\\ &=\frac{e^{-in\pi}}{8\pi}\left[\frac{u^2e^{-inu}}{-in}- \frac{2ue^{-inu}}{(-in)^2}+\frac{2e^{-inu}}{(-in)^3}\right]_{u=-\pi}^{u=\pi}\\ &=\frac{1}{8\pi}\left[\frac{\pi^2}{in}(\underbrace{1-e^{-2\pi in}}_{0})+\frac{2\pi}{n^2}(\underbrace{1+e^{-2\pi in}}_{2})-\frac{2}{in^3}(\underbrace{1-e^{-2\pi in}}_{0})\right]\\ &=\frac{1}{2n^2} \end{align}
Hence the Fourier series of $f$ is $$ \frac{\pi^2}{12} + \sum_{\substack{n\in\mathbb{Z}\\n\neq0}}\frac{1}{2n^2}(\cos n\theta+i\sin n\theta) = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac {\cos{n\theta}}{n^2} $$
Alternatively, the Fourier series of $f$ can be given in the following form: $$ \frac{1}{2\pi}\int_0^{2\pi}f(\theta)\,d\theta+\sum_{n=1}^{\infty}a_n\cos(n\theta)+\sum_{n=1}^{\infty}b_n\sin(n\theta) $$ where $$ a_n:=\frac{1}{\pi}\int_0^{2\pi}f(\theta)\cos(n\theta)\,d\theta\quad(n\geq1)\\ b_n:=\frac{1}{\pi}\int_0^{2\pi}f(\theta)\sin(n\theta)\,d\theta\quad(n\geq1) $$ In this case we note that $f$ is even hence $b_n=0$ for all $n$. Similar computations as those above lead directly to $$ \frac{\pi^2}{12} + \sum_{n=1}^{\infty} \frac {\cos{n\theta}}{n^2} $$