# Evaluating $\int^{\pi/2}_{0}x\cot (x)dx$ using Leibniz's integration rule

How does one evaluate the following improper integral using Leibniz's integration rule?

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

I tried to add a new parameter $$\ln(\sec(tx))$$

$$f(t) = \int^{\frac{\pi}{2}}_{0}x\cot (x)\ln(\sec(tx))dx$$

$$\dfrac{\partial}{\partial t}f(t)= \int^{\frac{\pi}{2}}_{0}x\cot (x) \dfrac{\partial}{\partial t}\biggr (\ln(\sec(tx))\biggr)$$

$$\dfrac{\partial}{\partial t}f(t)= \int^{\frac{\pi}{2}}_{0}x\cot (x) x\tan(tx)dx$$

$$\dfrac{\partial}{\partial t}f(t)= \int^{\frac{\pi}{2}}_{0}x^2\cot (x) \tan(tx)dx$$

When $$t = 1$$,

$$\dfrac{\partial}{\partial t}f(1)= \int^{\frac{\pi}{2}}_{0}x^2\cot (x) \tan(x)dx = \int^{\frac{\pi}{2}}_{0}x^2dx$$

I could find $$f(1)$$ from there but I have to find $$f(0)$$.

• – Minus One-Twelfth Aug 24 '19 at 13:50
• Instead, I suggest making the choice: $$f(t)=\int_0^{\pi/2} x\cot(x)\arctan(t\cdot \tan(x))$$ Then differentiate w.r.t. $t$. – projectilemotion Aug 24 '19 at 13:51
• @MinusOne-Twelfth I've been looking for slightly different parameterization. – Melz Aug 24 '19 at 13:52
• Why wouldn't my parameter work here? – Melz Aug 24 '19 at 17:43
• Because evaluating $\int_0^{\pi/2} x^2\cot(x)\tan(tx)~dx$ for general $t$ is not an easy task. – projectilemotion Aug 25 '19 at 18:48

By integration by parts, $$\int_{0}^{\pi/2}x\cot(x)\,dx = -\int_{0}^{\pi/2}\log\sin(x)\,dx = -\int_{0}^{1}\frac{\log(t)}{\sqrt{1-t^2}}\,dt=-\left.\frac{d}{d\alpha}\int_{0}^{1}\frac{t^\alpha\,dt}{\sqrt{1-t^2}}\right|_{\alpha=0}$$ and by Euler's Beta function $$\int_{0}^{1}\frac{t^\alpha\,dt}{\sqrt{1-t^2}}=\frac{\sqrt{\pi}}{2}\cdot\frac{\Gamma\left(\frac{1+\alpha}{2}\right)}{\Gamma\left(1+\frac{\alpha}{2}\right)}$$ so $$\int_{0}^{\pi/2}x\cot(x)\,dx =\frac{\pi}{4}\left[\psi(1)-\psi\left(\tfrac{1}{2}\right)\right]=\frac{\pi}{2}\log(2).$$ There are plenty of other ways: exploiting symmetry, Fourier series, Weierstrass products etc.
The Gamma function is defined as $$\Gamma(s)=\int_0^\infty t^{s-1}e^{-t}dt.$$ Setting $$t=x^2$$ gives $$\Gamma(s)=2\int_0^\infty x^{2s-1}e^{-x^2}dx.$$ Thus, $$\Gamma(a)\Gamma(b)=4\int_0^\infty \int_0^\infty x^{2a-1}y^{2b-1}e^{-(x^2+y^2)}dxdy.$$ Then we convert the integrals to polar coordinates to get \begin{align} \Gamma(a)\Gamma(b)&=4\int_0^{\pi/2}\int_0^{\infty} r(r\cos\theta)^{2a-1}(r\sin\theta)^{2b-1}e^{-r^2}drd\theta\\ &=4\int_0^{\pi/2}\cos(\theta)^{2a-1}\sin(\theta)^{2b-1}\int_0^{\infty} r^{2a+2b-1}e^{-r^2}drd\theta\\ &=2\left(2\int_0^{\infty} r^{2a+2b-1}e^{-r^2}dr\right)\left(\int_0^{\pi/2}\cos(\theta)^{2a-1}\sin(\theta)^{2b-1}d\theta\right)\\ &=2\Gamma(a+b)\int_0^{\pi/2}\cos(\theta)^{2a-1}\sin(\theta)^{2b-1}d\theta . \end{align} So we have the integral $$\int_0^{\pi/2}\sin(t)^{a}\cos(t)^{b}dt=\frac{\Gamma(\frac{a+1}2)\Gamma(\frac{b+1}2)}{2\Gamma(\frac{a+b}2+1)}$$ which is equivalent to $$\int_0^1 t^a(1-t)^bdt=\mathrm B(a,b)=\frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}.$$ Anyway, as Jack noticed, $$\int_0^{\pi/2}x\cot x\ dx=-\int_0^{\pi/2}\ln\sin x\ dx.$$ But from the Leibniz integral rule, we know that $$\int_0^{\pi/2}\sin(t)^a\cos(t)^b\ln^{n}(\sin t)\ln^{m}(\cos t)dt=\partial_a^n\partial_b^m \frac{\Gamma(\frac{a+1}2)\Gamma(\frac{b+1}2)}{2\Gamma(\frac{a+b}2+1)}$$ so $$-\int_0^{\pi/2}\ln\sin x\ dx=-\partial_{a}\frac{\Gamma(\frac{a+1}2)\Gamma(\frac{1}2)}{2\Gamma(\frac{a}2+1)}\Bigg|_{a=0}=-\left(\frac{\sqrt\pi}2\right)^2\left[\psi_0\left(\tfrac12\right)-\psi_0(1)\right]=\frac\pi4\ln2\ .$$