How do I solve $\frac{1}{2\pi}\int_{-\infty}^\infty \frac{e^{i(t-t')u}\,du}{-u^2 + \omega^2 -i\epsilon}$ to find Green's function? 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?
 A: 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')$$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
\mrm{G}\pars{t,t'} & \equiv
{1 \over 2\pi}\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over
-u^{2} + \omega^{2} - \ic\epsilon}\,\dd u =
-\,{1 \over 2\pi}\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over
u^{2} - \omega^{2} + \ic\epsilon}\,\dd u
\\[5mm] & =
-\,{1 \over 2\pi}\,\mrm{P.V.}
\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over u^{2} - \omega^{2}}
\,\dd u -
{1 \over 2\pi}
\int_{-\infty}^{\infty}\expo{\ic\pars{t - t'}u}
\bracks{-\ic\pi\,\delta\pars{u^{2} - \omega^{2}}}\,\dd u
\\[1cm] & =
-\,{1 \over 4\pi\omega}\,\mrm{P.V.}\bracks{
\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over u - \omega}\,\dd u -
\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over u + \omega}\,\dd u}
\\[2mm] &
+ {\ic \over 2}\int_{-\infty}^{\infty}\expo{\ic\pars{t - t'}u}
\bracks{{\delta\pars{u - \omega} \over 2\verts{\omega}} +
{\delta\pars{u + \omega} \over 2\verts{\omega}}}\,\dd u
\\[1cm] & =
-\,{1 \over 4\pi\omega}\,\mrm{P.V.}\bracks{
\expo{\ic\omega\pars{t - t'}}\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over u}\,\dd u -
\expo{-\ic\omega\pars{t - t'}}\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over u}\,\dd u}
\\[2mm] &
+ {\ic \over 4\verts{\omega}}\bracks{\expo{\ic\omega\pars{t - t'}} +
\expo{-\ic\omega\pars{t - t'}}}
\\[1cm] & =
-\,{\ic \over 2\pi\omega}\,\sin\pars{\omega\bracks{t - t'}}\,
\mrm{P.V.}\int_{-\infty}^{\infty}{\expo{\ic\pars{t - t'}u} \over u}\,\dd u
+ {\ic \over 2\verts{\omega}}\,\cos\pars{\omega\bracks{t - t'}}
\\[1cm] & =
-\,{\ic \over 2\pi\omega}\,\sin\pars{\omega\bracks{t - t'}}
\int_{0}^{\infty}{\expo{\ic\pars{t - t'}u} - \expo{-\ic\pars{t - t'}u} \over u}\,\dd u
\\[2mm] & + {\ic \over 2\verts{\omega}}\,\cos\pars{\omega\bracks{t - t'}}
\\ & =
{\sin\pars{\omega\bracks{t - t'}} \over \pi\omega}\
\overbrace{\int_{0}^{\infty}{\sin\pars{\bracks{t - t'}u} \over u}\,\dd u}
^{\ds{\mrm{sgn}\pars{t - t'}\,{\pi \over 2}}}\
+\ {\ic \over 2\verts{\omega}}\,\cos\pars{\omega\bracks{t - t'}}
\\[5mm] & =
{\sin\pars{\omega\verts{t - t'}} \over 2\omega}
+
{\ic \over 2\verts{\omega}}\,\cos\pars{\omega\bracks{t - t'}}
\\[5mm] & =
{\sin\pars{\verts{\omega}\verts{t - t'}} \over 2\verts{\omega}}
+
{\ic \over 2\verts{\omega}}\,\cos\pars{\verts{\omega}\verts{t - t'}}
\\[5mm] & =
\bbx{\ic\,{\expo{-\ic\verts{\omega}\verts{t - t'}} \over 2\verts{\omega}}}\qquad
\mbox{as}\ \epsilon\ \to\ 0^{+}
\end{align}
