A Clever Integration Trick

This trick is from Integration for Engineers and Scientists by William Squire via The Handbook of Integration by Daniel Zwillinger.

Noting that
\begin{equation}
\frac{1}{x} = \int\limits_{0}^{\infty} \mathrm{e}^{-xt} \mathrm{d} t
\end{equation}
we can replace \(\frac{1}{x}\) in an integrand with its integral expression and reverse the order of integration to simplify evaluation of the integrals. Of course the integral must converge uniformly to allow us to reverse the order of integration and we must have \(t>0\).

Let us use this trick to evaluate
\begin{equation}
\int\limits_{0}^{\infty} \frac{\mathrm{e}^{-ax}-\mathrm{e}^{-bx}}{x} \mathrm{d} x
\end{equation}
for \(a,b > 0\).
Using our trick yields
\begin{align}
\int\limits_{0}^{\infty} \frac{\mathrm{e}^{-ax}-\mathrm{e}^{-bx}}{x} \mathrm{d} x & = \int\limits_{0}^{\infty}\int\limits_{0}^{\infty} \mathrm{e}^{-xt} (\mathrm{e}^{-ax}-\mathrm{e}^{-bx}) \mathrm{d} t \mathrm{d} x \\
& = \int\limits_{0}^{\infty}\int\limits_{0}^{\infty} \mathrm{e}^{-(a+t)x}-\mathrm{e}^{-(b+t)x} \mathrm{d} x \mathrm{d} t \\
& = -\int\limits_{0}^{\infty} \frac{\mathrm{e}^{-(a+t)x}}{a+t} – \frac{\mathrm{e}^{-(b+t)x}}{b+t} |_{0}^{\infty} \mathrm{d} t \\
& = \int\limits_{0}^{\infty} \frac{1}{a+t} – \frac{1}{b+t} \mathrm{d} t \\
& = \lim_{R \to \infty} \mathrm{ln}\frac{a+t}{b+t} |_{0}^{R} \\
& = \mathrm{ln}\left(\frac{b}{a}\right)
\end{align}

The conventional way to handle this integral is to recognize that it is the Frullani integral
\begin{equation}
\int\limits_{0}^{\infty} \frac{f(ax) – f(bx)}{x} \mathrm{d} x = [f(\infty) – f(0)]\mathrm{ln}\left(\frac{a}{b}\right)
\end{equation}
A simple substitution yields our result.

For the Frullani integral, we must have the existence of \(f(\infty)\) and \(f(0)\) using the appropriate limits. For other conditions on the integral as well as proofs, see

  1. On Cauchy-Frullani Integrals by A. M. Ostrowski. Use DOI 10.1007/BF02568143 with Sci-Hub to access the paper.
  2. On the Theorem of Frullani by Juan Arias-De-Reyna. Use DOI 10.2307/2048376 with Sci-Hub to access the paper.

Integrate \(\int_{0}^{\infty} \frac{\mathrm{ln}(x^{2}+a^{2})}{x^{2}+b^{2}} \mathrm{d} x\)

For \(a,b > 0\),

\begin{equation}
\int\limits_{0}^{\infty} \frac{\mathrm{ln}(x^{2}+a^{2})}{x^{2}+b^{2}} \mathrm{d} x = \frac{\pi}{b} \mathrm{ln}(a+b)
\label{eq:160806a1}
\tag{1}
\end{equation}

appeared on page 52 of Rediscovery of Malmsten’s integrals, their evaluation by contour integration methods and some related results by Iaroslav V. Blagouchine. This is a fascinating paper with many interesting results. In future blog posts, I will present some of Blagouchine’s results and solve some of the exercise problems that he proposed. For now, I will do this integral mainly to highlight a common trick used to evaluate contour integrals with logarithms of binomials.

