# Computing real integral using residues

Let's consider the following integral $$\int \limits_{-\infty}^{\infty} \frac{\cos2x}{(x^2+4)^2} \, dx. \tag{1}$$

I would like to compute $$(1)$$ using residue theory. Let's consider a complex function $$f(z) = \frac{\cos2z}{(z^2+4)^2} = \frac{\cos2x}{(z-2i)^2(z+2i)^2}.$$

Of course $$\text{Im}(-2i) < 0$$ thus I am to calculate residue only in the point $$z_0 = 2i$$.

Noting that $$z_0$$ is a double pole we have $$R = \text{res}_{z_0}f(z) = \lim_{z \to 2i} \frac{d}{dz} \bigg((z-2i)^2 \frac{\cos(2z)}{(z-2i)^2(z+2i)^2} \bigg).$$

After some calculations we get $$R = \frac{i \big(-5 + 3 e^8 \big)}{64 e^4}.$$ That implies $$\int \limits_{-\infty}^{\infty} \frac{\cos2x}{(x^2+4)^2} \, dx = 2 \pi i \frac{i \big(-5 + 3 e^8 \big)}{64 e^4} = -\frac{(-5 + 3 e^8) \pi}{32 e^4}.$$

According to WolframAlpha $$(1)$$ is equal to $$\frac{5 \pi}{16 e^4}.$$

What am I doing wrong?

