Solution (source code)

= Solution
{c}

For a nonzero integer $k$, direct <integration> gives
$$
\int_{-\pi}^{\pi}\cos(kx)\,dx=0,\qquad
\int_{-\pi}^{\pi}\sin(kx)\,dx=0,
$$
whereas $\int_{-\pi}^{\pi}1\,dx=2\pi$. The <product-to-sum formulas>
$$
\begin{aligned}
2\cos(mx)\cos(nx)&=\cos((m-n)x)+\cos((m+n)x),\\
2\sin(mx)\sin(nx)&=\cos((m-n)x)-\cos((m+n)x),\\
2\sin(mx)\cos(nx)&=\sin((m+n)x)+\sin((m-n)x)
\end{aligned}
$$
therefore establish <Fourier orthogonality>: for positive integers $m,n$,
$$
\begin{aligned}
\int_{-\pi}^{\pi}\cos(mx)\cos(nx)\,dx&=\pi\delta_{mn},\\
\int_{-\pi}^{\pi}\sin(mx)\sin(nx)\,dx&=\pi\delta_{mn},\\
\int_{-\pi}^{\pi}\sin(mx)\cos(nx)\,dx&=0.
\end{aligned}
$$
Here $\delta_{mn}$ is the <Kronecker delta>. In particular the <constant function> is orthogonal to every nonconstant <sine> and <cosine> in this system. Integrating the given <Fourier series>, then multiplying it by $\cos(mx)$ or $\sin(mx)$ and integrating, isolates its <Fourier coefficients>. Using the permitted interchange of the <sum> and <integral> gives
$$
\boxed{a_0=\frac1\pi\int_{-\pi}^{\pi}f(x)\,dx},\qquad
\boxed{a_n=\frac1\pi\int_{-\pi}^{\pi}f(x)\cos(nx)\,dx},\qquad
\boxed{b_n=\frac1\pi\int_{-\pi}^{\pi}f(x)\sin(nx)\,dx}\quad(n\geq1).
$$
If $f$ is an <even function>, then $f(x)\sin(nx)$ is an <odd function>, while $f(x)\cos(nx)$ is an <even function>. Thus
$$
\boxed{b_n=0,\qquad a_n=\frac2\pi\int_0^\pi f(x)\cos(nx)\,dx\quad(n\geq0)}.
$$
The <Fourier series> consequently reduces to a <Fourier cosine series>.