Solution (source code)

= Solution

The homogeneous solutions $(C_1+C_2x)e^{-x}$ are not $2\pi$-periodic unless $C_1=C_2=0$, so there is a unique periodic solution. For a forcing term $a_n\cos(nx)$, a trial solution $A_n\cos(nx)+B_n\sin(nx)$ gives
$$
A_n=\frac{a_n(1-n^2)}{(1+n^2)^2},
\qquad
B_n=\frac{2na_n}{(1+n^2)^2}.
$$
Using the <Fourier series> from part (a), for which only odd $n$ occur and $a_n=-4/(\pi n^2)$, yields
$$
\boxed{
y(x)=\frac\pi2-\frac4\pi
\sum_{\substack{n\geq1\\n\text{ odd}}}
\frac{(1-n^2)\cos(nx)+2n\sin(nx)}{n^2(1+n^2)^2}.}
$$
The coefficients decay fast enough to differentiate the series twice term by term, verifying the equation and periodicity.