Solving a definite integral How can i find the value of definite integral
$$\int_{0}^{\pi}\lfloor\cot x\rfloor dx$$ Here $\lfloor a\rfloor$ means greatest integer value of $a$. My doubt is that $\cot x$ will lie between negative of infinity to positive of infinity,so how can we solve this problem?

Let $y=\cot x$, so $x = \cot^{-1} y$ and $dx = -\frac{dy}{1+y^2}$
From here, we have
$$
\int_{-\infty}^\infty \frac{\lfloor y \rfloor}{1+y^2}dy
$$
Convert this into a sum by noting that $y=\lfloor y\rfloor+\hat y$. That is
$$
\sum_{\lfloor y\rfloor = -\infty}^\infty \lfloor y \rfloor\int_{0}^1 \frac{d\hat y}{1+(\lfloor y \rfloor + \hat y)^2}
$$
Now it should be relatively easy to integrate.
But you can do better than that, if you split the integration domain in half. That is,
$$
\int_0^{\pi/2} \lfloor \cot x\rfloor dx + \int_{\pi/2}^\pi \lfloor \cot x\rfloor dx
$$
Now, for the second half, make the substitution $x=\pi-y$, and let $x=y$ in the first integral. Can you simplify the result from there?
