Integrate $\int^{\frac{\pi}{2}}_{0} \{ \cot x\}$ dx So I have been trying to solve this question, 
$$
\int_{0}^{\pi/2}\left\{\,\cot\left(x\right)\,\right\}\,\mathrm{d}x
$$
where $\left\{\right\}$ means the fractional part.
$\left(\,x - \left\lfloor\,x\,\right\rfloor\,\right)$.
Progress so far, 


*

*MATLAB gives out the following answer when
int(cot(x)-fix(cot(x)),0,pi/2) is run, ans = int(cot(x) - fix(cot(x)), x, 0, pi/2)

*The tutorial here is somewhat tries to solve a different version of the problem.

*Writing $ \{ \text{cotx} \} $ as $ \text{cotx} - \newcommand{\floor}[1]{\lfloor #1 \rfloor} \lfloor \text{cot} x \rfloor $ gives us $\int^{\frac{\pi}{2}}_{0} \text{cotx} - \newcommand{\floor}[1]{\lfloor #1 \rfloor} \int^{\frac{\pi}{2}}_{0}{\lfloor \text{cot} x \rfloor}$ where the first part doesn't converge ( $ \infty $ ). 


Can someone help me?
 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{\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}
\int_{0}^{\pi/2}\braces{\cot\pars{x}}\dd x & =
\int_{0}^{\pi/2}\braces{\tan\pars{x}}\dd x
\,\,\,\stackrel{\tan\pars{x}\ \mapsto\ x}{=}\,\,\,
\int_{0}^{\infty}{\braces{x} \over x^{2} + 1}\,\dd x
\\[5mm] &=
\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} -
\int_{0}^{\Lambda}{\left\lfloor\,{x}\,\right\rfloor \over x^{2} + 1}\,\dd x}
\\[5mm] & =
\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} -
\int_{0}^{\left\lfloor\,\Lambda\,\right\rfloor}
{\left\lfloor\,{x}\,\right\rfloor \over x^{2} + 1}\,\dd x -
\int_{\left\lfloor\,\Lambda\,\right\rfloor}^{\Lambda}
{\left\lfloor\,{x}\,\right\rfloor \over x^{2} + 1}\,\dd x}
\end{align}

Note that
  $\ds{\lim_{\Lambda \to \infty}\int_{\left\lfloor\,\Lambda\,\right\rfloor}^{\Lambda}
{\left\lfloor\,{x}\,\right\rfloor \over x^{2} + 1}\,\dd x = 0}$.

Then,
\begin{align}
\int_{0}^{\pi/2}\braces{\cot\pars{x}}\dd x & =
\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} -
\sum_{n = 1}^{\left\lfloor\,\Lambda\,\right\rfloor - 1}
\int_{n}^{n + 1}{n \over x^{2} + 1}\,\dd x}
\\[5mm] & =
\lim_{\Lambda \to \infty}\braces{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} -
\sum_{n = 1}^{\left\lfloor\,\Lambda\,\right\rfloor - 1}
n\bracks{\arctan\pars{n + 1} - \arctan\pars{n}}}
\\[5mm] & =
\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} -
\sum_{n = 1}^{\left\lfloor\,\Lambda\,\right\rfloor}
\pars{n - 1}\arctan\pars{n} +
\sum_{n = 1}^{\left\lfloor\,\Lambda\,\right\rfloor - 1}n\arctan\pars{n}}
\\[5mm] & =
\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} -
\left\lfloor\,\Lambda\,\right\rfloor
\arctan\pars{\left\lfloor\,\Lambda\,\right\rfloor} +
\sum_{n = 1}^{\left\lfloor\,\Lambda\,\right\rfloor}\arctan\pars{n}}
\\[5mm] & =
\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} -
\left\lfloor\,\Lambda\,\right\rfloor
\arctan\pars{\left\lfloor\,\Lambda\,\right\rfloor} +
{\pi \over 2}\,\left\lfloor\,\Lambda\,\right\rfloor -
\sum_{n = 1}^{\left\lfloor\,\Lambda\,\right\rfloor}\arctan\pars{1 \over n}}
\\[5mm] & =
\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} +
\left\lfloor\,\Lambda\,\right\rfloor
\arctan\pars{1 \over \left\lfloor\,\Lambda\,\right\rfloor} -
\sum_{n = 1}^{\left\lfloor\,\Lambda\,\right\rfloor}\arctan\pars{1 \over n}}
\\[1cm] & =\
\underbrace{\overbrace{\quad\lim_{\Lambda \to \infty}\bracks{%
{1 \over 2}\ln\pars{\Lambda^{2} + 1} +
\left\lfloor\,\Lambda\,\right\rfloor
\arctan\pars{1 \over \left\lfloor\,\Lambda\,\right\rfloor} -
H_{\left\lfloor\,\Lambda\,\right\rfloor}}\quad}^{\ds{=\ 1 - \gamma}}}
_{\ds{~H_{z}:\ Harmonic\ Number.\ \gamma:\ Euler-Mascheroni\ Constant~}}
\\[2mm] & +
\sum_{n = 1}^{\infty}\bracks{{1 \over n} - \arctan\pars{1 \over n}}
\end{align}

Therefore, the original question is reduced to