The trick is to begin with a different integrand
\begin{equation}
f(z) = \frac{\mathrm{ln}(z+ia)}{z^{2}+b^{2}} = \frac{\mathrm{ln}(z+ia)}{(z-ib)(z+ib)}
\label{eq:160806a2}
\tag{2}
\end{equation}

Using the following contour

semi circle contour with pole on im axis

 

we note that a first order pole at \(z=ib\) is inside of the contour so we have
\begin{equation}
Res_{z=ib}[f(z)] = \frac{\mathrm{ln}(ib+ia)}{i2b} = \frac{\mathrm{ln}(i)+\mathrm{ln}(a+b)}{i2b} = \frac{i\frac{\pi}{2}+\mathrm{ln}(a+b)}{i2b}
\label{eq:160806a3}
\tag{3}
\end{equation}

\begin{align}
\oint\limits_{C} f(z) \mathrm{d} z & = i2\pi Res_{z=ib}[f(z)] = \frac{i\pi^{2}}{2b} + \frac{\pi}{b}\mathrm{ln}(a+b) \\
& = \lim_{R \to \infty} \int\limits_{-R}^{R} f(x) \mathrm{d} x + \int\limits_{C_{1}} f(z) \mathrm{d} z
\label{eq:160806a4}
\tag{4}
\end{align}

The second integral goes to 0 via the ML estimate. The first integral will be broken in half and we use the substitution \(y=-x\) to obtain
\begin{equation}
\int\limits_{-\infty}^{0} \frac{\mathrm{ln}(x+ia)}{x^{2}+b^{2}} \mathrm{d} x = \int\limits_{0}^{\infty} \frac{\mathrm{ln}(-y+ia)}{y^{2}+b^{2}} \mathrm{d} y
\label{eq:160806a5}
\tag{5}
\end{equation}

Adding the two halves of the integral together, we have the following in the numerator
\begin{equation}
\mathrm{ln}(-x+ia) + \mathrm{ln}(x+ia) = i\pi + \mathrm{ln}(x-ia) + \mathrm{ln}(x+ia) = \mathrm{ln}(x^{2}+a^{2})
\end{equation}

Now we have
\begin{equation}
\oint\limits_{C} f(z) \mathrm{d} z = \int\limits_{0}^{\infty} \frac{\mathrm{ln}(x^{2}+a^{2})}{x^{2}+b^{2}} \mathrm{d} x +
i\pi \int\limits_{0}^{\infty} \frac{1}{x^{2}+b^{2}} \mathrm{d} x
\label{eq:160806a6}
\tag{6}
\end{equation}

Equating real and imaginary parts of equations \eqref{eq:160806a6} and \eqref{eq:160806a4} yields our original result plus a bonus integral
\begin{equation}\int\limits_{0}^{\infty} \frac{1}{x^{2}+b^{2}} \mathrm{d} x = \frac{\pi}{2b}
\end{equation}
which we could have obtained via the inverse tangent function.

Note that the trick allowed the limits of the integral to work out with the semi circular contour and we recovered the original integrand. This is a standard trick but surprisingly I have read some complex analysis texts that do not cover it.

Integrate \(\int_{-1}^{1}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x\)

This integral appeared in Inside Interesting Integrals by Paul Nahin in the problem set of chapter 3. Using Wolfram Alpha, we get

\begin{equation}
\int\limits_{-1}^{1}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x = \pi
\label{eq:1}
\tag{1}
\end{equation}

Nahin suggests the following trig substitution, \(x = \cos(2y)\).

While the form of the integrand certainly does suggest that some type of trig substitution will work, let us do it with another method. If we write the integral as

\begin{equation}
\int\limits_{-1}^{1} (1+x)^{\frac{1}{2}}(1-x)^{-\frac{1}{2}} \mathrm{d} x
\end{equation}

this looks like a beta function. From Higher Transcendental Functions (Bateman Manuscript), Volume 1, Section 1.5.1, equation 10, we see

