How to evaluate $ \int_{0}^{\pi/2}\int_{0}^{x} \frac{1}{1 + \cot\left(t\right)}\,\mathrm{d}t \,\mathrm{d}x$? 
*

*I am stuck in a problem
$$ \int_{0}^{\pi/2}\int_{0}^{x}
\frac{1}{1 + \cot\left(t\right)}\,\mathrm{d}t \,\mathrm{d}x$$


*Using the convolution theorem I changed the double integral into a single integral \begin{align}
&\int_\limits 0^{\pi/2} \left(\frac{\pi}{2}-x\right)\frac{\sin\left(x\right)}
{\sin\left(x\right) +
\cos\left(x\right)}\,\mathrm{d}x =
\int_{0}^{\pi/2}\frac{x\cos\left(x\right)}
{\sin\left(x\right) +\cos\left(x\right)}\,\mathrm{d}x
\\[3mm] = &\
\int_{0}^{\pi/2}\frac{x}{1 + \tan\left(x\right)}\,\mathrm{d}x
=
\int_{0}^\infty\frac{\tan^{-1}\left(\theta\right)}{\left(1 + \theta\right)\left(1 + \theta^{2}\right)}\,\mathrm{d}\theta
\end{align}


*[Substituted $\tan\left(x\right) = \theta$]. Using integration by part
$$
v =\frac{\tan^{-1}\left(\theta\right)}{1+\theta^2}
\quad\mbox{and}\quad u=\frac{1}{1+\theta},
$$ I got the following integral as
$
\displaystyle\frac{1}{2}\int_{0}^\infty \left[\frac{\tan^{-1}\left(\theta\right)}{1 + \theta}\right]^{2}\,\mathrm{d}\theta
$.
I am not able to evaluate that.
 A: $$\begin{align}
\int_0^{\pi/2}\int_0^x \frac1{1+\cot(t)}\,dt\,dx&=\int_0^{\pi/2} \frac{\pi/2-t}{1+\cot(t)}\,dt\tag1\\\\
&=\int_0^{\pi/2}\frac{(\pi/2-t)
\sin(t)}{\sin(t)+\cos(t)}\,dt\tag2\\\\
&=\int_0^{\pi/2}\frac{(\pi/2-t)\sin(t)}{\sqrt{2}\cos(t-\pi/4)}\,dt\tag3\\\\
&=\int_{-\pi/4}^{\pi/4}\frac{(\pi/4-t)\sin(t+\pi/4)}{\sqrt{2}\cos(t)}\,dt\tag4\\\\
&=\frac12\int_{-\pi/4}^{\pi/4}\frac{(\pi/4-t)\left(\sin(t)+\cos(t)\right)}{\cos(t)}\,dt\tag5\\\\
&=\frac12 \int_{-\pi/4}^{\pi/4}\left(\frac\pi4 -t\tan(t)\right)\,dt\tag6\\\\
&=\frac{\pi^2}{16}-\int_0^{\pi/4}t\tan(t)\,dt\tag7\\\\
&=\frac{\pi^2}{16}-\left(\frac12 G-\frac{\pi}{8}\log(2)\right)\tag8
\end{align}$$
where $G$ is Catalan's Constant.

NOTES:

*

*Changed order of integration and carried out the resulting inner integral.

*Used the equality $\frac1{1+\cot(t)}=\frac{\sin(t)}{\sin(t)+\cos(t)}$.

*Used the identity $\sin(t)+\cos(t)=\sqrt{2}\cos(t-\pi/4)$.

*Enforced the substitution $t\mapsto t+\pi/4$.

*Expanded $\sin(t+\pi/4)=\frac{\sqrt 2}{2}(\sin(t)+\cos(t))$.

*Exploited even and odd symmetries of integrand.

