# How to integrate, $\int_{0}^{\pi/2}\sin (\tan\theta) \mathrm{d\theta}$?

Integrate, $$\int_{0}^{\frac{\pi}{2}}\sin (\tan\theta) \mathrm{d\theta}$$

-

First, make the change of variables $x = \arctan(t)$ to transform the integral t0

$$\int_{0}^{\frac{\pi}{2}}\sin (\tan\theta) \mathrm{d\theta} = \int_{0}^{\infty}\frac{\sin(t)}{t^2+1} {dt} \\ = -\frac{1}{2}\,{{\rm e}^{-1}}{ \operatorname {E_1} } \left( -1 \right) +\frac{1}{2}\,{{\rm e}}\,{\operatorname{E_1}} \left( 1 \right) - \frac{1}{2}\,i\pi \,{{\rm e}^{-1}}$$

where $\operatorname{E}_a(z)$ is the exponential integral

$$\operatorname{E}_a \left( z \right) =\int _{1}^{\infty }\!{{\rm e}^{-{t}z}}{{ t}}^{-a }{d{ t}}.$$

To see the details of evaluation of the last integral see here.

-
Good link and nice answer +1 –  Babak S. Dec 26 '12 at 4:02
@BabakSorouh: Thank you for your comment. I really appreciate it. –  Mhenni Benghorbal Dec 26 '12 at 4:03
@MhenniBenghorbal The conventional notation is $\mathrm{E}_a(z)$, rather than $\mathrm{Ei}(a,z)$, see the wiki page about the exponential integral. –  Sasha Dec 26 '12 at 18:37
@Sasha: Thank you. –  Mhenni Benghorbal Dec 27 '12 at 23:09

Making a change of variables $u=\tan(\theta)$: $$\int_0^{\pi/2} \sin\left(\tan \theta\right) \mathrm{d} \theta = \int_0^\infty \frac{\sin(u)}{1+u^2} \mathrm{d} u \tag{1}$$ In order to evaluate this we use the technique of Mellin transform.

1. Evaluate the Mellin transforms of $\sin(u)$ and $\left(1+u^2\right)^{-1}$: $$\mathcal{M}_s(\sin(u))= \int_0^\infty u^{s-1} \sin(u) \mathrm{d} u = \frac{\sqrt{\pi}}{2} 2^{s} \frac{\Gamma\left(\frac{1}{2} + \frac{s}{2}\right)}{\Gamma\left(1-\frac{s}{2}\right)}$$ defined in the strip $-1<\Re(s)<1$. Applying the inverse transform: $$\sin(u) = \frac{1}{2 \pi i} \int_{\gamma - i \infty}^{\gamma + i \infty} \frac{\sqrt{\pi}}{2} 2^{s} \frac{\Gamma\left(\frac{1}{2} + \frac{s}{2}\right)}{\Gamma\left(1-\frac{s}{2}\right)} u^{-s} \mathrm{d} s \tag{2}$$ where $\gamma$ is an arbitrary real constant such that $-1<\gamma<1$. The Mellin transform of the rational function $(1+u^2)^{-1}$ reads $$\mathcal{M}_s\left(\frac{1}{1+u^2}\right)= \int_0^\infty \frac{u^{s-1}}{1+u^2}\mathrm{d} u = \frac{1}{2} \Gamma\left(\frac{s}{2}\right) \Gamma\left(1-\frac{s}{2}\right) \tag{3}$$ and is defined in the strip $0<\Re(s)<2$.

