Definite integral with residues and a double pole I have the following integral
$$
    I = \int_{-\infty}^{+\infty}\frac{\sin x}{(x-\pi)^2(x+\pi/2)}dx\text{,}
$$
that I am supposed to solve with the theorem of residues.
I see that there are two simple poles in $\pi$ (given that $\pi$ is a simple zero of the numerator and a double zero of the denominator) and in $-\pi/2$.
Having only simple poles, this should mean that the integral exists in the sense of Cauchy principal value.
When I take the usual step of considering the analytic function
$$
    f(z)=\frac{e^{iz}}{(z-\pi)^2(z+\pi/2)}\text{.}
$$
I see that the simple pole $\pi$ becomes a double pole, because it is not anymore a zero of the numerator.
Can I still proceed with
$$
I = \operatorname{Im}\big[\pi i\big(R[\pi]+R[-\pi/2]\big)\big] \text{,}
$$
where $R[z_0]$ is the residue of $f$ in $z_0$,
or there is some other consideration to take into account?
 A: 
Can I still proceed with $$I = \operatorname{Im}\big[\pi i\big(R[\pi]+R[-\pi/2]\big)\big] \text{,}$$ where $R[z_0]$ is the residue of $f$ in $z_0$, or there is some other consideration to take into account?

"No" for the pole at $z_0=\pi$, because $\displaystyle\lim_{r\to0^+}\int_{C_r}f(z)\,\mathrm{d}z$ diverges for the semi-circular arc $C_r$ centered at $z_0=\pi$ and radius $r$.

For the integrand
$$f(z)=\frac{e^{iz}}{(z-\pi)^2(z+\pi/2)}$$
The Laurent series of $f(z)$ near $z_0=\pi$ is
$$f(z)=\frac{b_2}{(z-z_0)^2}+\frac{b_1}{z-z_0}+\mathcal{O}(1)$$
For the upper semi-circular arc $C_r$, let's use parameterization $z=z_0+re^{i\theta}$ with $0\leq\theta\leq\pi$,
$$\begin{aligned}
\lim_{r\to0^+}\int_{C_r}f(z)\,\mathrm{d}z
&=\lim_{r\to0^+}\int_0^\pi f(z_0+re^{i\theta})rie^{i\theta}\,\mathrm{d}\theta \\
&=\lim_{r\to0^+}\int_0^\pi\left[\frac{b_2}{r^2e^{2i\theta}}+\frac{b_1}{re^{i\theta}}+\mathcal{O}(1)\right]rie^{i\theta}\,\mathrm{d}\theta \\
&=\lim_{r\to0^+}\int_0^\pi\left[\frac{b_2}{re^{i\theta}}+ib_1+\mathcal{O}(r)\right]\,\mathrm{d}\theta \\
&=\lim_{r\to0^+}\frac{-2ib_2}{r}+\pi i b_1
\end{aligned}$$
As $r\to0^+$, $\mathcal{O}(r)\to0$ but $1/r\to\infty$, hence it diverges. The same can be shown using the lower semi-circular arc with $\pi\leq\theta\leq2\pi$.
Generally, the even power terms with $n\geq2$ (such as $z^{-2}$, $z^{-4}$, $\cdots$, etc.) in the principal part of the Laurent series diverges. On the other hand, the odd power terms with $n\geq3$ (such as $z^{-3}$, $z^{-5}$, $\cdots$, etc.) all vanishes. The coefficient of $z^{-1}$ term is the residue.

@Svyatoslav's method in the comments can work because the Laurent series of the complex integrand in that post has only $z^{-3}$ and $z^{-1}$ terms.
We may try the regularization method. One possible way is to "shift" the poles up from real line. The integrand is rewritten as
$$f(z)=\frac{e^{iz}}{(z-\pi-i\epsilon)^2(z+\pi/2-i\epsilon)}$$
Then proceed with residue calculus as usual, and take the limit $\epsilon\to0^+$ at the end. The problem of regularization is that there is no unique way to "shift" the poles, and each gives different results.

A: If we decompose in simple fractions the rational part of the function under the integral sign
$$
\frac{1}{(x-\pi)^2(x+\pi/2)}=\frac{4}{9\pi^2}\cdot\frac{1}{x+\pi/2}-\frac{4}{9\pi^2}\cdot\frac{1}{x-\pi}+\frac{2}{3\pi}\cdot\frac{1}{(x-\pi)^2}
$$
and taking into account that we have
$$
\text{p.v.}\int_{-\infty}^{+\infty}\frac{\sin x}{(x-\pi)^2}dx=
{}-\text{p.v.}\int_{-\infty}^{+\infty}\frac{\sin t}{t^2}dt=0
$$
we see that we can only consider the first two terms of the decomposition
$$
\frac{4}{9\pi^2}\cdot\frac{1}{x+\pi/2}-\frac{4}{9\pi^2}\cdot\frac{1}{x-\pi}=
-\frac{2}{3\pi}\cdot\frac{1}{(x-\pi)(x+\pi/2)}
$$
so the integral becomes
$$
-\frac{2}{3\pi}\int_{-\infty}^{+\infty}\frac{\sin x}{(x-\pi)(x+\pi/2)}dx
$$
that can be evaluated with standard methods.
