Weird integral whose simplicity is only apparent in the complex plane

Every so often we come across an integral that seems absolutely impossible on its face, but is easily attacked – in fact, is custom designed – for the residue theorem. I wonder why a first year complex analysis class doesn’t show off this case as Exhibit A in why the residue theorem is so useful.

OK, so here’s the integral:

$$\int_{-\infty}^{\infty} \frac{dx}{\left ( e^x+x+1\right )^2+\pi^2} $$

So what’s wrong? Well, the combination of $x$ and the exponential is ugly. There is no obvious symmetry that helps to keep us strictly in the positive numbers, nor is there any obvious scale that allows for, say, Taylor expansion.

But a very quick look outside the box shows that this integral can be attacked by extension into the complex plane. The reason is that $i \pi$ is a pole of the integrand. (Try it out.) $-i \pi$, too. And that’s all, it turns out. So the residue theorem should work here just fine.

I am going to take a slight detour, while still using the residue theorem. First sub $x=\log{u}$ in the integral and get that the integral is equal to

$$\int_0^{\infty} \frac{du}{u \left [(u+1+\log{u})^2 + \pi^2\right ]} $$

Now consider the following contour integral in the complex plane

$$\oint_C \frac{dz}{z (z+1+\log{z}-i \pi)} $$

where $C$ is a keyhole contour of outer radius $R$ and inner radius $\epsilon$ about the positive real axis. The contour integral is equal to

$$\int_{\epsilon}^R \frac{dx}{x (x+1+\log{x}-i \pi )} + i R \int_0^{2 \pi} d\theta \, \frac{e^{i \theta}}{R e^{i \theta} (R e^{i \theta} + 1 + \log{\left ( R e^{i \theta}\right )-i \pi)}} \\ + \int_R^{\epsilon} \frac{dx}{x (x+1+\log{x}+i \pi )}+i \epsilon \int_{2 \pi}^0 d\phi \, \frac{e^{i \phi}}{\epsilon e^{i \phi} (\epsilon e^{i \phi} + 1 + \log{\left ( \epsilon e^{i \phi}\right )-i \pi)}} $$

In the limit as $R \to \infty$, the magnitude of the second integral vanishes as $2 \pi/R$. As $\epsilon \to 0$, the magnitude of the fourth integral vanishes as $2 \pi/\log{\epsilon}$. Thus, in this limit, the contour integral is equal to

$$\int_0^{\infty} \frac{dx}{x(x+1+\log{x}-i \pi)} – \int_0^{\infty} \frac{dx}{x(x+1+\log{x}+i \pi)} = i 2 \pi \int_0^{\infty} \frac{dx}{x \left[(x+1+\log{x})^2+\pi^2\right]}$$

By the residue theorem, the contour integral is also equal to $i 2 \pi$ times the sum of the residues at the poles of the integrand inside $C$, i.e. outside the origin and the positive real axis. Now, the only pole inside $C$ is at $z=-1$ (this may be verified by examining the polar form of $z$). Also, the pole at $z=-1$ is a double pole; this may be seen by observing that $y+\log{(1-y)} \sim -y^2/2$ as $y \to 0$.

Thus, we need to compute the residue at $z=-1$ as follows:

$$\begin{align}\operatorname*{Res}_{z=-1} \frac{1}{z (z+1+\log{z}-i \pi)} &= \lim_{z\to -1}\left [\frac{d}{dz} \frac{(z+1)^2}{z (z+1+\log{z}-i \pi)} \right ]\\ &= -\lim_{y\to 0} \left [\frac{d}{dy} \frac{y^2}{(1-y) [y+\log{(1-y)}]} \right ] \\ &= -\lim_{y\to 0} \left [ \frac{y (2 y+(2-y) \log (1-y))}{(1-y)^2 (y+\log (1-y))^2}\right ] \end{align}$$

This limit is a tricky one. The numerator may be expanded in a series as follows:

$$\begin{align}-y (2 y +(2-y) \log{(1-y)}) &= -y \left (2 y – 2 y + y^2 – y^2 – \frac{2}{3} y^3 + \frac12 y^3 + O(y^4)\right )\\ &= \frac16 y^4 + O(y^5)\end{align}$$

The denominator is $y^4/4+O(y^5)$; thus we may say that the limit in question, and therefore the residue, is $2/3$. By the residue theorem

$$i 2 \pi \int_0^{\infty} \frac{dx}{x \left[(x+1+\log{x})^2+\pi^2\right]} = i 2 \pi \frac{2}{3}$$


$$\int_{-\infty}^{\infty} \frac{dx}{(e^x+x+1)^2+\pi^2} = \frac{2}{3}$$

Wow. I’ll bet you didn’t guess that. I dare you to find a real method of deriving this that is even half as pretty as this complex method. I was not successful of finding any real method to evaluate this, but maybe the reader will have better luck than me.

Of course, one can apply the residue theorem directly on the given integral by recognizing the pole at $z=i \pi$. Thus, consider a contour integral

$$\oint_C \frac{dz}{(e^z+z+1)^2+\pi^2} $$

