TITLE: Integral $T_n=\int_{0}^{\pi/2}x^{n}\ln(1+\tan x)\,dx$
QUESTION [19 upvotes]: 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.

REPLY [2 votes]: 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<x<\pi$$
$$\ln \cos x=-\ln2+\sum_{k=1}^{\infty}(-1)^{k-1}\frac{\cos 2kx}{k};\,-\frac{\pi}{2}<x<\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)$$