# How do you Evaluate $\int_{-\infty}^\infty \frac{\cos(x)}{x^2+1}dx$ Without Using Residue Calculus

So I'm having trouble computing this integral:

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

After seeing some other answers on this website, I've realized that many people are using residues to get an answer. However, I know nothing about complex analysis, so I wanted to know if there is a better way of doing it without it.

I started by finding the indefinite integral which is:

$$-\dfrac{\sinh\left(1\right)\left(\operatorname{Si}\left(x+\mathrm{i}\right)+\operatorname{Si}\left(x-\mathrm{i}\right)\right)-\mathrm{i}\cosh\left(1\right)\left(\operatorname{Ci}\left(x+\mathrm{i}\right)-\operatorname{Ci}\left(x-\mathrm{i}\right)\right)}{2}$$

but finding what this function comes out to when finding the limit of it towards $\infty$ and $-\infty$ I get $-\pi\sinh(1)$

Now, I could be very wrong with both the indefinite integral and the value. Am I doing something wrong? Am I forgetting to take into account something I should be? Thanks in advanced!

• Your antiderivative seems fine. And if we denote this by $I(x)$ with aid of Mathematica, it indeed yields the correct value as we have $$\lim_{x\to\infty}I(x) = -\frac{\pi}{2}\sinh 1, \qquad \lim_{x\to-\infty} I(x) = \frac{\pi}{2}\sinh 1 - \pi \cosh 1.$$ So my bet is that you forgot to take the branch cut of $\operatorname{Ci}$ into consideration Nov 5, 2017 at 1:01
• @SangchulLee Huh, that's odd, do you know how to come about with the answer for the one with x approaching negative infinity? Also, I'm pretty sure I took account of the branch cut of Ci Nov 5, 2017 at 1:09
• In fact the best explanation for this comes from complex analysis. The extra factor appears when the contour crosses the singularity of $\frac{\cos z}{z}$ at $z = 0$. I am currently working to find an explanation that does not use complex analysis. Nov 5, 2017 at 1:16
• Here is one explanation: for $x \in \mathbb{R}$ we have $$\operatorname{Ci}(x\pm i) = \operatorname{Ci}(-x\mp i) - \operatorname{Ci}(\mp i) + \operatorname{Ci}(\pm i).$$ So if you know that $\operatorname{Ci}(x\pm i) \to 0$ as $x\to\infty$, it follows that $\operatorname{Ci}(x\pm i) \to \pm (\operatorname{Ci}(i) - \operatorname{Ci}(-i))$ as $x\to-\infty$. Now the answer follows from $$\operatorname{Ci}(i) - \operatorname{Ci}(-i) = i\pi.$$ Nov 5, 2017 at 1:48
• @SangchulLee That's interesting, because actually replacing $i\pi$ for the definite integral calculation, it still doesn't seem to give $\frac{\pi}{e}$ Also want to preface that I'm still probably doing it wrong. Nov 5, 2017 at 2:00

Here's a much nicer way using the standard differentiation under the integral sign technique. Let's first consider the general case$$I(a)=\int\limits_{-\infty}^{\infty}\frac {\cos ax}{1+x^2}\, dx$$Through integration by parts on $u=1/(1+x^2)$ and $dv=\cos ax\, dx$, we have$$a\cdot I(a)=2\int\limits_{-\infty}^{\infty}\frac {x\sin ax}{(1+x^2)^2}\, dx$$Differentating with respect to $a$, we obtain$$a\cdot I'(a)+I(a)=2I(a)-2\int\limits_{-\infty}^{\infty}\frac {\cos ax}{(1+x^2)^2}\, dx$$Combining like terms, we realize that the right-hand side is similar to what we obtained before. So differentiating (again), we finally see that$$a\cdot I''(a)=-2\int\limits_{-\infty}^{\infty}\frac {x\sin ax}{(1+x^2)^2}\, dx=a\cdot I(a)$$Solving the simple differential equation that follows, the general solution is $I(a)=C_1e^{a}+C_2e^{-a}$. When we set $a=0$, we see that $C_1=0$ and similarly, $C_2=\pi$ for $a\to\infty$. Therefore, the general solution is$$\int\limits_{-\infty}^{\infty}\frac {\cos ax}{1+x^2}\, dx=\color{blue}{\frac {\pi}{e^{|a|}}}$$

• A way of using the Feynman's Trick would really clarify actually if you could do that. Nov 5, 2017 at 1:16
• @TomHimler That's the problem. I'm not sure what's supposed to be the correct substitution. I have a gut-feeling that it can be integrated using Feynman's trick, probably because I've seen a variant somewhere where differentiation can be used, but I'm not sure. I will update the answer as I make progress. Nov 5, 2017 at 1:17
• I would really appreciate it if you can. In the meantime, I'll try to see if I can do it as well. Nov 5, 2017 at 1:18
• @TomHimler I think I've got it. Although it does involve a little bit of differential equations, namely solving$$I''(a)-I(a)=0$$You can do that, right? Nov 5, 2017 at 1:27
• Yes, thank you, I really appreciate the effort you've made to help me. Nov 5, 2017 at 1:33

Step 1. Let $s > 0$ and $\beta \in \mathbb{C}$. Then using the gaussian integral $\int_{-\infty}^{\infty} e^{-sx^2} \, dx = \sqrt{\pi/s}$, we have

