# Integral $T_n=\int_{0}^{\pi/2}x^{n}\ln(1+\tan x)\,dx$

For $$n\in\Bbb N_0$$, evaluate in closed form $$T_n=\int_{0}^{\pi/2}x^{n}\ln(1+\tan x)\,dx$$

After seeing @mrtaurho's answer to this question, I realized that it would be possible to generalize his method and compute many integrals in the form $$\int_0^{\pi/2}P(x)\ln(1+\tan x)\,dx$$ where $$P$$ is a polynomial in $$x$$. This would be possible once one broke down the integral into lots of little pieces, many of which would be in the forms $$\int_{\pi/4}^{3\pi/4}x^n\ln\sin x\,dx$$ or $$\int_0^{\pi/2}x^n\ln\cos x\,dx$$ or some other similar integrals. I figured that such generalizations would be fairly 'easy' once the general pattern was pinned down. My attempts are below.

For starters, we see that \begin{align} T_n&=\int_0^{\pi/2}x^n\ln(\sin x+\cos x)\,dx-\int_0^{\pi/2}x^n\ln\cos x\,dx\\ &=\int_0^{\pi/2}x^n\ln\left(\sqrt{2}\sin\left(x+\frac{\pi}4\right)\right)\,dx-\int_0^{\pi/2}x^n\ln\cos x\,dx\\ &=\int_0^{\pi/2}x^n\ln\left(\sqrt{2}\sin\left(x+\frac{\pi}4\right)\right)\,dx-\int_0^{\pi/2}x^n\ln\cos x\,dx\\ &=\frac12\left(\frac\pi2\right)^{n+1}\frac{\ln2}{n+1}+\int_0^{\pi/2}x^n\ln\sin\left(x+\frac{\pi}4\right)\,dx-\int_0^{\pi/2}x^n\ln\cos x\,dx\\ &=\frac12\left(\frac\pi2\right)^{n+1}\frac{\ln2}{n+1}-\int_0^{\pi/2}x^n\ln\cos x\,dx+\sum_{k=0}^{n}(-1)^{n-k}{n\choose k}\left(\frac\pi4\right)^{n-k}\int_{\pi/4}^{3\pi/4}x^k\ln\sin x\,dx\\ &=\frac12\left(\frac\pi2\right)^{n+1}\frac{\ln2}{n+1}-c_n+\sum_{k=0}^{n}(-1)^{n-k}{n\choose k}\left(\frac\pi4\right)^{n-k}s_k \end{align} From this point on, we will be making heavy use of the Clausen functions $$\mathrm{Cl}_s(z)$$.

