I want to find the Green's function defined by the following equation:
$$\left(\frac{d^2}{dt^2} + \omega^2 - i\epsilon \right)G(t,t') = \delta(t-t').$$
For this I performed the Fourier transform of both sides, using identities for the Fourier transform of a second derivative to get the algebraic equation:
$$\left(-u^2 + \omega^2 -i\epsilon \right) \tilde{G}(u,t') = \frac{1}{\sqrt{2\pi}} e^{-it'u}.$$
We can solve this algebraically and perform the inverse Fourier transform:
\begin{align} G(t,t') &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}} \frac{e^{-it'u}}{-u^2 + \omega^2 -i\epsilon} \: e^{itu}\,du \\ &= \frac{1}{2\pi}\int_{-\infty}^\infty \frac{e^{i(t-t')u}\,du}{-u^2 + \omega^2 -i\epsilon} \end{align}
I can solve this by identifying the poles and using the residue theorem, but it's not clear to me how to do this. Can someone explain? How do I identify the poles and what contour should I choose to get the result?
Let $G(t,t')$ be represented by the integral
$$\begin{align} G(t,t') &= \frac1{2\pi}\int_{-\infty}^\infty \frac{e^{i(t-t')u}}{-u^2 + \omega^2 -i\epsilon}\,du\tag1 \end{align}$$
We proceed to use the residue theorem to evaluate the integral in $(1)$.
The function $\displaystyle f(z)=\frac{e^{i(t-t')z}}{-z^2 + \omega^2 -i\epsilon}$ has poles at $\displaystyle z=\pm \sqrt{\omega^2-i\epsilon}$. We need to identify the location of these poles.
We assume that $\epsilon$ is chosen such that $2\text{Re}(\omega)\text{Im}(\omega)-\epsilon<0$, and that $-\pi<\arg(\omega^2-i\epsilon)<0$.
Hence, the pole at $\sqrt{\omega^2-i\epsilon}$ is in the lower-half plane while the pole at $-\sqrt{\omega^2-i\epsilon}$ is in the upper-half plane.
Let $C^{+}$ ($C^-$) be the closed contour in the complex plane comprised of $(i)$ the real line segment from $-R$ to $R$ and $(ii)$ the semicircular arc in the upper-half plane (lower-half plane), centered at the origin, from $R$ to $-R$.
Using the residue theorem, we have for $R>\left|\sqrt{\omega^2-i\epsilon}\,\right|$
$$\begin{align} \oint_{C^+} \frac{e^{i(t-t')z}}{-z^2 + \omega^2 -i\epsilon}\,dz&=\int_{-R}^R \,\,\frac{e^{i(t-t')u}}{-u^2 + \omega^2 -i\epsilon}\,du+\int_0^\pi \frac{e^{i(t-t')Re^{i\phi}}}{-R^2e^{i2\phi}+\omega^2-i\epsilon}\,iRe^{i\phi}\,d\phi\tag2\\\\ &=2\pi i\text{Res}\left(\frac{e^{i(t-t')z}}{-z^2 + \omega^2 -i\epsilon},z=-\sqrt{\omega^2-i\epsilon}\right)\\\\ &=2\pi\left( \frac i2 \,\frac{e^{-i\sqrt{\omega^2-i\epsilon}\,(t-t')}}{\sqrt{\omega^2-i\epsilon}}\right) \end{align}$$
As $R\to \infty$, the second integral on the right-hand side of $(2)$ vanishes for $t>t'$ and we find
$$G(t,t')=\frac i2 \,\frac{e^{-i\sqrt{\omega^2-i\epsilon}\,(t-t')}}{\sqrt{\omega^2-i\epsilon}} \tag3$$
Using the residue theorem, we have for $R>\left|\sqrt{\omega^2-i\epsilon}\,\right|$
$$\begin{align} \oint_{C^-} \frac{e^{i(t-t')z}}{-z^2 + \omega^2 -i\epsilon}\,dz&=\int_{-R}^R \,\,\frac{e^{i(t-t')u}}{-u^2 + \omega^2 -i\epsilon}\,du+\int_{2\pi}^\pi \frac{e^{i(t-t')Re^{i\phi}}}{-R^2e^{i2\phi}+\omega^2-i\epsilon}\,iRe^{i\phi}\,d\phi\tag2\\\\ &=-2\pi i\text{Res}\left(\frac{e^{i(t-t')z}}{-z^2 + \omega^2 -i\epsilon},z=+\sqrt{\omega^2-i\epsilon}\right)\\\\ &=2\pi\left( \frac i2 \,\frac{e^{i\sqrt{\omega^2-i\epsilon}\,(t-t')}}{\sqrt{\omega^2-i\epsilon}}\right) \end{align}$$
As $R\to \infty$, the second integral on the right-hand side of $(2)$ vanishes for $t<t'$ and we find
$$G(t,t')=\frac i2 \,\frac{e^{i\sqrt{\omega^2-i\epsilon}\,(t-t')}}{\sqrt{\omega^2-i\epsilon}} \tag4$$
Putting $(3)$ and $(4)$ together yields
$$G(t,t')=\frac i2 \,\frac{e^{-i\sqrt{\omega^2-i\epsilon}\,|t-t'|}}{\sqrt{\omega^2-i\epsilon}} $$
Taking the limit as $\epsilon\to 0$, we obtain
$$g(t,t')=\frac i2 \frac{e^{-i\omega |t-t'|}}{\omega}$$
where $g(t,t')$ is the solution to the ODE
$$\frac{d^2g(t,t')}{dt^2}+\omega^2 g(t,t')=\delta(t-t')$$