# How can I find $\int_0^{\pi/2}x\cot x\,dx$? [duplicate]

Can $\displaystyle\int_0^{\pi/2}x\cot x\,dx$ be found using elementary functions? If so how could I possibly do it? Is there any other way to calculate above definite integral?

## marked as duplicate by Hans Lundmark, Nosrati, José Carlos Santos, levap, erfinkSep 21 '17 at 23:27

• Have you tried integration by parts? – ajd Mar 4 '14 at 5:04

Using integration by parts, we find that

\begin{align}I = \int_0^{\pi/2} dx \, x \, \cot{x} &= \left [x \log{\sin{x}} \right ]_0^{\pi/2} - \int_0^{\pi/2} dx \, \log{\sin{x}} \\ &= - \int_0^{\pi/2} dx \, \log{\sin{x}} \end{align}

Note that

$$I = - \int_0^{\pi/2} dx \, \log{\cos{x}}$$

so that

\begin{align} 2 I &= -\int_0^{\pi/2} dx \, \log{\sin{x}} -\int_0^{\pi/2} dx \, \log{\cos{x}}\\ &= -\int_0^{\pi/2} dx \, \log{(\sin{x} \cos{x})} \\ &= -\int_0^{\pi/2} dx \, \log{\frac{\sin{2x}}{2}} \\ &= \frac{\pi}{2} \log{2} - \int_0^{\pi/2} dx \, \log{\sin{2 x}}\\ &= \frac{\pi}{2} \log{2} - \frac12 \int_0^{\pi} du \, \log{\sin{u}}\\ &= \frac{\pi}{2} \log{2} + I\end{align}

Therefore,

$$I = \int_0^{\pi/2} dx \, x \, \cot{x} = \frac{\pi}{2} \log{2}$$

Using the Riemann-Lebesgue lemma, one can show that $$\int_{a}^{b} f(x) \cot (x) \ dx = 2 \sum_{n=1}^{\infty} \int_{a}^{b} f(x) \sin(2nx) \ dx$$

Then $$\int^{\pi /2}_{0} x \cot(x) \ dx = 2 \sum_{n=1}^{\infty} \int_{0}^{\pi /2} x \sin(2nx) \ dx$$

$$= 2 \sum_{n=1}^{\infty} \Big( \frac{\sin(2nx)}{4n^{2}} - \frac{x}{2n} \cos(2nx) \Big|^{\pi/2}_{0} \Big)$$

$$= -\frac{\pi}{2} \sum_{n=1}^{\infty} \frac{(-1)^{n}}{n} = \frac{\pi \ln 2}{2}$$

$\newcommand{\+}{^{\dagger}} \newcommand{\angles}[1]{\left\langle #1 \right\rangle} \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace} \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack} \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,} \newcommand{\dd}{{\rm d}} \newcommand{\down}{\downarrow} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}} \newcommand{\expo}[1]{\,{\rm e}^{#1}\,} \newcommand{\fermi}{\,{\rm f}} \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{{\rm i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\isdiv}{\,\left.\right\vert\,} \newcommand{\ket}[1]{\left\vert #1\right\rangle} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left( #1 \right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}} \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,} \newcommand{\sech}{\,{\rm sech}} \newcommand{\sgn}{\,{\rm sgn}} \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$ \begin{align} \int_{0}^{\pi/2}x\cot\pars{x}\,\dd x&= \overbrace{\left.x\ln\pars{\sin\pars{x}}\right\vert_{0}^{\pi/2}}^{\ds{0}}\ -\ \int_{0}^{\pi/2}\ln\pars{\sin\pars{x}}\,\dd x \\[3mm]&=-\,\half\bracks{% \int_{0}^{\pi/2}\ln\pars{\sin\pars{x}}\,\dd x + \int_{0}^{\pi/2}\ln\pars{\sin\pars{{\pi \over 2} - x}}\,\dd x} \\[3mm]&=-\,\half\int_{0}^{\pi/2}\ln\pars{\sin\pars{2x} \over 2}\,\dd x =-\,{1 \over 4}\int_{0}^{\pi}\ln\pars{\sin\pars{x}}\,\dd x + {1 \over 4}\,\pi\ln\pars{2} \\[3mm]&=-\,{1 \over 2}\int_{0}^{\pi/2}\ln\pars{\sin\pars{x}}\,\dd x + {1 \over 4}\,\pi\ln\pars{2} =\half\int_{0}^{\pi/2}x\cot\pars{x}\,\dd x + {1 \over 4}\,\pi\ln\pars{2} \end{align}

$$\color{#00f}{\large\int_{0}^{\pi/2}x\cot\pars{x}\,\dd x = \half\,\pi\ln\pars{2}}$$

$$\int_0^\frac{\pi}{2}x\cot xdx=\int_0^\frac{\pi}{2}xd\ln(\sin(x))=xd\ln(\sin(x))\bigg|^\frac{\pi}{2}_0-\int_0^\frac{\pi}{2}\ln(\sin(x))dx\\ =\frac{\pi}{2}\ln2$$ For the last step, see Last Step.