How to find $$\int_0 ^ \frac{\pi}{2} \frac{\cot x}{\cot x + \csc x}\,dx \,\,?$$
The integrand $ \frac{\cot x}{\cot x + \csc x} $ is not defined at $x =0$. But the function is bounded on $(0 , \frac{\pi}{2}]$. $$\lim _{x \to 0} \frac{\cot x}{\cot x + \csc x} = 0$$ So this is not an improper integral.
My Attempt : $$\int_0 ^ \frac{\pi}{2} \frac{\cot x}{\cot x + \csc x} = \lim_{t \to 0} \int_t ^ \frac{\pi}{2} \frac{\cot x}{\cot x + \csc x} = \lim_{t \to 0} \left[(\frac{\pi}{2} - 1)+ (\tan{\frac{t}{2} - t})\right] = \left(\frac{\pi}{2} - 1\right)$$.
I know how to find the anti-derivative of the integrand. I first found out the anti-derivative of the integrand in $[t , \frac{\pi}{2}]$ , where $0 < t < \frac{\pi}{2}$. Let's say it is $\phi(t)$. Then I find $\lim_{t \to 0} \phi(t)$. I am not sure if this is a right way. Can anyone please check it?
$$\int_0 ^ \frac{\pi}{2} \frac{\cot x}{\cot x + cosec x} dx=\int_{0}^{\pi/2} \frac{\cos x}{1+\cos x} dx=\pi/2-\int_{0}^{\pi/2} \frac{dx}{1+\cos x} dx$$ $$=\pi/2-\frac{1}{2}\int_{0}^{\pi/2} \sec^2(x/2)~dx=\pi/2-\tan x |_{0}^{\pi/2}=\pi/2-1.$$