Calculate the value of the integral $\int_{0}^{\infty} \frac{\cos 3x}{(x^{2}+a^{2})^{2}} dx$ where $a>0$ is an arbitrary positive number. Question: Calculate the value of the integral $ \displaystyle \int_{0}^{\infty} \frac{\cos 3x}{(x^{2}+a^{2})^{2}} dx$ where $a>0$ is an arbitrary positive number.
Thoughts: I don't know how to establish convergence so that a symmetric limit can be used, but if I can do so, then we have that the integral equals $\displaystyle \frac{1}{2} \int_{-\infty}^{\infty} \frac{\cos 3x}{(x^{2}+a^{2})^{2}} dx = \displaystyle \lim_{R \to \infty} \int_{-R}^{R} \frac{\cos 3x}{(x^{2}+a^{2})^{2}} dx = Re \left (\displaystyle \lim_{R \to \infty} \int_{-R}^{R} \frac{e^{i(3x)}}{(x^{2}+a^{2})^{2}} dx  \right ) $
which has double poles at $x=ia$ and $x=-ia$, so the integral may be evaluated by calculating residues. Can anyone show me how to solve the problem? All input is appreciated, I am studying for an exam in complex analysis. 
 A: If you are interested in another method:
$$\begin{aligned}f(t)=\int_0^{\infty} \frac{\cos 3xt}{(x^2+a^2)^2}\,dx\Rightarrow \mathcal{L}\{f(t)\} &=\int_0^{\infty}e^{-st}\int_0^{\infty}\frac{\cos 3xt}{(x^2+a^2)^2}\,dx\,dt\\&=\int_0^{\infty}\frac{1}{(x^2+a^2)^2}\int_0^{\infty} e^{-st}\cos 3xt\,dt\,dx\\&=\int_0^{\infty}\frac{s\,dx}{(x^2+a^2)^2(9x^2+s^2)}\\&=\frac{3\pi}{2a^2(3a+s)^2}+\frac{\pi s}{4a^3(3a+s)^2}\end{aligned}$$
Which follows from a quick partial fraction decomposition.
Next,
$$\mathcal{L}^{-1}\left\{\frac{3\pi}{2a^2(3a+s)^2}\right\}+\mathcal{L}^{-1}\left\{\frac{\pi s}{4a^3(3a+s)^2}\right\}=\frac{3\pi t}{2a^2e^{3at}}+\frac{\pi(1-3at)}{4a^3e^{3at}}$$
By setting, $t=1$, we get:
$$\int_0^{\infty}\frac{\cos 3x\,dx}{(x^2+a^2)^2}=\frac{\pi(3a+1) }{4a^3e^{3a}}$$
A: Let $S=\{-ia, ia\}$, let $ \varphi \colon \Bbb C\setminus S\to \Bbb C, z\mapsto\dfrac{e^{i(3z)}}{(z^2+a^2)^2}$.
Given $n\in \Bbb N$ such that $n> a$, define $\gamma (n):=\gamma _1(n)\lor \gamma _2(n)$ with $\gamma _1(n)\colon [-n,n]\to \Bbb C, t\mapsto t$ and $\gamma _2(n)\colon [0,\pi]\to \Bbb C, \theta \mapsto ne^{i\theta}$, ($\gamma (n)$ is an upper semicircle).
Observe that $S$ is the set of singularities of $\varphi$ and both of them are second order poles.
Therefore $$\operatorname {Res}(\varphi ,ia)=\left.\dfrac{d}{dz}\left(z\mapsto (z-ia)^2\varphi (z)\right)\right\vert_{z=ia}\overset{\text{W.A.}}{=}\left.\dfrac{ie^{i3z}(3ia+3z+2i)}{(z+ia)^3}\right\vert_{z=ia} = \dfrac{e^{-3a}(3a+1)}{4a^3i}.$$
Here is the link for the equality $\text {W.A.}$.
Quick considerations about winding numbers, inside and outside region of $\gamma(n)$, the fact that $n>a$, the fact that $\varphi$ is holomorphic and the residue theorem yield $$\displaystyle \int \limits_{\gamma (n)}\varphi (z)dz=2\pi i\cdot \dfrac{e^{-3a}(3a+1)}{4a^3i}= \dfrac{\pi e~^{-3a}(3a+1)}{2a^3}.$$
On the other hand $\displaystyle \int \limits _{\gamma (n)}\varphi=\int \limits _{\gamma _1(n)}\varphi +\int \limits_{\gamma _2(n)}\varphi \tag {*}$
Note that $$\displaystyle\int \limits _{\gamma _1(n)}\varphi(z)dz=\int \limits _{-n}^n\varphi (t)dt=\int \limits_{-n}^n\dfrac{e^{i(3t)}}{(t^2+a^2)^2}dt=\int \limits_{-n}^n\dfrac{\cos(3t)+i\sin 3t)}{(t^2+a^2)^2}dt=\int \limits _{-n}^n\dfrac{\cos (3t)}{(t^2+a^2)^2}dt.$$
The last equality is due to $t\mapsto \dfrac{\sin (3t)}{(t^2+a^2)^2}$ being an odd function and due to the integral being computed on a symmetric interval.
Furthermore, $$\int \limits _{\gamma _2(n)}\varphi (z)dz=\int \limits _0^\pi \varphi(ne^{i\theta})\cdot ine^{i\theta}d\theta=\int \limits _0^\pi\dfrac{e^{i\cdot 3ne^{i\theta}}ine^{i\theta}}{(n^2e^{2ni\theta }+a^2)^2}d\theta=n\int \limits _0^\pi i\dfrac{e^{i\cdot 3n(\cos (\theta)+i\sin (\theta))}e^{i\theta}}{(n^2e^{2ni\theta }+a^2)^2}d\theta=\\
=n\int \limits _0^\pi i\dfrac{e^{-3n\sin (\theta)}e^{i(3n\cos (\theta)+\theta)}}{(n^2e^{2ni\theta }+a^2)^2}d\theta,$$
from where one gets $$\left \vert\, \int \limits _{\gamma _2(n)}\varphi (z)dz\right \vert\leq n\int \limits _0^\pi \left \vert i\dfrac{e^{-3n\sin (\theta)}e^{i(3n\cos (\theta)+\theta)}}{(n^2e^{2ni\theta }+a^2)^2}\right \vert d\theta =n\int \limits_0^\pi \left \vert\dfrac{e^{-3n\sin (\theta)}}{(n^2e^{2ni\theta }+a^2)^2}\right \vert d\theta=\\=n\int \limits_0^\pi \dfrac{\left \vert e^{-3n\sin (\theta)}\right \vert}{\left \vert n^2e^{2ni\theta }+a^2\right \vert^2}d\theta \underset{(n>a)}{\leq} n\int \limits _0^\pi \dfrac{e^{-3a\sin (\theta)}}{(n^2-a^2)^2}d\theta=\dfrac{n}{(n^2-a^2)^2}\int \limits _0^\pi e^{-3a\sin (\theta)}d\theta\overset{n\to +\infty}{\longrightarrow} 0$$
Taking the limit in $(*)$ one finally gets $$\dfrac{\pi e~^{-3a}(3a+1)}{2a^3}=\int \limits_{-\infty}^{+\infty} \dfrac{\cos (3t)}{(t^2+a^2)^2}dt.$$
Due to the evenness of $t\to \dfrac{\cos (3t)}{(t^2+a^2)^2}$ it follows that $\displaystyle \int \limits_{0}^{+\infty} \dfrac{\cos (3t)}{(t^2+a^2)^2}dt=\dfrac{\pi e~^{-3a}(3a+1)}{4a^3}$ which agrees with WA.
I regret having started this.
A: Since you're studying for an exam, I'll try to be a bit more vague. The function you're considering is an even function. So 

