## Integral Kokeboken (Integral Cookbook)

Integral Kokeboken (pdf file) is the title of a free book about integration techniques. It is written in Norwegian, but with the assistance of online translators and the universality of mathematics, non-Norwegian speakers can read it. Thus far I have only skimmed it, but it appears to be similar to other integration books listed at my Links page.

## Prove $$\int_{0}^{1} \frac{\sin^{-1}(x)}{x} dx = \frac{\pi}{2}\ln2$$

I stumbled upon the interesting definite integral

\int\limits_{0}^{1} \frac{\sin^{-1}(x)}{x} dx = \frac{\pi}{2}\ln2

Here is my proof of this result.

Let $$u=\sin^{-1}(x)$$ then integrate by parts,
\begin{align}
\int \frac{\sin^{-1}(x)}{x} dx &= \int u \cot(u) du \\
&= u \ln\sin(u) – \int \ln\sin(u) du
\tag{1}
\label{eq:20161030-1}
\end{align}

\begin{align}
\int \ln\sin(u) du &= \int \ln\left(\frac{\mathrm{e}^{iu} – \mathrm{e}^{-iu}}{i2} \right) du \\
&= \int \ln \left(\mathrm{e}^{iu} – \mathrm{e}^{-iu} \right) du \,- \int \ln (i2) du \\
&= \int \ln \left(1 – \mathrm{e}^{-i2u} \right) du + \int \ln \mathrm{e}^{iu} du \,-\, u\ln (i2) \\
&= \int \ln \left(1 – \mathrm{e}^{-i2u} \right) du + \frac{i}{2}u^{2} -u\ln 2 \,-\, ui\frac{\pi}{2}
\tag{2}
\label{eq:20161030-2}
\end{align}

To evaluate the integral above, let $$y=\mathrm{e}^{-i2u}$$

\int \ln \left(1 – \mathrm{e}^{-i2u} \right) du = \frac{i}{2} \int \frac{\ln (1-y)}{y} dy
= -\frac{i}{2} \mathrm{Li}_{2}(y) = -\frac{i}{2} \mathrm{Li}_{2}\mathrm{e}^{-i2u}
\tag{3}
\label{eq:20161030-3}

Now we substitute equation \eqref{eq:20161030-3} into equation \eqref{eq:20161030-2}, then substitute that result into equation \eqref{eq:20161030-1}, switch variables back to $$x$$, and apply limits,
\begin{align}
\int\limits_{0}^{1} \frac{\sin^{-1}(x)}{x} dx
&= \sin^{-1}(x) \ln (x) + \sin^{-1}(x)\left(\ln 2 + i\frac{\pi}{2}\right) \\
&- \frac{i}{2}[\sin^{-1}(x)]^{2} + \frac{i}{2} \mathrm{Li}_{2}\mathrm{e}^{-i2\sin^{-1}(x)} \Big|_{0}^{1} \\
&= \frac{\pi}{2}\ln2
\end{align}

## Evaluate $$\int_{0}^{1} x^{a} \mathrm{ln}^{k}(x) dx$$

This problem was inspired by a simpler problem posed at Mathematics Stack Exchange.

Consider

\int\limits_{0}^{1} x^{a} dx = (a+1)^{-1}

\frac{\partial}{\partial a}\int\limits_{0}^{1} x^{a} \mathrm{ln}(x) dx = \frac{\partial}{\partial a} (a+1)^{-1}
= -(a+1)^{-2}

Repeat until the pattern emerges to find the solution to our problem

\int\limits_{0}^{1} x^{a} \mathrm{ln}^{k}(x) dx = \frac{(-1)^{k} k!}{(a+1)^{k+1}}

We also obtain the solution of a simpler problem
\begin{align}
\int\limits_{0}^{1} \mathrm{ln}^{k}(x) dx &= \lim_{a \to 0} \int\limits_{0}^{1} x^{a} \mathrm{ln}^{k}(x) dx \\
&= \lim_{a \to 0} \frac{(-1)^{k} k!}{(a+1)^{k+1}} \\
&= (-1)^{k} k!
\end{align}

