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

$$\int_{0}^{\frac{\pi }{2}}x\cot(x)dx$$

I tried integration by parts and got $\dfrac{1}{2}\int_{0}^{\frac{\pi }{2}}x^{2} \csc^{2}x dx$ which doesn't help at all. I don't really know what to do. Any help will be greatly appreciated.

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)

• $$...=(\pi/2) \ln \sin (\pi /2 ) - \lim _{y\rightarrow 0} y \ln \sin y -\int _0 ^{\pi /2} \ln \sin x dx$$ If you rewrite the argument of the limit as $$\frac{y}{\sin y} \sin y \ln \sin y$$ you are done. – pppqqq May 5 '13 at 19:04

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$

Another way to do this integral:

$$I=\int_0^{\pi/2}x\cot(x)\,dx=\int_0^{\pi/2}(\pi/2-x)\tan(x)\,dx\\ \Rightarrow 2I=\int_0^{\pi/2}\frac{2x\cos^2(x)+2(\pi/2-x)\sin^2(x)}{2\sin(x)\cos(x)}\, dx\\=\int_0^{\pi/2}\frac{2x\cos(2x)+\frac{\pi}{2}(1-\cos(2x))}{\sin(2x)}\,dx\\\Rightarrow 4I=\int_0^{\pi}\frac{x\cos(x)+\frac{\pi}{2}(1-\cos(x))}{\sin(x)}\, dx\\=\int_0^{\pi/2}x\cot(x)\,dx+\frac{\pi}{2}\int_0^{\pi/2}\csc(x)-\cot(x)\,dx+\int_{\pi/2}^\pi (x-\pi)\cot(x)\,dx+\frac{\pi}{2}\int_{\pi/2}^\pi\csc(x)+\cot(x)\,dx\\=2I+\pi\int_0^{\pi/2}\csc(x)-\cot(x)\,dx\\=2I-\pi\log|1+\cos(x)|]^{\pi/2}_0\\\Rightarrow I=\frac{\pi}{2}\log(2).$$