## 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

\frac{1}{x} = \int\limits_{0}^{\infty} \mathrm{e}^{-xt} \mathrm{d} t

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

\int\limits_{0}^{\infty} \frac{\mathrm{e}^{-ax}-\mathrm{e}^{-bx}}{x} \mathrm{d} x

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

\int\limits_{0}^{\infty} \frac{f(ax) – f(bx)}{x} \mathrm{d} x = [f(\infty) – f(0)]\mathrm{ln}\left(\frac{a}{b}\right)

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$$,

\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}

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

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}

Using the following contour

we note that a first order pole at $$z=ib$$ is inside of the contour so we have

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}

\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

\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}

Adding the two halves of the integral together, we have the following in the numerator

\mathrm{ln}(-x+ia) + \mathrm{ln}(x+ia) = i\pi + \mathrm{ln}(x-ia) + \mathrm{ln}(x+ia) = \mathrm{ln}(x^{2}+a^{2})

Now we have

\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}

Equating real and imaginary parts of equations \eqref{eq:160806a6} and \eqref{eq:160806a4} yields our original result plus a bonus integral
\int\limits_{0}^{\infty} \frac{1}{x^{2}+b^{2}} \mathrm{d} x = \frac{\pi}{2b}

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

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

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

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

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

\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}

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

\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}

Now, let us consider

\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}

We let $$x=-y$$ to obtain

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

which we can rewrite as

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

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

\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}

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

\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

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

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

Putting it all together, we have

\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

## 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

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

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

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

We make the substitution $$y = px^{2}$$

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

Invoking the gamma function yields

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

Treating the other part of the original integral involving $$q$$ yields our final result

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

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

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

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

\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}.

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

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

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

\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.

The right hand side yields

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

And thus we have our result.