How to evaluate the improper integral $\int_{0}^{\pi/2} (\frac{\pi}{2} - x)\tan(x)\ dx$ I'm trying to compute 
$$\int_{0}^{\pi/2} (\frac{\pi}{2} - x)\tan(x)\ dx.$$
This is an improper integral and according to Mathematica, its value is $\frac{\pi \log(2)}{2}$. I can't expand the product because $\int_{0}^{\pi/2} \tan(x)$ and $\int_{0}^{\pi/2} x\tan(x)$ both diverge. I also don't see any obvious substitutions. If possible, I'd like to see a solution using elementary methods (i.e. no contour integration). 

In case this is relevant, I came across this integral when trying to find an alternate solution for this question. I started with 
$$ \int_1^{\infty}\frac{\ln x}{x\sqrt{x^2-1}}\ dx. $$
By integration by parts, this is equal to
$$ -\log(x) \arctan(\frac{1}{\sqrt{x^2-1}})\Big|_1^\infty + \int_1^\infty \frac{\arctan(\frac{1}{\sqrt{x^2-1}})}{x}\ dx $$
The left term is $0$. For the right term, I substituted $x = \sec(u)$ and got the integral 
$$\int_0^{\pi/2} \arctan(\frac{1}{\tan(u)}) \tan(u) \ du.$$
Then, since $\tan(u)\geq 0$ for $u \in [0,\pi/2]$, I used the identity $\arctan(y) + \arctan(1/y) = \pi/2$ for all $y > 0$ to get the integral I'm asking about. 
 A: Your are asking $$\int_0^{\frac{\pi}{2}} x\cot x dx$$

Note first the identity:
$$\sum_{n=1}^{N} \sin(2nx) = \frac{1}{2}\cot x - \frac{\cos(2N+1)x}{2\sin x}$$
Hence
$$\int_0^{\frac{\pi }{2}} {x\cot xdx}  = 2\sum\limits_{n = 1}^N {\int_0^{\frac{\pi }{2}} {x\sin (2nx)dx} }  + \int_0^{\frac{\pi }{2}} {\frac{x}{{\sin x}}\cos (2N + 1)xdx}$$
Since $x/\sin x$ is continuous on $[0,\pi/2]$, Riemann-Lebesgue lemma says the last term tends to 0.
Hence
$$\int_0^{\frac{\pi }{2}} {x\cot xdx}  = 2\sum\limits_{n = 1}^\infty  {\int_0^{\frac{\pi }{2}} {x\sin (2nx)dx} }  = 2\sum\limits_{n = 1}^\infty  {\frac{{{{( - 1)}^{n + 1}\pi}}}{{4 n}}}  = \frac{\pi }{2}\ln 2$$

Yet another proof comes from integration by parts:$$\int_0^{\frac{\pi }{2}} {x\cot xdx}  =  - \int_0^{\frac{\pi }{2}} {\ln (\sin x)dx} = -I$$
We have $$
I = \frac{1}{2}\int_0^\pi  {\ln (\sin x)dx}  = \int_0^{\frac{\pi }{2}} {\ln (\sin 2x)dx}  = \frac{\pi }{2}\ln 2 + \int_0^{\frac{\pi }{2}} {\ln (\sin x)dx}  + \int_0^{\frac{\pi }{2}} {\ln (\cos x)dx} $$
Therefore $$I = \frac{\pi }{2}\ln 2 + 2I$$

I believe the second proof is the standard way to evaluate this integral (this is a famous integral actually).
A: A symmetry argument is enough. By integration by parts your integral equals:
$$ I = -\int_{0}^{\pi/2}\log\cos(t)\,dt = -\int_{0}^{\pi/2}\log\sin(t)\,dt = -\int_{0}^{\pi/2}\log\frac{\sin(2t)}{2\sin t}\,dt $$
and since $-\int_{0}^{\pi/2}\log\sin(2t)\,dt=-\frac{1}{2}\int_{0}^{\pi}\log\sin(t)\,dt =I$ the previous line leads to
$$ I = I - I + \frac{\pi}{2}\log 2 $$
from which $I=\frac{\pi}{2}\log 2$.