\begin{equation}
\mathrm{B}(x,y) = 2^{1-x-y} \int\limits_{0}^{1} (1+t)^{x-1}(1-t)^{y-1} + (1+t)^{y-1}(1-t)^{x-1} \mathrm{d} t
\label{eq:2}
\tag{2}
\end{equation}

Let us begin with the original integral and the right half of the interval of integration

\begin{equation}
\int\limits_{0}^{1} (1+x)^{\frac{1}{2}}(1-x)^{-\frac{1}{2}} \mathrm{d} x = \int\limits_{0}^{1}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x
\label{eq:3}
\tag{3}
\end{equation}

Now, let us consider

\begin{equation}
\int\limits_{0}^{1} (1+x)^{-\frac{1}{2}}(1-x)^{\frac{1}{2}} \mathrm{d} x = \int\limits_{0}^{1}\sqrt{\frac{1-x}{1+x}} \mathrm{d} x
\label{eq:4}
\tag{4}
\end{equation}

We let \(x=-y\) to obtain

\begin{equation}
-\int\limits_{0}^{-1} \sqrt{\frac{1+y}{1-y}} \mathrm{d} y,
\label{eq:5}
\tag{5}
\end{equation}

which we can rewrite as

\begin{equation}
\int\limits_{-1}^{0}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x
\label{eq:6}
\tag{6}
\end{equation}

Adding the right hand side of equation \eqref{eq:3} and equation \eqref{eq:6} yields our original integral

\begin{equation}
\int\limits_{-1}^{0}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x + \int\limits_{0}^{1}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x = \int\limits_{-1}^{1}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x
\label{eq:7}
\tag{7}
\end{equation}

Likewise, adding the left hand sides of equations \eqref{eq:4} and \eqref{eq:3} yields

\begin{equation}
\int\limits_{-1}^{0}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x + \int\limits_{0}^{1}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x =
\int\limits_{0}^{1} (1+x)^{-\frac{1}{2}}(1-x)^{\frac{1}{2}} \mathrm{d} x + \int\limits_{0}^{1} (1+x)^{\frac{1}{2}}(1-x)^{-\frac{1}{2}} \mathrm{d} x
\end{equation}

If we combine this result into one integral and rearrange the integrand, we see that it is the same as the integral in \eqref{eq:2} with

\begin{equation}
x=\frac{3}{2} \,\, \mathrm{and} \,\, y=\frac{1}{2}
\end{equation}

Putting it all together, we have

\begin{equation}
\int\limits_{-1}^{1}\sqrt{\frac{1+x}{1-x}} \mathrm{d} x = 2\mathrm{B}\left(\frac{3}{2},\frac{1}{2}\right) = \pi
\end{equation}

Integrate \(\int^{\infty}_{0}\frac{e^{-px^{2}} – e^{-qx^{2}}}{x^{2}} \mathrm{d}x\)

This integral appeared in Paul Nahin’s very interesting book Inside Interesting Integrals. Nahin begins with a completely different integral and derives this one. Let us evaluate the integral directly and then redo it with Nahin’s method.

We begin by breaking up the integral and looking at each piece. So we have

\begin{equation}
\mathrm I = \int\limits^{\infty}_{0} x^{-2}\mathrm{e}^{-px^{2}} \mathrm{d}x.
\end{equation}

This looks very similar to a definition of the gamma function:

\begin{equation}
\Gamma(z) = \int\limits^{\infty}_{0} x^{z-1}\mathrm{e}^{-x} \mathrm{d}x.
\end{equation}

We make the substitution \(y = px^{2}\)

\begin{equation}
\mathrm I = \frac{\sqrt{p}}{2} \int\limits^{\infty}_{0} \mathrm{e}^{-y} y^{-\frac{3}{2}} \mathrm{d}y.
\end{equation}

Invoking the gamma function yields

