Improper integrals with singularities on the REAL AXIS (Complex Variable) I'm having some troubles when I try to solve improper integrals exercises that have singularities on the real axis. I have made a lot of exercises where singularities are inside a semicircle in the upper half side, but I don't know how to solve them when the singularities are on the real axis.
I read some books but I think they are not very good explained (at least, I can't understood them).
This is the exercise:
$$\int_{-\infty}^{\infty} \frac{\cos(2\pi x)}{x^2-1} dx$$
Using complex variable, I have:
$$f(z) =\frac{e^{i2\pi z}}{z^2-1}$$
so there are 2 singularities:
$z_1 = -1$ and $z_2 = 1$
I use a curve $C$ that is holomorphic inside it, because both singularities are out of it. Of course, I can divide $C$ in 6 curves: $C_R$ that is the "roof" of the curve and, using Jordan's Lemma, I can prove that 
$$\int_{C_R}^{ } \frac{e^{i2\pi z}}{z^2-1} dx = 0$$
but I don't know what do I have to do now. I saw in some places they said that the Residue Theorem over the semicircle around the singularities was something like: $$-i\pi\sum{}{}Res[f(z), z_k]$$ but I didn't understand why.
I hope you can help me, because I don't know what can I do.
Thanks!!
 A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\dsc}[1]{\displaystyle{\color{red}{#1}}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\Li}[1]{\,{\rm Li}_{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
First at all we realize that
$$\color{#66f}{%
\,{\rm P.V.}\int_{-\infty}^{\infty}\frac{\cos\pars{2\pi x}}{x^{2} - 1}\,\dd x}
=\Re\int_{-\infty}^{\infty}\frac{\expo{2\pi x\ic} - 1}{x^{2} - 1}\,\dd x
+\,{\rm P.V.}\int_{-\infty}^{\infty}\frac{\dd x}{x^{2} - 1}
$$
The first integral, in the right hand side, vanishes out which can be shown by means of a contour integration. Then, we are left with a 'simple' term: 
\begin{align}\color{#66f}{%
\,{\rm P.V.}\int_{-\infty}^{\infty}\frac{\cos\pars{2\pi x}}{x^{2} - 1}\,\dd x}
&=\,{\rm P.V.}\int_{-\infty}^{\infty}\frac{\dd x}{x^{2} - 1}
\\[5mm]&=\lim_{\epsilon \to 0^{+}}\bracks{%
\int_{-\infty}^{-1 - \epsilon}\frac{\dd x}{x^{2} - 1}
+\int_{-1 + \epsilon}^{1 - \epsilon}\ \frac{\dd x}{x^{2} - 1}
+\int_{1 + \epsilon}^{\infty}\frac{\dd x}{x^{2} - 1}}
\end{align}
Since
$\ds{\int\frac{\dd x}{x^{2} - 1} =\half\,\ln\pars{\verts{\frac{1 - x}{1 + x}}}  + \mbox{a constant}}$, the above expression is reduced to:
\begin{align}&\color{#66f}{\large%
\,{\rm P.V.}\int_{-\infty}^{\infty}\frac{\cos\pars{2\pi x}}{x^{2} - 1}\,\dd x}
\\[5mm]&=\lim_{\epsilon \to 0^{+}}\ \braces{%
\ln\pars{\verts{\frac{2 + \epsilon}{-\epsilon}}}
+\ln\pars{\verts{\frac{\epsilon}{2 - \epsilon}\,\frac{\epsilon}{2 - \epsilon}}}
-\ln\pars{\verts{\frac{-\epsilon}{2 + \epsilon}}}}=\color{#66f}{\large 0}
\end{align}
A: Divergent Integral
Note that
$$
\frac{\cos(2\pi x)}{x^2-1}=\frac{\cos(2\pi x)}2\left(\frac1{x-1}-\frac1{x+1}\right)
$$
The integral diverges at $x=-1$ and $x=1$, but we can compute the Cauchy Principal Value, which involves removing a small interval centered around each singularity.

Cauchy Principal Value
The reason that centering is important is that if the singularity is of the first order, then we have a situation similar to
$$
\int_{-1}^{-r}\frac1x\,\mathrm{d}x+\int_r^1\frac1x\,\mathrm{d}x=0
$$
where the effect of the singularity is cancelled around an interval centered on $0$ since $\frac1x$ is an odd function.
An easy way to approach the evaluation of the Cauchy Principal Value is using contour integration. Consider the integral of $\frac1z$ along the contour $\color{#0000FF}{[-1,-r]}\cup\color{#C000FF}{re^{i[\pi,0]}}\cup\color{#0000FF}{[r,1]}$: 
$$
\begin{align}
&\int_{-1}^{-r}\frac1z\,\mathrm{d}z+\int_{\pi}^0\overbrace{\frac1{re^{i\theta}}}^{1/z}\,\overbrace{\vphantom{\frac1z}ire^{i\theta}\mathrm{d}\theta}^{\mathrm{d}z}+\int_r^1\frac1z\,\mathrm{d}z\\
&=\log(r)+\int_\pi^0i\,\mathrm{d}\theta-\log(r)\\
&=-\pi i
\end{align}
$$
which is $-\pi i$ times the residue of $\frac1z$ at $0$ since the contour takes $\frac12$ turn clockwise around $0$.
Thus, we can compute the Cauchy Principal Value by computing a contour integral and subtracting the contributions of semicircles around the singularities, which will be $\pi i$ times the residues of those singularities.
There are at least two ways to evaluate the Cauchy Principal Value for this problem.

Contour Integration
Using the counter-clockwise contour, which contains no singularities,
$$
\small\color{#00A000}{\gamma}=\color{#0000FF}{[-R,-1-r]}\cup\overbrace{\color{#C000FF}{re^{i[\pi,0]}-1}}^{\begin{array}{c}\text{$\frac12$ turn clockwise}\\\text{about $-1$}\end{array}}\cup\color{#0000FF}{[-1+r,1-r]}\cup\overbrace{\color{#C000FF}{re^{i[\pi,0]}+1}}^{\begin{array}{c}\text{$\frac12$ turn clockwise}\\\text{about $+1$}\end{array}}\cup\color{#0000FF}{[1+r,R]}\cup\overbrace{\color{#C00000}{Re^{i[0,\pi]}}}^{\text{vanishes}}
$$

as $R\to\infty$ and $r\to0$, we get that
$$
\begin{align}
\small\mathrm{PV}\int_{-\infty}^\infty\frac{\cos(2\pi x)}{x^2-1}\,\mathrm{d}x
&\,\small=\mathrm{Re}\!\left(\color{#0000FF}{\int_{-R}^{-1-r}\frac{e^{2\pi ix}}{x^2-1}\,\mathrm{d}x}
+\color{#0000FF}{\int_{-1+r}^{1-r}\frac{e^{2\pi ix}}{x^2-1}\,\mathrm{d}x}
+\color{#0000FF}{\int_{1+r}^R\frac{e^{2\pi ix}}{x^2-1}\,\mathrm{d}x}\right)\\
&\small=\mathrm{Re}\!\left(\color{#00A000}{\int_\gamma\frac{e^{2\pi iz}}{z^2-1}\,\mathrm{d}z}
+\color{#C000FF}{\pi i\operatorname*{Res}_{z=-1}\left(\frac{e^{2\pi iz}}{z^2-1}\right)}
+\color{#C000FF}{\pi i\operatorname*{Res}_{z=1}\left(\frac{e^{2\pi iz}}{z^2-1}\right)}\right)\\
&\small=\mathrm{Re}\!\left(\color{#00A000}{0}\,-\,\color{#C000FF}{\frac{\pi i}4}\,+\,\color{#C000FF}{\frac{\pi i}4}\right)\\[4pt]
&\small=0
\end{align}
$$

Exploitation of Periodicity
$$
\begin{align}
\mathrm{PV}\int_{-\infty}^\infty\frac{\cos(2\pi x)}{x^2-1}\,\mathrm{d}x
&=\frac12\mathrm{PV}\int_{-\infty}^\infty\frac{\cos(2\pi x)}{x-1}\,\mathrm{d}x
-\frac12\mathrm{PV}\int_{-\infty}^\infty\frac{\cos(2\pi x)}{x+1}\,\mathrm{d}x\\
&=\frac12\mathrm{PV}\int_{-\infty}^\infty\frac{\cos(2\pi x)}x\,\mathrm{d}x
-\frac12\mathrm{PV}\int_{-\infty}^\infty\frac{\cos(2\pi x)}x\,\mathrm{d}x\\[6pt]
&=0
\end{align}
$$