Here is a more efficient method of evaluating the original integral inspired by a solution at the MSE link referenced above.
\begin{align}
\tag{a}
\int\limits_{0}^{1} x^{a} \mathrm{ln}^{k}(x) dx
&= (-1)^{k} \int\limits_{0}^{\infty} z^{k} \mathrm{e}^{-(a+1)z} dz \\
\tag{b}
&= \frac{(-1)^{k}}{(a+1)^{k+1}} \int\limits_{0}^{\infty} y^{k} \mathrm{e}^{-y} dy \\
&= \frac{(-1)^{k} \Gamma(k+1)}{(a+1)^{k+1}}
\end{align}

a. $$z=-\mathrm{ln}(x)$$

b. $$y=(a+1)z$$

## Evaluate $$\int_{0}^{\infty} \frac{x^{3}}{\mathrm{e}^{x}-1} dx$$

How to evaluate

\int\limits_{0}^{\infty} \frac{x^{3}}{\mathrm{e}^{x}-1} dx

was a question posed at Mathematics Stack Exchange. Here is my solution to a more general problem.

We consider the more general integral
\begin{align}
\int\limits_{0}^{\infty} \frac{x^{n}}{\mathrm{e}^{ax}-1} dx
&= \int\limits_{0}^{\infty} \frac{\mathrm{e}^{-ax} x^{n}}{1-\mathrm{e}^{-ax}} dx \\
&= \int\limits_{0}^{\infty} \mathrm{e}^{-ax} x^{n} \sum\limits_{k = 0}^{\infty} \mathrm{e}^{-kax} dx \\
&= \sum\limits_{k = 0}^{\infty} \int\limits_{0}^{\infty} x^{n} \mathrm{e}^{-(a+ak)x} dx
\end{align}

To evaluate the integral, let $$(a+ak)x = z$$

\int\limits_{0}^{\infty} x^{n} \mathrm{e}^{-(a+ak)x} dx
= \frac{1}{a^{n+1}} \frac{1}{(1+k)^{n+1}} \int\limits_{0}^{\infty} z^{n} \mathrm{e}^{-z} dz
= \frac{1}{a^{n+1}} \frac{1}{(1+k)^{n+1}} \Gamma(n+1)

Now we have

\int\limits_{0}^{\infty} \frac{x^{n}}{\mathrm{e}^{ax}-1} dx
= \frac{1}{a^{n+1}} \Gamma(n+1) \sum\limits_{k = 1}^{\infty} \frac{1}{k^{n+1}}
= \frac{1}{a^{n+1}} \Gamma(n+1) \zeta(n+1)

The original problem is

\int\limits_{0}^{\infty} \frac{x^{3}}{\mathrm{e}^{x}-1} dx
= \Gamma(4) \zeta(4) = 6\frac{\pi^{4}}{90} = \frac{\pi^{4}}{15}

## Integration Trick: $$\frac{\sin(\theta)}{\theta} = \frac{1}{2} \int_{-1}^{1} \mathrm{e}^{i\theta x} dx$$

The substitution

\frac{\sin(\theta)}{\theta} = \frac{1}{2} \int\limits_{-1}^{1} \mathrm{e}^{i\theta x} dx

comes in handy from time to time. A good example of how it is used can be found here.

## Prove $$\mathrm{erf}(x) = \frac{1}{\pi} \int_{0}^{\infty} \mathrm{e}^{-t} \frac{\sin(2x\sqrt{t})}{t} dt$$

How to prove

\mathrm{erf}(x) = \frac{1}{\pi} \int\limits_{0}^{\infty} \mathrm{e}^{-t} \frac{\sin(2x\sqrt{t})}{t} dt

was a question posed at Mathematics Stack Exchange. The poster did not want a solution using contour integration. Here is my solution.

\begin{align}
\tag{1a}
\int\limits_{0}^{\infty} \mathrm{e}^{-t} \frac{\sin(2x\sqrt{t})}{t} dt
&= x \int\limits_{-1}^{1} \int\limits_{0}^{\infty} \mathrm{e}^{-t} \mathrm{e}^{i2x\theta \sqrt{t}} \frac{1}{\sqrt{t}} dt d\theta \\
\tag{1b}
&= 2x \int\limits_{-1}^{1} \int\limits_{0}^{\infty} \mathrm{e}^{-y^{2}+i2x\theta y} dy d\theta \\
\tag{1c}
&= 2x \int\limits_{-1}^{1} \mathrm{e}^{-x^{2} \theta ^{2}} \int\limits_{0}^{\infty} \mathrm{e}^{-(y-ix\theta)^{2}} dy d\theta \\
\end{align}