where $C$ is a semicircle of radius $R$ in the upper half plane. (The pole at $z=-i \pi$ with the contour being in the lower half plane works as well.) It is straightforward to show that the integral about the arc vanishes as $R \to \infty$. The integral is then simply $i 2 \pi$ times the residue at $z=i \pi$, which is a double pole. I leave this as an exercise for the reader.

Expansions of $e^x$

A very basic question was asked recently: What is a better approximation to $e^x$, the usual Taylor approximation, or a similar approximation involving $1/e^{-x}$? More precisely, given an integer $m$, which is a better approximation to $e^x$: $$f_1(x) = \sum_{k=0}^m \frac{x^k}{k!} $$ or $$f_2(x) = \frac1{\displaystyle \sum_{k=0}^m \frac{(-1)^k x^k}{k!}} $$ The answer is amazingly simple: […]

Real evaluation of an improper log integral

The problem posed in M.SE concerns real methods of evaluating $$\int_0^{\infty} dx\frac{\log(x)}{\cosh(x) \sec(x)- \tan(x)} $$ The place I started is the nifty result, proven here, that $$\frac{\sin{x}}{\cosh{t} – \cos{x}} = 2 \sum_{k=1}^{\infty} e^{-k t} \sin{k x} $$ Of course, the integral actually looks like $$\int_0^{\infty} dx \frac{\cos{x}}{\cosh{x} – \sin{x}} \log{x} $$ so we need to […]

Generalizing an already tough integral

I did the case $p=1$ here. The generalization to higher $p$ may involve higher-order derivatives as follows: $$\begin{align}K_p &= \int_0^{\pi/2} dx \frac{x^{2 p}}{1+\cos^2{x}} = \frac1{2^{4 p-1}} \int_{-\pi}^{\pi} dy \frac{y^{2 p}}{3+\cos{y}} \end{align}$$ So define, as before, $$J(a) = \int_{-\pi}^{\pi} dy \frac{e^{i a y}}{3+\cos{y}} $$ Then $$K_p = \frac{(-1)^p}{2^{4 p-1}} \left [\frac{d^{2 p}}{da^{2 p}} J(a) \right ]_{a=0}$$ […]

Mathematica v9.0.1 states that this integral does not converge.

The problem is to evaluate the following integral: $$\int_0^{\infty} dx \frac{\log(1+x)}{\left(1+x^2\right)\,\left(1+x^3\right)}$$ This one turned out to be messy but straightforward. What did surprise is the way in which I would need to employ the residue theorem. Clearly, the integral is more amenable to real methods than a contour integration. What happens, though, is that the […]

An unusually alternating sum

Problem: evaluate the following sum… $$\sum_{k=0}^{\infty}\dfrac{(-1)^{\frac{k(k+1)}{2}}}{(2k+1)^2}$$ This is unusual because the $-1$ is raised to the $k (k+1)/2$ power, rather than the usual $k$th power. On the surface, this problem may look hopeless, but really, it is all about determining the pattern of odd and even numbers from the sequence $k (k+1)/2$, which turns out […]

Algebraically difficult integral

Well, some integrals are not all that hard to evaluate in principle. The one I am posting here should be an open and shut application of the residue theorem, using the unit circle as a contour. The form of the integrand, however, should give a little pause. It turns out that actually computing residues on […]

An integral involving a quadratic phase

This one was first posted on the site Integrals and Series and was brought to my attention on M.SE by Cody. My solution involves a contour integration, although the approach is far from trivial. Yet again, the solution boils down to finding a contour and a function to integrate over the contour. The problem involves […]

An integral that illustrates the beauty of contour integration methods

I attack many of the integrals in this blog using contour integration methods, some of which are obvious and some of which take a little more imagination. Here is one that illustrates the beauty an power of such methods as much as any other integral here. The problem is to derive the integral representation $$\sin […]

Funky triple integral

Note: There was a sign error in the original solution, which I have since fixed. Problem: Evaluate $$ \int _0 ^{\infty}\int _0 ^{\infty}\int _0 ^{\infty} \log(x)\log(y)\log(z)\cos(x^2+y^2+z^2)dzdydx$$ Solution: One way to attack this is to exploit the symmetry of the integral. Start by expanding the cosine term into individual pieces, i.e., $$\begin{align}\cos{(x^2+y^2+z^2)} &= \cos{x^2} \cos{(y^2+z^2)} – […]

An odd-looking integral of a square root of trig functions

The integral to evaluate is $$\int_0^{\pi/3} \big((\sqrt{3}\cos x-\sin x)\sin x\big)^{1/2}\cos x \,dx $$ A cursory glance at this specimen leads to exasperation, as the $\pi/3$ in the limit seems arbitrary, and the integrand seems devoid of an antiderivative. It turns out, however, that one way to attack this integral is to transform it into a […]

Integral of function with deceptive triple pole