\begin{align}
\bbx{\int_{0}^{\pi/2}\braces{\cot\pars{x}}\dd x =
1 - \gamma +
\sum_{n = 0}^{\infty}\bracks{{1 \over n + 1} - \arctan\pars{1 \over n + 1}}}
\label{1}\tag{1}
\end{align}
The 'remaining' sum is a identity ( see $\ds{\mathbf{\color{#000}{6.1.27}}}$ in A & S Table ). Namely,
$$
\sum_{n = 0}^{\infty}\bracks{{1 \over n + 1} - \arctan\pars{1 \over n + 1}} =
\mrm{arg}\pars{\Gamma\pars{1 + \ic}} + \gamma
$$
$$
\mbox{such that}\quad
\bbox[15px,#ffe,border:1px dotted navy]{\ds{\int_{0}^{\pi/2}\braces{\cot\pars{x}}\dd x =
1 + \mrm{arg}\pars{\Gamma\pars{1 + \ic}}}} \approx 0.6984
$$
A: As a further addendum,
$$ \gamma = \lim_{N\to +\infty}\sum_{n=1}^{+\infty}\left[\frac{1}{n}-\log\left(1+\frac{1}{n}\right)\right] \tag{1}$$
hence the whole problem boils down to evaluating
$$ A = \sum_{n\geq 1}\left[\frac{1}{n}-\arctan\frac{1}{n}\right]\stackrel{\mathcal{L}^{-1}}{=}\int_{0}^{+\infty}\frac{1-\frac{\sin s}{s}}{e^s-1}\,ds=\sum_{m\geq 1}\frac{(-1)^{m+1}}{2m+1}\zeta(2m+1) \tag{2}$$
that is $1-\frac{\pi}{4}+\sum_{m\geq 1}\frac{(-1)^{m+1}}{2m+1}\left(\zeta(2m+1)-1\right).$ This is related with $\text{Im}\log\Gamma$ by the Weierstrass product for the $\Gamma$ function.
A: Supplementing Thomas Andrews' answer, since:
$$
S_N =\ln(N+1) - \sum_{n=1}^N \arctan \left(\frac{1}{n} \right) = \ln(N+1) - \sum_{k=0}^\infty \frac{(-1)^k}{2k+1}\sum_{n=1}^N n^{-2k-1} \\
= \ln(N+1) - H_N - \sum_{k=1}^\infty \frac{(-1)^k}{2k+1}H_{N,2k+1}
$$
Where the $H_{N,i}$ denote the generalized Harmonic Numbers, which approaches in the limit:
$$
S=\lim_{N\to\infty} S_N = -\gamma - \sum_{k=1}^\infty \frac{(-1)^k\zeta(2k+1)}{2k+1}
$$
Which by $(124)$ here, we have:
$$
S = -\gamma - \Im(-i\gamma + \ln(\Gamma(1-i))) = - \Im(\ln(\Gamma(1-i)))
$$
The integral therefore equals:
$$
I = 1 - \Im(\ln(\Gamma(1-i))) \approx 0.698359
$$
Through the use of the argument, this also equals:
$$
I = 1 - \arg(\Gamma(1-i)) = 1 + \frac{\pi}{2} + \arg(\Gamma(i))
$$
A: Just a start:
The typical way of doing this sort of problem is to let $a_n=\cot^{-1} n=\arctan\frac{1}{n}$. Then the integral can be written:
$$\sum_{n=0}^{\infty} \int_{a_{n+1}}^{a_{n}} ((\cot x)-n)\,dx=\sum_{n=0}^{\infty}\left(n(a_{n+1}-a_{n})+ \int_{a_{n+1}}^{a_n}\cot x\,dx\right)$$
You get the partial sum:
$$\begin{align}\sum_{n=0}^{N}\left(n(a_{n+1}-a_{n})+ \int_{a_{n+1}}^{a_n}\cot x\,dx\right)&=-\left(\sum_{n=1}^{N} a_n \right)+ Na_{N+1} +\int_{a_{N+1}}^{\pi/2}\cot x\,dx\\
&=-\left(\sum_{n=1}^{N} a_n \right) + Na_{N+1}+\log|\sin \pi/2|-\log|\sin a_{N+1}|\\
&=-\left(\sum_{n=1}^{N} a_n \right) + Na_{N+1} +\frac{1}{2}\log((N+1)^2+1)
\end{align}$$
The last since $\sin a_n =\sin\cot^{-1} n=\frac{1}{\sqrt{n^2+1}}$.
Since $Na_{N+1}\to 1$, and $\log((N+1)^2+1)-2\log(N+1)\to 0$ the limit is the same as the limit:
$$\lim_{N\to\infty}\left(\log(N+1)-\left(\sum_{n=1}^{N} a_n \right)+1 \right)$$
When I enter into Wolfram Alpha a request for:
$$\sum_{n=1}^{N}\left(\log(n+1)-\log(n)-\arctan \frac{1}{n}\right)$$
it finds no closed form, with approximate value $\approx-0.299155$, so your integral is $\approx 0.700845$.
Since $$\begin{align}\log(1+n)-\log(n)&=\log(1+1/n)\\
&=\frac{1}{n}-\frac{1}{2n^2}+\frac{1}{3n^3}-\cdots\end{align}$$ and $$\arctan\frac{1}{n}=\frac{1}{n}-\frac{1}{3n^3}+\frac{1}{5n^5}\cdots$$
So your integral is $$\begin{align}1+&\left(2\zeta(3)-\zeta(2)-\zeta(4)\right)\\+&\left(2\zeta(7)-\zeta(6)-\zeta(8)\right)\\+&\cdots\\+&\left(2\zeta(4n-1)-\zeta(4n-2)-\zeta(4n)\right)\\+&\cdots\end{align}$$
