Prove that the integral of $x\cos(x)/(x-2)(x-1)$ from negative to positive infinity is $\pi(\sin1-2\sin2)$. Use an indented contour To do this I used the Residue Thm but the main issue here is that I cannot get the sine term to appear. Perhaps I'm ignoring something here. 
We know that the singularity is $x=1,2$ so we should just calculate the residue at these two points as follows:
\begin{equation*}
Res(f,2)=-\cos1, \\
Res(f,1)=2\cos2.
\end{equation*}
Once we multiply this and sum it we get: $2\pi i(-\cos1+2\cos2)$. No sines appear. Can someone correct me here?
 A: The Integral, as stated diverges at $x=1$ and $x=2$, but the Cauchy Principal Value can be computed.
$$
\begin{align}
\mathrm{PV}\int_{-\infty}^\infty\frac{x\cos(x)\,\mathrm{d}x}{(x-1)(x-2)}
&=\frac12\int_{\gamma^+}\frac{ze^{iz}\,\mathrm{d}z}{(z-1)(z-2)}
+\frac12\int_{\gamma^-}\frac{ze^{-iz}\,\mathrm{d}z}{(z-1)(z-2)}\\
&\color{#C00000}{+\frac{\pi i}{2}\operatorname*{Res}_{z=1}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)
+\frac{\pi i}{2}\operatorname*{Res}_{z=2}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)}\\
&\color{#00A000}{-\frac{\pi i}{2}\operatorname*{Res}_{z=1}\left(\frac{ze^{-iz}}{(z-1)(z-2)}\right)
-\frac{\pi i}{2}\operatorname*{Res}_{z=2}\left(\frac{ze^{-iz}}{(z-1)(z-2)}\right)}\\
&=\frac{\pi i}{2}\frac{e^i}{-1}+\frac{\pi i}{2}\frac{2e^{2i}}{1}
-\frac{\pi i}{2}\frac{e^{-i}}{-1}-\frac{\pi i}{2}\frac{2e^{-2i}}{1}\\[9pt]
&=\pi\sin(1)-2\pi\sin(2)
\end{align}
$$
where $\gamma^+$ consists of the straight line contours and upper semi-circles; that is,
$$
[-R,1-r]\cup1+re^{i[\pi,0]}\cup[1+r,2-r]\cup2+re^{i[\pi,0]}\cup[2+r,R]\cup Re^{i[0,\pi]}
$$
and $\gamma^-$ consists of the straight line contours and lower semi-circles; that is,
$$
[-R,1-r]\cup1+re^{-i[\pi,0]}\cup[1+r,2-r]\cup2+re^{-i[\pi,0]}\cup[2+r,R]\cup Re^{-i[0,\pi]}
$$

The integrals around the two large semi-circles, in blue, vanish. Since there are no singularities contained in either contour, their integrals are $0$. For the principal value, which is just the integral over the straight line contours, we must subtract the contributions from the red and green semi-circles; this is done using the residues at $z=1$ and $z=2$.

This can also be computed using only $\gamma^+$ if we take the real part.
$$
\begin{align}
\mathrm{PV}\int_{-\infty}^\infty\frac{x\cos(x)\,\mathrm{d}x}{(x-1)(x-2)}
&=\mathrm{Re}\left(\int_{\gamma^+}\frac{ze^{iz}\,\mathrm{d}z}{(z-1)(z-2)}
\right)\\
&+\mathrm{Re}\left[\pi i\operatorname*{Res}_{z=1}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)
+\pi i\operatorname*{Res}_{z=2}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)\right]\\
&=\mathrm{Re}\left(\pi i\frac{e^i}{-1}+\pi i\frac{2e^{2i}}{1}\right)\\[6pt]
&=\pi\sin(1)-2\pi\sin(2)
\end{align}
$$
A: As the OP admits some freedom of interpretation I propose here the slightly "dirty" approach to start from the antiderivative and try to invoke the fundamental lemma of calculus.
We can verify by calculating the derivative that the indefinite integral is given by
$$
a(x) = \int \frac{x \cos (x)}{(x-1) (x-2)} \, dx\\
=-\cos (1) \text{Ci}(1-x)+2 \cos (2) \text{Ci}(2-x)\\
-\sin (1) \text{Si}(1-x)+2 \sin (2) \text{Si}(2-x)$$
where $\text{Ci}$ and $\text{Si}$ are cos- and sine integral, resp. (see https://mathworld.wolfram.com/SineIntegral.html)
In order to be on the safe side we plot real and imaginary part of the function $a(x)$

The limits are
$$a_{+\infty}=\underset{x\to \infty }{\text{lim}}a(x) = \frac{1}{2} \pi  \sin (1)-\pi  \sin (2)-i \pi  \cos (1)+2 i \pi  \cos (2)$$
and
$$a_{-\infty}=\underset{x\to -\infty }{\text{lim}}a(x) = \pi  \sin (2)-\frac{1}{2} \pi  \sin (1)$$
Now the integral should be equal to the difference
$$i=a_{+\infty}-a_{-\infty} = \pi  (\sin (1)-2 \sin (2))-i \pi  (\cos (1)+2 \cos (2))$$
The real part of $i$ is the desired result.
As for the imaginary part, we invoke the "dirtyness" of our method once more and neglected it.