Notes:

a. Use

\frac{\sin(\phi)}{\phi} = \frac{1}{2}\int\limits_{-1}^{1} \mathrm{e}^{i\phi w} dw

b. $$\sqrt{t} = y$$

c. Complete the square.

Evaluate
\begin{align}
\int \mathrm{e}^{-(y-ix\theta)^{2}} dy &= \int \mathrm{e}^{-z^{2}} dz \\
&= \frac{\sqrt{\pi}}{2} \mathrm{erf}(z) = \frac{\sqrt{\pi}}{2} \mathrm{erf}(y-ix\theta)
\end{align}
here we let $$z = y-ix\theta$$. Applying limits to the integral yields
\begin{align}
\int\limits_{0}^{\infty} \mathrm{e}^{-(y-ix\theta)^{2}} dy
&= \frac{\sqrt{\pi}}{2} \mathrm{erf}(y-ix\theta) \Big|_{0}^{\infty} \\
&= \frac{\sqrt{\pi}}{2} [1 + i \mathrm{erfi}(x\theta)]
\tag{2}
\end{align}

Substituting equation 2 into equation 1c yields two integrals. Dropping constants we have first
\begin{align}
\int\limits_{-1}^{1} \mathrm{e}^{-x^{2} \theta ^{2}} d\theta &= \frac{1}{x} \int \mathrm{e}^{-w^{2}} dw \\
&= \frac{\sqrt{\pi}}{2x} \mathrm{erf}(w) \\
&= \frac{\sqrt{\pi}}{2x} \mathrm{erf}(x\theta) \Big|_{-1}^{1} \\
&= \frac{\sqrt{\pi}}{x} \mathrm{erf}(x)
\end{align}
secondly, we have

\int\limits_{-1}^{1} \mathrm{e}^{-x^{2} \theta ^{2}} \mathrm{erfi}(x\theta) d\theta = 0

noting that the imaginary error function is an odd function.

Putting the pieces together yields
\begin{align}
\int\limits_{0}^{\infty} \mathrm{e}^{-t} \frac{\sin(2x\sqrt{t})}{t} dt
&= 2x \int\limits_{-1}^{1} \mathrm{e}^{-x^{2} \theta ^{2}} \int\limits_{0}^{\infty} \mathrm{e}^{-(y-ix\theta)^{2}} dy d\theta \\
&= 2x \frac{\sqrt{\pi}}{2} \frac{\sqrt{\pi}}{x} \mathrm{erf}(x) \\
&= \pi\, \mathrm{erf}(x)
\end{align}

## Evaluate $$\int_{0}^{\infty} \mathrm{e}^{-ax^{2}} \cos(bx) \mathrm{d}x$$

How to evaluate

I = \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \cos(bx) \mathrm{d}x
\tag{1}
\label{eq:20161022-1}

was a question posed at Mathematics Stack Exchange. I encourage readers to follow the link to see solutions that use a rectangular contour to evaluate this integral as an alternative method to the one presented below.

Let
\begin{align}
I_{1} &= \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \mathrm{e}^{ibx} \mathrm{d}x
= \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}+ibx} \mathrm{d}x \\
&= \mathrm{e}^{-b^{2}/4a} \int\limits_{0}^{\infty} \mathrm{e}^{-a(x-ib/2a)^{2}} \mathrm{d}x \\
\tag{2}
\label{eq:20161022-2}
\end{align}
Here we completed the square and note that $$\mathrm{Re}\,I_{1} = I$$.

Consider the indefinite integral
\begin{align}
\int \mathrm{e}^{-a(x-ib/2a)^{2}} \mathrm{d}x
&= \int \mathrm{e}^{-ay^{2}} \mathrm{d}y \\
&= \frac{1}{\sqrt{a}} \int \mathrm{e}^{-z^{2}} \mathrm{d}z = \frac{1}{2} \sqrt{\frac{\pi}{a}} \mathrm{erf}(z) \\
&= \frac{1}{2} \sqrt{\frac{\pi}{a}} \mathrm{erf}\left(x\sqrt{a} – \frac{ib}{2\sqrt{a}}\right)
\tag{3}
\label{eq:20161022-3}
\end{align}
we used the substitutions, $$y=x- \frac{ib}{2a}$$ and $$z^{2} = ay^{2}$$.

