TITLE: Evaluating $\int_{-\infty}^{\infty}\frac{\sin ax-a \sin x}{x^3(x^2+1)} \ dx$ using contour integration
QUESTION [10 upvotes]: How would you compute the integral $$\int_{-\infty}^\infty \frac{\sin ax-a\sin x}{x^3(x^2+1)} \ dx ?$$
We will integrate along two circular contours and a striaghtline section between them.(Half donut shape) In the solution my professor give, it stated consider the function $$g(z)=\frac{-1+a+e^{iaz}-ae^{iz}}{z^3(z^2+1)}$$ instead of $$f(z)=\frac{e^{iaz}-ae^{iz}}{z^3(z^2+1)}$$ because $g$ has simple poles at the real lines. However, the result when we calculate the residue at $i$ is different. I checked the answer using Wolfram, the calculation using $g$ is the correct answer. Can someone explain why?

REPLY [3 votes]: The reason why $g$ gives the correct answer is that
$$
\begin{align}
\sin(ax)-a\sin(x)&=\frac1{2i}\left(\vphantom{\frac1{2i}}\left[e^{iax}-e^{-iax}\right]-\left[ae^{ix}-ae^{-ix}\right]\right)\\
&=\frac1{2i}\left(\vphantom{\frac1{2i}}\left[e^{iax}-ae^{ix}\right]-\left[e^{-iax}-ae^{-ix}\right]\right)\\
&=\frac1{2i}\left(\vphantom{\frac1{2i}}\left[\color{#0000FF}{-1+a}+e^{iax}-ae^{ix}\right]-\left[\color{#0000FF}{-1+a}+e^{-iax}-ae^{-ix}\right]\right)\\
\end{align}
$$
In fact, we cannot perform the integral using $f$ and the half-doughnut contour without showing that the $\frac1{z^2}$ term of $f(z)$ is $0$. Expanding, we get
$$
\frac{e^{iaz}-ae^{iz}}{z^3(z^2+1)}\sim\frac{1-a}{z^3}-\frac{a^2-3z+2}{2z}-i\frac{a^3-a}6+O(z)
$$
Furthermore, we need to show that for the small semi-circle $\gamma=re^{i[0,\pi]}$,
$$
\begin{align}
\int_\gamma\frac{\mathrm{d}z}{z^3}
&=\left[-\frac1{2z^2}\right]_{+r}^{-r}\\
&=0
\end{align}
$$
Thus, as RandomVariable has noted previously, we can do the integral either with or without the addition of $-1+a$, but with the $-1+a$, we only have to deal with simple poles.

Regarding the change in the residues at $i$ and $-i$, those changes are cancelled by the change in the residue at $0$. In fact,
$$
\begin{align}
\operatorname*{Res}_{z=0}\frac{-1+a}{z^3(z^2+1)}&=(1-a)\\
\operatorname*{Res}_{z=i}\frac{-1+a}{z^3(z^2+1)}&=-\frac{1-a}2\\
\operatorname*{Res}_{z=-i}\frac{-1+a}{z^3(z^2+1)}&=-\frac{1-a}2
\end{align}
$$

However, by moving the contour away from the singularities things become simpler.
Since $\dfrac{\sin(az)-a\sin(z)}{z^3(z^2+1)}$ is bounded in the rectangle
$$
[-R,R]\cup R+[0,i/2]\cup[R,-R]+i/2\cup-R+[i/2,0]
$$
we get that all singularities are removable. Therefore,
$$
\int_{-\infty}^\infty\frac{\sin(ax)-a\sin(x)}{x^3(x^2+1)}\,\mathrm{d}x
=\int_{-\infty+i/2}^{\infty+i/2}\frac{\sin(az)-a\sin(z)}{z^3(z^2+1)}\,\mathrm{d}z
$$
Using the contours
$$
\begin{align}
\gamma_+&=[-R,R]+i/2\cup Re^{i[0,\pi]}+i/2\\
\gamma_-&=[-R,R]+i/2\cup Re^{-i[0,\pi]}+i/2
\end{align}
$$
where $\gamma_+$ circles the singularity at $i$ counterclockwise and $\gamma_-$ circles the singularities at $0$ and $-i$ clockwise, we get
$$
\begin{align}
\int_{-\infty}^\infty\frac{\sin(ax)-a\sin(x)}{x^3(x^2+1)}\,\mathrm{d}x
&=\frac1{2i}\int_{\gamma_+}\frac{e^{iaz}-ae^{iz}}{z^3(z^2+1)}\,\mathrm{d}z
-\frac1{2i}\int_{\gamma_-}\frac{e^{-iaz}-ae^{-iz}}{z^3(z^2+1)}\,\mathrm{d}z\\
&=\pi\operatorname*{Res}_{z=i}\left[\frac{e^{iaz}-ae^{iz}}{z^3(z^2+1)}\right]\\
&+\pi\operatorname*{Res}_{z=0}\left[\frac{e^{-iaz}-ae^{-iz}}{z^3(z^2+1)}\right]
+\pi\operatorname*{Res}_{z=-i}\left[\frac{e^{-iaz}-ae^{-iz}}{z^3(z^2+1)}\right]\\
&=\pi\left[\frac{e^{-a}-ae^{-1}}2\right]\\
&+\pi\left[-\frac{a^2-3a+2}2\right]+\pi\left[\frac{e^{-a}-ae^{-1}}2\right]\\
&=\pi\left[e^{-a}-ae^{-1}-\frac{a^2-3a+2}2\right]
\end{align}
$$