2. Now substituting $(2)$ into $(1)$, choosing $\gamma$ such that $-1<\gamma<0$, and interchanging the order of integration: $$\begin{eqnarray} \int_0^\infty \frac{\sin(u)}{1+u^2} \mathrm{d} u &=& \frac{1}{2\pi i} \frac{\sqrt{\pi}}{2} \int_{\gamma-i \infty}^{\gamma+i \infty} 2^{s} \frac{\Gamma\left(\frac{1}{2} + \frac{s}{2}\right)}{\Gamma\left(1-\frac{s}{2}\right)} \left( \int_0^\infty \frac{u^{-s}}{1+u^2} \mathrm{d}u \right) \mathrm{d} s \\ &\stackrel{(2)}{=}& \frac{1}{2\pi i} \frac{\sqrt{\pi}}{2} \int_{\gamma-i \infty}^{\gamma+i \infty} 2^{s} \frac{\Gamma\left(\frac{1}{2} + \frac{s}{2}\right)}{\Gamma\left(1-\frac{s}{2}\right)} \left(\frac{1}{2} \Gamma\left(\frac{1-s}{2}\right) \Gamma\left(1-\frac{1-s}{2}\right) \right)\mathrm{d} s \\ &=& \frac{1}{2\pi i} \frac{\sqrt{\pi}}{4} \int_{\gamma-i \infty}^{\gamma+i \infty} \Gamma\left(\frac{1}{2}-\frac{s}{2}\right) \frac{\Gamma\left(\frac{1}{2}+\frac{s}{2}\right)^2}{\Gamma\left(1-\frac{s}{2}\right)} \left(\frac{1}{2}\right)^{-s} \mathrm{d}s \\ &\stackrel{\text{reflection}}{=}& \frac{1}{2\pi i} \frac{\pi}{2} \int_{\gamma - i \infty}^{\gamma+i \infty} \Gamma(s) \tan\left(\frac{\pi}{2} s \right) \mathrm{d}s \end{eqnarray}$$ The latter integral can be evaluated as a sum over residues at poles to the left of the integration contour, situated at odd negative integers. The poles of $\Gamma(s)$ are even non-positive integers are canceled by zeros of the tangent function. The poles at the odd negative integers are double poles: $$\operatorname{Res}_{s=-2k-1} \left(\frac{\pi}{2} \Gamma\left(s\right) \tan\left(\frac{\pi}{2} s\right) \right) = \frac{1}{\Gamma\left(2k+2\right)} \psi\left(2k+2\right)$$ where $\psi(x)$ is the digamma function.

Thus we have the result: $$\begin{eqnarray} \int_0^\infty \frac{\sin u}{1+u^2} \mathrm{d} u &=& \sum_{k=0}^\infty \frac{\psi(2k+2)}{\Gamma(2k+2)} = \frac{1}{2} \left( \sum_{k=0}^\infty \frac{\psi(k+1)}{\Gamma(k+1)} - \sum_{k=0}^\infty (-1)^k \frac{\psi(k+1)}{\Gamma(k+1)}\right) \\ &=& \frac{1}{2} \left(f(1) - f(-1)\right) = \frac{\exp(-1)}{2} \operatorname{Ei}(1) - \frac{\exp(1)}{2} \operatorname{Ei}(-1) \end{eqnarray}$$ where $\operatorname{Ei}(x)$ denotes the exponential integral special function. We now proceed to prove that, for real non-zero $x$: $$f(x) = \sum_{k=0}^\infty x^k \frac{\gamma(k+1)}{\Gamma(k+1)} = \mathrm{e}^{x} \left( \frac{1}{2} \log(x^2) - \operatorname{Ei}(-x) \right)$$ Indeed, denoting the Euler-Mascheroni constant as $C$, and using $H_n = -\sum_{k=1}^n \frac{(-1)^k}{k} \binom{n}{k}$: $$\begin{eqnarray} \sum_{k=0}^\infty x^k \frac{\gamma(k+1)}{\Gamma(k+1)} &=& \sum_{k=0}^\infty x^k \frac{-C +H_{k}}{k!} = - C \mathrm{e}^{x} - \sum_{k=1}^\infty \frac{x^k}{k!} \sum_{m=1}^k \frac{(-1)^m}{m} \binom{k}{m} \\ &=& -C \mathrm{e}^{x} - \sum_{m=0}^\infty \frac{x^m}{m!} \sum_{k=1}^\infty \frac{(-x)^k}{k \cdot k!} = -C \mathrm{e}^{x} - \mathrm{e}^{x} \left( \operatorname{Ei}(-x) - \log |x| -C \right) \\ &=& \mathrm{e}^{x} \left( \log |x| - \operatorname{Ei}(-x) \right) \end{eqnarray}$$

-
+1 Involved, but cool nonetheless. –  user40314 Dec 26 '12 at 18:53