42

I need to find $\displaystyle\int_{-\infty}^{\infty} \frac{\cos x}{x^{2} + a^{2}}\ dx$ where $a > 0$. To do this, I set $f(z) = \displaystyle\frac{\cos z}{z^{2} + a^{2}}$ and integrate along the semi-circle of radius $R$. For the residue at $ia$ I get $\displaystyle\frac{\cos(ia)}{2ia}$. Then letting $R \rightarrow \infty$, the integral over the arc is zero, so I get $\displaystyle\int_{-\infty}^{\infty} \frac{\cos x}{x^{2} + a^{2}}\ dx = 2 \pi i \frac{\cos(ia)}{2ia} = \frac{\pi \cos(ia)}{a}$. But this is supposed to be $\displaystyle\frac{\pi e^{-a}}{a}$, so I am doing something wrong.

In a similar problem, I have to evaluate $\displaystyle\int_{-\infty}^{\infty} \frac{x \sin x}{x^{2} + a^{2}}\ dx$ and get $\pi i \sin(ia)$ whereas this is supposed to be $\pi e^{-a}$. I think I am getting some detail wrong in both cases. Can anyone enlighten me?

Pedro
  • 6,518
  • 4
    The integral over the arc is NOT zero if you are integrating $\cos(x)$ (cosines become hyperbolic cosines for imaginary $x$ which grow exponentially!). It IS, if you replace $\cos x$ with $e^{ix}$ and then take the real part at the very end of the evaluation. – Alex R. May 03 '12 at 20:51
  • I was able to derive the result correctly by replacing $\cos(x)$ with $e^{ix}$ as you said, but I do not understand why the integral would not be zero. The length of the curve is $\pi R$. The supremum would be at most $\frac{1}{R^{2} + a^{2}}$. How come this isn't zero? – Pedro May 03 '12 at 21:03
  • 1
    Again, you are thinking that $\cos(x)$ is between -1 and 1, but this is only true for real $x$. Otherwise you have $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$ so try to plug in $x=a+bi$ and you will see that you are gurunteed to have exponential blowup as $|x|\rightarrow \infty$ along any path away from the real axis – Alex R. May 03 '12 at 21:52
  • You really need either to use $\cos(x)=\frac{\exp(ix)+\exp(-ix)}{2}$ or $\cos(x)=\Re(\exp(ix))$ so that we work with $\exp(ix)$ over the upper half-plane. $\cos(ix)$ blows up exponentially as the imaginary part of $x$ gets large, so we can't use it in the contour integration. – robjohn May 04 '12 at 02:23

5 Answers5

41

