Evaluate the integral $\int_0^{\pi/2}\frac{\tan x}{\tan(\frac{x}{2})} \, dx$ Evaluate the integral.
$$\int_0^{\frac{\pi}{2}}\frac{\tan{x}}{\tan(\frac{x}{2})}\,dx$$
I tried to solve it with $u = \tan{x/2}$, but i got divergent part of the solution. How can I integrate it, such that, when boundaries are plugged in, the result will be able to be calculated.
 A: Write $$\frac{\tan x}{\tan \frac{x}{2}} = \frac{\sin x}{\cos x} \frac{\cos\frac{x}{2}}{\sin\frac{x}{2}} = \frac{2\sin\frac{x}{2} \cos\frac{x}{2}}{\cos x}\frac{\cos\frac{x}{2}}{\sin\frac{x}{2}} = \frac{2\cos^2\frac{x}{2}}{\cos x} = \frac{1 + \cos x}{\cos x}$$Then your integral reduces to $$\int_0^{\frac{\pi}{2}} (\sec x + 1)\, dx$$
A: hint
with $ t=\tan(\frac x2) $,
$$dx=2\frac{dt}{1+t^2}$$
$$\tan(x)=\frac{2t}{1-t^2}$$
$ I $ becomes
$$I=4\int_0^1\frac{dt}{(1-t^2)(1+t^2)}$$
$$=2\int_0^1(\frac{1}{1-t^2}+\frac{1}{1+t^2})dt$$
$$=\int_0^1(\frac{1}{1-t}+\frac{1}{1+t}+\frac{2}{1+t^2})dt$$
$$=+\infty$$
$ I $ is then divergent.
A: Hint (almost solution):
Put $u = \tan \frac{x}2$. Hence $x = 2 \arctan u$ and
\begin{align}
\text{answer} & = \int_0^{\tan \frac12} \frac{\left( \frac{2u}{1-u^2} \right)}{u} \cdot \frac{2\,du}{1+u^2} \\[6pt]
& = 4\int_0^{\tan \frac12} \frac{du}{(1+u^2)(1-u^2)} \\[6pt]
& =\int_0^{\tan \frac12} \frac{A\,du}{1+u^2} + \int_0^{\tan \frac12} \frac{B\,du}{1+u^2}
\end{align}
for some $A$ and $B$.