That would be right if $$\cos$$ was bounded on the upper half plane. But it is not. Use the fact that$$\frac{\cos(2x)}{(x^2+4)^2}=\operatorname{Re}\left(\frac{e^{2ix}}{(x^2+4)^2}\right)$$when $$x\in\mathbb R$$.
• How can I know whether a complex functions is bounded or not? I guess that when I integrate $\cos$ or $\sin$ I have to use the fact you mentioned above? Jul 2, 2019 at 12:08
• As far as I know, there is no general method of finding whether or not a function is bounded on a given subset of its domain. In the case of $\cos$, you can use the fact that, if$t\in(0,\infty)$, then $\cos(it)=\cosh(t)$ and that $\lim_{t\to\infty}\cosh(t)=\infty$. On the other hand, if $\operatorname{Im}(z)\geqslant0$, then$$\lvert e^{iz}\rvert=e^{\operatorname{Re}(iz)}=e^{-\operatorname{Im}(z)}\leqslant1.$$ Jul 2, 2019 at 13:17
You said you were interested in Residues. I will Laplace Transforms (which is residues in disguise). To do so, I will employ Feynman's Trick by first introducing the following function: $$$$F(t) = \int_{-\infty}^\infty \frac{\cos(tx)}{\left(x^2 + 4\right)^2}\:dx$$$$ We observe that your integral $$I = F(2)$$. First we observe that the parity of the integrand is even, thus, $$$$F(t) = 2\int_{0}^\infty \frac{\cos(tx)}{\left(x^2 + 4\right)^2}\:dx$$$$ We now proceed to take the Laplace Transform of $$F(t)$$. To do so, we must employ Fubini's Theorem: \begin{align} \mathscr{L}_{t \rightarrow s}\left[ F(t)\right] &= 2\int_{0}^\infty \frac{\mathscr{L}_{t \rightarrow s}\left[\cos(tx)\right]}{\left(x^2 + 4\right)^2}\:dx = 2 \int_0^\infty \frac{s}{s^2 + x^2} \cdot \frac{1}{(x^2 + 4)^2}\:dx \nonumber \\ &= 2s \int_0^\infty \frac{1}{(s^2 + x^2)(x^2 + 4)^2}\:dx \nonumber \\ &= 2s \int_0^\infty \frac{1}{(s^2 - 4)^2}\left[ \frac{s^2 - 4}{(x^2 + 4)^2} - \frac{1}{x^2 + 4} + \frac{1}{s^2 + x^2}\right]\:dx \nonumber \\ &= \frac{2s}{(s^2 - 4)^2}\left[ (s^2 - 4)\int_0^\infty \frac{1}{(x^2 + 4)^2}\:dx - \int_0^\infty \frac{1}{x^2 + 4}\:dx + \int_0^\infty\frac{1}{s^2 + x^2}\:dx \right] \nonumber \\ &=\frac{2s}{(s^2 - 4)^2} \left[ (s^2 - 4)A - B + C\right] \end{align} We now resolve $$A,B,C$$. We start with $$C$$: $$$$C = \int_0^\infty \frac{1}{s^2 + x^2}\:dx = \left[ \frac{1}{s}\arctan\left(\frac{x}{s}\right) \right]_0^\infty = \frac{1}{s}\cdot \frac{\pi}{2} = \frac{\pi}{2s}$$$$ We observe that $$B$$ is just $$C$$ when $$s = 2$$, thus: $$$$B = \int_0^\infty \frac{1}{2^2 + x^2}\:dx = \frac{\pi}{2\cdot 2} = \frac{\pi}{4}$$$$ For $$A$$ we make the substitution $$x = 2\tan(p)$$: \begin{align} A &= \int_0^\frac{\pi}{2} \frac{1}{\left(4\tan^2(p) + 4\right)^2} \cdot 2\sec^2(p)\:dp = \frac{1}{8}\int_0^\frac{\pi}{2} \cos^2(x)\:dx = \frac{1}{8}\int_0^\frac{\pi}{2} \frac{\cos(2x) + 1}{2}\:dx \nonumber \\ &= \frac{1}{16}\left[ \frac{\sin(2x)}{2} + x \right]_0^\frac{\pi}{2} = \frac{1}{16} \cdot \frac{\pi}{2} = \frac{\pi}{32} \end{align}
Thus, \begin{align} \mathscr{L}_{t \rightarrow s}\left[ F(t)\right] &=\frac{2s}{(s^2 - 4)^2} \left[ (s^2 - 4)A - B + C\right] = \frac{2s}{(s^2 - 4)^2} \left[ (s^2 - 4)\frac{\pi}{32} - \frac{\pi}{4} + \frac{\pi}{2s}\right] \nonumber \\ &= 2 \pi \left[ \frac{1}{32}\cdot\frac{s}{s^2 - 4} - \frac{1}{4}\cdot \frac{s}{(s^2 - 4)^2} + \frac{1}{2} \cdot \frac{1}{(s^2 - 4)^2}\right] \end{align} To resolve $$F(t)$$ we now take the inverse Laplace Transform: \begin{align} F(t) &= 2 \pi \left[ \frac{1}{32}\mathscr{L}^{-1}_{s \rightarrow t}\left[\frac{s}{s^2 - 4}\right] - \frac{1}{4}\mathscr{L}^{-1}_{s \rightarrow t}\left[\frac{s}{(s^2 - 4)^2}\right] + \frac{1}{2} \mathscr{L}^{-1}_{s \rightarrow t}\left[ \frac{1}{(s^2 - 4)^2}\right]\right] \nonumber \\ &= 2 \pi \left[ \frac{1}{32}\cdot \cosh(2t) - \frac{1}{4} \cdot\frac{t\sinh(2t)}{4} + \frac{1}{2}\cdot \frac{2t\cosh(2t) - \sinh(2t)}{16}\right] \nonumber \\ &= \pi \left[ \frac{1}{16}\cdot \cosh(2t) - \frac{t\sinh(2t)}{8} + \frac{2t\cosh(2t) - \sinh(2t)}{16}\right] \nonumber \\ &= e^{-2t}(2t + 1)\frac{\pi}{16} \end{align} Thus, $$$$F(t) = \int_{-\infty}^\infty \frac{\cos(tx)}{\left(x^2 + 4\right)^2}\:dx = e^{-2t}(2t + 1)\frac{\pi}{16}$$$$ Recall that for your integral $$I = F(2)$$, thus, $$$$I = F(2) = e^{-2(2)}(2(2) + 1)\frac{\pi}{16} = 5e^{-4} \frac{\pi}{16}$$$$
I want to write more details, may helps someone. Consider $$\int_C \frac{e^{2iz}}{(z^2+4)^2} \, dz$$ where $$C$$ is the contour, the semicircle in upper half plane (as you have gotten I think), then the integrand has poles at $$z=\pm 2i$$, which it's reside at $$z=2i$$ is $$\operatorname{Res}_{f}(2i) = \lim_{z\to2i} \frac{d}{dz} \bigg((z-2i)^2 \frac{e^{2iz}}{(z-2i)^2(z+2i)^2} \bigg) = \lim_{z\to2i} e^{2iz}\dfrac{2iz-6}{(z+2i)^3}=-i\dfrac{5}{32}e^{-4}$$ then $$\int_{-R}^{R}\dfrac{\cos2z+i\sin2z}{(z^2+4)^2} \, dz+\int_\gamma \frac{e^{2iz}}{(z^2+4)^2} \, dz=2\pi i\times-i\dfrac{5}{32}e^{-4}=\dfrac{5\pi}{16}e^{-4}$$ where $$\gamma$$ is upper semicircle $$|z|=1$$. Finally take the limit $$R\to\infty$$ and \$find the result.