TITLE: Integration involving greatest integer function : $\int_0^{\pi} [\cot(x)] \, dx$
QUESTION [6 upvotes]: What the integral of $$\int_0^{\pi} [\cot(x)]dx$$  where $[\cdot]$ represents greatest integer function. I know integral of $\cot$ is $|\log(\sin(x))|$ but $\log$ is not defined for $0$ or is there something else I'm forgetting?

REPLY [4 votes]: Outline
Observe the symmetry (up to sign) of $\cot x$ about $\frac{\pi}{2}$.
So the fundamental idea we use here is $[\cot x] = -[\cot (\pi - x)] - 1$ when $ x \in (0,\frac{\pi}{2})$ 
So $$\int_0^{\frac{\pi}{2}} [\cot(x)]\,dx + \int_0^{\frac{\pi}{2}} [\cot(\pi - x)]\,dx = -\int_0^{\frac{\pi}{2}} 1 \,dx$$ which gives 
$$\bbox[5px, border:2px solid #C0A000]{\int_0^{\pi} [\cot(x)]\,dx = \color{blue}{-\frac{\pi}{2}}}$$