$\int_{0}^{R}\frac{\cos(3x)}{(x^2+a^2)^2}=\frac{1}{2}\int_{-R}^{R}\frac{\cos(3x)}{(x^2+a^2)^2}$

Thus, it suffices to compute the symmetric limit. Using this contour, the residue theorem shows that for $R>0$ sufficiently large, 

$\int_{-R}^{R}\frac{e^{3ix}}{(x^2+a^2)^2}\ dx+\int_{\gamma_R}\frac{e^{3iz}}{(z^2+a^2)^2}\ dz=2\pi i\cdot \text{res}_{ia}\left(\frac{e^{3iz}}{(z^2+a^2)^2}\right)$

Since $ia$ is the only pole in the semicircular region (where $\gamma_R$ is the semicircular portion of the contour [as indicated in the picture]). Jordan's Lemma shows that the second integral vanishes as $R\to \infty$, so it suffices to compute the residue (don't forget that $ia$ is a double pole). After taking the real part of both sides, you'll have the value of the integral you desire. 
Note: Jordan's Lemma is sort of an unnecessary tool for this specific problem, but I chose to refer you to it since it comes up a lot when doing contour integration, and knowing it saves a lot of time and reduces redundant arguments/calculations. 
A: Answering my comment. Note that, when you parametrize the upper have of the circle $z=Re^{I\theta},\, 0\leq \theta\leq \pi$and dealing with the integral
$$ \int_{C_R}\frac{e^{iz}}{z^2+a^2}dz $$
the integrand becomes
$$ \Bigg|\frac{e^{iz}}{z^2+a^2}\Bigg| \leq \frac{\Big|e^{i R e^{R\theta}}\Big|}{R^2-a^2} = \frac{e^{-R \sin(\theta)}}{R^2-a^2}. $$
Now, you can see that $R\sin(\theta ) \geq 0 $ for $0\leq \theta\leq \pi$ which insures that 
$$ \lim_{R\to \infty}  \frac{e^{-R \sin(\theta)}}{R^2-a^2} = 0 .$$
