Comparison of Fourier series and Laplace transform solutions to mass-spring system with Dirac-comb excitation I'm trying to solve the differential equation
$$y''+y=\sum_{-\infty}^{\infty}\delta(x-n\pi)\qquad n \in \mathbb{Z}\tag{1}$$
with initial conditions $$y(0)=y'(0)=0\tag{2}$$
using both Laplace transform and Fourier series. I would like to see that the two methods give the same steady state time domain response. I know that the solution to this is the half-wave rectified sine, and I can get that using the Laplace transform. But I'm stuck when solving it using Fourier-series.
As far as I know, the Fourier-series of the Dirac-comb with period $\pi$ is
$$\sum_{-\infty}^{\infty}\delta(x-n\pi)=\dfrac{1}{\pi}+\dfrac{2}{\pi}\sum_{n=1}^\infty\, \cos(2nx).\tag{3}$$
I solved the ODE by separating this sum into $f_0(x)=\dfrac{1}{\pi}$ and then $f_n(x)=\dfrac{2}{\pi} \cos(2nx)$, found the sum of the particular integral and the homogeneous solution for those, put them into a sum and got
$$y(x)=\dfrac{1}{\pi}+\dfrac{2}{\pi}\sum_{n=1}^\infty \dfrac{1}{1-4n^2} \cos(2nx).\tag{4}$$
But the Fourier-series of the half wave rectified sine should be
$$y(x)=\dfrac{1}{\pi}+\mathbf{\dfrac{1}{2}}\mathbf{\sin(x)}+\dfrac{2}{\pi}\sum_{n=1}^\infty \dfrac{1}{1-4n^2} \cos(2nx).\tag{5}$$
so I'm missing the sine term from my answer and I just can't see where it comes into the game when I solve the ODE the way I did. Any help with this would be much appreciated as I've been unable to resolve this despite many attempts.
 A: OP is considering the ODE
$$ y^{\prime\prime}(x)+y~=~III_{\pi}(x)~\equiv~\delta(x-\pi\mathbb{Z})~\equiv~\frac{1}{\pi}\sum_{n\in 2\mathbb{Z}}e^{inx}~\equiv~\frac{1}{\pi}+\frac{2}{\pi}\sum_{n\in 2\mathbb{N}}\cos(nx)\tag{A}$$
for $2\pi$-periodic functions $y(x)=y(x+2\pi)$. Here $III$ is the Dirac comb/Shah function. The Fourier series $$y(x)~=~\sum_{n\in\mathbb{Z}}c_ne^{inx}\tag{B}$$
should solve
$$\forall n\in \mathbb{Z}:~~
(1-n^2)c_n~=~\frac{1}{\pi}\delta^n_{2\mathbb{Z}}, \tag{C}$$
i.e.
$$ c_n~=~\left\{\begin{array}{rl} 
-\frac{1}{\pi}\frac{1}{n^2-1}&\text{for }n\text{ even},\cr 
\text{undetermined}&\text{for }n~=~\pm 1, \cr
0&\text{otherwise}.\end{array}\right. \tag{D}$$
The first initial condition (IC) yields
$$0~=~y(0)~=~\frac{1}{\pi}+c_1+c_{-1}
-\frac{2}{\pi}\underbrace{\sum_{n\in 2\mathbb{N}}\frac{1}{n^2-1}}_{=\frac{1}{2}}~=~c_1+c_{-1}.\tag{E}$$
The Fourier series is not differentiable at $x\in\pi\mathbb{Z}$, so OP's other IC $y^{\prime}(0)=0$ does not make much sense. Instead let us evaluate
$$y(\pm\frac{\pi}{2})~=~\frac{1}{\pi} \pm i(c_1-c_{-1})
-\frac{2}{\pi} \underbrace{\sum_{n\in 2\mathbb{N}} \frac{(-1)^{n/2}}{n^2-1}}_{=\frac{2-\pi}{4}}~=~ \frac{1}{2} \pm i(c_1-c_{-1}).\tag{F}$$
The half wave rectified sine wave has $y(-\frac{\pi}{2})=0$, which leads to
$$ c_1~=~\frac{1}{4i}~=~-c_{-1},\tag{G}$$
which in turn leads to OP's last formula (5).
