Evaluate the following integral: $\int_0^{\frac{\pi}{2}} \lbrace\tan x\rbrace\mathrm{d}x$ $$I=\int_0^{\frac{\pi}{2}} \lbrace\tan x\rbrace\mathrm{d}x$$
So I have this interesting integral and I tried to evaluate it:
Let $u=\tan x$ we'll have the following:
\begin{align}
\int_0^\infty \frac{\lbrace u\rbrace}{1+u^2 }\mathrm{d}u&=\int_0^\infty \frac{u-\lfloor u\rfloor}{1+u^2}\mathrm{d}u\\
&=\lim_{a\to +\infty} \Bigg(\int_0^a \frac{u}{u^2+1}\mathrm{d}u-\int_0^a\frac{\lfloor u\rfloor}{u^2+1}\mathrm{d}u\Bigg)
\end{align}
And the first part is obvious:
$$\int_0^a \frac{u}{u^2+1}\mathrm{d}u=\frac{\ln (a^2+1)}2$$
Therefore:
$$I=\lim_{a\to +\infty}\Bigg(\frac{\ln (a^2+1)}2-\underbrace{\int_0^a\frac{\lfloor u\rfloor}{u^2+1}\mathrm{d}u}_{F}\Bigg)$$
And $F$ is the part where I got stuck because $\lfloor x\rfloor$ can't be simplified or approximated. Any thoughts or hints?
 A: This got messy towards the end.