To evaluate $$s_n$$, we will need to note that $$\int\ln\sin x\,dx=-\frac12\mathrm{Cl}_2(2x)-x\ln2$$. With this in mind, we integrate by parts: \begin{align} s_n&=-x^n\left(\frac12\mathrm{Cl}_2(2x)+x\ln2\right)\bigg|_{\pi/4}^{3\pi/4}+n\int_{\pi/4}^{3\pi/4}x^{n-1}\left(\frac12\mathrm{Cl}_2(2x)+x\ln2\right)dx\\ &=\frac12\left(\frac\pi4\right)^n\left[(3^n+1)\mathrm G+\frac{1-3^n}{2}\pi\ln2\right]+n\int_{\pi/4}^{3\pi/4}x^{n-1}\left(\frac12\mathrm{Cl}_2(2x)+x\ln2\right)dx\\ &=\frac12\left(\frac\pi4\right)^n\left[(3^n+1)\mathrm G+\frac{1+3^n(2n-1)}{n+1}\frac\pi2\ln2\right]+\frac{n}2\int_{\pi/4}^{3\pi/4}x^{n-1}\mathrm{Cl}_2(2x)dx\\ &=\alpha_n+\frac{n}{2^{n+1}}\int_{\pi/2}^{3\pi/2}x^{n-1}\mathrm{Cl}_2(x)dx\tag{1} \end{align} Where $$\mathrm G$$ is Catalan's constant. I know that the remaining integral can be tackled through repeated integration by parts: \begin{align} \int_{\pi/2}^{3\pi/2}x^{n-1}\mathrm{Cl}_2(x)dx&=-x^{n-1}\mathrm{Cl}_3(x)\bigg|_{\pi/2}^{3\pi/2}+(n-1)\int_{\pi/2}^{3\pi/2}x^{n-2}\mathrm{Cl}_3(x)dx\\ f_{n-1}&=\frac{3}{32}\left(\frac\pi2\right)^{n-1}(3^{n-1}-1)\zeta(3)+(n-1)f_{n-2} \end{align} Where $$f_m=\int_{\pi/2}^{3\pi/2}x^{m}\mathrm{Cl}_{n-m+1}(x)dx$$ Anyway, we have from integration by parts that $$f_j=\underbrace{(-1)^{n-j}\left(\frac\pi2\right)^{n-j}\left[3^j\mathrm{Cl}_{n-j+2}\left(\frac{3\pi}{2}\right)-\mathrm{Cl}_{n-j+2}\left(\frac{\pi}{2}\right)\right]}_{u_j}+\underbrace{(-1)^{n-j+1}j}_{v_j}f_{j-1}$$ And from here, we have $$f_j=f_0\prod_{k=1}^{j}v_k+\sum_{k=0}^{j-1}u_{j-k}\prod_{\ell=1}^{k}v_{j-\ell+1}$$ Which is $$f_j=(-1)^{\frac{j}2(2n-j+1)}j!f_0+n!\sum_{k=0}^{j-1}(-1)^{\frac{k(k+1)}2}\frac{u_{j-k}}{(n-k)!}$$ So $$f_{n-1}=(-1)^{\frac{(n-1)(n+2)}2}(n-1)!f_0+n!\sum_{k=0}^{n-2}(-1)^{\frac{k(k+1)}2}\frac{u_{n-k-1}}{(n-k-1)!}\tag{2}$$ Plugging $$(2)$$ into $$(1)$$ gives $$s_n$$. As for closed forms, we may evaluate the $$\mathrm{Cl}$$ expressions in $$u_j$$ by noting that $$\mathrm{Cl}_{2n}\left(\frac{3\pi}{2}\right)=-\mathrm{Cl}_{2n}\left(\frac{\pi}{2}\right)=-\beta(2n)$$ and $$\mathrm{Cl}_{2n+1}\left(\frac{3\pi}{2}\right)=\mathrm{Cl}_{2n+1}\left(\frac{\pi}{2}\right)=\frac{1-2^{2n}}{2^{4n+1}}\zeta(2n+1)$$ Where $$\beta(s)=\sum_{k\geq0}\frac{(-1)^k}{(2k+1)^s}$$ is the Dirichlet Beta function.

As for $$c_n$$, the process would probably be similar but way more nasty--which begs my question:

Is there a more efficient/different way to evaluate $$T_n$$? Answers involving special functions (including hypergeometric functions) are welcome.

Edit: Confirming my previous suspicions, we find (from integration by parts) that $$c_n=-\left(\frac\pi2\right)^{n+1}\frac{\ln2}{n+1}+\frac{n}{2^n}\sum_{k=0}^{n-1}(-1)^{n-k-1}{n-1\choose k}\pi^{n-k-1}g_k$$ Where $$g_k=\int_{\pi}^{2\pi}x^{k}\mathrm{Cl}_2(x)dx$$ Then from IBP again, $$g_k=\left(\frac34-2^k\right)\pi^k\zeta(3)+kd_{k-1}$$ where $$d_j=\int_\pi^{2\pi} x^j\mathrm{Cl}_{k-j+2}(x)dx$$ IBP again provides the (solvable) recurrence $$d_j=(-1)^{k-j+1}x^j\mathrm{Cl}_{k-j+3}(x)\bigg|_\pi^{2\pi}+(-1)^{k-j}jd_{j-1}$$ So, in effect, we have found a horrendous finite sum for $$T_n$$. As for closed forms, we note that $$\mathrm{Cl}_{2m}(a\pi)=0\qquad a,m\in\Bbb Z, m\geq1$$ And $$\mathrm{Cl}_{2m+1}(2a\pi)=\zeta(2m+1)$$ $$\mathrm{Cl}_{2m+1}((2a+1)\pi)=(1-2^{-2m})\zeta(2m+1)$$ So after all, \begin{align} T_n&=\frac32\left(\frac\pi2\right)^{n+1}\frac{\ln2}{n+1}+\frac{n}{2^n}\sum_{k=0}^{n-1}(-1)^{n-k}{n-1\choose k}\pi^{n-k-1}\left[\left(\frac34-2^k\right)\pi^k\zeta(3)+kd_{k-1}\right]\\ &+\sum_{k=0}^{n}(-1)^{n-k}{n\choose k}\left(\frac\pi4\right)^{n-k}\left[\alpha_k+\frac{k}{2^{k+1}}f_{k-1}\right] \end{align} Which is the nastiest integral I've ever seen. I will see if this sum confirms the known results.

