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.
^^
– mrtaurho May 12 '19 at 10:21