$\begin{array}\\
I
&=\int_0^{\frac{\pi}{2}} \{\tan x\}dx\\
&=\int_0^{\frac{\pi}{4}} \{\tan x\}dx+\int_{\frac{\pi}{4}}^{\frac{\pi}{2}} \{\tan x\}dx\\
&=\int_0^{\frac{\pi}{4}} \tan xdx+\int_0^{\frac{\pi}{4}} \{\tan (\pi/2-x)\}dx\\
&=\dfrac{\ln(2)}{2}+\int_0^{\frac{\pi}{4}} \{\dfrac1{\tan (x)}\}dx\\
&=\dfrac{\ln(2)}{2}+\sum_{k=1}^{\infty}\int_{\tan^{(-1)}(1/(k+1))}^{\tan^{(-1)}(1/k)} \{\dfrac1{\tan (x)}\}dx
\qquad (*)\\
&=\dfrac{\ln(2)}{2}+\sum_{k=1}^{\infty}\int_{v_{k+1}}^{v_k} \{\dfrac1{\tan (x)}\}dx
\qquad v_k = \tan^{(-1)}(1/k)\\
&=\dfrac{\ln(2)}{2}+\sum_{k=1}^{\infty}\int_{v_{k+1}}^{v_k} (\dfrac1{\tan (x)}-k)dx\\
&=\dfrac{\ln(2)}{2}+\sum_{k=1}^{\infty}\left(\int_{v_{k+1}}^{v_k} \dfrac1{\tan (x)}dx-\int_{v_{k+1}}^{v_k} kdx\right)\\
&=\dfrac{\ln(2)}{2}+\sum_{k=1}^{\infty}\left(\ln(\sin(t))|_{v_{k+1}}^{v_k}-k(v_k-v_{k+1})\right)
\qquad (**)\\
&=\dfrac{\ln(2)}{2}+\sum_{k=1}^{\infty}\left(\ln(\dfrac{1}{\sqrt{k^2+1}})-\ln(\dfrac{1}{\sqrt{(k+1)^2+1}})-k(v_k-v_{k+1})\right)\\
&=\dfrac{\ln(2)}{2}+\sum_{k=1}^{\infty}\left(\ln(\dfrac{\sqrt{(k+1)^2+1}}{\sqrt{k^2+1}})-k(v_k-v_{k+1})\right)\\
&=\dfrac{\ln(2)}{2}
+\lim_{m \to \infty}\sum_{k=1}^{m}\left(\ln(\dfrac{\sqrt{(k+1)^2+1}}{\sqrt{k^2+1}})-k(v_k-v_{k+1})\right)\\
&=\dfrac{\ln(2)}{2}
+\lim_{m \to \infty}\left((\ln(\dfrac{\sqrt{(m+1)^2+1}}{\sqrt{2}})-\sum_{k=1}^{m}k(v_k-v_{k+1})\right)\\
&=\dfrac{\ln(2)}{2}
+\lim_{m \to \infty}\left((\ln(\dfrac{\sqrt{(m+1)^2+1}}{\sqrt{2}})-\sum_{k=1}^{m}kv_k+\sum_{k=1}^{m}kv_{k+1})\right)\\
&=\dfrac{\ln(2)}{2}
+\lim_{m \to \infty}\left((\ln(\dfrac{\sqrt{(m+1)^2+1}}{\sqrt{2}})-\sum_{k=1}^{m}kv_k+\sum_{k=2}^{m+1}(k-1)v_{k})\right)\\
&=\dfrac{\ln(2)}{2}
+\lim_{m \to \infty}\left((\ln(\dfrac{\sqrt{(m+1)^2+1}}{\sqrt{2}})-\sum_{k=1}^{m}kv_k+\sum_{k=2}^{m+1}kv_{k}-\sum_{k=2}^{m+1}v_{k})\right)\\
&=\dfrac{\ln(2)}{2}
+\lim_{m \to \infty}\left(\frac12(\ln(m^2+2m+2)-\ln(2))-v_1+(m+1)v_{m+1}-\sum_{k=2}^{m+1}v_{k})\right)\\
&=\lim_{m \to \infty}\left(\frac12\ln(m^2+2m+2)+(m+1)v_{m+1}-\sum_{k=1}^{m+1}v_{k})\right)\\
&=1+\lim_{m \to \infty}\left(\frac12(\ln(m^2)+\ln(1+2/m+2/m^2)-\sum_{k=1}^{m+1}v_{k})\right)\\
&=1+\lim_{m \to \infty}\left(\ln(m)-\sum_{k=1}^{m+1}v_{k})\right)\\
&=1+\lim_{m \to \infty}\left(\ln(m)-\sum_{k=1}^{m+1}\tan^{(-1)}(1/k)\right)\\
\end{array}
$
(*)
Want
$k
\le \dfrac1{\tan(x)}
\le k+1
$
so
$1/k
\le \tan(x)
\le 1/(k+1)
$
so
$\tan^{(-1)}(1/(k+1))
\le x
\le \tan^{(-1)}(1/k)
$
(**)
Since
$\sin(\arctan(x))
=\dfrac{x}{\sqrt{x^2+1}}
$,
$\sin(v_k)
=\sin(\tan^{(-1)}(1/k))
=\dfrac{1/k}{\sqrt{(1/k)^2+1}}
=\dfrac{1}{\sqrt{k^2+1}}
$
$v_k-v_{k+1}
=\tan^{(-1)}(1/k)-\tan^{(-1)}(1/(k+1))
=\tan^{(-1)}(\dfrac{\frac1{k}-\frac1{k+1}}{1+\frac1{k(k+1)}})
=\tan^{(-1)}(\dfrac{1}{k(k+1)+1})
$
A: Note that we can write
$$\begin{align}
\int_{0}^{N}\frac{x-\lfloor x\rfloor }{x^2+1}\,dx&=\frac12\log(N^2+1)-\sum_{n=1}^N\int_{n-1}^n \frac{\lfloor x\rfloor }{x^2+1}\,dx\\\\
&=\frac12\log(N^2+1)-\sum_{n=1}^N (n-1)(\arctan(n)-\arctan(n-1))\\\\
&=\frac12\log(N^2+1)+\sum_{k=1}^N \arctan(n)-N\arctan(N)\\\\
&=\frac12\log(N^2+1)+N(\arctan(1/N))-\sum_{n=1}^N \arctan(1/n)\\\\
&=\log(N)+1-\sum_{n=1}^N \arctan(1/n)+O\left(\frac{1}{N^2}\right)\\\\
&=\sum_{n=1}^N \left(\frac1n-\arctan(1/n)\right) -\gamma +1+O\left(\frac1N\right)
\end{align}$$
Letting $N\to\infty$, we find that
$$\int_0^{\pi/2}\tan(\{x\})\,dx=1-\gamma +\sum_{n=1}^\infty \left(\frac1n-\arctan(1/n)\right)$$
