Part (b):
The function is even, so $b_n = 0$.
\begin{equation*}
a_0 = \frac{2}{\pi} \int_{0}^{\pi} \sin x dx\\
= \frac{4}{\pi}.
\end{equation*}
\begin{equation*}
a_n = \frac{2}{\pi} \int_{0}^{\pi} \sin x \cos nx dx
\end{equation*}
Using $2\sin a \cos b = \sin(a+b) + \sin(a-b)$,
\begin{equation*}
=\frac{1}{\pi} \int_{0}^{\pi} \sin ((n+1)x) + \sin ((1-n)x) dx\\
\end{equation*}
Notice that for $n = 1$, the solution is $0$.
\begin{equation*}
=-\frac{1}{\pi}\left[\frac{\cos((n+1)x)}{n+1} - \frac{\cos((n-1)x)}{n-1} \right]_{0}^{\pi}\\
=-\frac{1}{\pi}\left[\frac{(-1)^{n+1}}{n+1} - \frac{1}{n+1} - \frac{(-1)^{n+1}}{n-1} + \frac{1}{n-1} \right]_{0}^{\pi}\\
=\frac{1}{\pi}\big((-1)^n + 1 \big) \big(\frac{1}{n+1} + \frac{1}{n-1} \big)\\
=\frac{-2}{\pi} \big((-1)^n + 1 \big) \big( \frac{1}{n^2 - 1} \big).\\
\end{equation*}
Let $n=2k$. Thus, for $n>1$,
\begin{equation*}
|\sin x| = \frac{2}{\pi} -\frac{4}{\pi} \sum_{k=1}^{\infty} \frac{1}{(2k)^2 - 1}\cos (2kx).
\end{equation*}
Part (a):
Again, the function $|\cos x|$ is even, so $b_n = 0$.
We proceed as above:
\begin{equation*}
a_0 = \frac{2}{\pi} \int_{0}^{\pi} |\cos x| dx \\
= \frac{2}{\pi} \int_{0}^{\frac{\pi}{2}} \cos x dx - \frac{2}{\pi} \int_{\frac{\pi}{2}}^{\pi} \cos x dx\\
= \frac{4}{\pi}\\
\end{equation*}
\begin{equation*}
a_n = \frac{2}{\pi} \int_{0}^{\pi} |\cos x|\cos{nx} dx \\
= \frac{2}{\pi} \int_{0}^{\frac{\pi}{2}} \cos x \cos{nx} dx - \frac{2}{\pi} \int_{\frac{\pi}{2}}^{\pi} \cos x \cos{nx} dx\\
= \frac{2}{\pi}\left(-2\frac{\cos{\frac{\pi n}{2}}}{n^2 - 1}\right)\\
\end{equation*}
Therefore,
\begin{equation*}
|\cos x| = \frac{2}{\pi} - \frac{4}{\pi}\sum_{n=1}^{\infty} \frac{\cos{\frac{\pi n}{2}}}{n^2 - 1} \cos{nx}.
\end{equation*}
Both functions are continuous, so the Fourier series will converge to each function at every point.