Tricky elementary integral $\int_{0}^{\frac{\pi}{2}}x\cot(x)dx$.

Solution 1:

The integral is due to Leonhard Euler.

$$I=\int_0^{\pi/2}x\cot xdx=\int_0^{\pi/2}x(\ln\sin x)^\prime dx=-\int_0^{\pi/2}\ln\sin xdx$$

Take $x=\pi/2-u$, we have $$I=-\int_0^{\pi/2}\ln\cos udu$$

Therefore $$2I=-\int_0^{\pi/2}(\ln\sin x+\ln\cos x)dx=\frac\pi2\ln2-\int_0^{\pi/2}\ln\sin2xdx$$

The later integral could be transformed:

$$J=\int_0^{\pi/2}\ln\sin2xdx=\frac12\int_0^\pi\ln\sin xdx=\int_0^{\pi/2}\ln\sin xdx=-I$$ since $\sin x=\sin(\pi-x)$, thus

$$J=\frac\pi2\ln2$$


As an extra exercise, try to calculate

$$I(r)=\int_0^\pi\ln(1-2r\cos x+r^2)dx$$ where $\lvert r\rvert\neq1$. (due to S.D. Poisson)

Solution 2:

A handy formula when integrating a polynomial times cot or csc.

It can be shown that:

$\displaystyle \int_{a}^{b}p(x)\cot(x)dx=2\sum_{k=1}^{\infty}\int_{a}^{b}p(x)\sin(2kx)dx$

So, you have $\displaystyle 2\sum_{k=1}^{\infty}\int_{0}^{\frac{\pi}{2}}x\sin(2kx)dx$

$=\displaystyle \sum_{k=1}^{\infty}\left(\frac{\sin(k\pi)}{2k^{2}}-\frac{\pi\cos(k\pi)}{2k}\right)$

Note that $\displaystyle \sin(\pi k)=0, \;\ \cos(\pi k)=(-1)^{k}$.

So, it reduces to:

$\displaystyle \frac{\pi}{2}\sum_{k=1}^{\infty}\frac{(-1)^{k+1}}{k}$

$=\displaystyle \frac{\pi}{2}\ln(2)$

The above formula is satisfied as long as sin(x/2) or cos(x/2) is not zero in [a,b].

Try it with other upper limits like $\frac{\pi}{4}$ or $p(x)=x^{2}$.

If you're familiar with Zeta sums and the Catalan constant(which may pop up) you can integrate these functions easier.

There is an analogous formula for csc:

$\displaystyle \int_{a}^{b}p(x)csc(x)dx=2\sum_{k=0}^{\infty}\int_{a}^{b}p(x)\sin(2k+1)x dx$