• And I thought it was a mess to evaluate the case $n=2$... ^^ May 12 '19 at 10:21
• Well its an organizable mess May 12 '19 at 18:13
• A short answer - also for your question - is here . ;) May 23 '19 at 9:04

A closed form for $$T_n$$ is $$T_n=\frac{\log{2}}{2(n+1)}\Big(\frac{\pi}{2}\Big)^{n+1} -\frac{n!}{2^{n+1}}\Big(\sum_{m=0}^n \frac{(\pi/2)^{n-m}}{(n-m)!}(1+(-1)^m)\sum_{k=0}^m \frac{(\pi/2)^{m-k}}{(m-k)!}(-1)^k\,d_k$$ $$- \sum_{m=0}^n \frac{\pi^{n-m}}{(n-m)!}\sin{(\pi\,m/2)}\zeta(m+2)\,+\, \sin{(\pi\,n/2)}\text{Li}_{n+2}(-1)\, \Big)$$ where $$d_k=\cos{(\pi\,k/2)}\Big(\frac{\psi^{(k+1)}(3/4) - \psi^{(k+1)}(1/4)}{2^{2k+4}(k+1)!} \Big)-\sin{(\pi\,k/2)}\,2^{-(k+2)}\, \text{Li}_{k+2}(-1).$$ The $$\psi^{(k)}(x)$$ are the derivatives of the polygamma function and $$\text{Li}_{k}(x)$$ is the polylogarithm. At argument -1 we know $$\text{Li}_{k+2}(-1)=-(1-2^{-(k+1)})\zeta(k+2).$$

As it is written it is easy to see that we break out of the class of zeta-evaluated-at-integers. For even $$k$$ the first term in the $$d_k$$ is all that remains and in fact $$d_0=-G,$$ where $$G$$ is Catalan's constant. I haven't worked with Clausen functions, but I suspect there is a way to relate the OP's relation to mine by using them.

The solution turns on the trigonometric identity $$1+\tan(x) = \sqrt{2}\,\sec(x)\,\sin{(x+\pi/4)}.$$

Inserting and separating logs, $$T_n = \int_0^{\pi/2} x^n \log\Big(\frac{2 \sin(x+\pi/4)}{2 \cos(x) }\Big)\,dx + \frac{\log{2}}{2}\int_0^{\pi/2} x^n \, dx$$ $$= -\underbrace{\int_0^{\pi/2} x^n \log{(2\cos{x})}\,dx}_{I_n} \,+\,\underbrace{\int_0^{\pi/2} x^n \log{(2\sin(x+\pi/4))}\,dx}_{K_n} + \frac{\log{2}}{2(n+1)}\Big(\frac{\pi}{2}\Big)^{n+1}$$

$$K_n$$ has some similarities with $$I_n$$ so let's do a few manipulations first:

$$K_n = \int_{-\pi/4}^{\pi/4}(x+\pi/4)^n\log{(2 \cos{x})}\,dx = \sum_{m=0}^n (1+(-1)^m) \binom{n}{m} \Big(\frac{\pi}{4}\Big)^{n-m} \underbrace{\int_0^{\pi/4} x^n \log{(2\cos{x})}\,dx}_{J_m}$$ The difference between $$I_n$$ and $$J_n$$ is the upper limits of $$\pi/2$$ and $$\pi/4$$, respectively. The key fact used is the Fourier expansion $$\log(2\cos{x})=\sum_{k=1}^\infty \frac{(-1)^{k-1}}{k} \cos{(2k\,x)}$$