One integral posted came from Hermite’s integral representation of the Hurwitz zeta function. The integral is not the most difficult that I have ever evaluated, but is interesting from a pedagogical point of view. The problem is to evaluate $$\int_0^{\infty} dx \frac{x}{(e^x-1) (x^2+4 \pi^2)^2}$$ This integral may be done via the residue theorem, by considering […]

Deceptively Tricky Integral II

Evaluate the following integral $$\int_0^{\pi/2} dx \frac{x^2}{1+\cos^2 x}$$ This integral is deviously difficult. It may look like it has the solution I provided for this integral, but, as you will see, there is an additional wrinkle. As in the linked solution, I will express the integral in a form in which I may attack via […]

Improper integral of a high power of log

I feel like I’ve developed something new in evaluating this integral. Previously, when confronted with an integral of log to the n times a function, I considered the integral of log to the n+1 times the function over a keyhole contour. This gave me the original integral, but also all of the other integrals of […]

Two integrals, each easier than it looks

I start with an integral that stymied a bunch of people for the better part of an hour. The following solution had a lot of people slapping their heads. The problem is to evaluate, for any real $\alpha$, the following integral: $$\int_0^{\pi/2} \frac{dx}{1+\tan^{\alpha}{x}}$$ Solution: use the fact that $$\tan{\left (\frac{\pi}{2}-x\right)} = \frac{1}{\tan{x}}$$ i.e., $$\frac1{1+\tan^{\alpha}{x}} = […]

A crazy-ass integral, the evaluation of which got a lot of love at Math.SE

There are a lot of integrals posted at Math.SE. I attempt to evaluate quite a few of them. Many times, I fail spectacularly; you will typically not hear of those because I feel there is nothing to say. Occasionally, I succeed; of course, you will hear about those because I post and then post again […]

Deceptively tricky integral

Someone wanted us to evaluate the following integral: $$\int\limits_0^\pi dx{\frac{{{x^2}}}{{\sqrt 5-2\cos x}}}$$ This looks straightforward, although the factor of $x^2$ does seem to complicate things a little. Actually, a lot. The usual tricks to deal with powers leads us down a road that leads to interesting territory involving dilogarithms. Let’s define $$J(a) = \int_{-\pi}^{\pi} dx […]

Unlikely application of Parseval’s equality

A poster somehow got a numerical value for an integral and wondered if it could be expressed in terms of simple constants. Let $\operatorname{erfi}(x)$ be the imaginary error function $$\operatorname{erfi}(x)=\frac{2}{\sqrt{\pi}}\int_0^xe^{z^2}dz.$$ Consider the integral $$I=\int_0^\infty\frac{\sin(x)\ \operatorname{erfi}\left(\sqrt{x}\right)\ e^{-x\sqrt{2}}}{x}dx.$$ Its numeric value is approximately $0.625773669454426$ The question is: Is it possible to express $I$ in a closed form […]

A nifty integral worked out via contour integration

Problem: evaluate the following integral: $$\int_0^{\infty}dx \frac{e^{-a x^2(x^2-\pi^2)}\cos(2\pi a x^3)}{\cosh x} $$ To evaluate this integral, consider the following integral in the complex plane: $$\oint_C \frac{dz}{\sinh{z}} e^{-a (z^2-\pi^2/4)^2}$$ where $C=C_1+C_2+C_3+C_4+C_5+C_6$ as illustrated below: $$\int_{C_1} \frac{dz}{\sinh{z}} e^{-a (z^2-\pi^2/4)^2} = \int_{i \pi/2}^{R+i \pi/2} \frac{dx}{\sinh{x}} e^{-a (x^2-\pi^2/4)^2}$$ $$\int_{C_2} \frac{dz}{\sinh{z}} e^{-a (z^2-\pi^2/4)^2} = i\int_{\pi/2}^{-\pi/2} \frac{dy}{\sinh{(R+iy)}} e^{-a [(R+i y)^2-\pi^2/4]^2} $$ […]

An integral with difficult branch points

The challenge here is merely to evaluate the following integral: $$\int_0^{\infty} dx \frac{\log{(1+x^3)}}{(1+x^2)^2}$$ This integral is a tough one because of the branch points strewn throughout the complex plane, as well as the utter lack of symmetry. It turns out, however, that we may still use the residue theorem to evaluate the integral so long […]

Interesting way to compute $\pi$ and its consequences

A poster on SE wondered how he could prove the following: $$\sum_{j=2}^\infty \prod_{k=1}^j \frac{2 k}{j+k-1} = \pi$$ Well! I never would have thought of this on my own, but I’m not really here to think up stuff like this on my own. Rather, I am here to solve the problems of confused souls, and here […]

Cosine transform of sinc cubed

Some dude asked to evaluate the following integral: $$\int_0^{\infty} dt \, \frac{\sin^3{\pi t}}{(\pi t)^3} \cos{u t}$$ I propose to perform a direct computation using Cauchy’s theorem, i.e., extension into the complex plane. I will then verify the solution using the convolution theorem. DIRECT EVALUATION Rewrite the integral as $$\frac12 \int_{-\infty}^{\infty} dt \, \frac{\sin^3{\pi t}}{(\pi t)^3} […]