Let $\gamma$ be the path along the real axis then circling back counter-clockwise through the upper half-plane, letting the circle get infinitely big. $$ \begin{align} \int_{-\infty}^\infty\frac{\cos(x)}{x^2+a^2}\mathrm{d}x\tag{1} &=\Re\left(\int_{-\infty}^\infty\frac{\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\\tag{2} &=\Re\left(\int_{\gamma}\frac{\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\\tag{3} &=\Re\left(2\pi i\,\mathrm{Res}\left(\frac{\exp(ix)}{x^2+a^2},ia\right)\right)\\\tag{4} &=\Re\left(2\pi i\,\lim_{z\to ia}\frac{\exp(ix)}{x+ia}\right)\\\tag{5} &=\Re\left(2\pi i\,\frac{\exp(-a)}{2ia}\right)\\[3pt] &=\frac{\pi \exp(-a)}{a}\tag6 \end{align} $$ $(1)$: $\Re(\exp(ix))=\cos(x)$
$(2)$: The integral along the circle back through the upper half-plane vanishes as the circle gets bigger.
$(3)$: There is only one singularity of $\dfrac{\exp(ix)}{x^2+a^2}$ in the upper half-plane, at $x=ia$. The integral along $\gamma$ is the residue of $\dfrac{\exp(ix)}{x^2+a^2}$ at $x=ia$.
$(4)$: The singularity of $\dfrac{\exp(ix)}{x^2+a^2}$ at $x=ia$ is a simple pole. We can compute the residue as $\displaystyle\lim_{x\to ia}(x-ia)\frac{\exp(ix)}{x^2+a^2}=\lim_{x\to ia}\frac{\exp(ix)}{x+ia}$.
$(5)$: plug in $x=ia$.
$(6)$: evaluate


Following the same strategy, $$ \begin{align} \int_{-\infty}^\infty\frac{x\sin(x)}{x^2+a^2}\mathrm{d}x &=\Im\left(\int_{-\infty}^\infty\frac{x\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\ &=\Im\left(\int_{\gamma}\frac{x\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\ &=\Im\left(2\pi i\,\mathrm{Res}\left(\frac{x\exp(ix)}{x^2+a^2},ia\right)\right)\\ &=\Im\left(2\pi i\,\lim_{z\to ia}\frac{x\exp(ix)}{x+ia}\right)\\ &=\Im\left(2\pi i\,\frac{ia\exp(-a)}{2ia}\right)\\[6pt] &=\pi \exp(-a) \end{align} $$

robjohn
  • 345,667
  • Would it be valid to preform the integral along the lower half plane moving clockwise? – akozi Feb 04 '20 at 01:50
  • 2
    @akozi: yes. You will have to use $\color{#C00}{-}\Im\left(\int_{-\infty}^\infty\frac{x\exp(\color{#C00}{-}ix)}{x^2+a^2}\mathrm{d}x\right)$ – robjohn Feb 04 '20 at 03:45
22

Although the OP is searching for a way forward using contour integration and the residue theorem, I thought it might be instructive to present an approach that uses real analysis only. To that end, we proceed.


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

$$g(a)=\int_{-\infty}^\infty \frac{\cos(x)}{x^2+a^2}\,dx \tag1$$

Exploiting the even symmetry of the integrand and enforcing the substitution $x\to ax$ reveals

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

Now let $f(a)=\frac {|a|}2 g(a)=\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx$.

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 $(3)$ 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}\text{sgn}(a)+\int_0^\infty \frac{\sin(ax)}{x(x^2+1)}\,dx\tag4 \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 $(4)$ to obtain for $a\ne 0$

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

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

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

Using $f(0)=\pi/2$ and $f'(0^\pm)=\mp \pi/2$, we find that $f(a)=\frac{\pi e^{-|a|}}{2}$. Multiplying by $2/|a|$ yields the coveted result

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

as expected!

Mark Viola
  • 179,405
  • I just corrected I typo, I hope you don't mind. – Shashi Dec 26 '17 at 10:01
  • 1
    @shashi Not at all. Much appreciative. – Mark Viola Dec 26 '17 at 16:14
  • I am sorry,I saw their end part which is for sine function. – Fawad Jan 03 '19 at 16:06
  • (+1) how to generalise this answer for $\int_{0}^{\infty} \frac{cos(bx)}{a^2+x^2} dx$ – M Desmond Mar 07 '19 at 06:04
  • 1
    @mdesmond Have you tried to proceed as in this post? – Mark Viola Mar 07 '19 at 16:08
  • Yeah ! I got it $\int_{0}^{\infty} \frac{cos(bx)}{a^2+x^2} dx=\frac{\pi}{2a} e^{-ab}$ thanks ! – M Desmond Mar 07 '19 at 18:23
  • @MDesmond Pleased to hear! – Mark Viola Mar 07 '19 at 21:43
  • The end of your solution has a gap: you use $f'(0)$ and $f''(0)$, but you never justified that $f(a)$ is differentiable at $a=0$, and in fact $f$ is not differentiable at $a=0$! For all real $a$, $f(a)=(\pi/2)e^{-|a|}$, so the graph of $f$ has a corner at $a=0$: see the picture on page 20 of kconrad.math.uconn.edu/blurbs/analysis/diffunderint.pdf (the integral there in (14.1) is over the whole real line). So you need more work to justify your ODE solution just for $a>0$ (not all real $a$). Using boundary values at $0$ is subtle. See pages 22 and 23 in my link (your $f(a)$ is my $F(t)$). – KCd Dec 12 '22 at 20:09
  • @KCd First, it's a bit curious as to why you singled out this post and NONE of the others, all of which have the SAME answer. Second, note that the OP assumed that $a>0$. So, I suppose you missed that, right? In any case, I edited the post to account for all real $a\ne0$. Thanks for stopping by. I suggest you $(1)$ read the posted question before commenting and $(2)$ STOP singling out a solution!!!!!!!!!!!!!!1 – Mark Viola Dec 12 '22 at 20:44
  • The issue I raised was not the final answer, but a step towards reaching that answer: you relied on a 2nd-order ODE and others did not, and that is where there was a gap. That is why I did not comment on the other answers. Since you were dealing with an ODE only for $a>0$, some justification is needed to bring in values of $f$ or $f’$ as $a\to 0$. Essentially, one should justify that expressions found for $a>0$ have a limit as $a\to 0$ that equals what intuition suggests. This is what I was pointing out before. It does not come up in the other answers here. – KCd Dec 12 '22 at 21:34
  • Uniform convergence for $a$ bounded away from $0$ gets an ODE that is valid for $a>0$. The integral expression for $f(a)$ is UC and hence is continuous. The integral expression for $f'(a)$ in $(4)$ is also UC and hence is continuous. The sign function is continuous from the left and right. This is embedded in the development. What more does one need? – Mark Viola Dec 12 '22 at 22:06
  • Be more explicit that integrals depending on $a$ are continuous not just for $a > 0$ (or $a\not=0$), but also for $a \geq 0$ (or all $a$). For comparison, consider $h(a) := \int_0^\infty x\sin(ax)/(x^2+1),dx$. It converges for all $a$ (as an improper Riemann integral) and intuition suggests to most people that $h(a)$ is continuous for all $a$ "because" $\sin(ax)$ is continuous in $a$, but $h(0) = 0$ and $h(a) = (\pi/2)e^{-a}$ for $a > 0$, so $h(a) \to \pi/2$ as $a \to 0^+$ and $h(0) \not= \pi/2$. That is why I felt computing $C_1$ and $C_2$ at the end should be done a bit more carefully. – KCd Dec 12 '22 at 23:30
  • Look @Kcd . I've had enough. If you or other readers can't understand basic calculus, then that's unfortunate. The proof is spelled out. You have a solution that IS continuous from the right and from the left due to UC. Do you just not understand? Or are you being difficult to deal with? – Mark Viola Dec 12 '22 at 23:56
7

Let us integrate along the contour $\Gamma$, which is the semicircle of radius $R$ described above. Let $C_R$ be the arc of the contour with radius $R$. We may say that

$$\oint_{\Gamma}\frac{\cos z}{z^2+a^2}\, dz=\int_{-R}^{R}\frac{\cos x}{x^2+a^2}\, dx+\int_{C_R}\frac{\cos z}{z^2+a^2}\, dz$$

Note that $\cos x = \operatorname{Re}\,(e^{ix})$. Thus

$$ f(z)=\frac{\operatorname{Re}\,(e^{iz})}{z^2+a^2} = \operatorname{Re}\,\left(\frac{e^{iz}}{(z+ia)(z-ia)}\right) $$

Because $f(z)$ can be written ias $g(z)e^{iaz}$ and suffices all of the conditions of Jordan's lemma, we see that the integral along the arc tends to zero when $R\to \infty$. Thus

$$ \lim_{R\to\infty}\oint_{\Gamma}\frac{\cos z}{z^2+a^2}\, dz=\lim_{R\to\infty} \int_{-R}^{R}\frac{\cos x}{x^2+a^2}\, dx+0 $$

To solve the LHS, we find the residues. The residue, similar to the one you found is $$ b=\frac{e^{i^2a}}{ia+ia}=\frac{e^{-a}}{2ia} $$

Thus

$$ \displaystyle\int_{-\infty}^{\infty} \frac{\cos x}{x^{2} + a^{2}}\, dx= \lim_{R\to\infty}\oint_{\Gamma}\frac{\cos z}{z^2+a^2}\, dz=\operatorname{Re}\,\left(\displaystyle\int_{-\infty}^{\infty} \frac{e^{iz}}{z^{2} + a^{2}}\, dz\right) =\operatorname{Re}\,(2\pi ib)=\operatorname{Re}\,(2\pi i\frac{e^{-a}}{2ia}) = \frac{\pi e^{-a}}{a} $$


Similarly, with $\displaystyle\int_{-\infty}^{\infty} \frac{x \sin x}{x^{2} + a^{2}}\ dx$ we change $\sin x$ to $\operatorname{Im}\,(e^{ix})$ and make the function complex-valued.

$$g(z)=\frac{z\sin z}{z^2+a^2}=\operatorname{Im}\,\left(\frac{ze^{iz}}{(z+ia)(z-ia)}\right)$$

Jordan's lemma again can be used to show that the integral around the arc tends to zero as $R\to\infty$. We then proceed to find the residues. The residue of pole $z_1=ia$ is

$$b=\frac{iae^{-a}}{2ia}=\frac{e^{-a}}{2}$$

$z_1$ is the unique pole in the contour, so upon multiplying its residue, $b$, with $2\pi i$ we find: $$ \displaystyle\int_{-\infty}^{\infty} \frac{x \sin x}{x^{2} + a^{2}}\, dx= \lim_{R\to\infty}\oint_{\Gamma} \frac{x \sin x}{x^{2} + a^{2}}\, dz= \operatorname{Im}\,\left(\displaystyle\int_{-\infty}^{\infty} \frac{ze^{iz}}{(z+ia)(z-ia)}\, dz\right)= \operatorname{Im}\,(2\pi ib)= \operatorname{Im}\,(2\pi i \frac{e^{-a}}{2})= \operatorname{Im}\,(\pi e^{-a}i)= \pi e^{-a} $$

Argon
  • 25,303
4

The integrals $\int_{0}^{\infty}\frac{\cos (x)}{x^{2}+a^{2}} \, dx$ and $\int_{0}^{\infty} \frac{x \sin (x)}{x^{2}+a^{2}} \, dx$ are specific cases of the integral $$I(s,a) = \int_{0}^{\infty} x^{s-1} \, \frac{\sin\left(\frac{\pi s}{2}-x \right)}{x^{2}+a^{2}} \, dx = \frac{\pi}{2} \, a^{s-2} e^{-a}, \quad 0 < s< 3, \ a>0. \tag{1}$$

(This integral appears as an exercise on page 154 of the textbook An Introduction to the Theory of Functions of a Complex Variable by E.T. Copson. Copson attributes it to Cauchy.)

Using the branch of $z^{s-1}$ that corresponds to the branch of the logarithm where $- \frac{\pi}{2} <\arg(z) \le \frac{3 \pi}{2}$, we can show $(1)$ by integrating the function $$f(z) =z^{s-1} \, \frac{e^{- i \pi s/2}e^{iz}}{z^{2}+a^{2}} $$ counterclockwise around an indented contour that consists of the real axis and the large semicircle above it. (The indentation is needed to avoid the branch point at the origin.)

Near the origin, $f(z)$ behaves like a constant times $z^{s-1}$. As long as $s >0$, the contribution from the semicircular indentation about the branch point at the origin will vanish as its radius goes to zero.

So letting the radius of the large semicircle go to $\infty$ and applying Jordan's lemma, we get, for $0 < s< 3$, $$\begin{align} \int_{-\infty}^{0} (|x|e^{i \pi})^{s-1} \, \frac{e^{- i \pi s/2} e^{ix}}{x^{2}+a^{2}} \, dx + \int_{0}^{\infty} x^{s-1} \frac{e^{- i \pi s/2}e^{ix}}{x^{2}+a^{2}} \, dx &= 2 \pi i \operatorname{Res} [f(z), e^{i \pi /2}a] \\ &= 2 \pi i \left( (e^{i \pi /2}a)^{s-1} \frac{e^{- i \pi s/2} e^{-a}}{2ia}\right)\\ & = \frac{\pi}{i} \, a^{s-2} e^{-a}. \end{align}$$

But the left side of the equation can be written as $$-\int_{0}^{\infty} u^{s-1} \, \frac{e^{i \pi s/2}e^{-iu}}{u^{2}+a^{2}} \, du+ \int_{0}^{\infty} x^{s-1} \frac{e^{- i \pi s/2}e^{ix}}{x^{2}+a^{2}} \, dx = 2i \int_{0}^{\infty} x^{s-1} \, \frac{\sin\left(x- \frac{\pi s}{2} \right)}{x^{2}+a^{2}} \, dx.$$ The result then follows.

As a side note, notice that the value of $I(s,1)$ does not depend on $s$.

3

Following method makes no use of contour integration and Leibniz integral rule, $\mathcal{P}\{\}$ is Cauchy principal value.

Assume $a>0$,

$\int_{-\infty}^\infty\frac{\cos(x)}{x^2+a^2}\text{d}x=\frac{1}{2a}\Re\Bigg\{\int_{-\infty}^\infty\left(\frac{e^{xi}}{a+xi}+\frac{e^{xi}}{a-xi}\right)\text{d}x\Bigg\}$

$$\operatorname{Ei}(z):=-\mathcal{P}\Bigg\{\int_1^\infty\frac{e^{zt}}{t}\text{d}t\Bigg\}$$

\begin{align*}\operatorname{Ei}(z)-\operatorname{Ei}(\overline{z})=-2i\mathcal{P}\Bigg\{\int_1^{\infty}\frac{e^{\Re(z)t}\sin(\Im(z)t)}{t} \text{d}t\Bigg\}\\=-2i\mathcal{P}\Bigg\{\int_{\Im(z)}^\infty\frac{e^{\frac{\Re(z)}{\Im(z)}t}\sin(t)}{t}\text{d}t\Bigg\}\end{align*}

Let $z\mapsto \overline{z}$,

$$\operatorname{Ei}(z)-\operatorname{Ei}(\overline{z})=2i\mathcal{P}\Bigg\{\int_{-\Im(z)}^\infty\frac{e^{-\frac{\Re(z)}{\Im(z)}t}\sin(t)}{t}\text{d}t\Bigg\}$$

We have for $\Re(z)>0$,

$$\lim_{\Im(z)\to\infty}\operatorname{Ei}(z)-\operatorname{Ei}(\overline{z})=2\pi i$$

Clearly for $\Re(z)<0$,

$$\lim_{\Im(z)\to\infty}\operatorname{Ei}(z)-\operatorname{Ei}(\overline{z})=0$$

Using above limits and the fact that $\operatorname{Ei}'(z)=\frac{e^z}{z}$,

\begin{align*}\int_{-\infty}^\infty\frac{e^{xi}}{a+xi}\text{d}x=-ie^{-a}\int_{a-\infty i}^{a+\infty i}\frac{e^t }{t} \text{d}t=-ie^{-a}\lim_{z\to\infty}\left(\operatorname{Ei}(a+zi)-\operatorname{Ei}(a-zi)\right)\\=2\pi e^{-a}\end{align*} \begin{align*}\int_{-\infty}^\infty\frac{e^{xi}}{a-xi}\text{d}x=ie^{a}\int_{-a-\infty i}^{-a+\infty i}\frac{e^{t}}{t}\text{d}t=ie^a\lim_{z\to\infty}\left(\operatorname{Ei}(-a+zi)-\operatorname{Ei}(-a-zi)\right)\\=0\end{align*}

$$\implies\int_{-\infty}^\infty\frac{\cos(x)}{x^2+a^2}\text{d}x=\frac{\pi}{ae^a}$$