I am working through the section on Contour Integration in Mathematical Methods of Physics by Mathews and Walker and there are 2 integrals that I cannot figure out how to do. One of the integrals is
$$\int_0^\infty \frac{\sin x}{x(a^2 + x^2)} \, \mathrm dx.$$
It's obvious that there are poles at $x = 0$, and $x = \pm ia$, but I'm not sure how to draw the contour. I know the answer is something like $\frac{\pi}{2a^2}\left(1-\exp{\left(-1/\sqrt{\frac{1}{a^2}}\right)}\right)$, but I'm not sure how this is achieved. Any help would be appreciated.
Sketch for the solution: let $f(x):=\frac{\sin x}{x(x+a)^2}$, then note that $$ \int _0^\infty f(x)\,\mathrm d x=\frac12\int_{-\infty }^{\infty }f(x) \,\mathrm d x=\frac12\lim_{R\to \infty }\int_{-R}^{R}f(x)\,\mathrm d x\tag1 $$ And from the residue theorem we have that $$ \int_{-R}^{R}f(x)\,\mathrm d x+\int_{\gamma_R }f(z)\,\mathrm d z=2\pi i\sum_{z\in V}\operatorname{Res}(f,z)\tag2 $$ where $\gamma_R $ is the path from $R$ to $-R$ in the upper half of the boundary of the disk $R\Bbb D $ in the complex plane, $\operatorname{Res}(f,z)$ is the residue of $f$ around $z$, and $V:=R\Bbb D\cap\{z\in\Bbb C:\operatorname{Im}(z)> 0\}$. Therefore $$ \int_{0}^{\infty }f(x)\,\mathrm d x=\frac12\lim_{R\to \infty }\left(2\pi i\sum_{z\in V}\operatorname{Res}(f,z)-\int_{\gamma_R }f(z)\,\mathrm d z\right)\tag3 $$ Now it can be shown that if $\lim_{|z|\to \infty }zf(z)=0$ then $\lim_{R\to \infty }\int_{\gamma _R}f(z)\,\mathrm d z=0$ (see here). Hence for your case $$ \int_{0}^{\infty }f(x)\,\mathrm d x=\pi i\operatorname{Res}(f,ia)\tag4 $$