Examining the error function expression, we have

\lim_{x \to 0} \mathrm{erf}\left(x\sqrt{a} – \frac{ib}{2\sqrt{a}}\right)
= \mathrm{erf}\left(- \frac{ib}{2\sqrt{a}}\right)
= -i\,\mathrm{erfi}\left(\frac{b}{2\sqrt{a}}\right)
\tag{4}
\label{eq:20161022-4}

which is a pure imaginary quantity with the assumption that all of the variables in the argument of the imaginary error function are real and $$a \gt 0$$. We also have

\lim_{x \to \infty} \mathrm{erf}\left(x\sqrt{a} – \frac{ib}{2\sqrt{a}}\right) = 1
\tag{5}
\label{eq:20161022-5}

Using equations \eqref{eq:20161022-4} and \eqref{eq:20161022-5} in equation \eqref{eq:20161022-3} we obtain

\mathrm{Re}\left(\int\limits_{0}^{\infty} \mathrm{e}^{-a(x-ib/2a)^{2}} \mathrm{d}x \right) = \frac{1}{2} \sqrt{\frac{\pi}{a}}
\tag{6}
\label{eq:20161022-6}

Combining equations \eqref{eq:20161022-6} and \eqref{eq:20161022-2} yields our final result

\int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \cos(bx) \mathrm{d}x = \frac{1}{2} \sqrt{\frac{\pi}{a}} \,\mathrm{e}^{-b^{2}/4a}

## Evaluate $$\frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x$$

How to evaluate

\frac{1}{\sqrt{2 \pi}} \int\limits_{-\infty}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x

was a question posed at Mathematics Stack Exchange. Here is my solution.

We begin with a slightly different integral and then use the trick of differentiating under the integral. Let
\begin{align}
I(a) &= \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \mathrm{d}x \\
&= \frac{1}{\sqrt{a}} \int\limits_{0}^{\infty} \mathrm{e}^{-y^{2}} \mathrm{d}y \\
&= \frac{\sqrt{\pi}}{2} \frac{1}{\sqrt{a}} \mathrm{erf}(y) \Big|_{0}^{\infty} \\
&= \frac{\sqrt{\pi}}{2} \frac{1}{\sqrt{a}}
\end{align}
We used the substitution $$y^{2} = ax^{2}$$.

Then
\begin{align}
I &= \frac{1}{\sqrt{2 \pi}} \int\limits_{-\infty}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x
= \frac{2}{\sqrt{2 \pi}} \int\limits_{0}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x \\
&= -\frac{2}{\sqrt{2 \pi}} \lim_{a \to 1/2} \frac{\partial I(a)}{\partial a}
= \frac{2}{\sqrt{2 \pi}} \lim_{a \to 1/2} \int\limits_{0}^{\infty} x^{2} \mathrm{e}^{-ax^{2}} \mathrm{d}x
= \frac{2}{\sqrt{2 \pi}} \int\limits_{0}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x \\
&= -\frac{2}{\sqrt{2 \pi}} \frac{\sqrt{\pi}}{2} \lim_{a \to 1/2} \frac{\partial}{\partial a} a^{-1/2}
= -\frac{1}{\sqrt{2}} \left(-\frac{1}{2}\right) \lim_{a \to 1/2} a^{-3/2} \\
&= 1
\end{align}

## Integration Trick $$[f(x)]^{-a} = \frac{1}{\Gamma(a)} \int_{0}^{\infty} z^{a-1} \mathrm{e}^{-f(x)z} \mathrm{d}z$$

A useful integration trick to convert the reciprocal of a function into an integral is

\frac{1}{[f(x)]^{a}} = \frac{1}{\Gamma(a)} \int\limits_{0}^{\infty} z^{a-1} \mathrm{e}^{-f(x)z} \mathrm{d}z

The derivation is straightforward, let $$y=f(x)z$$ and use the usual integral definition of the gamma function. However, one must be careful calculating the new limits of integration. If they differ from 0 and/or $$\infty$$ then the incomplete gamma function must be used and the resulting integral may cause other difficulties.

See here for an excellent example of how this trick can greatly simplify the evaluation of a difficult integral.