*Carried out integral of $\pi/4$
To arrive at $(8)$, we integrate by parts with $u=t$ and $v=-\log(\cos(t))$ to find
$$\int_0^{\pi/4}t\tan(t)\,dt=\frac\pi8+\int_0^{\pi/4}\log(\cos(t))\,dt\tag9$$
Next using the Fourier series $\log(\cos(t))=-\log(2)+\sum_{k=1}^\infty \frac{(-1)^{k-1}\cos(2kt)}{k}$ in $(9)$ and integrating term by term reveals
$$\begin{align}
\int_0^{\pi/4}\log(\cos(t))\,dt&=-\frac\pi4 \log(2)+\frac12\sum_{k=1}^\infty \frac{(-1)^{k-1}}{(2k-1)^2}\\\\
&=-\frac\pi4 \log(2)+\frac12 G\tag{10}
\end{align}$$
Substituting $(10)$ into $(9)$, we find that
$$\int_0^{\pi/4}t\tan(t)\,dt=-\frac\pi8+\frac12 G$$
Putting it all together yields the coveted result
$$\int_0^{\pi/2}\int_0^x \frac1{1+\cot(t)}\,dt\,dx=\frac{\pi^2}{16}-\left(\frac12 G-\frac{\pi}{8}\log(2)\right)$$
A: Since on $[0,\frac\pi 2]$ we have $\sin(x)+\cos(x)=\sqrt{2}\sin(x+\frac\pi 4)\ge 0$ then:
$\displaystyle \begin{align}\int_0^{\frac \pi 2}\int_0^x\frac {\sin(t)}{\sin(t)+\cos(t)}\,dt\,dx&=\frac 12\int_0^{\frac \pi 2}\bigg(x-\ln(\sin(x)+\cos(x))\bigg)\,dx\\\\&=\frac{\pi^2}{16}-\frac 12\frac\pi 2\ln(\sqrt{2})-\frac 12\int_0^{\frac \pi 2}\ln(\sin(x+\frac\pi 4))\,dx\\\\&=\frac{\pi^2}{16}-\frac{\pi\ln(2)}{8}-\int_0^{\frac \pi 4}\ln(\cos(x))\,dx\end{align}$
Last one is obtained by change $x-\frac\pi 4$ and then parity of $\cos(x)$, and its value is:  $\frac K2-\frac{\pi\ln(2)}4$.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\bbox[5px,#ffd]{\int_{0}^{\pi/2}\int_{0}^{x}
{\dd t\,\dd x \over 1 + \cot\pars{t}}} =
\int_{0}^{\pi/2}{1 \over 1 + \cot\pars{t}}\int_{t}^{\pi/2}
\dd x\,\dd t
\\[5mm] = &\
\int_{0}^{\pi/2}{\pi/2 - t \over 1 + \cot\pars{t}}\,\dd t
\,\,\,\stackrel{t\ \mapsto\ \pi/2 - t}{=}\,\,\,
\int_{0}^{\pi/2}{t \over 1 + \tan\pars{t}}\,\dd t
\\[5mm] = &\
\int_{-\pi/4}^{\pi/4}{t + \pi/4 \over 1 + \bracks{\tan\pars{t} + 1}/\bracks{1 - \tan\pars{t}}}\,\dd t
\\[5mm] = &\
{1 \over 2}\int_{-\pi/4}^{\pi/4}\pars{t + {\pi \over 4}}
\bracks{1 -\tan\pars{t}}\,\dd t
\\[5mm] = &\
-\,\
\underbrace{{1 \over 2}\int_{-\pi/4}^{\pi/4}t\tan\pars{t}\,\dd t}
_{\ds{{1 \over 2}\,G - {1 \over 8}\,\pi\ln\pars{2}}}\ +\
\underbrace{{1 \over 2}\int_{-\pi/4}^{\pi/4}{\pi \over 4}\,\dd t}
_{\ds{\pi^{2} \over 16}}
\\[5mm] = &\
\bbx{-\,{1 \over 2}\,G + {1 \over 8}\,\pi\ln\pars{2} + {\pi^{2} \over 16}} \\ &
\end{align}
User ${\tt @Mark Viola}$
already evaluated the last integral.
