I'm having some trouble solving an ODE using the Green's function method. The problem I'm working in is the simple harmonic oscillator equation $$ L[y(t)]=f(t)$$ $$ L = \frac{d^2}{dt^2}+\omega^2$$ $$y(0)=1,y'(0)=0$$ Now I'll construct my Green's function. I have two linear independent solutions for the homogeneous version ( $f(t)=0$ ) of my problem: $y_1(t)=\cos(\omega t)$ and $y_2(t)=\sin(\omega t)$.
I know that the Green's function satisfies $L[G(t,\xi)]=\delta(t-\xi)$. For $t\neq\xi$ we have that $L[G(t,\xi)]=0$.
My function should be $$ G(t,\xi)=\left\{\begin{matrix} A\cos(\omega t) + B \sin(\omega t),& t<\xi \\ C\cos(\omega t) + D \sin(\omega t),& \xi<t \end{matrix}\right. $$
Applying the initial conditions $G(0,\xi)=1,G'(0,\xi)=0$ we find that $A=1$ and $B=0$. $$ G(t,\xi)=\left\{\begin{matrix} \cos(\omega t),& t<\xi \\ C\cos(\omega t) + D \sin(\omega t),& \xi<t \end{matrix}\right. $$
Using the continuity of the function at $t=\xi$ and the discontinuity of the derivative at $t=\xi$ we should have $$C \cos(\omega \xi)+D \sin(\omega \xi)-\cos(\omega \xi)=0 \\ -C\sin(\omega \xi)+D\cos(\omega \xi)+\sin(\omega\xi)=\frac{1}{\omega}$$
Solving this system we find that $C=1-\dfrac{\sin(\omega\xi)}{\omega}, \;D=\dfrac{\cos(\omega\xi)}{\omega}$.
Finally, the Green's function should be $$ G(t,\xi)=\left\{\begin{matrix} \cos(\omega t),& t<\xi \\ \dfrac{1}{\omega}\left[\omega-\sin(\omega\xi)\right]\cos(\omega t) + \dfrac{1}{\omega}\cos(\omega\xi)\sin(\omega t),& \xi<t \end{matrix}\right. $$
Now I should be able to find a solution for the ODE using the Green's function because $y(t)=\int_0^\infty f(\xi)\,G(t,\xi)\,d\xi$
I'm having trouble with this last step. Some of the functions I should try are $f(t)=e^{-t}$ and $f(t)=\cos(t)$. For the case where the "forcing function" is a cosine, the integral does not converge. I tried the following \begin{align*} y(t) &=\int_0^\infty f(\xi)\,G(t,\xi)\,d\xi\\ &=\int_0^t \cos(\xi)\left[ \frac{1}{\omega}\left[\omega-\sin(\omega\xi)\right]\cos(\omega t) + \frac{1}{\omega}\cos(\omega\xi)\sin(\omega t)\right]d\xi\\ &\quad+\int_t^\infty \cos(\xi)\,\cos(\omega t)\,d\xi \end{align*}
The first integral is not hard to compute and it give us an answer. But the second integral does not converge. I thought that the Green's function should give us a solution for this problem because this ODE has a solution that we can easily get with other methods.
So, my question is: what is going wrong with my construction? Is my Green's function wrong or am I taking the integral in the wrong way with the wrong limits? Thanks in advance!
The idea is to write $$ y(t)=y_0(t)+\int_0^tG(t,ξ)f(ξ)\,dξ, $$ where
Thus $$ y_0(t)=\cos(ωt),\\ G_ξ(t)=\Theta(t-ξ)\frac{\sin(ω(t-ξ))}{ω}, $$ where $Θ$ is the Heaviside or unit-jump/ramp function.