Computing a complex integral potentially using residues The question is:
Compute:
$$\mbox{p.v.}\int_{-\infty}^{\infty}\frac{x\sin4x}{{x^2}-1}dx$$
Initially I thought it was straight forward and I could just use residues. However, the Residue Theorem requires the poles to be in the upper plane ($y > 0$), and in this case, that is not the case. So, now I have no idea what to do since I cannot use residues. 
 A: Let $C_R$ denote the counterclockwise semicircular arc extending from $R$ to $-R$ in the plane and $C_{\rho_1} , C_{\rho_2}$ be the counterclockwise semicircular arcs extending from $-1 - \rho_1$ to $-1 + \rho_1$ and from $1 -\rho_1$ and $1+\rho_1,$ respectively. Note that $\frac{x\sin 4x}{x^2 -1} = \Im \frac{x\exp{4ix}}{x^2 -1}.$ 
Consider also that $\,\displaystyle{f(z) = \frac{z\exp{4iz}}{z^2 -1}}\, $ has simple poles at $-1$ and $1.$ By Jordan's Lemma, there exists $\theta \in [0, \pi ]$ such that $$\displaystyle\int_{C_R} \frac{z\exp{4iz}}{z^2-1} \le \frac{\pi }{4} \frac{1}{R^2 \exp{2i\theta }-1}$$ The right hand side of this inequality tends to zero. Using the residue theorem, 
$$\int_{C_R} \frac{z\exp{4iz}}{z^2-1} + \int_{-C_{\rho_1}} \frac{z\exp{4iz}}{z^2-1} + \int_{-C_{\rho_2}} \frac{z\exp{4iz}}{z^2-1} +\int_{-R}^{-1 -\rho_1} \frac{x\exp{4ix}}{x^2-1} dx +$$
$$+\int_{-1 +\rho_1}^{1 - \rho_e} \frac{x\exp{4ix}}{x^2-1} dx +\int_{1 + \rho_1}^{R} \frac{x\exp{4ix}}{x^2-1} dx = 0$$ 
Letting $R$ tend to infinity and $\rho_1 \rho_2$ tend to zero, we have 
$$\textrm{pv }\int_{-\infty }^{\infty } \frac{x\exp{4ix}}{x^2 -1 }dx = \pi i [\textrm{ Res } (f, -1) + \textrm{ Res } (f, 1) ] = \pi i \cos 4 $$ 
Hence 
$$\textrm{pv } \int_{-\infty }^{\infty } \frac{x\sin 4x}{x^2 -1 }dx = \pi \cos 4.$$
A: Consider the following diagram:
$\hspace{3.25cm}$
The principal value integral is the integral over the path in black as the paths in red get smaller and the paths in blue and green get bigger. We will evaluate this by first breaking up $\sin(4z)=\dfrac{e^{i4z}-e^{-i4z}}{2i}$ so that we can close the path of integration of each piece along a different path.
$\dfrac{e^{i4z}}{2i}$ will be integrated over the paths in black, red, and blue ($\gamma^+$). $\gamma^+$ contains the singularities at $z=-1$ and $z=1$
$\dfrac{e^{-i4z}}{2i}$ will be integrated over the paths in black, red, and green ($\gamma^-$). $\gamma^-$ contains no singularities.
The sum of the integrals described above, include the integrals over the red half circles. We will eliminate the integrals over the red half circles by subtracting half of $2\pi i$ times the residue of $\dfrac{z\sin(4z)}{z^2-1}$ at $z=-1$ and $z=1$.
Thus, we get
$$
\begin{align}
=\hspace{-11.5pt}\int_{-\infty}^\infty\frac{x\sin(4x)}{x^2-1}\mathrm{d}x
&=\color{#0000FF}{\frac1{2i}\int_{\gamma^+}\frac{ze^{i4z}}{z^2-1}\mathrm{d}z}
-\color{#00A000}{\frac1{2i}\int_{\gamma^-}\frac{ze^{-i4z}}{z^2-1}\mathrm{d}z}\\
&-\color{#C00000}{\pi i\mathrm{Res}_{z=-1}\left(\frac{z\sin(4z)}{z^2-1}\right)}
-\color{#C00000}{\pi i\mathrm{Res}_{z=1}\left(\frac{z\sin(4z)}{z^2-1}\right)}\\
&=\color{#0000FF}{\frac{2\pi i}{2i}\mathrm{Res}_{z=-1}\left(\frac{ze^{i4z}}{z^2-1}\right)}
+\color{#0000FF}{\frac{2\pi i}{2i}\mathrm{Res}_{z=1}\left(\frac{ze^{i4z}}{z^2-1}\right)}\\
&-\color{#C00000}{\pi i\mathrm{Res}_{z=-1}\left(\frac{z\sin(4z)}{z^2-1}\right)}
-\color{#C00000}{\pi i\mathrm{Res}_{z=1}\left(\frac{z\sin(4z)}{z^2-1}\right)}\\
&=\color{#0000FF}{\pi\frac{e^{-i4}}{2}}+\color{#0000FF}{\pi\frac{e^{i4}}{2}}\\
&-\color{#C00000}{\pi i\frac{\sin(-4)}{2}}-\color{#C00000}{\pi i\frac{\sin(4)}{2}}\\[6pt]
&=\pi\cos(4)
\end{align}
$$