\begin{equation}
\mathrm I = \frac{\sqrt{p}}{2} \Gamma\Big(-\frac{1}{2}\Big) = -\sqrt{p}\sqrt{\pi}.
\end{equation}

Treating the other part of the original integral involving \(q\) yields our final result

\begin{equation}
\int\limits^{\infty}_{0}\frac{\mathrm{e}^{-px^{2}} – \mathrm{e}^{-qx^{2}}}{x^{2}} \mathrm{d}x = \sqrt{\pi}(\sqrt{q}-\sqrt{p}).
\end{equation}

As I mentioned earlier, Nahin derived this result beginning with an entirely different integral. A casual glance at the original integral should make us suspect that this is the case as it is clear that both parts of the integrand are identical. In other words, why solve the original integral as opposed to the integral that I used at the beginning of the analysis. Such is the case with many of the results in Inside Interesting Integrals. This is the result of working backward, yielding an evaluated integral via some methods as opposed to starting from an integral that one wants to evaluate. I am not criticizing this approach, as it has resulted in an enormous number of useful integral evaluations. Indeed, it can create an unlimited number of evaluated integrals. Also, such “accidental” integrals can result from contour integration even when directly attacking a given integral. Consider that it often happens that upon the last step in evaluating an integral via contour integration, one equates real and imaginary parts in which one is the solution to the original integral while the other is a bonus.

Let us now see how Nahin achieved his result. He begins with

\begin{equation}
\int\limits_{0}^{\infty} \mathrm{e}^{-x^{2}} \mathrm{d}x
\end{equation}

for which Nahin derived the answer of \(\frac{1}{2} \sqrt{\pi} \) earlier in the book. What is interesting here is that this integral can be done easily with the gamma function by letting \( x^{2} = y \). This quickly results in

\begin{equation}
\int\limits_{0}^{\infty} \mathrm{e}^{-x^{2}} \mathrm{d}x = \frac{1}{2} \int\limits_{0}^{\infty} \mathrm{e}^{-y} y^{-1/2} \mathrm{d} y =
\frac{1}{2} \Gamma\Big(\frac{1}{2}\Big) = \frac{1}{2} \sqrt{\pi}.
\end{equation}

If someone saw this, then they would immediately recognize that the integral sought can be evaluated via the gamma function as I did above. Nevertheless, let us continue with Nahin’s analysis.

Nahin makes a change of variable, \(x = t\sqrt{a} \) to introduce the parameter \(a\), and thus obtains

\begin{equation}
\int\limits_{0}^{\infty} \mathrm{e}^{-at^{2}} \mathrm{d}t = \frac{1}{2}\frac{\sqrt{\pi}}{\sqrt{a}}
\end{equation}

Then he invokes a useful and interesting trick. He integrates the equation with respect to \(a\), between two arbitrary end points, and changes the order of integration. Changing the order of integration requires some care, as it is only valid if the integral converges uniformly. Here, the integral is just a gamma function, which we know converges uniformly. This is usually the case for “well behaved”, “non-crazy” integrals. So, Nahin has for the left hand side

\begin{equation}
\int\limits_{p}^{q}\left\{\int\limits_{0}^{\infty} \mathrm{e}^{-at^{2}} \mathrm{d}t\right\}\mathrm{d}a = \int\limits_{0}^{\infty}\left\{\int\limits_{p}^{q}\mathrm{e}^{-at^{2}} \mathrm{d}a\right\} \mathrm{d}t = \int\limits_{0}^{\infty}\frac{\mathrm{e}^{-pt^{2}} – \mathrm{e}^{-qt^{2}}}{t^{2}} \mathrm{d}t.
\end{equation}

The right hand side yields

\begin{equation}
\int\limits_{p}^{q}\frac{1}{2}\frac{\sqrt{\pi}}{\sqrt{a}} \mathrm{d}a = \sqrt{\pi}(\sqrt{q}-\sqrt{p}).
\end{equation}

And thus we have our result.