Let's work with $$J_n$$ first. The first step is scaling, the second is inserting the Fourier expansion, the third is writing in an equivalent form, and the fourth is setting up for using an operator method: $$J_n = 2^{-(n+1)}\int_0^{\pi/2} x^n \log{(2 \cos{(x/2)})}\,dx =2^{-(n+1)} \sum_{k=1}^\infty \frac{(-1)^{k-1}}{k} \int_0^{\pi/2} x^n \cos{(k\,x)}\,dx$$ $$=2^{-(n+1)}\sum_{k=1}^\infty \frac{(-1)^{k-1}}{k}Re\Big[ \int_0^{\pi/2} x^n \exp{(i\,k\,x)}\,dx\Big]=$$ $$=2^{-(n+1)}\sum_{k=1}^\infty \frac{(-1)^{k-1}}{k}Re\Big[ \big(-i \frac{d}{dk}\big)^n \int_0^{\pi/2} \exp{(i\,k\,x)}\,dx\Big]$$ $$=2^{-(n+1)}\sum_{k=1}^\infty \frac{(-1)^{k}}{k}Re\Big[ i \big(-i \frac{d}{dk}\big)^n \frac{ \exp{(i\,k\,x)}}{k}\,\Big|_{x=0}^{\pi/2} \,\Big]$$ Write $$\bar{J}_n = 2^{n+1}J_n$$ for simplicity. Tautologically, where $$[u^n]$$ denotes the 'coefficient of' operator, $$\bar{J}_n = n!\,[u^n]\sum_{n=0}^\infty \frac{u^n}{n!} \bar{J}_n .$$ Use this and switch the $$k$$ and $$n$$ summations to find $$\bar{J}_n = n!\,[u^n] \,Re\Big[ i \sum_{k=1}^\infty \frac{(-1)^{k}}{k} \Big( \sum_{n=0}^\infty \frac{u^n}{n!} \big(-i \frac{d}{dk}\big)^n \Big) \frac{ \exp{(i\,k\,x)}}{k}\,\Big|_{x=0}^{\pi/2}\, \Big]$$ The sum in the big parentheses is an exponential. Now use the well-known operator formula $$\exp(a\frac{d}{dx}) = f(x+a).$$ $$\bar{J}_n = n! [u^n]\,Re\Big[ i \sum_{k=1}^\infty \frac{(-1)^{k}}{k} \frac{ \exp{(i\,(k-iu)\,x)}}{k-iu}\,\Big|_{x=0}^{\pi/2}\, \Big]$$ $$= - n!\,[u^n] \,Im\Big[ e^{u\,\pi/2} \sum_{k=1}^\infty \frac{(-i)^{k}}{k(k-iu)} - \sum_{k=1}^\infty \frac{(-1)^{k}}{k(k-iu)} \Big]$$ It is easy to prove by geometric expansion of $$1/(k+a)$$ and interchanging summations that $$\sum_{k=1}^\infty \frac{x^k}{k(k+a)}=\sum_{k=0}^\infty (-a)^k \text{Li}_{k+2}(x).$$ Essentially, a partial fraction expansion has been turned into a power series. We have 2 sums of this form. In one sum you'll end up wth expressions like $$Im[ (-i)^k$$Li$$_{k+2}(-i)].$$ Thus we need the expansion

$$\text{Li}_{k+2}(-i)(-i)^k = i\cos{(\pi\,k/2)}\Big(\frac{\psi^{(k+1)}(3/4) - \psi^{(k+1)}(1/4)}{2^{2k+4}(k+1)!} \Big) - (\cos{(\pi\,k/2)}-i \sin{(\pi\,k/2)}) (1-2^{-(k+1)})\frac{\zeta(k+2)}{2^{k+2}}+ \frac{1}{2} \frac{E_{k+1}}{(k+1)!}\big( \frac{\pi}{2} \big)^{k+2}.$$

The $$E_k$$ are the Euler numbers.

The non-obvious steps of the proof have been shown. The remainder is doing the Cauchy products and extracting the coefficient of $$u.$$ For the expression $$I_n,$$ it's even easier because the upper limit of the integration is $$\pi,$$ so you end up with entirely real arguments for the polylogarithm. Some simplification has been performed to get the final answer, but without going through the details it's easy to see why the answer has the structure it does (e.g., double sum).

