# Calculating $\int_{0}^\infty \frac{\cos(2x)}{(x^2 + 1)(x^2 + 4)} dx$ using residue calculus

I want to calculate

$$\int_{0}^\infty \frac{\cos(2x)}{(x^2 + 1)(x^2 + 4)} dx$$

using residue calculus

My solution

First observation is that:

$$\int_\mathbb R \frac{e^{2ix}}{(x^2 + 1)(x^2 + 4)} dx = \int_\mathbb R \frac{\cos(2x)}{(x^2 + 1)(x^2 + 4)} dx + i \int_\mathbb R \frac{\sin(2x)}{(x^2 + 1)(x^2 + 4)}dx$$

whereas $$\int_\mathbb R \frac{\sin(2x)}{(x^2 + 1)(x^2 + 4)}dx = 0$$ since this function is odd, as multiplication of odd function with even function.

If we define now $$f(z) = \frac{e^{2iz}}{(z^2 + 1)(z^2 + 4)} = \frac{e^{2iz}}{(z^2 - i^2)(z^2 - 4i^2)} = \frac{e^{2iz}}{(z-i)(z+i)(z-2i)(z+2i)}$$

We will see that we have four poles in points $$i, -i, 2i, -2i$$ with rank $$1$$.

Now let's define our contour for $$r > 2$$:

$$\gamma_1: [-r ,r] \ni t \rightarrow t \in \mathbb C$$

$$\gamma_2: [0, \pi] \ni t \rightarrow Re^{it}$$

Our final contour is $$\gamma = \gamma_1 + \gamma_2$$

Firstly let's consider our integral on $$\gamma_2$$:

$$|\int_ {\gamma_2} f(z) dz| = |\int_0 ^ \pi \frac{e^{2ire^{it}}}{((re^{it})^2 + 1)((re^{it})^2 + 4)}ire^{it} dt| \le \int_0^\pi|\frac{|e^{-2\sin(t)}|}{((re^{it})^2 + 1)((re^{it})^2 + 4)}r dt$$

Now we know that:

$$\frac{1}{|(re^{it})^2 + 1|} \le \frac{1}{r^2 - 1}$$ $$\frac{1}{|(re^{it})^2 + 4|} \le \frac{1}{r^2 - 4}$$ $$\int_0^\pi e^{-A \sin t}dt < \frac{\pi}{A}$$

so

$$\int_0^\pi|\frac{|e^{-2\sin(t)}|}{((re^{it})^2 + 1)((re^{it})^2 + 4)}r dt < \frac{r\pi}{2} \cdot \frac{1}{(r^2 - 1)(r^2 + 4)} \rightarrow 0$$

So when going with $$r$$ to infinity we'll have our integral only on $$\gamma_1$$. To calculate so, we'll just calculate residuals in $$i$$ and $$2i$$:

$$\textrm{res}_if(z) = \lim_{z \rightarrow i} = \lim_{z \rightarrow i}\frac{e^{2iz}}{(z + i)(z - 2i)(z + 2i)} = \frac{e^{-2}}{6}$$

$$\textrm{res}_{2i}f(z) = \lim_{z \rightarrow 2i} = \lim_{z \rightarrow 2i}\frac{e^{2iz}}{(z - i)(z - i)(z + 2i)} = \frac{e^{-4}}{12}$$

So finally we have that our integral equals to:

$$\pi(\frac{e^{-2}}{6} + \frac{e^{-4}}{12})$$

which unfortunately is different from what wolfamalpha suggests. Could you please tell me where did I make the mistake?

Those residues are wrong. You have\begin{align}\operatorname{res}_{z=i}\frac{e^{2iz}}{(z^2+1)(z^2+4)}&=\lim_{z\to i}\frac{e^{2iz}}{(z+i)(z^2+4)}\\&=\frac{e^{-2}}{6i}\end{align}and, by the same argument,$$\operatorname{res}_{z=2i}\frac{e^{2iz}}{(z^2+1)(z^2+4)}=-\frac{e^{-4}}{12i}.$$Therefore\begin{align}\int_{-\infty}^\infty\frac{\cos(2x)}{(x^2+1)(x^2+4)}\,\mathrm dx&=\int_{-\infty}^\infty\frac{e^{2ix}}{(x^2+1)(x^2+4)}\,\mathrm dx\\&=2\pi i\left(\frac{e^{-2}}{6i}-\frac{e^{-4}}{12i}\right)\\&=2\pi\left(\frac{e^{-2}}6-\frac{e^{-4}}{12}\right).\end{align}So,$$\int_0^\infty\frac{\cos(2x)}{(x^2+1)(x^2+4)}\,\mathrm dx=\pi\left(\frac{e^{-2}}6-\frac{e^{-4}}{12}\right).$$