<s>[INST] Fourier Series for $|\cos(x)|$ I'm having trouble figuring out the Fourier series of $|\cos(x)|$ from $-\pi$ to $\pi$.
I understand its an even function, so all the $b_n$s are $0$
$$a_0 = \frac 2 \pi \int_0^\pi |\cos(x)|\,dx = 0$$
$$a_n = \frac 2 \pi \int _0^\pi  |\cos(x)| \cos(nx) \, dx = \frac 2 \pi \int_0^\pi \cos^2(x)\,dx.$$
since for all $j,k$ not equal the integral is zero.
so only $a_1$ remains. is this correct? 
How would I evaluate $\sum_{n=1}^\infty (-1)^{n-1} /(4n^2 - 1)\  {}$?
 [/INST] You must breakup the integral into three intervals:
$\left[-\pi \cdots -\frac{\pi}{2} \right]$,
$\left[-\frac{\pi}{2} \cdots \frac{\pi}{2} \right]$, and 
$\left[\frac{\pi}{2} \cdots \pi \right]$
Which represent the regions where the sign of $\cos x$ changes. 
\begin{equation*}
\left\vert \cos x\right\vert =
\begin{cases}
-\cos x & -\pi \le x \le -\frac{\pi}{2} \\
 \cos x & \frac{\pi}{2} \le x \le \frac{\pi}{2} \\
-\cos x & \frac{\pi}{2} \le x \le \pi
\end{cases}
\end{equation*}
When I plugged the integral over the three regions into Maple I got:
\begin{align*}
a_n &=\frac{1}{2 \pi} \int\limits_{t=-\pi}^{\pi} \left\vert \cos(t) \right\vert \cos(nt) \\
&= \frac{1}{2 \pi} \int\limits_{t=-\pi}^{-\frac{\pi}{2}}(-\cos(t)) \cos(nt) \\
&+ \frac{1}{2 \pi} \int\limits_{t=-\frac{\pi}{2}}^{\frac{\pi}{2}}\cos(t) \cos(nt) \\
&+ \frac{1}{2 \pi} \int\limits_{t=\frac{\pi}{2}}^{\pi}(-\cos(t)) \cos(nt) \\
&=-4{\frac {\cos \left( \frac{1}{2} \pi  n \right) }{ \left( -1+{n}^{2} \right) \pi }}
\end{align*}
Since, $\left\vert \cos t \right\vert$ is even you could break the integral in two and find $a_n$ as in Julián's answer.
\begin{align*}
a_n &=\frac{2}{\pi} \int\limits_{t=0}^{\pi} \left\vert \cos(t) \right\vert \cos(nt) \\
&= \frac{2}{\pi} \int\limits_{t=0}^{\frac{\pi}{2}}\cos(t) \cos(nt) \\
&+ \frac{2}{\pi} \int\limits_{t=\frac{\pi}{2}}^{\pi}(-\cos(t)) \cos(nt) \\
&=-4{\frac {\cos \left( \frac{1}{2} \pi  n \right) }{ \left( -1+{n}^{2} \right) \pi }}
\end{align*}
for $1 < n$ and $a_0 = \frac{2}{\pi}$
My answer is simply an amplification of Julián's answer, but, I hope it helps.
</s>