• This is excellent! Thanks so much :) May 15 '19 at 21:43
• @ skbmore Well done ! I tried for several days - no avail. You might be interested in my somewhat remote (partial) answer (math.stackexchange.com/a/3222047/198592), especially in the generating function. May 16 '19 at 11:38
• @Dr.WolfgangHintze : The comment of Claude Leibovici was, that we should use polylogarithms. This was the right hint. If you are interested in a simple solution for that problem, then please look at my answer for the question here . May 16 '19 at 13:13
• @ user90369 Really a very elegant and brief solution. May 16 '19 at 13:27
• @Dr.WolfgangHintze : Thanks for your kind response. The heart of the solution is the transition from $tan$ to $Li_0$. And the only necessary formulas are the addition theorem for tangents and the integral recursion for the polylogarithm. ;) Without using the polylogarithms the calculations are too long and overloaded with unnecessary constructions: a lot of work for a small result. It's often the case that the approach already determines the solution. May 16 '19 at 14:26

Below is somewhat different way to tackle this problem.

$$T_n=\frac{\pi^{n+1}\ln2}{(n+1)2^{n+2}}+\int_{0}^{\pi/2}x^{n}\ln\sin( x+\frac{\pi}{4})\,dx-\int_{0}^{\pi/2}x^{n}\ln\cos x\,dx$$

Three basic formulas follow

Fourier series : $$\ln \sin x=-\ln2-\sum_{k=1}^{\infty}\frac{\cos 2kx}{k};\,0

$$\ln \cos x=-\ln2+\sum_{k=1}^{\infty}(-1)^{k-1}\frac{\cos 2kx}{k};\,-\frac{\pi}{2}

and $$\int x^k\cos x\,dx =\sum_{\nu=0}^{k}\nu!\binom{k}{\nu}x^{k-\nu}\sin (x+\frac{\nu\pi}{2})$$

This last formula can be obtained by integration by parts.

The rest is to use $$T_n$$, these 3 formulas, elementary integration and summation procedures.

I'm not going to produce these calculations here because they don't add anything new (no clever tricks or something like) and are too lengthy.

Instead i write down the final result

$$T_n=f_0(n)+f_1(n)+f_2(n)+f_3(n)$$

where

$$f_0(n)=\frac{\pi^{n+1}\ln2}{(n+1)2^{n+2}}+\frac{n!\sin\frac{n\pi}{2}}{2^{n+1}}\left ( 1-\frac{1}{2^{n+1}} \right )\zeta (n+2)$$

$$f_1(n)=\frac{(-1)^n}{2}\left ( \frac{\pi}{4} \right )^n\sum_{k=0}^{n}(-1)^k\binom{n}{k}\sum_{\nu=0}^{k}(-1)^\nu(2\nu)!\binom{k }{2\nu}\left ( \frac{2}{\pi} \right )^{2\nu}\left (1+\frac{3^k}{3^{2\nu}} \right )\beta (2\nu+2)$$

$$f_2(n)=\frac{(-1)^n}{8}\left ( \frac{\pi}{4} \right )^n\sum_{k=0}^{n}(-1)^k\binom{n}{k}\sum_{\nu=0}^{k}(-1)^\nu(2\nu+1)!\binom{k }{2\nu+1}\left ( \frac{1}{\pi} \right )^{2\nu+1}\left (\frac{3^k}{3^{2\nu+1}}-1 \right )\left ( 1-\frac{1}{2^{2\nu+2}} \right )\zeta (2\nu+3)$$

$$f_3(n)=\frac{\pi^n}{2^{n+1}}\sum_{k=0}^{n}(-1)^k(2k+1)!\binom{n }{2k+1}\frac{\zeta (2k+3)}{\pi^{2k+1}}$$

where

$$\beta (m)=\sum_{k=0}^{\infty}\frac{(-1)^k}{(2k+1)^m}$$

is The Dirichlet beta function and

$$\zeta (m)=\sum_{k=1}^{\infty}\frac{1}{k^m}$$

is The Riemann zeta function

As an example let's compute $$T_3$$:

$$T_3=\frac{\pi^4}{128}\ln 2-\frac{93}{128}\zeta (5)-\frac{3\pi}{8}\beta (4)+\frac{105\pi^2}{512}\zeta (3)+\frac{\pi^3}{16}\beta (2)$$

• Very nice! Thanks for the hard work :) May 18 '19 at 15:11
• @clathratus 99% of the work was done by my TI-89 Titanium (graphing calculator) :) May 19 '19 at 12:38