# Closed form of $\ln^n \tan x\, dx$

Here is an integral I am really stuck at. I am pretty sure that a general closed form of the integral:

$$\mathcal{J}=\int_0^{\pi/2} \ln^n \tan x\, {\rm d}x, \;\; n \in \mathbb{N}$$

exists. Well if $n$ is odd , then the integral is obviously zero due to symmetry. On the contrary if $n$ is even then the closed form I seek must contain the beta dirichlet function however I am unable to reach it. Setting $m=2n$ then:

$$\int_{0}^{\pi/2}\ln^m \tan x\, {\rm d}x=\int_{0}^{\infty}\frac{\ln^m u}{u^2+1}\, {\rm d}u= 2\int_{0}^{1}\frac{\ln^m u}{u^2+1}\, {\rm d}u$$

If we expand the denominator in a Taylor series, namely $1+x^2=\sum \limits_{n=0}^{\infty} (-1)^n x^n$ then the last integral is written as:

$$2\int_{0}^{1}\ln^m x \sum_{n=0}^{\infty}(-1)^n x^n \, {\rm d}x = 2\sum_{n=0}^{\infty}(-1)^n \int_{0}^{1}x^n \ln^m x \, {\rm d}x = 2 \sum_{n=0}^{\infty}\frac{(-1)^n (-1)^m m!}{\left ( n+1 \right )^{m+1}}= 2 (-1)^m m! \sum_{n=0}^{\infty}\frac{(-1)^n}{\left ( n+1 \right )^{m+1}}$$

Apparently there is something wrong here. I used the result

$$\int_{0}^{1}x^m \ln^n x \, {\rm d}x = \frac{(-1)^n n!}{\left ( m+1 \right )^{n+1}}$$

as presented here.

Edit/ Update: A conjecture of mine is that the closed form actually is:

$$\int_0^{\pi/2} \ln^{m} \tan x \, {\rm d}x=2m! \beta(m+1), \;\; m \;\;{\rm even}$$

For $m=2$ matches the result $\displaystyle \int_0^{\pi/2} \ln^2 \tan x\, {\rm d}x= \frac{\pi^3}{8}$.

• The taylor expansion you used is not right. $\frac{1}{1+x^2}=\sum_{n=0}^{\infty}{(-1)}^nx^{2n}$ – Oussama Boussif Sep 23 '15 at 13:47
• @OussamaBoussif Oups.. I forgot about that. Yes. Now I saw that Jack gave an answer. – Tolaso Sep 23 '15 at 13:49

We want to compute:

$$I_m = \int_{0}^{\pi/2}\left(\log\tan x\right)^{2m}\,dx = \int_{0}^{1}\frac{\left(\log t\right)^{2m}}{1+t^2}\,dt=\sum_{k\geq 0}(-1)^k\int_{0}^{1}t^{2k}(\log t)^{2m}\,dt$$ that is:

$$I_m = (2m)!\sum_{k\geq 0}\frac{2(-1)^k}{(2k+1)^{2m+1}}=|E_{2m}|\cdot\left(\frac{\pi}{2}\right)^{2m+1}.$$

The last identity was already proved here.

• Your final answer needs a factor of $(-1)^m$ since. Every other Euler number is negative (e.g., $E_2=-1$). I believe that you might have an extra factor of $1/2$ also. – Mark Viola Sep 23 '15 at 15:47
• @Dr.MV: I will check the $\frac{1}{2}$, but I used $E_{2m}$ as the absolute value of an Euler number, just like in the linked question. – Jack D'Aurizio Sep 23 '15 at 15:50
• That's fine. I understand that you referenced the answer, but it might make things clearer if that point was made explicitly. ;-) – Mark Viola Sep 23 '15 at 16:03
• @Dr.MV: you're right, it is best to keep notations straight. Thank you for the revision, as always :) – Jack D'Aurizio Sep 23 '15 at 16:04
• You're welcome. By the way, I provided an answer to the problem also. I'd like to hear your thoughts on it if you have any time to review. – Mark Viola Sep 23 '15 at 16:08

We begin with the integral $I$ as given by

$$I_n=\int_0^{\pi/2}\log^n (\tan x)\,dx \tag 1$$

Enforcing the substitution $\tan x\to x$, $(1)$ becomes

$$I_n=\int_0^\infty \frac{\log^n x}{1+x^2}\,dx=\left.\left(\frac{d^n}{da^n}\int_0^{\infty}\frac{x^a}{1+x^2}\,dx\right)\right|_{a=0}\tag 2$$

We evaluate the integral in $(2)$ using the residue theorem. To that end, we analyze the closed-contour integral $J$ as given by

$$J\oint_C\frac{z^a}{1+z^2}\,dz$$

where $C$ is the classical "key-hole" contour. From the residue theorem we have

\begin{align} J&=\oint_C\frac{z^a}{1+z^2}\,dz\\\\ &=2\pi i\left(\frac{e^{i\pi a/2}}{2i}+\frac{e^{i3\pi a/2}}{-2i}\right) \\\\ &=-2i\,\pi\, e^{ia\pi}\sin(\pi a/2) \end{align}

We can write $J$ as

\begin{align} J&=\left(1-e^{i2\pi a}\right)\,\int_0^{\infty}\frac{x^a}{1+x^2}\,dx\\\\ &=-2i e^{i\pi a}\sin(\pi a)\,\int_0^{\infty}\frac{x^a}{1+x^2}\,dx \end{align}

Therefore, we have

$$\int_0^{\infty}\frac{x^a}{1+x^2}\,dx=\frac{\pi}{2\cos (\pi a/2)}$$

and

\begin{align} I_n&=\left.\left(\frac{d^n}{da^n}\frac{\pi}{2\cos (\pi a/2)}\right)\right|_{a=0}\\\\ &=(\pi/2)^{n+1}\left.\left(\frac{d^n\sec x}{dx^n}\right)\right|_{x=0} \end{align}

From the Series for the Secant Function we have

$$\left.\frac{d^n \sec x}{dx^n}\right|_{x=0}= \begin{cases}0&,n\,\,\text{odd}\\\\ (i)^n\,E_n &,n\,\,\text{even} \end{cases}$$

Finally,

$$\bbox[5px,border:2px solid #C0A000]{I_{2n}=(\pi/2)^{2n+1}(-1)^nE_{2n}}$$

• @Dr.Mr Perhaps you'd like to fix the code containing the \bbox. ...:) – Tolaso Sep 23 '15 at 16:09
• @Tolaso Thank you ... I have done so. – Mark Viola Sep 23 '15 at 16:09
• @JackD'Aurizio Thank you!! That means a lot. – Mark Viola Sep 23 '15 at 16:10
• @Tolaso: Alternately, letting $t=\dfrac1{1+x^2},~$ and recognizing the expression of the beta function in the new integral, then using Euler's reflection formula for the $\Gamma$ function works just as well. – Lucian Sep 24 '15 at 4:27
• @Lucian Just curious ... but why is this comment placed here? – Mark Viola Sep 24 '15 at 13:42