TITLE: Proving that $\int_0^{\pi/2} (\sin (\tan (x))+\cot (x) \cos (\tan (x))-\cot (x))\cot (x) \, dx=\frac{\pi(e-2)}{2e}$
QUESTION [5 upvotes]: I think one of the ways of doing it is by the use of the differentiation with parameter. Do you see
an easy way of calculating it by real methods?
$$\int_0^{\pi/2}  (\sin (\tan (x))+\cot (x) \cos (\tan (x))-\cot (x))\cot (x) \, dx=\frac{\pi(e-2)}{2e}$$
What tools would you like to employ? Solutions are just optional.
EDIT_I: or in other words we might focus on the harder part, that is proving that
$$\int_0^{\pi/2} \cot ^2(x) (1-\cos (\tan (x))) \, dx=\frac{\pi}{2e}$$
EDIT_II: and after some work all gets reduced to calculating 
$$\int_0^{\infty} \frac{\cos(x)}{1+x^2} \ dx$$ that is well-known, this being the last part.
EDIT_III: we're done. Thanks!

REPLY [6 votes]: Maybe it's interesting to note that we can also solve the integrals using complex analysis, noting that $$\int_{0}^{\infty}\frac{\sin\left(u\right)}{u\left(1+u^{2}\right)}du=\frac{1}{2}\textrm{Im}\left(\int_{-\infty}^{\infty}\frac{e^{iu}-1}{u\left(1+u^{2}\right)}du\right)
 $$ and $$\int_{0}^{\infty}\frac{\cos\left(u\right)-1}{u^{2}\left(1+u^{2}\right)}du=\frac{1}{2}\textrm{Re}\left(\int_{-\infty}^{\infty}\frac{e^{iu}-1}{u^{2}\left(1+u^{2}\right)}du\right)
 $$ or using the Feynman trick. Take $$I\left(a\right)=\int_{0}^{\infty}\frac{\sin\left(au\right)}{u\left(1+u^{2}\right)}du,\ a>0.
 $$ We can observe that $$-I''\left(a\right)+I\left(a\right)=\int_{0}^{\infty}\frac{\sin\left(au\right)}{u}du=\frac{\pi}{2}
 $$ hence $$ I\left(a\right)=\frac{\pi}{2}+Ae^{a}+Be^{-a}
 $$ and evaluating $I\left(\infty\right)
 $ and $I'\left(0^{+}\right)
 $ we get $$A=0,\ B=-\frac{\pi}{2}
 $$ then $$I\left(a\right)=\frac{\pi}{2}\left(1-e^{-a}\right).
 $$ Now if we put $$J\left(a\right)=\int_{0}^{\infty}\frac{\cos\left(au\right)-1}{u^{2}\left(1+u^{2}\right)}du
 $$ we note that $$J'\left(a\right)=-\int_{0}^{\infty}\frac{\sin\left(au\right)}{u\left(1+u^{2}\right)}du=-I\left(a\right)
 $$ then $$J\left(a\right)=-\frac{\pi}{2}\left(a+e^{-a}\right)+C
 $$ and observing that $$0=J\left(0\right)=-\frac{\pi}{2}+C
 $$ we get $$C=\frac{\pi}{2}
 $$ so the integral is equal to$$\lim_{a\rightarrow1}\frac{\pi}{2}\left(1-e^{-a}\right)-\frac{\pi}{2}\left(a+e^{-a}\right)+\frac{\pi}{2}=\frac{\pi}{2}-\frac{\pi}{e}.
 $$