\begin{align*} \int_{-\infty}^{\infty} e^{-s(x-\beta)^2} \, dx &= \int_{-\infty}^{\infty} \bigg( e^{-sx^2} + \int_{0}^{1} \overbrace{ 2s\beta(x-\beta t) e^{-s(x-\beta t)^2} }^{= \frac{\partial}{\partial t} e^{-s(x-\beta t)^2}} \, dt \bigg) \, dx \\ &= \sqrt{\frac{\pi}{s}} -\beta \int_{0}^{1} \int_{-\infty}^{\infty} (-2s)(x-\beta t) e^{-s(x-\beta t)^2} \, dx dt \quad {\small(\because\text{Fubini})}\\ &= \sqrt{\frac{\pi}{s}} -\beta \int_{0}^{1} \left[ e^{-s(x-\beta t)^2} \right]_{x=-\infty}^{x=\infty} \, dt = \bbox[border:1px dashed green,6px]{ \sqrt{\frac{\pi}{s}} }. \end{align*}

Then plugging $\beta=\pm\mathrm{i}/2s$, we check that

$$\int_{-\infty}^{\infty} e^{-sx^2}\cos(x) \, dx = \sqrt{\frac{\pi}{s}} e^{-1/4s}.$$

Step 2. Using the previous step,

\begin{align*} I := \int_{-\infty}^{\infty} \frac{\cos x}{x^2+1} \, dx &= \int_{-\infty}^{\infty} \cos x \left( \int_{0}^{\infty} e^{-(x^2+1)s} \, ds \right) \, dx \\ &= \int_{0}^{\infty} \left( \int_{-\infty}^{\infty} e^{-sx^2}\cos(x) \, dx \right) e^{-s} \, ds \quad {\small(\because\text{Fubini})}\\ &= \int_{0}^{\infty} \sqrt{\frac{\pi}{s}} e^{-\left( s + \frac{1}{4s}\right)} \, ds \\ &= \int_{0}^{\infty} \sqrt{2\pi} e^{-\frac{1}{2}\left( t^2 + \frac{1}{t^2}\right)} \, dt. \quad {\small(2s=t^2)} \end{align*}

Finally here is a very slick way of computing the last integral. Applying the substitution $t\mapsto 1/t$ shows that

$$\int_{0}^{\infty} e^{-\frac{1}{2}\left( t^2 + \frac{1}{t^2}\right)} \, dt = \int_{0}^{\infty} \frac{1}{t^2} e^{-\frac{1}{2}\left( t^2 + \frac{1}{t^2}\right)} \, dt.$$

So averaging,

$$I = \sqrt{\frac{\pi}{2}} \int_{0}^{\infty} \left(1 + \frac{1}{t^2}\right) e^{-\frac{1}{2}\left( t - \frac{1}{t}\right)^2 - 1} \, dt.$$

Finally, applying the substitution $u = t - \frac{1}{t}$ proves

$$I = \sqrt{\frac{\pi}{2}} \int_{-\infty}^{\infty} e^{-\frac{u^2}{2} - 1} \, du = \frac{\pi}{e}.$$

• I think you’ve forgotten to pull $e^{-1}$ out of the last integral Nov 5, 2017 at 1:44
• @adfriedman, Oh yes, I made a silly typo by writing $2$ instead of $e$. Nov 5, 2017 at 1:49

Let $f(a)$ be given by the convergent improper integral

$$f(a)=\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx \tag1$$

Since the integral $\int_0^\infty \frac{x\sin(ax)}{x^2+1}\,dx$ is uniformly convergent for $|a|\ge \delta>0$, we may differentiate under the integral in $(1)$ for $|a|>\delta>0$ to obtain

\begin{align} f'(a)&=-\int_0^\infty \frac{x\sin(ax)}{x^2+1}\,dx\\\\ &=-\int_0^\infty \frac{(x^2+1-1)\sin(ax)}{x(x^2+1)}\,dx\\\\ &=-\int_0^\infty \frac{\sin(ax)}{x}\,dx+\int_0^\infty \frac{\sin(ax)}{x(x^2+1)}\,dx\\\\ &=-\frac{\pi}{2}+\int_0^\infty \frac{\sin(ax)}{x(x^2+1)}\,dx\tag2 \end{align}

Again, since the integral $\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx$ converges uniformly for all $a$, we may differentiate under the integral in $(2)$ to obtain

$$f''(a)=\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx=f(a)\tag 3$$

Solving the second-order ODE in $(3)$ reveals

$$f(a)=C_1 e^{a}+C_2 e^{-a}$$

Using $f(0)=\pi/2$ and $f'(0)=-\pi/2$, we find that $C_1=0$ and $C_2=\frac{\pi}{2}$ and hence $f(a)=\frac{\pi e^{-a}}{2}$. Setting $a=1$ and exploiting even symmetry yields the coveted result

$$\bbox[5px,border:2px solid #C0A000]{\int_{-\infty}^\infty \frac{\cos(x)}{x^2+1}\,dx=\frac{\pi}{e}}$$

as expected!

Do you know the Fourier inversion theorem ? $$\frac{2}{1+x^2} = \int_{-\infty}^\infty e^{-|t|}e^{i x t}dt$$ where $\frac{d}{dt} e^{-|t|} \in L^1$ thus $$\int_{-\infty}^\infty \frac{2 e^{-i xu}}{1+x^2}dx = \lim_{A \to \infty} \int_{-A}^A e^{-ixu} (\int_{-\infty}^\infty e^{-|t|}e^{i x t}dt)dx=\lim_{A \to \infty}\int_{-\infty}^\infty e^{-|t|} A\frac{\sin(A(t-u))}{A(t-u)}dt$$ which converges to $2\pi e^{-|u|}$ by integration by parts