# Evaluating $\int_{-\infty}^\infty\frac{\cos(2x)}{x^2+4}\:\mathrm{d}x$

As stated in the title, I want to evaluate the integral $$I=\int_{-\infty}^\infty\frac{\cos(2x)}{x^2+4}\:\mathrm{d}x$$ I'm pretty sure it evaluates to $$\frac{\pi}{2e^4}$$ But I'm not sure how to evaluate it.

I have read an Instagram post where 3 different methods are provided for proving that $$$$I(t)=\int_{-\infty}^\infty\frac{\cos(tx)}{x^2+1}\:\mathrm{d}x=\frac{\pi}{e^t}$$$$ and I think similar logic can be applied here, but I am not sure how yet.

One of the methods mentioned in the post uses laplace transform to prove it but it's a little bit long. I'm wondering if there's any elegant method for evaluating $$I$$

I encountered this integral when I tried to solve this integral from one of the members of the Instagram math community. $$\omega=\int_0^{\infty}\frac{x^2-4}{x^2+4}\:\frac{\sin 2x}{x}\mathrm{d}x$$ I first split the integral, used a property of laplace transform and some properties of the sine integral then used integration by parts and got to here $$\omega=\frac{\pi}{2}-\left(2\int_{-\infty}^\infty\frac{\cos(2s)}{s^2+4}\:\mathrm{d}s+\pi\right)$$ Thank you so much for your help and attention! (BTW I'm not so proficient in complex analysis so I would prefer a solution without one :P)

• This is a stab in the dark but my guess is that this is a Cauchy Theorem problem (complex analysis). Jul 13, 2020 at 14:45
• The easiest way is using the residue theorem from complex analysis. Are you familiar with it? The answer is indeed $\frac{\pi}{2e^4}$.
– Mark
Jul 13, 2020 at 14:46
• @Mark I'm not so familiar with it but I'll have a look at it and learn more about it. Jul 13, 2020 at 14:48
• $I=\Re \int_{-\infty}^{\infty}\frac{e^{2ix}}{x^2+4} \,dx$ Jul 13, 2020 at 16:30

It can be solved using differentiation under the integral sign. Consider the following integral:

$$$$I(t)=\int\limits_{-\infty}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx = 2\int\limits_{0}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx$$$$

for any positive real $$t$$ and $$k$$. The first derivative with respect to $$t$$ is:

$$$$I'(t)= -2\int\limits_{0}^{+\infty} \frac{x\sin(tx)}{x^{2}+k} \,dx$$$$

$$$$\Leftrightarrow \hspace{.3cm}I'(t)= -2\int\limits_{0}^{+\infty} \frac{x^{2}\sin(tx)}{x(x^{2}+k)} \,dx$$$$

$$$$\Leftrightarrow \hspace{.3cm}I'(t)= -2\int\limits_{0}^{+\infty} \frac{(x^{2}+k-k)\sin(tx)}{x(x^{2}+k)} \,dx$$$$

$$$$\Leftrightarrow \hspace{.3cm}I'(t)= -2\int\limits_{0}^{+\infty} \frac{\sin(tx)}{x} \,dx +2k\int\limits_{0}^{+\infty} \frac{\sin(tx)}{x(x^{2}+k)} \,dx$$$$

The first one is just the sine integral as $$x\rightarrow \infty$$ and it is known to converge to $$\frac{\pi}{2}$$. Thus:

$$$$I'(t)= 2k\int\limits_{0}^{+\infty} \frac{\sin(tx)}{x(x^{2}+k)} \,dx -\pi$$$$

Differentiating once more with respect to $$t$$ yields:

$$$$I''(t)= 2k\int\limits_{0}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx$$$$

$$$$\Leftrightarrow \hspace{.3cm}I''(t)-kI(t)=0$$$$

The general solution to the ODE is:

$$$$I(t)=c_{1}e^{\sqrt{k}t}+c_{2}e^{-\sqrt{k}t}$$$$

Plugging some conditions $$\left(I(t=0) \,\,\text{and}\,\, I'(t=0)\right)$$ allows you to find that $$c_{1}=0$$ and that $$c_{2}=\frac{\pi}{\sqrt{k}}$$. Then:

$$$$\boxed{\int\limits_{-\infty}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx = \frac{\pi}{\sqrt{k}}e^{-\sqrt{k}t}}$$$$

for positive real values of $$t$$ and $$k$$. If you plug $$t=2$$ and $$k=4$$, you obtain the desired result.

Too long for a comment, just reducing this case, to the case you know from instagram and some notes.

For $$t \in \mathbb R,a > 0$$ let:$$I(t,a) = \int_{-\infty}^\infty \frac{\cos(tx)}{x^2+a^2}dx$$

Note that it converges for every $$t \in \mathbb R,a> 0$$. Taking substitution $$x=ay$$, $$dx=ady$$ we get: $$I(t,a) = \int_{-\infty}^\infty \frac{\cos(aty)}{a^2y^2+a^2}(ady) = \frac{1}{a} \int_{-\infty}^\infty \frac{\cos(aty)}{y^2+1}dy = \frac{1}{a} \cdot I(ta,1)$$

So it boils down to evaluate $$I(s) := I(s,1) = \int_{-\infty}^\infty \frac{\cos(sx)}{x^2+1}dx$$

There are many ways of calculating it. Probably the easiest one might be either complex analysis or noticing it is almost the characteristic function of Cauchy distribution (it does not require $$"$$complex analysis$$"$$ (even though there are complex numbers under integral sign) to calculate, however it would be a long road for you if you're not familiar with notion of characteristic function and inverse formula for them. It can be calculated via taking derivative and manipulations, however one need to be a bit careful with showing we can go with derivative under integral sign, since $$\frac{d}{ds}(\frac{\cos(sx)}{x^2+1}) = -\frac{x\sin(xs)}{x^2+1}$$ and integral of the latter does not converge when treated as improper lebesgue integral on the whole line (so dominated convergence theorem cannot be applied straightforward). However, it does converge when treated as improper Riemann integral or limit of proper Lebesgue integrals, so it actually makes sense. We'll proceed by a bit different way. It is amazing what a substitution can do:

Let $$s>0$$ and take substitution: $$y=sx, dy = sdx$$, then: $$I(s) = \int_{-\infty}^\infty \frac{s\cos(y)}{s^2+y^2}dy$$

Derivative of function under integral (with respect to $$s$$) yields $$\frac{\cos(y)(s^2+y^2) - 2s^2\cos(y)}{(s^2+y^2)^2} = \frac{cos(y)(y^2-s^2)}{(s^2+y^2)^2}$$, which is integrable on the whole line, treated as Lebesgue improper integral, so dominated convergence theorem allows us to go with derivative under integral. Taking integral one more time (justification is the same) we get: $$\frac{d^2}{ds^2} I(s) = \int_{-\infty}^\infty \cos(y) \cdot (\frac{d^2}{ds^2} \frac{s}{y^2+s^2}) dy = - \int_{-\infty}^\infty \cos(y) \cdot (\frac{d^2}{dy^2} \frac{s}{y^2+s^2})dy$$ Integrating by parts gives us: $$\frac{d^2}{ds^2}I(s) = -\frac{d}{dy}(\frac{s}{y^2+s^2})\cos(y)|_{-\infty}^\infty -\int_{-\infty}^\infty \sin(y) \frac{d}{dy}(\frac{s}{y^2+s^2})dy$$ I'll leave calculations so that boundary terms goes to zero. One time again: $$\frac{d^2}{ds^2}I(s) = - \sin(y)\frac{s}{y^2+s^2}|_{-\infty}^\infty + \int_{-\infty}^\infty \frac{s\cos(y)}{y^2+s^2}dy = I(s)$$

Hence the general solution is $$I(s) = Ae^s + Be^{-s}$$ for some constants $$A,B$$. We can find them by letting $$s \to \infty$$ and $$s \to 0^+$$. Indeed, back to first form of integral, by dominated convergence $$\lim_{s \to 0^+} I(s) = \lim_{s \to 0^+} \frac{\cos(sx)}{x^2+1}dx = \pi$$, so $$A + B = \pi$$.

To justify limit as $$s \to \infty$$ we use integration by parts with $$cos(sx)$$ and $$\frac{1}{x^2+1}$$, getting: $$\lim_{s \to \infty}I(s) = \lim_{s \to \infty} \int_{-\infty}^\infty \frac{\cos(sx)}{x^2+1}dx = \lim_{s \to \infty} \int_{-\infty}^\infty \frac{2x\sin(sx)}{s(x^2+1)^2}dx$$ which tends to zero, since we can bound $$|\sin(sx)| \le 1$$, and we have something that tends to zero left. But if $$Ae^s + Be^{-s} \to 0$$ as $$s \to \infty$$, then $$A=0$$. So $$B=\pi$$.

And we get $$I(s) = \pi e^{-s}$$ for $$s > 0$$ and by symetry and easy calculation for $$s=0$$, we get for any $$s \in \mathbb R$$: $$I(s) = \pi e^{-|s|}$$

This means that $$I(t,a) = \frac{1}{a} I(ta,1) = \frac{\pi}{a}e^{-|ta|}$$ So your integral is equal indeed, to $$\frac{\pi}{2e^4}$$

I guess this might also help (no need to evaluate the derivative of Integral). The Fourier Cosine Integral is given by:

$$f(w) = \int_{0}^{\infty }A(x)\cos(xw)dx$$

where

$$A(x) = \frac{2}{\pi}\int_{0}^{\infty }f(w)\cos(xw)dw$$

Now let,

$$f(w) = \frac{\pi}{2k}e^{-kw}$$

Therefore,

$$A(x) = \frac{2}{\pi}\int_{0}^{\infty }\frac{\pi}{2k}e^{-kw}\cos(wx)dw$$

$$A(x) = \frac{1}{k}\int_{0}^{\infty }e^{-kw}\cos(wx)dw$$

In order to solve the above integral, we need the following equation (more on this can be found here):

$$\int{e^{aw}\cos({bw})dw}= \dfrac{e^{aw}}{a^{2}+b^{2}}[a\cos(bw)+b\sin(bw)] + C$$

If we substitute $$a = -k$$ and $$b = x$$, we get:

$$\int_{0}^{\infty } e^{-kw} \cos(xw) dw = \frac{k}{x^2+k^2}$$

Therefore,

$$A(x) = \frac{1}{x^2+k^2}$$

and therefore,

$$f(w) = \int_{0}^{\infty }A(x)\cos(xw)dx$$

can be rewritten as:

$$\int_{0}^{\infty }\frac{\cos(xw)}{x^2+k^2}dx = \frac{\pi}{2k}e^{-kw}$$

Now,

$$\int_{-\infty}^{\infty }\frac{\cos(xw)}{x^2+k^2}dx = 2\int_{0}^{\infty }\frac{\cos(xw)}{x^2+k^2} = \frac{\pi}{k}e^{-kw}$$

Now simply substitute w = 2 and k = 2 to get,

$$\int_{-\infty}^\infty\frac{\cos(2x)}{x^2+4}\:\mathrm{d}x = \frac{\pi}{2e^4}$$