Example 9. Calculate the integral

$$
I=\int_{0}^{\infty} \frac{x \sin a x}{x^{2}+k^{2}} d x \quad(a>0, k>0)
$$
Solution. Introduce the auxiliary function

$$
f(z)=\frac{z e^{i a z}}{z^{2}+k^{2}}
$$

It is easy to see that if $z=x$, then $\operatorname{Im} f(x)$ coincides with the integrand $\varphi(x)=\frac{x \sin a x}{x^{2}+k^{2}}$. Consider the contour shown in Fig. 7. For sufficiently large $R$, on the contour $C_{R}$, the function $g(z)=\frac{z}{z^{2}+k^{2}}$ satisfies the inequality
$|g(z)|\boldsymbol{k}$ By the residue theorem, we have

$$
\int_{-R}^{R} \frac{x e^{i a x}}{x^{2}+k^{2}} d x+\int_{C_{R}} \frac{z e^{i a z}}{z^{2}+k^{2}} d z=2 \pi i \sigma
$$

where

$$
\sigma=\operatorname{res}\left(\frac{z e^{i a z}}{z^{2}+k^{2}}\right)=\lim _{z \rightarrow i k}\left(\frac{z e^{i a z}}{z^{2}+k^{2}}(z-i k)\right)=\frac{1}{2} e^{-a k}
$$

In the limit as $R \rightarrow \infty$, taking into account relation (5), we get

$$
\int_{-\infty}^{+\infty} \frac{x e^{i a x}}{x^{2}+k^{2}} d x=\pi i e^{-a k}
$$

Separating the real and imaginary parts on both sides, we obtain

$$
\int_{-\infty}^{+\infty} \frac{x \sin a x}{x^{2}+k^{2}} d x=\pi e^{-a k}
$$

Since the integrand is even, we finally get

$$
I=\frac{\pi}{2} e^{-a k}
$$